The Death Of Editmesh - Part 1

I've removed editmesh altogether (other then scanfill, which is
seperate code that happens to reuse the editmesh structures).
The compatibility layer I had written for old editmesh tools
was more trouble then it was worth, though it did help in the 
early stages of this project.

There's a fair amount of breakage, and there's bunches of tools
(mostly minor ones) I need to port over still.  Biggest ones are
join triangles and loop to region, and spin/screw.

This probably isn't really testable, I'll hopefully have more
work done on this soon, but might not be before next week.
This commit is contained in:
Joseph Eagar 2010-01-28 00:45:30 +00:00
parent 3af4392087
commit 20fac2eca7
43 changed files with 3271 additions and 14237 deletions

@ -1,336 +1,344 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="BL_bmesh"
ProjectGUID="{6A51010A-9393-4D77-84B4-5BBCDA6E7C25}"
RootNamespace="BL_bmesh"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\build\msvc_9\intern\bmfont\include;..\..\..\..\build\msvc_9\intern\bsp\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\decimation\include;..\..\..\..\build\msvc_9\intern\elbeem\include;..\..\..\..\build\msvc_9\intern\iksolver\include;..\..\..\source\blender;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\editors\include;..\..\..\source\blender\python;..\..\..\source\blender\blenlib;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\blender\makesrna;..\..\..\source\blender\nodes;..\..\..\source\blender\blenloader;..\..\..\source\kernel\gen_system;..\..\..\source\blender\renderconverter;..\..\..\source\blender\render\extern\include;..\..\..\source\gameengine\SoundSystem;..\..\..\..\build\msvc_9\extern\verse\include;..\..\..\..\build\msvc_9\intern\opennl\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\blender\gpu;..\..\source\blender\blenkernel;..\..\source\blender\makesdna;..\..\source\blender\blenlib;..\..\source\blender\bmesh;..\..\source\blender\editors\include;..\..\source\blender\bmesh\operators;..\..\source\blender\bmesh\intern;..\..\source\blender\editors\mesh"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\..\build\msvc_9\libs\debug\BL_bmesh.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\build\msvc_9\intern\bmfont\include;..\..\..\..\build\msvc_9\intern\bsp\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\decimation\include;..\..\..\..\build\msvc_9\intern\elbeem\include;..\..\..\..\build\msvc_9\intern\iksolver\include;..\..\..\source\blender;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\editors\include;..\..\..\source\blender\python;..\..\..\source\blender\blenlib;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\blender\makesrna;..\..\..\source\blender\nodes;..\..\..\source\blender\blenloader;..\..\..\source\kernel\gen_system;..\..\..\source\blender\renderconverter;..\..\..\source\blender\render\extern\include;..\..\..\source\gameengine\SoundSystem;..\..\..\..\build\msvc_9\extern\verse\include;..\..\..\..\build\msvc_9\intern\opennl\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\blender\gpu;..\..\source\blender\blenkernel;..\..\source\blender\makesdna;..\..\source\blender\blenlib;..\..\source\blender\bmesh;..\..\source\blender\editors\include;..\..\source\blender\bmesh\operators;..\..\source\blender\bmesh\intern;..\..\source\blender\editors\mesh"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\..\build\msvc_9\libs\BL_bmesh.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
<ProjectReference
ReferencedProjectIdentifier="{31628053-825D-4C06-8A21-D13883489718}"
RelativePathToProject=".\blenlib\BLI_blenlib.vcproj"
/>
<ProjectReference
ReferencedProjectIdentifier="{CAE37E91-6570-43AC-A4B4-7A37A4B0FC94}"
RelativePathToProject=".\blenkernel\BKE_blenkernel.vcproj"
/>
<ProjectReference
ReferencedProjectIdentifier="{E013786A-9575-4F34-81B2-33290357EE87}"
RelativePathToProject=".\makesdna\DNA_makesdna.vcproj"
/>
<ProjectReference
ReferencedProjectIdentifier="{1CC733F1-6AB5-4904-8F63-C08C46B79DD9}"
RelativePathToProject="..\..\intern\guardedalloc\make\msvc_9_0\guardedalloc.vcproj"
/>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_construct.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\bmesh_dupeops.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_eulers.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_filters.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_interp.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_iterators.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_marking.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_mesh.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_mods.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_opdefines.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_operators.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_operators_private.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_polygon.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_private.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_queries.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_structure.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_structure.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_to_editmesh.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_walkers.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\connectops.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\createops.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\dissolveops.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\edgesplitop.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\editmesh_to_bmesh.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\extrudeops.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\mesh_conv.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\mirror.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\removedoubles.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\subdivideop.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\triangulateop.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\utils.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\source\blender\bmesh\bmesh.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_error.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_filters.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_iterators.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_marking.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_operator_api.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_operators.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_queries.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_walkers.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="BL_bmesh"
ProjectGUID="{6A51010A-9393-4D77-84B4-5BBCDA6E7C25}"
RootNamespace="BL_bmesh"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\build\msvc_9\intern\bmfont\include;..\..\..\..\build\msvc_9\intern\bsp\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\decimation\include;..\..\..\..\build\msvc_9\intern\elbeem\include;..\..\..\..\build\msvc_9\intern\iksolver\include;..\..\..\source\blender;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\editors\include;..\..\..\source\blender\python;..\..\..\source\blender\blenlib;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\blender\makesrna;..\..\..\source\blender\nodes;..\..\..\source\blender\blenloader;..\..\..\source\kernel\gen_system;..\..\..\source\blender\renderconverter;..\..\..\source\blender\render\extern\include;..\..\..\source\gameengine\SoundSystem;..\..\..\..\build\msvc_9\extern\verse\include;..\..\..\..\build\msvc_9\intern\opennl\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\blender\gpu;..\..\source\blender\blenkernel;..\..\source\blender\makesdna;..\..\source\blender\blenlib;..\..\source\blender\bmesh;..\..\source\blender\editors\include;..\..\source\blender\bmesh\operators;..\..\source\blender\bmesh\intern;..\..\source\blender\editors\mesh"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\..\build\msvc_9\libs\debug\BL_bmesh.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\lib\windows\zlib\include;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\build\msvc_9\intern\bmfont\include;..\..\..\..\build\msvc_9\intern\bsp\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\decimation\include;..\..\..\..\build\msvc_9\intern\elbeem\include;..\..\..\..\build\msvc_9\intern\iksolver\include;..\..\..\source\blender;..\..\..\source\blender\avi;..\..\..\source\blender\imbuf;..\..\..\source\blender\editors\include;..\..\..\source\blender\python;..\..\..\source\blender\blenlib;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\blender\makesrna;..\..\..\source\blender\nodes;..\..\..\source\blender\blenloader;..\..\..\source\kernel\gen_system;..\..\..\source\blender\renderconverter;..\..\..\source\blender\render\extern\include;..\..\..\source\gameengine\SoundSystem;..\..\..\..\build\msvc_9\extern\verse\include;..\..\..\..\build\msvc_9\intern\opennl\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\blender\gpu;..\..\source\blender\blenkernel;..\..\source\blender\makesdna;..\..\source\blender\blenlib;..\..\source\blender\bmesh;..\..\source\blender\editors\include;..\..\source\blender\bmesh\operators;..\..\source\blender\bmesh\intern;..\..\source\blender\editors\mesh"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\..\build\msvc_9\libs\BL_bmesh.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
<ProjectReference
ReferencedProjectIdentifier="{31628053-825D-4C06-8A21-D13883489718}"
RelativePathToProject=".\blenlib\BLI_blenlib.vcproj"
/>
<ProjectReference
ReferencedProjectIdentifier="{CAE37E91-6570-43AC-A4B4-7A37A4B0FC94}"
RelativePathToProject=".\blenkernel\BKE_blenkernel.vcproj"
/>
<ProjectReference
ReferencedProjectIdentifier="{E013786A-9575-4F34-81B2-33290357EE87}"
RelativePathToProject=".\makesdna\DNA_makesdna.vcproj"
/>
<ProjectReference
ReferencedProjectIdentifier="{1CC733F1-6AB5-4904-8F63-C08C46B79DD9}"
RelativePathToProject="..\..\intern\guardedalloc\make\msvc_9_0\guardedalloc.vcproj"
/>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_construct.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\bmesh_dupeops.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_eulers.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_filters.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_interp.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_iterators.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_marking.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_mesh.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_mods.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_opdefines.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_operators.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_operators_private.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_polygon.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_private.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_queries.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_structure.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_structure.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_to_editmesh.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\bmesh_walkers.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\connectops.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\createops.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\dissolveops.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\edgesplitop.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\intern\editmesh_to_bmesh.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\extrudeops.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\join_triangles.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\mesh_conv.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\mirror.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\primitiveops.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\removedoubles.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\subdivideop.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\triangulateop.c"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\operators\utils.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\source\blender\bmesh\bmesh.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_error.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_filters.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_iterators.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_marking.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_operator_api.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_operators.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_queries.h"
>
</File>
<File
RelativePath="..\..\source\blender\bmesh\bmesh_walkers.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

@ -1199,6 +1199,10 @@
RelativePath="..\..\..\source\blender\editors\mesh\bmeshutils.c"
>
</File>
<File
RelativePath="..\..\..\source\blender\editors\mesh\editbmesh_add.c"
>
</File>
<File
RelativePath="..\..\..\source\blender\editors\mesh\editbmesh_bvh.c"
>
@ -1211,30 +1215,6 @@
RelativePath="..\..\..\source\blender\editors\mesh\editface.c"
>
</File>
<File
RelativePath="..\..\..\source\blender\editors\mesh\editmesh.c"
>
</File>
<File
RelativePath="..\..\..\source\blender\editors\mesh\editmesh_add.c"
>
</File>
<File
RelativePath="..\..\..\source\blender\editors\mesh\editmesh_lib.c"
>
</File>
<File
RelativePath="..\..\..\source\blender\editors\mesh\editmesh_loop.c"
>
</File>
<File
RelativePath="..\..\..\source\blender\editors\mesh\editmesh_mods.c"
>
</File>
<File
RelativePath="..\..\..\source\blender\editors\mesh\editmesh_tools.c"
>
</File>
<File
RelativePath="..\..\..\source\blender\editors\mesh\loopcut.c"
>

@ -151,6 +151,9 @@ typedef struct DMFaceIter {
int index;
int len;
/*you can set mat_nr and flags, and the backends
must detect and update the internal faces*/
int mat_nr;
int flags;

@ -66,6 +66,9 @@ struct BMesh *BKE_mesh_to_bmesh(struct Mesh *me, struct Object *ob);
use_face_origindex sets the tesselation faces' origindex layer
to point to the tesselation faces themselves, not the polys.
if both of the above are 0, it'll use the indices of the mpolys of the MPoly
data in pdata, and ignore the origindex layer altogether.
*/
int mesh_recalcTesselation(struct CustomData *fdata, struct CustomData *ldata,
struct CustomData *pdata, struct MVert *mvert, int totface,

@ -1841,6 +1841,10 @@ void cddm_stepiter(void *self)
CDDM_FaceIter *iter = self;
MPoly *mp;
mp = iter->cddm->mpoly + iter->head.index;
mp->flag = iter->head.flags;
mp->mat_nr = iter->head.mat_nr;
iter->head.index++;
if (iter->head.index >= iter->cddm->dm.numPolyData) {
iter->head.done = 1;
@ -1937,8 +1941,13 @@ DMFaceIter *cdDM_newFaceIter(DerivedMesh *source)
iter->liter.cddm = cddm;
iter->cddm = cddm;
iter->head.index = -1;
iter->head.step(iter);
if (source->numFaceData) {
iter->head.index = -1;
iter->head.step(iter);
} else {
iter->head.done = 1;
}
return (DMFaceIter*) iter;
}

@ -70,6 +70,7 @@
#include "BKE_mesh.h"
#include "BKE_shrinkwrap.h"
#include "BKE_mesh.h"
#include "BKE_tessmesh.h"
#ifndef DISABLE_PYTHON
#include "BPY_extern.h"
@ -406,7 +407,7 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f
{
DerivedMesh *dm;
Mesh *me= ob->data;
EditMesh *em = BKE_mesh_get_editmesh(me);
BMEditMesh *em = me->edit_btmesh;
float vec[3] = {0.0f, 0.0f, 0.0f}, tvec[3];
float normal[3] = {0.0f, 0.0f, 0.0f}, plane[3];
float imat[3][3], tmat[3][3];
@ -423,7 +424,7 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f
/* get DerivedMesh */
if (em) {
/* target is in editmode, so get a special derived mesh */
dm = CDDM_from_editmesh(em, ob->data);
dm = CDDM_from_BMEditMesh(em, ob->data);
freeDM= 1;
}
else {
@ -503,8 +504,6 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f
/* free temporary DerivedMesh created (in EditMode case) */
if (dm && freeDM)
dm->release(dm);
if (em)
BKE_mesh_end_editmesh(me, em);
}
/* function that sets the given matrix based on given vertex group in lattice */

@ -1387,6 +1387,11 @@ void bmDM_faceIterStep(void *self)
{
bmDM_faceIter *iter = self;
if (iter->f) {
iter->f->mat_nr = iter->head.mat_nr;
iter->f->head.flag = MEFlags_To_BMFlags(iter->head.flags, BM_FACE);
}
iter->f = iter->nextf;
iter->head.mat_nr = iter->f->mat_nr;

@ -80,21 +80,6 @@
#include "bmesh.h"
EditMesh *BKE_mesh_get_editmesh(Mesh *me)
{
return bmesh_to_editmesh(me->edit_btmesh->bm);
}
void free_editMesh(EditMesh *em);
void BKE_mesh_end_editmesh(Mesh *me, EditMesh *em)
{
BM_Free_Mesh(me->edit_btmesh->bm);
me->edit_btmesh->bm = editmesh_to_bmesh(em);
BMEdit_RecalcTesselation(me->edit_btmesh);
free_editMesh(em);
MEM_freeN(em);
}
static void mesh_ensure_tesselation_customdata(Mesh *me)
{
int tottex, totcol;
@ -1605,9 +1590,19 @@ static void mesh_loops_to_corners(CustomData *fdata, CustomData *ldata,
}
}
/*this function recreates a tesselation.
/*
this function recreates a tesselation.
returns number of tesselation faces.
returns number of tesselation faces.*/
use_poly_origindex sets whether or not the tesselation faces' origindex
layer should point to original poly indices or real poly indices.
use_face_origindex sets the tesselation faces' origindex layer
to point to the tesselation faces themselves, not the polys.
if both of the above are 0, it'll use the indices of the mpolys of the MPoly
data in pdata, and ignore the origindex layer altogether.
*/
int mesh_recalcTesselation(CustomData *fdata,
CustomData *ldata, CustomData *pdata,
MVert *mvert, int totface, int totloop,

@ -7501,7 +7501,6 @@ static void meshdeformModifier_do(
{
MeshDeformModifierData *mmd = (MeshDeformModifierData*) md;
Mesh *me= (mmd->object)? mmd->object->data: NULL;
EditMesh *em = (me)? BKE_mesh_get_editmesh(me): NULL;
BMEditMesh *bem = me->edit_btmesh;
DerivedMesh *tmpdm, *cagedm;
MDeformVert *dvert = NULL;

@ -1816,25 +1816,27 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4])
static void give_parvert(Object *par, int nr, float *vec)
{
EditMesh *em;
BMEditMesh *em;
int a, count;
vec[0]=vec[1]=vec[2]= 0.0f;
if(par->type==OB_MESH) {
Mesh *me= par->data;
em = BKE_mesh_get_editmesh(me);
em = me->edit_btmesh;
if(em) {
EditVert *eve;
for(eve= em->verts.first; eve; eve= eve->next) {
if(eve->keyindex==nr) {
BMVert *eve;
BMIter iter;
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
int *keyindex = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX);
if(keyindex && *keyindex==nr) {
memcpy(vec, eve->co, sizeof(float)*3);
break;
}
}
BKE_mesh_end_editmesh(me, em);
}
else {
DerivedMesh *dm = par->derivedFinal;

@ -1433,13 +1433,13 @@ void cgdm_faceIterStep(void *self)
return;
}
fiter->head.index++;
if (fiter->head.index >= ccgSubSurf_getNumFinalFaces(fiter->cgdm->ss)) {
if (fiter->head.index+1 >= ccgSubSurf_getNumFinalFaces(fiter->cgdm->ss)) {
fiter->head.done = 1;
return;
};
fiter->head.index++;
fiter->mf++;
fiter->head.flags = fiter->mface->flag;

@ -578,15 +578,6 @@ BMOpDefine def_extrudefaceregion = {
0
};
BMOpDefine def_makefgonsop = {
"makefgon",
{{BMOP_OPSLOT_INT, "trifan"}, /*use triangle fans instead of
real interpolation*/
{0} /*null-terminating sentinel*/},
bmesh_make_fgons_exec,
0
};
BMOpDefine def_dissolvevertsop = {
"dissolveverts",
{{BMOP_OPSLOT_ELEMENT_BUF, "verts"},
@ -644,9 +635,10 @@ BMOpDefine def_subdop = {
{BMOP_OPSLOT_MAPPING, "custompatterns"},
{BMOP_OPSLOT_MAPPING, "edgepercents"},
/*these next two can have multiple types of elements in them.*/
/*these next three can have multiple types of elements in them.*/
{BMOP_OPSLOT_ELEMENT_BUF, "outinner"},
{BMOP_OPSLOT_ELEMENT_BUF, "outsplit"},
{BMOP_OPSLOT_ELEMENT_BUF, "geomout"}, /*contains all output geometry*/
{BMOP_OPSLOT_INT, "quadcornertype"}, //quad corner type, see bmesh_operators.h
{BMOP_OPSLOT_INT, "gridfill"}, //fill in fully-selected faces with a grid
@ -658,22 +650,6 @@ BMOpDefine def_subdop = {
0
};
BMOpDefine def_edit2bmesh = {
"editmesh_to_bmesh",
{{BMOP_OPSLOT_PNT, "em"}, {BMOP_OPSLOT_MAPPING, "map"},
{0} /*null-terminating sentinel*/},
edit2bmesh_exec,
0
};
BMOpDefine def_bmesh2edit = {
"bmesh_to_editmesh",
{{BMOP_OPSLOT_PNT, "emout"},
{0} /*null-terminating sentinel*/},
bmesh2edit_exec,
0
};
BMOpDefine def_delop = {
"del",
{{BMOP_OPSLOT_ELEMENT_BUF, "geom"}, {BMOP_OPSLOT_INT, "context"},
@ -837,19 +813,114 @@ BMOpDefine def_edgesplit = {
0
};
/*
Create Grid
Creates a grid with a variable number of subdivisions
*/
BMOpDefine def_create_grid = {
"create_grid",
{{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts
{BMOP_OPSLOT_INT, "xsegments"}, //number of x segments
{BMOP_OPSLOT_INT, "ysegments"}, //number of y segments
{BMOP_OPSLOT_FLT, "size"}, //size of the grid
{BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with
{0, /*null-terminating sentinel*/}},
bmesh_create_grid_exec,
0,
};
/*
Create UV Sphere
Creates a grid with a variable number of subdivisions
*/
BMOpDefine def_create_uvsphere = {
"create_uvsphere",
{{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts
{BMOP_OPSLOT_INT, "segments"}, //number of u segments
{BMOP_OPSLOT_INT, "revolutions"}, //number of v segment
{BMOP_OPSLOT_FLT, "diameter"}, //diameter
{BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with--
{0, /*null-terminating sentinel*/}},
bmesh_create_uvsphere_exec,
0,
};
/*
Create Ico Sphere
Creates a grid with a variable number of subdivisions
*/
BMOpDefine def_create_icosphere = {
"create_icosphere",
{{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts
{BMOP_OPSLOT_INT, "subdivisions"}, //how many times to recursively subdivide the sphere
{BMOP_OPSLOT_FLT, "diameter"}, //diameter
{BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with
{0, /*null-terminating sentinel*/}},
bmesh_create_icosphere_exec,
0,
};
/*
Create Suzanne
Creates a monkey. Be wary.
*/
BMOpDefine def_create_monkey = {
"create_monkey",
{{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts
{BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with--
{0, /*null-terminating sentinel*/}},
bmesh_create_monkey_exec,
0,
};
/*
Create Cone
Creates a cone with variable depth at both ends
*/
BMOpDefine def_create_cone = {
"create_cone",
{{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts
{BMOP_OPSLOT_INT, "cap_ends"}, //wheter or not to fill in the ends with faces
{BMOP_OPSLOT_INT, "segments"},
{BMOP_OPSLOT_FLT, "diameter1"}, //diameter of one end
{BMOP_OPSLOT_FLT, "diameter2"}, //diameter of the opposite
{BMOP_OPSLOT_FLT, "depth"}, //distance between ends
{BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with--
{0, /*null-terminating sentinel*/}},
bmesh_create_monkey_exec,
0,
};
/*
Create Cone
Creates a cone with variable depth at both ends
*/
BMOpDefine def_create_cube = {
"create_cube",
{{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts
{BMOP_OPSLOT_FLT, "size"}, //size of the cube
{BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with--
{0, /*null-terminating sentinel*/}},
bmesh_create_cube_exec,
0,
};
BMOpDefine *opdefines[] = {
&def_splitop,
&def_dupeop,
&def_delop,
&def_edit2bmesh,
&def_bmesh2edit,
&def_subdop,
&def_triangop,
&def_dissolvefacesop,
&def_dissolveedgessop,
&def_dissolveedgeloopsop,
&def_dissolvevertsop,
&def_makefgonsop,
&def_extrudefaceregion,
&def_connectverts,
//&def_makeprim,
@ -892,6 +963,12 @@ BMOpDefine *opdefines[] = {
&def_scale,
&def_edgesplit,
&def_automerge,
&def_create_uvsphere,
&def_create_grid,
&def_create_icosphere,
&def_create_monkey,
&def_create_cone,
&def_create_cube,
};
int bmesh_total_ops = (sizeof(opdefines) / sizeof(void*));

@ -61,5 +61,11 @@ void bmesh_vertexshortestpath_exec(BMesh *bm, BMOperator *op);
void bmesh_scale_exec(BMesh *bm, BMOperator *op);
void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op);
void bmesh_automerge_exec(BMesh *bm, BMOperator *op);
void bmesh_create_cone_exec(BMesh *bm, BMOperator *op);
void bmesh_create_monkey_exec(BMesh *bm, BMOperator *op);
void bmesh_create_icosphere_exec(BMesh *bm, BMOperator *op);
void bmesh_create_uvsphere_exec(BMesh *bm, BMOperator *op);
void bmesh_create_grid_exec(BMesh *bm, BMOperator *op);
void bmesh_create_cube_exec(BMesh *bm, BMOperator *op);
#endif

@ -1,3 +1,4 @@
#if 0
#include "MEM_guardedalloc.h"
#include "BKE_customdata.h"
#include "DNA_listBase.h"
@ -313,4 +314,5 @@ EditMesh *bmesh_to_editmesh(BMesh *bmesh)
BMO_Finish_Op(bmesh, &conv);
return em;
}
}
#endif

@ -1,3 +1,4 @@
#if 0
#include "MEM_guardedalloc.h"
#include "BKE_customdata.h"
@ -471,4 +472,5 @@ BMesh *init_editmesh_to_bmesh(EditMesh *em, BMOperator *op)
BMO_Set_Pnt(op, "em", em);
return bm;
}
}
#endif

@ -101,27 +101,3 @@ void connectverts_exec(BMesh *bm, BMOperator *op)
BLI_array_free(loops);
BLI_array_free(verts);
}
int BM_ConnectVerts(EditMesh *em, int flag)
{
EditMesh *em2;
BMesh *bm = editmesh_to_bmesh(em);
BMOperator op;
BMO_Init_Op(&op, "connectverts");
BMO_HeaderFlag_To_Slot(bm, &op, "verts", flag, BM_VERT);
BMO_Exec_Op(bm, &op);
BMO_Finish_Op(bm, &op);
if (BMO_GetSlot(&op, "edgeout")->len > 0 &&
BMO_GetError(bm, NULL, NULL)==0)
{
em2 = bmesh_to_editmesh(bm);
set_editMesh(em, em2);
MEM_freeN(em2);
return 1;
}
return 0;
}

@ -0,0 +1,119 @@
#if 0
#include "MEM_guardedalloc.h"
#include "BKE_customdata.h"
#include "DNA_listBase.h"
#include "DNA_customdata_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include <string.h>
#include "BKE_utildefines.h"
#include "BKE_mesh.h"
#include "BKE_global.h"
#include "BKE_DerivedMesh.h"
#include "BKE_cdderivedmesh.h"
#include "BLI_editVert.h"
#include "mesh_intern.h"
#include "ED_mesh.h"
#include "BLI_math.h"
#include "BLI_array.h"
#include "BLI_blenlib.h"
#include "BLI_edgehash.h"
#include "BLI_heap.h"
#include "bmesh.h"
/*
* JOIN_TRIANGLES.C
*
* utility bmesh operators, e.g. transform,
* translate, rotate, scale, etc.
*
*/
/*assumes edges are validated before reaching this point*/
static float measure_facepair(BMesh *bm, BMVert *v1, BMVert *v2,
BMVert *v3, BMVert *v4, float limit)
{
/*gives a 'weight' to a pair of triangles that join an edge to decide how good a join they would make*/
/*Note: this is more complicated than it needs to be and should be cleaned up...*/
float no1[3], no2[3], measure = 0.0f, angle1, angle2, diff;
float edgeVec1[3], edgeVec2[3], edgeVec3[3], edgeVec4[3];
float minarea, maxarea, areaA, areaB;
/*First Test: Normal difference*/
normal_tri_v3(n1, v1->co, v2->co, v3->co);
normal_tri_v3(n2, v1->co, v3->co, v4->co);
if(no1[0] == no2[0] && no1[1] == no2[1] && no1[2] == no2[2]) angle1 = 0.0f;
else angle1 = angle_v2v2(no1, no2);
normal_tri_v3(n1, v2->co, v3->co, v4->co);
normal_tri_v3(n2, v4->co, v1->co, v2->co);
if(no1[0] == no2[0] && no1[1] == no2[1] && no1[2] == no2[2]) angle2 = 0.0f;
else angle2 = angle_v2v2(no1, no2);
measure += (angle1/360.0f) + (angle2/360.0f);
if(measure > limit) return measure;
/*Second test: Colinearity*/
sub_v3_v3v3(edgeVec1, v1->co, v2->co);
sub_v3_v3v3(edgeVec2, v2->co, v3->co);
sub_v3_v3v3(edgeVec3, v3->co, v4->co);
sub_v3_v3v3(edgeVec4, v4->co, v1->co);
diff = 0.0;
diff = (
fabs(angle_v2v2(edgeVec1, edgeVec2) - 90) +
fabs(angle_v2v2(edgeVec2, edgeVec3) - 90) +
fabs(angle_v2v2(edgeVec3, edgeVec4) - 90) +
fabs(angle_v2v2(edgeVec4, edgeVec1) - 90)) / 360.0f;
if(!diff) return 0.0;
measure += diff;
if(measure > limit) return measure;
/*Third test: Concavity*/
areaA = area_tri_v3(v1->co, v2->co, v3->co) + area_tri_v3(v1->co, v3->co, v4->co);
areaB = area_tri_v3(v2->co, v3->co, v4->co) + area_tri_v3(v4->co, v1->co, v2->co);
if(areaA <= areaB) minarea = areaA;
else minarea = areaB;
if(areaA >= areaB) maxarea = areaA;
else maxarea = areaB;
if(!maxarea) measure += 1;
else measure += (1 - (minarea / maxarea));
return measure;
}
#define T2QUV_LIMIT 0.005
#define T2QCOL_LIMIT 3
static int compareFaceAttribs(BMesh *bm, BMEdge *e)
{
MTexPoly *tp1, *tp2;
MLoopCol *lcol1, *lcol2, *lcol3, *lcol4;
MLoopUV *luv1, *luv2, *luv3, *luv4;
BMLoop *l1, *l2;
l1 = e->loop
l2 = (BMLoop*)e->loop->radial.next->data;
}
void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op)
{
}
#endif

@ -0,0 +1,581 @@
#include "MEM_guardedalloc.h"
#include "DNA_meshdata_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_utildefines.h"
#include "BLI_math.h"
#include "BLI_ghash.h"
#include "BLI_blenlib.h"
#include "BLI_array.h"
#include "bmesh.h"
#include "mesh_intern.h"
#include "bmesh_private.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* ************************ primitives ******************* */
static float icovert[12][3] = {
{0.0f,0.0f,-200.0f},
{144.72f, -105.144f,-89.443f},
{-55.277f, -170.128,-89.443f},
{-178.885f,0.0f,-89.443f},
{-55.277f,170.128f,-89.443f},
{144.72f,105.144f,-89.443f},
{55.277f,-170.128f,89.443f},
{-144.72f,-105.144f,89.443f},
{-144.72f,105.144f,89.443f},
{55.277f,170.128f,89.443f},
{178.885f,0.0f,89.443f},
{0.0f,0.0f,200.0f}
};
static short icoface[20][3] = {
{1,0,2},
{1,0,5},
{2,0,3},
{3,0,4},
{4,0,5},
{1,5,10},
{2,1,6},
{3,2,7},
{4,3,8},
{5,4,9},
{10,1,6},
{6,2,7},
{7,3,8},
{8,4,9},
{9,5,10},
{6,10,11},
{7,6,11},
{8,7,11},
{9,8,11},
{10,9,11}
};
// HACK: these can also be found in cmoview.tga.c, but are here so that they can be found by linker
// this hack is only used so that scons+mingw + split-sources hack works
// ------------------------------- start copied code
/* these are not the monkeys you are looking for */
int monkeyo= 4;
int monkeynv= 271;
int monkeynf= 250;
signed char monkeyv[271][3]= {
{-71,21,98},{-63,12,88},{-57,7,74},{-82,-3,79},{-82,4,92},
{-82,17,100},{-92,21,102},{-101,12,95},{-107,7,83},
{-117,31,84},{-109,31,95},{-96,31,102},{-92,42,102},
{-101,50,95},{-107,56,83},{-82,66,79},{-82,58,92},
{-82,46,100},{-71,42,98},{-63,50,88},{-57,56,74},
{-47,31,72},{-55,31,86},{-67,31,97},{-66,31,99},
{-70,43,100},{-82,48,103},{-93,43,105},{-98,31,105},
{-93,20,105},{-82,31,106},{-82,15,103},{-70,20,100},
{-127,55,95},{-127,45,105},{-127,-87,94},{-127,-41,100},
{-127,-24,102},{-127,-99,92},{-127,52,77},{-127,73,73},
{-127,115,-70},{-127,72,-109},{-127,9,-106},{-127,-49,-45},
{-101,-24,72},{-87,-56,73},{-82,-89,73},{-80,-114,68},
{-85,-121,67},{-104,-124,71},{-127,-126,74},{-71,-18,68},
{-46,-5,69},{-21,19,57},{-17,55,76},{-36,62,80},
{-64,77,88},{-86,97,94},{-107,92,97},{-119,63,96},
{-106,53,99},{-111,39,98},{-101,12,95},{-79,2,90},
{-64,8,86},{-47,24,83},{-45,38,83},{-50,48,85},
{-72,56,92},{-95,60,97},{-127,-98,94},{-113,-92,94},
{-112,-107,91},{-119,-113,89},{-127,-114,88},{-127,-25,96},
{-127,-18,95},{-114,-19,95},{-111,-29,96},{-116,-37,95},
{-76,-6,86},{-48,7,80},{-34,26,77},{-32,48,84},
{-39,53,93},{-71,70,102},{-87,82,107},{-101,79,109},
{-114,55,108},{-111,-13,104},{-100,-57,91},{-95,-90,88},
{-93,-105,85},{-97,-117,81},{-106,-119,81},{-127,-121,82},
{-127,6,93},{-127,27,98},{-85,61,95},{-106,18,96},
{-110,27,97},{-112,-88,94},{-117,-57,96},{-127,-57,96},
{-127,-42,95},{-115,-35,100},{-110,-29,102},{-113,-17,100},
{-122,-16,100},{-127,-26,106},{-121,-19,104},{-115,-20,104},
{-113,-29,106},{-117,-32,103},{-127,-37,103},{-94,-40,71},
{-106,-31,91},{-104,-40,91},{-97,-32,71},{-127,-112,88},
{-121,-111,88},{-115,-105,91},{-115,-95,93},{-127,-100,84},
{-115,-96,85},{-115,-104,82},{-121,-109,81},{-127,-110,81},
{-105,28,100},{-103,20,99},{-84,55,97},{-92,54,99},
{-73,51,99},{-55,45,89},{-52,37,88},{-53,25,87},
{-66,13,92},{-79,8,95},{-98,14,100},{-104,38,100},
{-100,48,100},{-97,46,97},{-102,38,97},{-96,16,97},
{-79,11,93},{-68,15,90},{-57,27,86},{-56,36,86},
{-59,43,87},{-74,50,96},{-91,51,98},{-84,52,96},
{-101,22,96},{-102,29,96},{-113,59,78},{-102,85,79},
{-84,88,76},{-65,71,71},{-40,58,63},{-25,52,59},
{-28,21,48},{-50,0,53},{-71,-12,60},{-127,115,37},
{-127,126,-10},{-127,-25,-86},{-127,-59,24},{-127,-125,59},
{-127,-103,44},{-127,-73,41},{-127,-62,36},{-18,30,7},
{-17,41,-6},{-28,34,-56},{-68,56,-90},{-33,-6,9},
{-51,-16,-21},{-45,-1,-55},{-84,7,-85},{-97,-45,52},
{-104,-53,33},{-90,-91,49},{-95,-64,50},{-85,-117,51},
{-109,-97,47},{-111,-69,46},{-106,-121,56},{-99,-36,55},
{-100,-29,60},{-101,-22,64},{-100,-50,21},{-89,-40,-34},
{-83,-19,-69},{-69,111,-49},{-69,119,-9},{-69,109,30},
{-68,67,55},{-34,52,43},{-46,58,36},{-45,90,7},
{-25,72,16},{-25,79,-15},{-45,96,-25},{-45,87,-57},
{-25,69,-46},{-48,42,-75},{-65,3,-70},{-22,42,-26},
{-75,-22,19},{-72,-25,-27},{-13,52,-30},{-28,-18,-16},
{6,-13,-42},{37,7,-55},{46,41,-54},{31,65,-54},
{4,61,-40},{3,53,-37},{25,56,-50},{35,37,-52},
{28,10,-52},{5,-5,-39},{-21,-9,-17},{-9,46,-28},
{-6,39,-37},{-14,-3,-27},{6,0,-47},{25,12,-57},
{31,32,-57},{23,46,-56},{4,44,-46},{-19,37,-27},
{-20,22,-35},{-30,12,-35},{-22,11,-35},{-19,2,-35},
{-23,-2,-35},{-34,0,-9},{-35,-3,-22},{-35,5,-24},
{-25,26,-27},{-13,31,-34},{-13,30,-41},{-23,-2,-41},
{-18,2,-41},{-21,10,-41},{-29,12,-41},{-19,22,-41},
{6,42,-53},{25,44,-62},{34,31,-63},{28,11,-62},
{7,0,-54},{-14,-2,-34},{-5,37,-44},{-13,14,-42},
{-7,8,-43},{1,16,-47},{-4,22,-45},{3,30,-48},
{8,24,-49},{15,27,-50},{12,35,-50},{4,56,-62},
{33,60,-70},{48,38,-64},{41,7,-68},{6,-11,-63},
{-26,-16,-42},{-17,49,-49},
};
signed char monkeyf[250][4]= {
{27,4,5,26}, {25,4,5,24}, {3,6,5,4}, {1,6,5,2}, {5,6,7,4},
{3,6,7,2}, {5,8,7,6}, {3,8,7,4}, {7,8,9,6},
{5,8,9,4}, {7,10,9,8}, {5,10,9,6}, {9,10,11,8},
{7,10,11,6}, {9,12,11,10}, {7,12,11,8}, {11,6,13,12},
{5,4,13,12}, {3,-2,13,12}, {-3,-4,13,12}, {-5,-10,13,12},
{-11,-12,14,12}, {-13,-18,14,13}, {-19,4,5,13}, {10,12,4,4},
{10,11,9,9}, {8,7,9,9}, {7,5,6,6}, {6,3,4,4},
{5,1,2,2}, {4,-1,0,0}, {3,-3,-2,-2}, {22,67,68,23},
{20,65,66,21}, {18,63,64,19}, {16,61,62,17}, {14,59,60,15},
{12,19,48,57}, {18,19,48,47}, {18,19,48,47}, {18,19,48,47},
{18,19,48,47}, {18,19,48,47}, {18,19,48,47}, {18,19,48,47},
{18,19,48,47}, {18,-9,-8,47}, {18,27,45,46}, {26,55,43,44},
{24,41,42,54}, {22,39,40,23}, {20,37,38,21}, {18,35,36,19},
{16,33,34,17}, {14,31,32,15}, {12,39,30,13}, {11,48,45,38},
{8,36,-19,9}, {8,-20,44,47}, {42,45,46,43}, {18,19,40,39},
{16,17,38,37}, {14,15,36,35}, {32,44,43,33}, {12,33,32,42},
{19,44,43,42}, {40,41,42,-27}, {8,9,39,-28}, {15,43,42,16},
{13,43,42,14}, {11,43,42,12}, {9,-30,42,10}, {37,12,38,-32},
{-33,37,45,46}, {-33,40,41,39}, {38,40,41,37}, {36,40,41,35},
{34,40,41,33}, {36,39,38,37}, {35,40,39,38}, {1,2,14,21},
{1,2,40,13}, {1,2,40,39}, {1,24,12,39}, {-34,36,38,11},
{35,38,36,37}, {-37,8,35,37}, {-11,-12,-45,40}, {-11,-12,39,38},
{-11,-12,37,36}, {-11,-12,35,34}, {33,34,40,41}, {33,34,38,39},
{33,34,36,37}, {33,-52,34,35}, {33,37,36,34}, {33,35,34,34},
{8,7,37,36}, {-32,7,35,46}, {-34,-33,45,46}, {4,-33,43,34},
{-34,-33,41,42}, {-34,-33,39,40}, {-34,-33,37,38}, {-34,-33,35,36},
{-34,-33,33,34}, {-34,-33,31,32}, {-34,-4,28,30}, {-5,-34,28,27},
{-35,-44,36,27}, {26,35,36,45}, {24,25,44,45}, {25,23,44,42},
{25,24,41,40}, {25,24,39,38}, {25,24,37,36}, {25,24,35,34},
{25,24,33,32}, {25,24,31,30}, {15,24,29,38}, {25,24,27,26},
{23,12,37,26}, {11,12,35,36}, {-86,-59,36,-80}, {-60,-61,36,35},
{-62,-63,36,35}, {-64,-65,36,35}, {-66,-67,36,35}, {-68,-69,36,35},
{-70,-71,36,35}, {-72,-73,36,35}, {-74,-75,36,35}, {42,43,53,58},
{40,41,57,56}, {38,39,55,57}, {-81,-80,37,56}, {-83,-82,55,52},
{-85,-84,51,49}, {-87,-86,48,49}, {47,50,51,48}, {46,48,51,49},
{43,46,49,44}, {-92,-91,45,42}, {-23,49,50,-20}, {-94,40,48,-24},
{-96,-22,48,49}, {-97,48,21,-90}, {-100,36,50,23}, {22,49,48,-100},
{-101,47,46,22}, {21,45,35,25}, {33,34,44,41}, {13,14,28,24},
{-107,26,30,-106}, {14,46,45,15}, {14,44,43,-110}, {-111,42,23,-110},
{6,7,45,46}, {45,44,47,46}, {45,46,47,48}, {47,46,49,48},
{17,49,47,48}, {17,36,46,48}, {35,36,44,45}, {35,36,40,43},
{35,36,38,39}, {-4,-3,37,35}, {-123,34,33,1}, {-9,-8,-7,-6},
{-10,-7,32,-125}, {-127,-11,-126,-126}, {-7,-6,5,31}, {4,5,33,30},
{4,39,33,32}, {4,35,32,38}, {20,21,39,38}, {4,37,38,5},
{-11,-10,36,3}, {-11,15,14,35}, {13,16,34,34}, {-13,14,13,13},
{-3,1,30,29}, {-3,28,29,1}, {-2,31,28,-1}, {12,13,27,30},
{-2,26,12,12}, {35,29,42,36}, {34,35,36,33}, {32,35,36,31},
{30,35,36,29}, {28,35,36,27}, {26,35,36,25}, {34,39,38,35},
{32,39,38,33}, {30,39,38,31}, {28,39,38,29}, {26,39,38,27},
{25,31,32,38}, {-18,-17,45,44}, {-18,17,28,44}, {-24,-20,42,-23},
{11,35,27,14}, {25,28,39,41}, {37,41,40,38}, {34,40,36,35},
{32,40,39,33}, {30,39,31,40}, {21,29,39,22}, {-31,37,28,4},
{-32,33,35,36}, {32,33,34,34}, {18,35,36,48}, {34,25,40,35},
{24,25,38,39}, {24,25,36,37}, {24,25,34,35}, {24,25,32,33},
{24,13,41,31}, {17,11,41,35}, {15,16,34,35}, {13,14,34,35},
{11,12,34,35}, {9,10,34,35}, {7,8,34,35}, {26,25,37,36},
{35,36,37,38}, {37,36,39,38}, {37,38,39,40}, {25,31,36,39},
{18,34,35,30}, {17,22,30,33}, {19,29,21,20}, {16,26,29,17},
{24,29,28,25}, {22,31,28,23}, {20,31,30,21}, {18,31,30,19},
{16,30,17,17}, {-21,-22,35,34}, {-21,-22,33,32}, {-21,-22,31,30},
{-21,-22,29,28}, {-21,-22,27,26}, {-28,-22,25,31}, {24,28,29,30},
{23,24,26,27}, {23,24,25,25}, {-69,-35,-32,27}, {-70,26,25,-66},
{-68,-67,24,-33},
};
#define VERT_MARK 1
#define EDGE_ORIG 1
#define EDGE_MARK 2
#define FACE_MARK 1
void bmesh_create_grid_exec(BMesh *bm, BMOperator *op)
{
BMOperator bmop, prevop;
BMVert *eve, *preveve;
BMEdge *e;
float vec[3], mat[4][4], phi, phid, dia=BMO_Get_Float(op, "size");
int a, tot=BMO_Get_Int(op, "xsegments"), seg=BMO_Get_Int(op, "ysegments");
if (tot < 2) tot = 2;
if (seg < 2) seg = 2;
BMO_Get_Mat4(op, "mat", mat);
/* one segment first: the X axis */
phi= 1.0;
phid= 2.0/((float)tot-1);
for(a=0;a<tot;a++) {
vec[0]= dia*phi;
vec[1]= - dia;
vec[2]= 0.0f;
mul_m4_v3(mat,vec);
eve= BM_Make_Vert(bm, vec, NULL);
BM_Select(bm, eve, 1);
if (a) {
e = BM_Make_Edge(bm, preveve, eve, NULL, 1);
BMO_SetFlag(bm, e, EDGE_ORIG);
}
preveve = eve;
phi-=phid;
}
/* extrude and translate */
vec[0]= vec[2]= 0.0;
vec[1]= dia*phid;
mul_mat3_m4_v3(mat, vec);
for(a=0;a<seg-1;a++) {
if (a) {
BMO_InitOpf(bm, &bmop, "extrude_edge_only edges=%s", &prevop, "geomout");
BMO_Exec_Op(bm, &bmop);
BMO_Finish_Op(bm, &prevop);
BMO_Flag_Buffer(bm, &bmop, "geomout", VERT_MARK, BM_VERT);
} else {
BMO_InitOpf(bm, &bmop, "extrude_edge_only edges=%fe", EDGE_ORIG);
BMO_Exec_Op(bm, &bmop);
BMO_Flag_Buffer(bm, &bmop, "geomout", VERT_MARK, BM_VERT);
}
BMO_CallOpf(bm, "translate vec=%v verts=%s", vec, &bmop, "geomout");
prevop = bmop;
}
if (a)
BMO_Finish_Op(bm, &bmop);
BMO_Flag_To_Slot(bm, op, "vertout", VERT_MARK, BM_VERT);
}
void bmesh_create_uvsphere_exec(BMesh *bm, BMOperator *op)
{
BMOperator bmop, prevop;
BMVert *eve, *preveve, *v1;
BMEdge *e;
BMIter iter;
float vec[3], mat[4][4], cmat[3][3], phi, q[4];
float phid, dia=BMO_Get_Float(op, "diameter");
int a, seg=BMO_Get_Int(op, "segments"), tot=BMO_Get_Int(op, "revolutions");
BMO_Get_Mat4(op, "mat", mat);
phid= 2.0f*(float)M_PI/tot;
phi= .25f*(float)M_PI;
/* one segment first */
phi= 0;
phid/=2;
for(a=0; a<=tot; a++) {
vec[0]= dia*sin(phi);
vec[1]= 0.0;
vec[2]= dia*cos(phi);
eve= BM_Make_Vert(bm, vec, NULL);
BMO_SetFlag(bm, eve, VERT_MARK);
if(a==0) v1= eve;
else {
e = BM_Make_Edge(bm, preveve, eve, NULL, 0);
BMO_SetFlag(bm, e, EDGE_ORIG);
}
phi+= phid;
preveve = eve;
}
/* extrude and rotate */
phi= M_PI/seg;
q[0]= cos(phi);
q[3]= sin(phi);
q[1]=q[2]= 0;
quat_to_mat3(cmat, q);
for(a=0; a<seg; a++) {
if (a) {
BMO_InitOpf(bm, &bmop, "extrude_edge_only edges=%s", &prevop, "geomout");
BMO_Exec_Op(bm, &bmop);
BMO_Finish_Op(bm, &prevop);
} else {
BMO_InitOpf(bm, &bmop, "extrude_edge_only edges=%fe", EDGE_ORIG);
BMO_Exec_Op(bm, &bmop);
}
BMO_Flag_Buffer(bm, &bmop, "geomout", VERT_MARK, BM_VERT);
BMO_CallOpf(bm, "rotate cent=%v mat=%m3 verts=%s", vec, cmat, &bmop, "geomout");
prevop = bmop;
}
if (a)
BMO_Finish_Op(bm, &bmop);
BMO_CallOpf(bm, "removedoubles verts=%fv dist=%f", VERT_MARK, 0.001f);
/* and now do imat */
BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) {
if(BMO_TestFlag(bm, eve, VERT_MARK)) {
mul_m4_v3(mat, eve->co);
}
}
BMO_Flag_To_Slot(bm, op, "vertout", VERT_MARK, BM_VERT);
}
void bmesh_create_icosphere_exec(BMesh *bm, BMOperator *op)
{
BMVert *eva[12];
float vec[3], mat[4][4], phi, phid;
float dia = BMO_Get_Float(op, "diameter");
int a, subdiv = BMO_Get_Int(op, "subdivisions");
BMO_Get_Mat4(op, "mat", mat);
phid= 2.0f*(float)M_PI/subdiv;
phi= .25f*(float)M_PI;
dia/=200;
for(a=0;a<12;a++) {
vec[0]= dia*icovert[a][0];
vec[1]= dia*icovert[a][1];
vec[2]= dia*icovert[a][2];
eva[a]= BM_Make_Vert(bm, vec, NULL);
mul_m4_v3(mat, eva[a]->co);
BM_Select(bm, eva[a], 1);
}
for(a=0;a<20;a++) {
BMFace *evtemp;
BMVert *v1, *v2, *v3;
v1= eva[ icoface[a][0] ];
v2= eva[ icoface[a][1] ];
v3= eva[ icoface[a][2] ];
evtemp = BM_Make_QuadTri(bm, v1, v2, v3, NULL, NULL, 0);
BMO_SetFlag(bm, evtemp, FACE_MARK);
}
dia*=200;
for(a=1; a<subdiv; a++) {
BMOperator bmop;
BMO_InitOpf(bm, &bmop, "esubd edges=%he smooth=%f numcuts=%i gridfill=%i", EDGE_MARK, dia, 1, 1);
BMO_Exec_Op(bm, &bmop);
BMO_Flag_Buffer(bm, &bmop, "geomout", VERT_MARK, BM_VERT);
BMO_Finish_Op(bm, &bmop);
}
BMO_Flag_To_Slot(bm, op, "vertout", VERT_MARK, BM_VERT);
}
void bmesh_create_monkey_exec(BMesh *bm, BMOperator *op)
{
BMVert *eve;
BMVert **tv= MEM_mallocN(sizeof(*tv)*monkeynv*2, "tv");
float mat[4][4];
int i;
BMO_Get_Mat4(op, "mat", mat);
for (i=0; i<monkeynv; i++) {
float v[3];
v[0]= (monkeyv[i][0]+127)/128.0, v[1]= monkeyv[i][1]/128.0, v[2]= monkeyv[i][2]/128.0;
tv[i]= BM_Make_Vert(bm, v, NULL);
BMO_SetFlag(bm, tv[i], VERT_MARK);
tv[monkeynv+i]= (fabs(v[0]= -v[0])<0.001)?tv[i]: (eve=BM_Make_Vert(bm, v, NULL), mul_m4_v3(mat, eve->co), eve);
BMO_SetFlag(bm, tv[monkeynv+i], VERT_MARK);
mul_m4_v3(mat, tv[i]->co);
}
for (i=0; i<monkeynf; i++) {
BM_Make_QuadTri(bm, tv[monkeyf[i][0]+i-monkeyo], tv[monkeyf[i][1]+i-monkeyo], tv[monkeyf[i][2]+i-monkeyo], (monkeyf[i][3]!=monkeyf[i][2])?tv[monkeyf[i][3]+i-monkeyo]:NULL, NULL, 0);
BM_Make_QuadTri(bm, tv[monkeynv+monkeyf[i][2]+i-monkeyo], tv[monkeynv+monkeyf[i][1]+i-monkeyo], tv[monkeynv+monkeyf[i][0]+i-monkeyo], (monkeyf[i][3]!=monkeyf[i][2])?tv[monkeynv+monkeyf[i][3]+i-monkeyo]:NULL, NULL, 0);
}
MEM_freeN(tv);
BMO_Flag_To_Slot(bm, op, "vertout", VERT_MARK, BM_VERT);
}
void bmesh_create_cone_exec(BMesh *bm, BMOperator *op)
{
BMVert *v1, *v2, *lastv1=NULL, *lastv2=NULL, *cent1, *cent2, *firstv1, *firstv2;
float vec[3], mat[4][4], phi, phid;
float dia1 = BMO_Get_Float(op, "diameter1");
float dia2 = BMO_Get_Float(op, "diameter2");
float depth = BMO_Get_Float(op, "depth");
int cap_ends = BMO_Get_Int(op, "cap_ends"), segs=BMO_Get_Int(op, "segments");
int a;
BMO_Get_Mat4(op, "mat", mat);
phid= 2.0f*(float)M_PI/segs;
phi= .25f*(float)M_PI;
depth *= 0.5f;
if (cap_ends) {
vec[0] = vec[1] = 0.0f;
vec[2] = -depth;
cent1 = BM_Make_Vert(bm, vec, NULL);
vec[0] = vec[1] = 0.0f;
vec[2] = depth;
cent2 = BM_Make_Vert(bm, vec, NULL);
BMO_SetFlag(bm, cent1, VERT_MARK);
BMO_SetFlag(bm, cent2, VERT_MARK);
}
for (a=0; a<segs; a++) {
vec[0]= dia1*sin(phi);
vec[1]= dia1*cos(phi);
vec[2]= -depth;
mul_m4_v3(mat, vec);
v1 = BM_Make_Vert(bm, vec, NULL);
vec[0]= dia2*sin(phi);
vec[1]= dia2*cos(phi);
vec[2]= depth;
mul_m4_v3(mat, vec);
v2 = BM_Make_Vert(bm, vec, NULL);
BMO_SetFlag(bm, v1, VERT_MARK);
BMO_SetFlag(bm, v2, VERT_MARK);
if (a) {
if (cap_ends) {
BM_Make_QuadTri(bm, cent1, lastv1, v1, NULL, NULL, 0);
}
BM_Make_QuadTri(bm, lastv1, lastv2, v2, v1, NULL, 0);
} else {
firstv1 = v1;
firstv2 = v2;
}
lastv1 = v1;
lastv2 = v2;
}
if (!a)
return;
if (cap_ends) {
BM_Make_QuadTri(bm, cent1, firstv1, v1, NULL, NULL, 0);
}
BM_Make_QuadTri(bm, firstv1, firstv2, v2, v1, NULL, 0);
BMO_CallOpf(bm, "removedoubles verts=%fv dist=%f", VERT_MARK, 0.000001);
BMO_Flag_To_Slot(bm, op, "vertout", VERT_MARK, BM_VERT);
}
void bmesh_create_cube_exec(BMesh *bm, BMOperator *op)
{
BMVert *v1, *v2, *v3, *v4, *v5, *v6, *v7, *v8;
float vec[3], mat[4][4], off = BMO_Get_Float(op, "size") / 2.0f;
BMO_Get_Mat4(op, "mat", mat);
if (!off) off = 0.5f;
vec[0] = -off;
vec[1] = -off;
vec[2] = -off;
mul_m4_v3(mat, vec);
v1 = BM_Make_Vert(bm, vec, NULL);
BMO_SetFlag(bm, v1, VERT_MARK);
vec[0] = -off;
vec[1] = off;
vec[2] = -off;
mul_m4_v3(mat, vec);
v2 = BM_Make_Vert(bm, vec, NULL);
BMO_SetFlag(bm, v2, VERT_MARK);
vec[0] = off;
vec[1] = off;
vec[2] = -off;
mul_m4_v3(mat, vec);
v3 = BM_Make_Vert(bm, vec, NULL);
BMO_SetFlag(bm, v3, VERT_MARK);
vec[0] = off;
vec[1] = -off;
vec[2] = -off;
mul_m4_v3(mat, vec);
v4 = BM_Make_Vert(bm, vec, NULL);
BMO_SetFlag(bm, v4, VERT_MARK);
vec[0] = -off;
vec[1] = -off;
vec[2] = off;
mul_m4_v3(mat, vec);
v5 = BM_Make_Vert(bm, vec, NULL);
BMO_SetFlag(bm, v5, VERT_MARK);
vec[0] = -off;
vec[1] = off;
vec[2] = off;
mul_m4_v3(mat, vec);
v6 = BM_Make_Vert(bm, vec, NULL);
BMO_SetFlag(bm, v6, VERT_MARK);
vec[0] = off;
vec[1] = off;
vec[2] = off;
mul_m4_v3(mat, vec);
v7 = BM_Make_Vert(bm, vec, NULL);
BMO_SetFlag(bm, v7, VERT_MARK);
vec[0] = off;
vec[1] = -off;
vec[2] = off;
mul_m4_v3(mat, vec);
v8 = BM_Make_Vert(bm, vec, NULL);
BMO_SetFlag(bm, v8, VERT_MARK);
/*the four sides*/
BM_Make_QuadTri(bm, v5, v6, v2, v1, NULL, 0);
BM_Make_QuadTri(bm, v6, v7, v3, v2, NULL, 0);
BM_Make_QuadTri(bm, v7, v8, v4, v3, NULL, 0);
BM_Make_QuadTri(bm, v8, v5, v1, v4, NULL, 0);
/*top/bottom*/
BM_Make_QuadTri(bm, v1, v2, v3, v4, NULL, 0);
BM_Make_QuadTri(bm, v8, v7, v6, v5, NULL, 0);
BMO_Flag_To_Slot(bm, op, "vertout", VERT_MARK, BM_VERT);
}

@ -475,8 +475,10 @@ void bmesh_removedoubles_exec(BMesh *bm, BMOperator *op)
float vec[3];
v2 = verts[j];
if ((v2->co[0]+v2->co[1]+v2->co[2]) - (v->co[0]+v->co[1]+v->co[2])
> distsqr) break;
//if ((v2->co[0]+v2->co[1]+v2->co[2]) - (v->co[0]+v->co[1]+v->co[2])
// > distsqr) break;
if ((v2->co[0]-v->co[0]) + (v2->co[1]-v->co[1]) + (v2->co[2]-v->co[2]) > distsqr*4.0f)
break;
vec[0] = v->co[0] - v2->co[0];
vec[1] = v->co[1] - v2->co[1];

@ -964,6 +964,9 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op)
ELE_INNER, BM_ALL);
BMO_Flag_To_Slot(bmesh, op, "outsplit",
ELE_SPLIT, BM_ALL);
BMO_Flag_To_Slot(bmesh, op, "geomout",
ELE_INNER|ELE_SPLIT, BM_ALL);
}
/*editmesh-emulating function*/

@ -3386,6 +3386,8 @@ static int iteratorStopped(void *arg)
ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C)
{
return NULL;
#if 0
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
EditMesh *em =BKE_mesh_get_editmesh(((Mesh*)obedit->data));
@ -3491,6 +3493,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C)
MEM_freeN(em);
return rg;
#endif
}
#if 0

@ -91,13 +91,16 @@ void EDBM_MakeEditBMesh(struct ToolSettings *ts, struct Scene *scene, struct Obj
void EDBM_FreeEditBMesh(struct BMEditMesh *tm);
void EDBM_LoadEditBMesh(struct Scene *scene, struct Object *ob);
void EDBM_init_index_arrays(struct BMEditMesh *tm, int forvert, int foredge, int forface);
void EDBM_free_index_arrays(struct BMEditMesh *tm);
struct BMVert *EDBM_get_vert_for_index(struct BMEditMesh *tm, int index);
struct BMEdge *EDBM_get_edge_for_index(struct BMEditMesh *tm, int index);
struct BMFace *EDBM_get_face_for_index(struct BMEditMesh *tm, int index);
void EDBM_init_index_arrays(struct BMEditMesh *em, int forvert, int foredge, int forface);
void EDBM_free_index_arrays(struct BMEditMesh *em);
struct BMVert *EDBM_get_vert_for_index(struct BMEditMesh *em, int index);
struct BMEdge *EDBM_get_edge_for_index(struct BMEditMesh *em, int index);
struct BMFace *EDBM_get_face_for_index(struct BMEditMesh *em, int index);
struct BMFace *EDBM_get_actFace(struct BMEditMesh *em, int sloppy);
int EDBM_CallAndSelectOpf(struct BMEditMesh *em, struct wmOperator *op,
char *selectslot, char *fmt, ...);
/*flushes based on the current select mode. if in vertex select mode,
verts select/deselect edges and faces, if in edge select mode,
edges select/deselect faces and vertices, and in face select mode faces select/deselect

@ -1786,15 +1786,17 @@ void MESH_OT_select_less(wmOperatorType *ot)
static int mesh_select_nth_exec(bContext *C, wmOperator *op)
{
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)obedit->data));
BMEditMesh *em= ((Mesh *)obedit->data)->edit_btmesh;
int nth = RNA_int_get(op->ptr, "nth");
#if 0 //BMESH_TODO
if(EM_deselect_nth(em, nth) == 0) {
BKE_report(op->reports, RPT_ERROR, "Mesh has no active vert/edge/face.");
return OPERATOR_CANCELLED;
}
BKE_mesh_end_editmesh(obedit->data, em);
#else
BKE_report(op->reports, RPT_ERROR, "Unimplemented");
#endif
DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
@ -2053,3 +2055,21 @@ int EM_deselect_nth(EditMesh *em, int nth)
#endif
return 1;
}
void em_setup_viewcontext(bContext *C, ViewContext *vc)
{
view3d_set_viewcontext(C, vc);
if(vc->obedit) {
Mesh *me= vc->obedit->data;
vc->em= me->edit_btmesh;
}
}
/* poll call for mesh operators requiring a view3d context */
int EM_view3d_poll(bContext *C)
{
if(ED_operator_editmesh(C) && ED_operator_view3d_active(C))
return 1;
return 0;
}

File diff suppressed because it is too large Load Diff

@ -118,33 +118,6 @@ void EDBM_stats_update(BMEditMesh *em)
}
}
/*this function is defunct, dead*/
void EDBM_Tesselate(EditMesh *em)
{
EditMesh *em2;
EditFace *efa;
BMesh *bm;
int found=0;
for (efa=em->faces.first; efa; efa=efa->next) {
if ((efa->e1->h & EM_FGON) || (efa->e2->h & EM_FGON) ||
(efa->e3->h & EM_FGON) || (efa->e4&&(efa->e4->h&EM_FGON)))
{
found = 1;
break;
}
}
if (found) {
bm = editmesh_to_bmesh(em);
em2 = bmesh_to_editmesh(bm);
set_editMesh(em, em2);
MEM_freeN(em2);
BM_Free_Mesh(bm);
}
}
int EDBM_InitOpf(BMEditMesh *em, BMOperator *bmop, wmOperator *op, char *fmt, ...)
{
BMesh *bm = em->bm;
@ -228,6 +201,32 @@ int EDBM_CallOpf(BMEditMesh *em, wmOperator *op, char *fmt, ...)
return EDBM_FinishOp(em, &bmop, op, 1);
}
int EDBM_CallAndSelectOpf(BMEditMesh *em, wmOperator *op, char *selectslot, char *fmt, ...)
{
BMesh *bm = em->bm;
BMOperator bmop;
va_list list;
va_start(list, fmt);
if (!BMO_VInitOpf(bm, &bmop, fmt, list)) {
BKE_report(op->reports, RPT_ERROR,
"Parse error in EDBM_CallOpf");
va_end(list);
return 0;
}
if (!em->emcopy)
em->emcopy = BMEdit_Copy(em);
em->emcopyusers++;
BMO_Exec_Op(bm, &bmop);
BMO_HeaderFlag_Buffer(em->bm, &bmop, selectslot, BM_SELECT, BM_ALL);
va_end(list);
return EDBM_FinishOp(em, &bmop, op, 1);
}
int EDBM_CallOpfSilent(BMEditMesh *em, char *fmt, ...)
{
BMesh *bm = em->bm;
@ -258,12 +257,10 @@ void EDBM_MakeEditBMesh(ToolSettings *ts, Scene *scene, Object *ob)
BMesh *bm;
if (!me->mpoly && me->totface) {
printf("yeek!! bmesh conversion issue! may lose shapekeys!\n");
em = make_editMesh(scene, ob);
bm = editmesh_to_bmesh(em);
free_editMesh(em);
printf("yeek!! bmesh conversion issue! may lose lots of geometry!\n");
/*BMESH_TODO need to write smarter code here*/
bm = BKE_mesh_to_bmesh(me, ob);
} else {
bm = BKE_mesh_to_bmesh(me, ob);
}
@ -788,7 +785,8 @@ MTexPoly *EDBM_get_active_mtexpoly(BMEditMesh *em, BMFace **act_efa, int sloppy)
int EDBM_texFaceCheck(BMEditMesh *em)
{
/* some of these checks could be a touch overkill */
return em && em->bm->totface && CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY);
return em && em->bm->totface && CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY) &&
CustomData_has_layer(&em->bm->ldata, CD_MLOOPCOL);
}
int EDBM_vertColorCheck(BMEditMesh *em)

@ -0,0 +1,529 @@
/* $Id: bmesh_tools.c
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2004 by Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Joseph Eagar
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include "MEM_guardedalloc.h"
#include "PIL_time.h"
#include "BLO_sys_types.h" // for intptr_t support
#include "DNA_mesh_types.h"
#include "DNA_material_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_view3d_types.h"
#include "DNA_key_types.h"
#include "DNA_windowmanager_types.h"
#include "RNA_types.h"
#include "RNA_define.h"
#include "RNA_access.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
#include "BLI_rand.h"
#include "BLI_ghash.h"
#include "BLI_linklist.h"
#include "BLI_heap.h"
#include "BLI_array.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_utildefines.h"
#include "BKE_bmesh.h"
#include "BKE_report.h"
#include "BKE_tessmesh.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_mesh.h"
#include "ED_view3d.h"
#include "ED_util.h"
#include "ED_screen.h"
#include "ED_transform.h"
#include "ED_object.h"
#include "UI_interface.h"
#include "mesh_intern.h"
#include "bmesh.h"
#include "editbmesh_bvh.h"
/* uses context to figure out transform for primitive */
/* returns standard diameter */
static float new_primitive_matrix(bContext *C, float *loc, float *rot, float primmat[][4])
{
Object *obedit= CTX_data_edit_object(C);
View3D *v3d =CTX_wm_view3d(C);
float mat[3][3], rmat[3][3], cmat[3][3], imat[3][3];
unit_m4(primmat);
eul_to_mat3(rmat, rot);
invert_m3(rmat);
/* inverse transform for initial rotation and object */
copy_m3_m4(mat, obedit->obmat);
mul_m3_m3m3(cmat, rmat, mat);
invert_m3_m3(imat, cmat);
copy_m4_m3(primmat, imat);
/* center */
VECCOPY(primmat[3], loc);
VECSUB(primmat[3], primmat[3], obedit->obmat[3]);
invert_m3_m3(imat, mat);
mul_m3_v3(imat, primmat[3]);
if(v3d) return v3d->grid;
return 1.0f;
}
/* ********* add primitive operators ************* */
static void make_prim_init(bContext *C, float *dia, float mat[][4],
int *state, float *loc, float *rot)
{
Object *obedit= CTX_data_edit_object(C);
*state = 0;
if(obedit==NULL || obedit->type!=OB_MESH) {
obedit= ED_object_add_type(C, OB_MESH, loc, rot, FALSE);
/* create editmode */
ED_object_enter_editmode(C, EM_DO_UNDO|EM_IGNORE_LAYER); /* rare cases the active layer is messed up */
*state = 1;
}
else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
*dia *= new_primitive_matrix(C, loc, rot, mat);
}
static void make_prim_finish(bContext *C, int *state, int enter_editmode)
{
Object *obedit = CTX_data_edit_object(C);
DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
/* userdef */
if (*state && !enter_editmode) {
ED_object_exit_editmode(C, EM_FREEDATA); /* adding EM_DO_UNDO messes up operator redo */
}
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit);
}
static int add_primitive_plane_exec(bContext *C, wmOperator *op)
{
Object *obedit;
Mesh *me;
BMEditMesh *em;
float loc[3], rot[3], mat[4][4], dia;
int enter_editmode;
int state;
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode);
make_prim_init(C, &dia, mat, &state, loc, rot);
obedit = CTX_data_edit_object(C);
me = obedit->data;
em = me->edit_btmesh;
if (!EDBM_CallAndSelectOpf(em, op, "vertout",
"create_grid xsegments=%i ysegments=%i size=%f mat=%m4", 1, 1, sqrt(2.0), mat))
return OPERATOR_CANCELLED;
/* BMESH_TODO make plane side this: sqrt(2.0f) - plane (diameter of 1.41 makes it unit size) */
make_prim_finish(C, &state, enter_editmode);
return OPERATOR_FINISHED;
}
void MESH_OT_primitive_plane_add(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Add Plane";
ot->description= "Construct a filled planar mesh with 4 vertices.";
ot->idname= "MESH_OT_primitive_plane_add";
/* api callbacks */
ot->invoke= ED_object_add_generic_invoke;
ot->exec= add_primitive_plane_exec;
ot->poll= ED_operator_scene_editable;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
ED_object_add_generic_props(ot, TRUE);
}
static int add_primitive_cube_exec(bContext *C, wmOperator *op)
{
Object *obedit;
Mesh *me;
BMEditMesh *em;
float loc[3], rot[3], mat[4][4], dia;
int enter_editmode;
int state;
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode);
make_prim_init(C, &dia, mat, &state, loc, rot);
obedit= CTX_data_edit_object(C);
me = obedit->data;
em = me->edit_btmesh;
if (!EDBM_CallAndSelectOpf(em, op, "vertout", "create_cube mat=%m4 size=%f", mat, 2.0f))
return OPERATOR_CANCELLED;
/* BMESH_TODO make plane side this: sqrt(2.0f) - plane (diameter of 1.41 makes it unit size) */
make_prim_finish(C, &state, enter_editmode);
return OPERATOR_FINISHED;
}
void MESH_OT_primitive_cube_add(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Add Cube";
ot->description= "Construct a cube mesh.";
ot->idname= "MESH_OT_primitive_cube_add";
/* api callbacks */
ot->invoke= ED_object_add_generic_invoke;
ot->exec= add_primitive_cube_exec;
ot->poll= ED_operator_scene_editable;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
ED_object_add_generic_props(ot, TRUE);
}
static int add_primitive_circle_exec(bContext *C, wmOperator *op)
{
#if 0
int enter_editmode;
float loc[3], rot[3];
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode);
make_prim_ext(C, loc, rot, enter_editmode,
PRIM_CIRCLE, RNA_int_get(op->ptr, "vertices"), 0, 0,
RNA_float_get(op->ptr,"radius"), 0.0f, 0,
RNA_boolean_get(op->ptr, "fill"));
#endif
return OPERATOR_FINISHED;
}
void MESH_OT_primitive_circle_add(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Add Circle";
ot->description= "Construct a circle mesh.";
ot->idname= "MESH_OT_primitive_circle_add";
/* api callbacks */
ot->invoke= ED_object_add_generic_invoke;
ot->exec= add_primitive_circle_exec;
ot->poll= ED_operator_scene_editable;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* props */
RNA_def_int(ot->srna, "vertices", 32, INT_MIN, INT_MAX, "Vertices", "", 3, 500);
RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00);
RNA_def_boolean(ot->srna, "fill", 0, "Fill", "");
ED_object_add_generic_props(ot, TRUE);
}
static int add_primitive_tube_exec(bContext *C, wmOperator *op)
{
#if 0
int enter_editmode;
float loc[3], rot[3];
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode);
make_prim_ext(C, loc, rot, enter_editmode,
PRIM_CYLINDER, RNA_int_get(op->ptr, "vertices"), 0, 0,
RNA_float_get(op->ptr, "radius"),
RNA_float_get(op->ptr, "depth"), 1,
RNA_boolean_get(op->ptr, "cap_ends"));
#endif
return OPERATOR_FINISHED;
}
void MESH_OT_primitive_tube_add(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Add Tube";
ot->description= "Construct a tube mesh.";
ot->idname= "MESH_OT_primitive_tube_add";
/* api callbacks */
ot->invoke= ED_object_add_generic_invoke;
ot->exec= add_primitive_tube_exec;
ot->poll= ED_operator_scene_editable;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* props */
RNA_def_int(ot->srna, "vertices", 32, INT_MIN, INT_MAX, "Vertices", "", 2, 500);
RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00);
RNA_def_float(ot->srna, "depth", 1.0f, 0.0, FLT_MAX, "Depth", "", 0.001, 100.00);
RNA_def_boolean(ot->srna, "cap_ends", 1, "Cap Ends", "");
ED_object_add_generic_props(ot, TRUE);
}
static int add_primitive_cone_exec(bContext *C, wmOperator *op)
{
#if 0
int enter_editmode;
float loc[3], rot[3];
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode);
make_prim_ext(C, loc, rot, enter_editmode,
PRIM_CONE, RNA_int_get(op->ptr, "vertices"), 0, 0,
RNA_float_get(op->ptr,"radius"), RNA_float_get(op->ptr, "depth"),
0, RNA_boolean_get(op->ptr, "cap_end"));
#endif
return OPERATOR_FINISHED;
}
void MESH_OT_primitive_cone_add(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Add Cone";
ot->description= "Construct a conic mesh (ends filled).";
ot->idname= "MESH_OT_primitive_cone_add";
/* api callbacks */
ot->invoke= ED_object_add_generic_invoke;
ot->exec= add_primitive_cone_exec;
ot->poll= ED_operator_scene_editable;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* props */
RNA_def_int(ot->srna, "vertices", 32, INT_MIN, INT_MAX, "Vertices", "", 2, 500);
RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00);
RNA_def_float(ot->srna, "depth", 1.0f, 0.0, FLT_MAX, "Depth", "", 0.001, 100.00);
RNA_def_boolean(ot->srna, "cap_end", 0, "Cap End", "");
ED_object_add_generic_props(ot, TRUE);
}
static int add_primitive_grid_exec(bContext *C, wmOperator *op)
{
#if 0
int enter_editmode;
float loc[3], rot[3];
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode);
make_prim_ext(C, loc, rot, enter_editmode,
PRIM_GRID, RNA_int_get(op->ptr, "x_subdivisions"),
RNA_int_get(op->ptr, "y_subdivisions"), 0,
RNA_float_get(op->ptr,"size"), 0.0f, 0, 1);
#endif
return OPERATOR_FINISHED;
}
void MESH_OT_primitive_grid_add(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Add Grid";
ot->description= "Construct a grid mesh.";
ot->idname= "MESH_OT_primitive_grid_add";
/* api callbacks */
ot->invoke= ED_object_add_generic_invoke;
ot->exec= add_primitive_grid_exec;
ot->poll= ED_operator_scene_editable;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* props */
RNA_def_int(ot->srna, "x_subdivisions", 10, INT_MIN, INT_MAX, "X Subdivisions", "", 3, 1000);
RNA_def_int(ot->srna, "y_subdivisions", 10, INT_MIN, INT_MAX, "Y Subdivisions", "", 3, 1000);
RNA_def_float(ot->srna, "size", 1.0f, 0.0, FLT_MAX, "Size", "", 0.001, FLT_MAX);
ED_object_add_generic_props(ot, TRUE);
}
static int add_primitive_monkey_exec(bContext *C, wmOperator *op)
{
#if 0
int enter_editmode;
float loc[3], rot[3];
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode);
make_prim_ext(C, loc, rot, enter_editmode,
PRIM_MONKEY, 0, 0, 2, 0.0f, 0.0f, 0, 0);
#endif
return OPERATOR_FINISHED;
}
void MESH_OT_primitive_monkey_add(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Add Monkey";
ot->description= "Construct a Suzanne mesh.";
ot->idname= "MESH_OT_primitive_monkey_add";
/* api callbacks */
ot->invoke= ED_object_add_generic_invoke;
ot->exec= add_primitive_monkey_exec;
ot->poll= ED_operator_scene_editable;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
ED_object_add_generic_props(ot, TRUE);
}
static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op)
{
Object *obedit;
Mesh *me;
BMEditMesh *em;
float loc[3], rot[3], mat[4][4], dia;
int enter_editmode;
int state;
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode);
make_prim_init(C, &dia, mat, &state, loc, rot);
obedit = CTX_data_edit_object(C);
me = obedit->data;
em = me->edit_btmesh;
if (!EDBM_CallAndSelectOpf(em, op, "vertout",
"create_uvsphere segments=%i revolutions=%i diameter=%f mat=%m4",
RNA_int_get(op->ptr, "rings"), RNA_int_get(op->ptr, "segments"),
RNA_float_get(op->ptr,"size"), mat))
return OPERATOR_CANCELLED;
make_prim_finish(C, &state, enter_editmode);
return OPERATOR_FINISHED;
}
void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Add UV Sphere";
ot->description= "Construct a UV sphere mesh.";
ot->idname= "MESH_OT_primitive_uv_sphere_add";
/* api callbacks */
ot->invoke= ED_object_add_generic_invoke;
ot->exec= add_primitive_uvsphere_exec;
ot->poll= ED_operator_scene_editable;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* props */
RNA_def_int(ot->srna, "segments", 32, INT_MIN, INT_MAX, "Segments", "", 3, 500);
RNA_def_int(ot->srna, "rings", 24, INT_MIN, INT_MAX, "Rings", "", 3, 500);
RNA_def_float(ot->srna, "size", 1.0f, 0.0, FLT_MAX, "Size", "", 0.001, 100.00);
ED_object_add_generic_props(ot, TRUE);
}
static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
{
#if 0
int enter_editmode;
float loc[3], rot[3];
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode);
make_prim_ext(C, loc, rot, enter_editmode,
PRIM_ICOSPHERE, 0, 0, RNA_int_get(op->ptr, "subdivisions"),
RNA_float_get(op->ptr,"size"), 0.0f, 0, 0);
#endif
return OPERATOR_FINISHED;
}
void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Add Ico Sphere";
ot->description= "Construct an Icosphere mesh.";
ot->idname= "MESH_OT_primitive_ico_sphere_add";
/* api callbacks */
ot->invoke= ED_object_add_generic_invoke;
ot->exec= add_primitive_icosphere_exec;
ot->poll= ED_operator_scene_editable;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* props */
RNA_def_int(ot->srna, "subdivisions", 2, 0, 6, "Subdivisions", "", 0, 8);
RNA_def_float(ot->srna, "size", 1.0f, 0.0f, FLT_MAX, "Size", "", 0.001f, 100.00);
ED_object_add_generic_props(ot, TRUE);
}

@ -61,6 +61,7 @@
#include "BKE_utildefines.h"
#include "BKE_customdata.h"
#include "BKE_context.h"
#include "BKE_tessmesh.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
@ -94,40 +95,54 @@ void object_facesel_flush_dm(Object *ob)
{
Mesh *me= get_mesh(ob);
DerivedMesh *dm= ob->derivedFinal;
MFace *faces, *mf, *mf_orig;
int *index_array = NULL;
MPoly *faces, *mf, *mf_orig;
DMFaceIter *fiter;
int *index = NULL;
int totface;
int i;
if(me==NULL || dm==NULL)
return;
index_array = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
fiter = dm->newFaceIter(dm);
totface = dm->getNumFaces(dm);
if(!index_array)
return;
faces = dm->getTessFaceArray(dm);
totface = dm->getNumTessFaces(dm);
mf= faces;
for (i= 0; i<totface; i++, mf++) { /* loop over derived mesh faces */
mf_orig= me->mface + index_array[i];
mf->flag= mf_orig->flag;;
for (i=0; !fiter->done; fiter->step(fiter), i++) {
index = fiter->getCDData(fiter, CD_ORIGINDEX, -1);
if (!index) {
fiter->free(fiter);
return;
}
mf_orig = me->mpoly + *index;
fiter->flags = mf_orig->flag;
}
fiter->free(fiter);
}
/* returns 0 if not found, otherwise 1 */
int facesel_face_pick(struct bContext *C, Mesh *me, short *mval, unsigned int *index, short rect)
int facesel_face_pick(struct bContext *C, Mesh *me, Object *ob,
short *mval, unsigned int *index, short rect)
{
Scene *scene = CTX_data_scene(C);
ViewContext vc;
view3d_set_viewcontext(C, &vc);
if (!me || me->totface==0)
if (!me || me->totpoly==0)
return 0;
// XXX if (v3d->flag & V3D_INVALID_BACKBUF) {
/*we can't assume mfaces have a correct origindex layer that indices to mpolys.
so instead we have to regenerate the tesselation faces altogether.
the final 0, 0 paramters causes it to use the index of each mpoly, instead
of reading from the origindex layer.*/
me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, &me->pdata,
me->mvert, me->totface, me->totloop, me->totpoly, 0, 0);
mesh_update_customdata_pointers(me);
makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH);
// XXX if (v3d->flag & V3D_INVALID_BACKBUF) {
// XXX drawview.c! check_backbuf();
// XXX persp(PERSP_VIEW);
// XXX }
@ -144,7 +159,7 @@ int facesel_face_pick(struct bContext *C, Mesh *me, short *mval, unsigned int *i
*index = view3d_sample_backbuf(&vc, mval[0], mval[1]);
}
if ((*index)<=0 || (*index)>(unsigned int)me->totface)
if ((*index)<=0 || (*index)>(unsigned int)me->totpoly)
return 0;
(*index)--;
@ -154,41 +169,37 @@ int facesel_face_pick(struct bContext *C, Mesh *me, short *mval, unsigned int *i
/* last_sel, use em->act_face otherwise get the last selected face in the editselections
* at the moment, last_sel is mainly useful for gaking sure the space image dosnt flicker */
MTFace *EM_get_active_mtface(EditMesh *em, EditFace **act_efa, MCol **mcol, int sloppy)
MTexPoly *EDBM_get_active_mtface(BMEditMesh *em, BMFace **act_efa, int sloppy)
{
EditFace *efa = NULL;
BMFace *efa = NULL;
BMLoop *l;
BMIter iter, liter;
if(!EM_texFaceCheck(em))
if(!EDBM_texFaceCheck(em))
return NULL;
efa = EM_get_actFace(em, sloppy);
efa = EDBM_get_actFace(em, sloppy);
if (efa) {
if (mcol) {
if (CustomData_has_layer(&em->fdata, CD_MCOL))
*mcol = CustomData_em_get(&em->fdata, efa->data, CD_MCOL);
else
*mcol = NULL;
}
if (act_efa) *act_efa = efa;
return CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
return CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
}
if (act_efa) *act_efa= NULL;
if(mcol) *mcol = NULL;
return NULL;
}
void reveal_tface(Scene *scene)
{
Mesh *me;
MFace *mface;
MPoly *mface;
int a;
me= get_mesh(OBACT);
if(me==0 || me->totface==0) return;
if(me==0 || me->totpoly==0) return;
mface= me->mface;
a= me->totface;
mface= me->mpoly;
a= me->totpoly;
while(a--) {
if(mface->flag & ME_HIDE) {
mface->flag |= ME_FACE_SEL;
@ -204,20 +215,20 @@ void reveal_tface(Scene *scene)
void hide_tface(Scene *scene)
{
Mesh *me;
MFace *mface;
MPoly *mface;
int a;
int shift=0, alt= 0; // XXX
me= get_mesh(OBACT);
if(me==0 || me->totface==0) return;
if(me==0 || me->totpoly==0) return;
if(alt) {
reveal_tface(scene);
return;
}
mface= me->mface;
a= me->totface;
mface= me->mpoly;
a= me->totpoly;
while(a--) {
if(mface->flag & ME_HIDE);
else {
@ -239,30 +250,30 @@ void hide_tface(Scene *scene)
/* Set tface seams based on edge data, uses hash table to find seam edges. */
static void hash_add_face(EdgeHash *ehash, MFace *mf)
static void hash_add_face(EdgeHash *ehash, MPoly *mf, MLoop *mloop)
{
BLI_edgehash_insert(ehash, mf->v1, mf->v2, NULL);
BLI_edgehash_insert(ehash, mf->v2, mf->v3, NULL);
if(mf->v4) {
BLI_edgehash_insert(ehash, mf->v3, mf->v4, NULL);
BLI_edgehash_insert(ehash, mf->v4, mf->v1, NULL);
MLoop *ml, *ml2;
int i;
for (i=0, ml=mloop; i<mf->totloop; i++, ml++) {
ml2 = mloop + (i+1) % mf->totloop;
BLI_edgehash_insert(ehash, ml->v, ml2->v, NULL);
}
else
BLI_edgehash_insert(ehash, mf->v3, mf->v1, NULL);
}
void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index)
{
MFace *mf;
int a, doit=1, mark=0;
char *linkflag;
EdgeHash *ehash, *seamhash;
MPoly *mf;
MLoop *ml;
MEdge *med;
char *linkflag;
int a, b, doit=1, mark=0;
ehash= BLI_edgehash_new();
seamhash = BLI_edgehash_new();
linkflag= MEM_callocN(sizeof(char)*me->totface, "linkflaguv");
linkflag= MEM_callocN(sizeof(char)*me->totpoly, "linkflaguv");
for(med=me->medge, a=0; a < me->totedge; a++, med++)
if(med->flag & ME_SEAM)
@ -270,17 +281,17 @@ void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index)
if (mode==0 || mode==1) {
/* only put face under cursor in array */
mf= ((MFace*)me->mface) + index;
hash_add_face(ehash, mf);
mf= ((MPoly*)me->mpoly) + index;
hash_add_face(ehash, mf, me->mloop + mf->loopstart);
linkflag[index]= 1;
}
else {
/* fill array by selection */
mf= me->mface;
for(a=0; a<me->totface; a++, mf++) {
mf= me->mpoly;
for(a=0; a<me->totpoly; a++, mf++) {
if(mf->flag & ME_HIDE);
else if(mf->flag & ME_FACE_SEL) {
hash_add_face(ehash, mf);
hash_add_face(ehash, mf, me->mloop + mf->loopstart);
linkflag[a]= 1;
}
}
@ -290,35 +301,26 @@ void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index)
doit= 0;
/* expand selection */
mf= me->mface;
for(a=0; a<me->totface; a++, mf++) {
mf= me->mpoly;
for(a=0; a<me->totpoly; a++, mf++) {
if(mf->flag & ME_HIDE)
continue;
if(!linkflag[a]) {
MLoop *mnextl;
mark= 0;
if(!BLI_edgehash_haskey(seamhash, mf->v1, mf->v2))
if(BLI_edgehash_haskey(ehash, mf->v1, mf->v2))
mark= 1;
if(!BLI_edgehash_haskey(seamhash, mf->v2, mf->v3))
if(BLI_edgehash_haskey(ehash, mf->v2, mf->v3))
mark= 1;
if(mf->v4) {
if(!BLI_edgehash_haskey(seamhash, mf->v3, mf->v4))
if(BLI_edgehash_haskey(ehash, mf->v3, mf->v4))
mark= 1;
if(!BLI_edgehash_haskey(seamhash, mf->v4, mf->v1))
if(BLI_edgehash_haskey(ehash, mf->v4, mf->v1))
mark= 1;
ml = me->mloop + mf->loopstart;
for (b=0; b<mf->totloop; b++, ml++) {
mnextl = b < mf->totloop-1 ? ml - 1 : me->mloop + mf->loopstart;
if (!BLI_edgehash_haskey(seamhash, ml->v, mnextl->v))
if (!BLI_edgehash_haskey(ehash, ml->v, mnextl->v))
mark = 1;
}
else if(!BLI_edgehash_haskey(seamhash, mf->v3, mf->v1))
if(BLI_edgehash_haskey(ehash, mf->v3, mf->v1))
mark = 1;
if(mark) {
linkflag[a]= 1;
hash_add_face(ehash, mf);
hash_add_face(ehash, mf, me->mloop + mf->loopstart);
doit= 1;
}
}
@ -330,24 +332,24 @@ void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index)
BLI_edgehash_free(seamhash, NULL);
if(mode==0 || mode==2) {
for(a=0, mf=me->mface; a<me->totface; a++, mf++)
for(a=0, mf=me->mpoly; a<me->totpoly; a++, mf++)
if(linkflag[a])
mf->flag |= ME_FACE_SEL;
else
mf->flag &= ~ME_FACE_SEL;
}
else if(mode==1) {
for(a=0, mf=me->mface; a<me->totface; a++, mf++)
for(a=0, mf=me->mpoly; a<me->totpoly; a++, mf++)
if(linkflag[a] && (mf->flag & ME_FACE_SEL))
break;
if (a<me->totface) {
for(a=0, mf=me->mface; a<me->totface; a++, mf++)
if (a<me->totpoly) {
for(a=0, mf=me->mpoly; a<me->totpoly; a++, mf++)
if(linkflag[a])
mf->flag &= ~ME_FACE_SEL;
}
else {
for(a=0, mf=me->mface; a<me->totface; a++, mf++)
for(a=0, mf=me->mface; a<me->totpoly; a++, mf++)
if(linkflag[a])
mf->flag |= ME_FACE_SEL;
}
@ -365,7 +367,7 @@ void select_linked_tfaces(bContext *C, Object *ob, short mval[2], int mode)
unsigned int index=0;
me = get_mesh(ob);
if(me==0 || me->totface==0) return;
if(me==0 || me->totpoly==0) return;
if (mode==0 || mode==1) {
// XXX - Causes glitches, not sure why
@ -383,7 +385,7 @@ void select_linked_tfaces(bContext *C, Object *ob, short mval[2], int mode)
void selectall_tface(Object *ob, int action)
{
Mesh *me;
MFace *mface;
MPoly *mface;
int a;
me= get_mesh(ob);
@ -392,8 +394,8 @@ void selectall_tface(Object *ob, int action)
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
mface= me->mface;
a= me->totface;
mface= me->mpoly;
a= me->totpoly;
while(a--) {
if((mface->flag & ME_HIDE) == 0 && mface->flag & ME_FACE_SEL) {
action = SEL_DESELECT;
@ -403,8 +405,8 @@ void selectall_tface(Object *ob, int action)
}
}
mface= me->mface;
a= me->totface;
mface= me->mpoly;
a= me->totpoly;
while(a--) {
if((mface->flag & ME_HIDE) == 0) {
switch (action) {
@ -429,14 +431,14 @@ void selectall_tface(Object *ob, int action)
void selectswap_tface(Scene *scene)
{
Mesh *me;
MFace *mface;
MPoly *mface;
int a;
me= get_mesh(OBACT);
if(me==0) return;
mface= me->mface;
a= me->totface;
mface= me->mpoly;
a= me->totpoly;
while(a--) {
if(mface->flag & ME_HIDE);
else {
@ -454,49 +456,39 @@ int minmax_tface(Scene *scene, float *min, float *max)
{
Object *ob;
Mesh *me;
MFace *mf;
MTFace *tf;
MPoly *mf;
MTexPoly *tf;
MLoop *ml;
MVert *mv;
int a, ok=0;
int a, b, ok=0;
float vec[3], bmat[3][3];
ob = OBACT;
if (ob==0) return ok;
me= get_mesh(ob);
if(me==0 || me->mtface==0) return ok;
if(!me || !me->mtpoly) return ok;
copy_m3_m4(bmat, ob->obmat);
mv= me->mvert;
mf= me->mface;
tf= me->mtface;
for (a=me->totface; a>0; a--, mf++, tf++) {
mf= me->mpoly;
tf= me->mtpoly;
for (a=me->totpoly; a>0; a--, mf++, tf++) {
if (mf->flag & ME_HIDE || !(mf->flag & ME_FACE_SEL))
continue;
VECCOPY(vec, (mv+mf->v1)->co);
mul_m3_v3(bmat, vec);
add_v3_v3v3(vec, vec, ob->obmat[3]);
DO_MINMAX(vec, min, max);
VECCOPY(vec, (mv+mf->v2)->co);
mul_m3_v3(bmat, vec);
add_v3_v3v3(vec, vec, ob->obmat[3]);
DO_MINMAX(vec, min, max);
VECCOPY(vec, (mv+mf->v3)->co);
mul_m3_v3(bmat, vec);
add_v3_v3v3(vec, vec, ob->obmat[3]);
DO_MINMAX(vec, min, max);
if (mf->v4) {
VECCOPY(vec, (mv+mf->v4)->co);
ml = me->mloop + mf->totloop;
for (b=0; b<mf->totloop; b++, ml++) {
VECCOPY(vec, (mv+ml->v)->co);
mul_m3_v3(bmat, vec);
add_v3_v3v3(vec, vec, ob->obmat[3]);
DO_MINMAX(vec, min, max);
DO_MINMAX(vec, min, max);
}
ok= 1;
}
return ok;
}
@ -504,12 +496,12 @@ int minmax_tface(Scene *scene, float *min, float *max)
#define ME_SEAM_DONE 2 /* reuse this flag */
static float edgetag_cut_cost(EditMesh *em, int e1, int e2, int vert)
static float edgetag_cut_cost(BMEditMesh *em, int e1, int e2, int vert)
{
EditVert *v = EM_get_vert_for_index(vert);
EditEdge *eed1 = EM_get_edge_for_index(e1), *eed2 = EM_get_edge_for_index(e2);
EditVert *v1 = EM_get_vert_for_index( (eed1->v1->tmp.l == vert)? eed1->v2->tmp.l: eed1->v1->tmp.l );
EditVert *v2 = EM_get_vert_for_index( (eed2->v1->tmp.l == vert)? eed2->v2->tmp.l: eed2->v1->tmp.l );
BMVert *v = EDBM_get_vert_for_index(em, vert);
BMEdge *eed1 = EDBM_get_edge_for_index(em, e1), *eed2 = EDBM_get_edge_for_index(em, e2);
BMVert *v1 = EDBM_get_vert_for_index(em, (BMINDEX_GET(eed1->v1) == vert)? BMINDEX_GET(eed1->v2): BMINDEX_GET(eed1->v1) );
BMVert *v2 = EDBM_get_vert_for_index(em, (BMINDEX_GET(eed2->v1) == vert)? BMINDEX_GET(eed2->v2): BMINDEX_GET(eed2->v1) );
float cost, d1[3], d2[3];
cost = len_v3v3(v1->co, v->co);
@ -523,16 +515,17 @@ static float edgetag_cut_cost(EditMesh *em, int e1, int e2, int vert)
return cost;
}
static void edgetag_add_adjacent(EditMesh *em, Heap *heap, int mednum, int vertnum, int *nedges, int *edges, int *prevedge, float *cost)
static void edgetag_add_adjacent(BMEditMesh *em, Heap *heap, int mednum, int vertnum,
int *nedges, int *edges, int *prevedge, float *cost)
{
int startadj, endadj = nedges[vertnum+1];
for (startadj = nedges[vertnum]; startadj < endadj; startadj++) {
int adjnum = edges[startadj];
EditEdge *eedadj = EM_get_edge_for_index(adjnum);
BMEdge *eedadj = EDBM_get_edge_for_index(em, adjnum);
float newcost;
if (eedadj->f2 & ME_SEAM_DONE)
if (eedadj->head.eflag2 & ME_SEAM_DONE)
continue;
newcost = cost[mednum] + edgetag_cut_cost(em, mednum, adjnum, vertnum);
@ -545,20 +538,20 @@ static void edgetag_add_adjacent(EditMesh *em, Heap *heap, int mednum, int vertn
}
}
void edgetag_context_set(Scene *scene, EditEdge *eed, int val)
void edgetag_context_set(BMEditMesh *em, Scene *scene, BMEdge *eed, int val)
{
switch (scene->toolsettings->edge_mode) {
case EDGE_MODE_SELECT:
EM_select_edge(eed, val);
BM_Select(em->bm, eed, val);
break;
case EDGE_MODE_TAG_SEAM:
if (val) {eed->seam = 255;}
else {eed->seam = 0;}
if (val) {BM_SetHFlag(eed, BM_SEAM);}
else {BM_ClearHFlag(eed, BM_SEAM);}
break;
case EDGE_MODE_TAG_SHARP:
if (val) {eed->sharp = 1;}
else {eed->sharp = 0;}
if (val) {BM_SetHFlag(eed, BM_SEAM);}
else {BM_ClearHFlag(eed, BM_SEAM);}
break;
case EDGE_MODE_TAG_CREASE:
if (val) {eed->crease = 1.0f;}
@ -571,15 +564,15 @@ void edgetag_context_set(Scene *scene, EditEdge *eed, int val)
}
}
int edgetag_context_check(Scene *scene, EditEdge *eed)
int edgetag_context_check(Scene *scene, BMEdge *eed)
{
switch (scene->toolsettings->edge_mode) {
case EDGE_MODE_SELECT:
return (eed->f & SELECT) ? 1 : 0;
return BM_TestHFlag(eed, BM_SELECT) ? 1 : 0;
case EDGE_MODE_TAG_SEAM:
return eed->seam ? 1 : 0;
return BM_TestHFlag(eed, BM_SEAM);
case EDGE_MODE_TAG_SHARP:
return eed->sharp ? 1 : 0;
return BM_TestHFlag(eed, BM_SHARP);
case EDGE_MODE_TAG_CREASE:
return eed->crease ? 1 : 0;
case EDGE_MODE_TAG_BEVEL:
@ -589,28 +582,29 @@ int edgetag_context_check(Scene *scene, EditEdge *eed)
}
int edgetag_shortest_path(Scene *scene, EditMesh *em, EditEdge *source, EditEdge *target)
int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, BMEdge *target)
{
EditEdge *eed;
EditVert *ev;
BMEdge *eed;
BMVert *ev;
BMIter iter;
Heap *heap;
float *cost;
int a, totvert=0, totedge=0, *nedges, *edges, *prevedge, mednum = -1, nedgeswap = 0;
/* we need the vert */
for (ev= em->verts.first, totvert=0; ev; ev= ev->next) {
ev->tmp.l = totvert;
BM_ITER(ev, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
BMINDEX_SET(ev, totvert);
totvert++;
}
for (eed= em->edges.first; eed; eed = eed->next) {
eed->f2 = 0;
if (eed->h) {
eed->f2 |= ME_SEAM_DONE;
BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
eed->head.eflag2 = 0;
if (BM_TestHFlag(eed, BM_SELECT)) {
eed->head.eflag2 |= ME_SEAM_DONE;
}
eed->tmp.l = totedge;
BMINDEX_SET(eed, totedge);
totedge++;
}
@ -621,9 +615,9 @@ int edgetag_shortest_path(Scene *scene, EditMesh *em, EditEdge *source, EditEdge
cost = MEM_mallocN(sizeof(*cost)*totedge, "SeamPathCost");
/* count edges, compute adjacent edges offsets and fill adjacent edges */
for (eed= em->edges.first; eed; eed = eed->next) {
nedges[eed->v1->tmp.l+1]++;
nedges[eed->v2->tmp.l+1]++;
BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
nedges[BMINDEX_GET(eed->v1)+1]++;
nedges[BMINDEX_GET(eed->v2)+1]++;
}
for (a=1; a<totvert; a++) {
@ -633,107 +627,108 @@ int edgetag_shortest_path(Scene *scene, EditMesh *em, EditEdge *source, EditEdge
}
nedges[0] = nedges[1] = 0;
for (a=0, eed= em->edges.first; eed; a++, eed = eed->next) {
edges[nedges[eed->v1->tmp.l+1]++] = a;
edges[nedges[eed->v2->tmp.l+1]++] = a;
BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
edges[nedges[BMINDEX_GET(eed->v1)+1]++] = a;
edges[nedges[BMINDEX_GET(eed->v2)+1]++] = a;
cost[a] = 1e20f;
prevedge[a] = -1;
a++;
}
/* regular dijkstra shortest path, but over edges instead of vertices */
heap = BLI_heap_new();
BLI_heap_insert(heap, 0.0f, SET_INT_IN_POINTER(source->tmp.l));
cost[source->tmp.l] = 0.0f;
EM_init_index_arrays(em, 1, 1, 0);
BLI_heap_insert(heap, 0.0f, SET_INT_IN_POINTER(BMINDEX_GET(source)));
cost[BMINDEX_GET(source)] = 0.0f;
EDBM_init_index_arrays(em, 1, 1, 0);
while (!BLI_heap_empty(heap)) {
mednum = GET_INT_FROM_POINTER(BLI_heap_popmin(heap));
eed = EM_get_edge_for_index( mednum );
eed = EDBM_get_edge_for_index(em, mednum);
if (mednum == target->tmp.l)
if (mednum == BMINDEX_GET(target))
break;
if (eed->f2 & ME_SEAM_DONE)
if (eed->head.eflag2 & ME_SEAM_DONE)
continue;
eed->f2 |= ME_SEAM_DONE;
eed->head.eflag2 |= ME_SEAM_DONE;
edgetag_add_adjacent(em, heap, mednum, eed->v1->tmp.l, nedges, edges, prevedge, cost);
edgetag_add_adjacent(em, heap, mednum, eed->v2->tmp.l, nedges, edges, prevedge, cost);
edgetag_add_adjacent(em, heap, mednum, BMINDEX_GET(eed->v1), nedges, edges, prevedge, cost);
edgetag_add_adjacent(em, heap, mednum, BMINDEX_GET(eed->v2), nedges, edges, prevedge, cost);
}
MEM_freeN(nedges);
MEM_freeN(edges);
MEM_freeN(cost);
BLI_heap_free(heap, NULL);
for (eed= em->edges.first; eed; eed = eed->next) {
eed->f2 &= ~ME_SEAM_DONE;
BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
eed->head.eflag2 &= ~ME_SEAM_DONE;
}
if (mednum != target->tmp.l) {
if (mednum != BMINDEX_GET(target)) {
MEM_freeN(prevedge);
EM_free_index_arrays();
EDBM_free_index_arrays(em);
return 0;
}
/* follow path back to source and mark as seam */
if (mednum == target->tmp.l) {
if (mednum == BMINDEX_GET(target)) {
short allseams = 1;
mednum = target->tmp.l;
mednum = BMINDEX_GET(target);
do {
eed = EM_get_edge_for_index( mednum );
eed = EDBM_get_edge_for_index(eed, mednum);
if (!edgetag_context_check(scene, eed)) {
allseams = 0;
break;
}
mednum = prevedge[mednum];
} while (mednum != source->tmp.l);
} while (mednum != BMINDEX_GET(source));
mednum = target->tmp.l;
mednum = BMINDEX_GET(target);
do {
eed = EM_get_edge_for_index( mednum );
eed = EDBM_get_edge_for_index(em, mednum);
if (allseams)
edgetag_context_set(scene, eed, 0);
edgetag_context_set(em, scene, eed, 0);
else
edgetag_context_set(scene, eed, 1);
edgetag_context_set(em, scene, eed, 1);
mednum = prevedge[mednum];
} while (mednum != -1);
}
MEM_freeN(prevedge);
EM_free_index_arrays();
EDBM_free_index_arrays(em);
return 1;
}
/* *************************************** */
static void seam_edgehash_insert_face(EdgeHash *ehash, MFace *mf)
static void seam_edgehash_insert_face(EdgeHash *ehash, MPoly *mf, MLoop *loopstart)
{
BLI_edgehash_insert(ehash, mf->v1, mf->v2, NULL);
BLI_edgehash_insert(ehash, mf->v2, mf->v3, NULL);
if (mf->v4) {
BLI_edgehash_insert(ehash, mf->v3, mf->v4, NULL);
BLI_edgehash_insert(ehash, mf->v4, mf->v1, NULL);
MLoop *ml1, *ml2;
int a;
for (a=0; a<mf->totloop; a++) {
ml1 = loopstart + a;
ml2 = loopstart + (a+1) % mf->totloop;
BLI_edgehash_insert(ehash, ml1->v, ml2->v, NULL);
}
else
BLI_edgehash_insert(ehash, mf->v3, mf->v1, NULL);
}
void seam_mark_clear_tface(Scene *scene, short mode)
{
Mesh *me;
MFace *mf;
MPoly *mf;
MLoop *ml1, *ml2;
MEdge *med;
int a;
int a, b;
me= get_mesh(OBACT);
if(me==0 || me->totface==0) return;
if(me==0 || me->totpoly==0) return;
if (mode == 0)
mode = pupmenu("Seams%t|Mark Border Seam %x1|Clear Seam %x2");
@ -744,9 +739,9 @@ void seam_mark_clear_tface(Scene *scene, short mode)
if (mode == 2) {
EdgeHash *ehash = BLI_edgehash_new();
for (a=0, mf=me->mface; a<me->totface; a++, mf++)
for (a=0, mf=me->mpoly; a<me->totpoly; a++, mf++)
if (!(mf->flag & ME_HIDE) && (mf->flag & ME_FACE_SEL))
seam_edgehash_insert_face(ehash, mf);
seam_edgehash_insert_face(ehash, mf, me->mloop + mf->loopstart);
for (a=0, med=me->medge; a<me->totedge; a++, med++)
if (BLI_edgehash_haskey(ehash, med->v1, med->v2))
@ -759,11 +754,11 @@ void seam_mark_clear_tface(Scene *scene, short mode)
EdgeHash *ehash1 = BLI_edgehash_new();
EdgeHash *ehash2 = BLI_edgehash_new();
for (a=0, mf=me->mface; a<me->totface; a++, mf++) {
for (a=0, mf=me->mpoly; a<me->totpoly; a++, mf++) {
if ((mf->flag & ME_HIDE) || !(mf->flag & ME_FACE_SEL))
seam_edgehash_insert_face(ehash1, mf);
seam_edgehash_insert_face(ehash1, mf, me->mloop + mf->loopstart);
else
seam_edgehash_insert_face(ehash2, mf);
seam_edgehash_insert_face(ehash2, mf, me->mloop + mf->loopstart);
}
for (a=0, med=me->medge; a<me->totedge; a++, med++)
@ -786,21 +781,24 @@ void seam_mark_clear_tface(Scene *scene, short mode)
int face_select(struct bContext *C, Object *ob, short mval[2], int extend)
{
Mesh *me;
MFace *mface, *msel;
MPoly *mface, *msel;
unsigned int a, index;
/* Get the face under the cursor */
me = get_mesh(ob);
if (!facesel_face_pick(C, me, mval, &index, 1))
if (!facesel_face_pick(C, me, ob, mval, &index, 1))
return 0;
msel= (((MFace*)me->mface)+index);
if (index >= me->totpoly || index < 0)
return 0;
msel= me->mpoly + index;
if (msel->flag & ME_HIDE) return 0;
/* clear flags */
mface = me->mface;
a = me->totface;
mface = me->mpoly;
a = me->totpoly;
if (!extend) {
while (a--) {
mface->flag &= ~ME_FACE_SEL;
@ -830,28 +828,28 @@ int face_select(struct bContext *C, Object *ob, short mval[2], int extend)
void face_borderselect(struct bContext *C, Object *ob, rcti *rect, int select, int extend)
{
Mesh *me;
MFace *mface;
MPoly *mface;
struct ImBuf *ibuf;
unsigned int *rt;
int a, sx, sy, index;
char *selar;
int a, sx, sy, index;
ViewContext vc;
view3d_set_viewcontext(C, &vc);
me= get_mesh(ob);
if(me==0) return;
if(me->totface==0) return;
if(me->totpoly==0) return;
selar= MEM_callocN(me->totface+1, "selar");
selar= MEM_callocN(me->totpoly+1, "selar");
sx= (rect->xmax-rect->xmin+1);
sy= (rect->ymax-rect->ymin+1);
if(sx*sy<=0) return;
if (extend == 0 && select) {
mface= me->mface;
for(a=1; a<=me->totface; a++, mface++) {
mface= me->mpoly;
for(a=1; a<=me->totpoly; a++, mface++) {
if((mface->flag & ME_HIDE) == 0)
mface->flag &= ~ME_FACE_SEL;
}
@ -873,8 +871,8 @@ void face_borderselect(struct bContext *C, Object *ob, rcti *rect, int select, i
rt++;
}
mface= me->mface;
for(a=1; a<=me->totface; a++, mface++) {
mface= me->mpoly;
for(a=1; a<=me->totpoly; a++, mface++) {
if(selar[a]) {
if(mface->flag & ME_HIDE);
else {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,898 +0,0 @@
/**
* $Id:
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2004 by Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
/*
editmesh_loop: tools with own drawing subloops, select, knife, subdiv
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "MEM_guardedalloc.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
#include "BLI_ghash.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_displist.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_utildefines.h"
#include "BKE_tessmesh.h"
#include "PIL_time.h"
#include "BIF_gl.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_mesh.h"
#include "ED_screen.h"
#include "ED_view3d.h"
#include "mesh_intern.h"
#include "bmesh.h"
/* **** XXX ******** */
static void BIF_undo_push() {}
static void BIF_undo() {}
static void error() {}
static int qtest() {return 0;}
/* **** XXX ******** */
/* New LoopCut */
static void edgering_sel(EditMesh *em, EditEdge *startedge, int select, int previewlines)
{
EditEdge *eed;
EditFace *efa;
EditVert *v[2][2];
float co[2][3];
int looking= 1,i;
/* in eed->f1 we put the valence (amount of faces in edge) */
/* in eed->f2 we put tagged flag as correct loop */
/* in efa->f1 we put tagged flag as correct to select */
for(eed= em->edges.first; eed; eed= eed->next) {
eed->f1= 0;
eed->f2= 0;
}
for(efa= em->faces.first; efa; efa= efa->next) {
efa->f1= 0;
if(efa->h==0) {
efa->e1->f1++;
efa->e2->f1++;
efa->e3->f1++;
if(efa->e4) efa->e4->f1++;
}
}
// tag startedge OK
startedge->f2= 1;
while(looking) {
looking= 0;
for(efa= em->faces.first; efa; efa= efa->next) {
if(efa->e4 && efa->f1==0 && efa->h == 0) { // not done quad
if(efa->e1->f1<=2 && efa->e2->f1<=2 && efa->e3->f1<=2 && efa->e4->f1<=2) { // valence ok
// if edge tagged, select opposing edge and mark face ok
if(efa->e1->f2) {
efa->e3->f2= 1;
efa->f1= 1;
looking= 1;
}
else if(efa->e2->f2) {
efa->e4->f2= 1;
efa->f1= 1;
looking= 1;
}
if(efa->e3->f2) {
efa->e1->f2= 1;
efa->f1= 1;
looking= 1;
}
if(efa->e4->f2) {
efa->e2->f2= 1;
efa->f1= 1;
looking= 1;
}
}
}
}
}
if(previewlines > 0 && select == 0){
// XXX persp(PERSP_VIEW);
// XXX glPushMatrix();
// XXX mymultmatrix(obedit->obmat);
for(efa= em->faces.first; efa; efa= efa->next) {
if(efa->v4 == NULL) { continue; }
if(efa->h == 0){
if(efa->e1->f2 == 1){
if(efa->e1->h == 1 || efa->e3->h == 1 )
continue;
v[0][0] = efa->v1;
v[0][1] = efa->v2;
v[1][0] = efa->v4;
v[1][1] = efa->v3;
} else if(efa->e2->f2 == 1){
if(efa->e2->h == 1 || efa->e4->h == 1)
continue;
v[0][0] = efa->v2;
v[0][1] = efa->v3;
v[1][0] = efa->v1;
v[1][1] = efa->v4;
} else { continue; }
for(i=1;i<=previewlines;i++){
co[0][0] = (v[0][1]->co[0] - v[0][0]->co[0])*(i/((float)previewlines+1))+v[0][0]->co[0];
co[0][1] = (v[0][1]->co[1] - v[0][0]->co[1])*(i/((float)previewlines+1))+v[0][0]->co[1];
co[0][2] = (v[0][1]->co[2] - v[0][0]->co[2])*(i/((float)previewlines+1))+v[0][0]->co[2];
co[1][0] = (v[1][1]->co[0] - v[1][0]->co[0])*(i/((float)previewlines+1))+v[1][0]->co[0];
co[1][1] = (v[1][1]->co[1] - v[1][0]->co[1])*(i/((float)previewlines+1))+v[1][0]->co[1];
co[1][2] = (v[1][1]->co[2] - v[1][0]->co[2])*(i/((float)previewlines+1))+v[1][0]->co[2];
glColor3ub(255, 0, 255);
glBegin(GL_LINES);
glVertex3f(co[0][0],co[0][1],co[0][2]);
glVertex3f(co[1][0],co[1][1],co[1][2]);
glEnd();
}
}
}
glPopMatrix();
} else {
/* (de)select the edges */
for(eed= em->edges.first; eed; eed= eed->next) {
if(eed->f2) EM_select_edge(eed, select);
}
}
}
void CutEdgeloop(Object *obedit, wmOperator *op, EditMesh *em, int numcuts)
{
#if 0
ViewContext vc; // XXX
EditEdge *nearest=NULL, *eed;
float fac;
int keys = 0, holdnum=0, selectmode, dist;
short mvalo[2] = {0, 0}, mval[2] = {0, 0};
short event=0, val, choosing=1, cancel=0, cuthalf = 0, smooth=0;
short hasHidden = 0;
char msg[128];
selectmode = em->selectmode;
if(em->selectmode & SCE_SELECT_FACE){
em->selectmode = SCE_SELECT_EDGE;
EM_selectmode_set(em);
}
BIF_undo_push("Loopcut Begin");
while(choosing && !cancel){
// XXX getmouseco_areawin(mval);
if (mval[0] != mvalo[0] || mval[1] != mvalo[1]) {
mvalo[0] = mval[0];
mvalo[1] = mval[1];
dist= 50;
nearest = findnearestedge(&vc, &dist); // returns actual distance in dist
// scrarea_do_windraw(curarea); // after findnearestedge, backbuf!
sprintf(msg,"Number of Cuts: %d (S)mooth: ",numcuts);
strcat(msg, smooth ? "on":"off");
// headerprint(msg);
/* Need to figure preview */
if(nearest){
edgering_sel(em, nearest, 0, numcuts);
}
// XXX screen_swapbuffers();
/* backbuffer refresh for non-apples (no aux) */
#ifndef __APPLE__
// XXX if(G.vd->drawtype>OB_WIRE && (G.vd->flag & V3D_ZBUF_SELECT)) {
// backdrawview3d(0);
// }
#endif
}
else PIL_sleep_ms(10); // idle
while(qtest())
{
val=0;
// XXX event= extern_qread(&val);
if(val && (event == MOUSEX || event == MOUSEY)){ ; }
else if(val && ((event==LEFTMOUSE || event==RETKEY) || (event == MIDDLEMOUSE || event==PADENTER)))
{
if(event == MIDDLEMOUSE){
cuthalf = 1;
}
if (nearest==NULL)
cancel = 1;
choosing=0;
mvalo[0] = -1;
}
else if(val && (event==ESCKEY || event==RIGHTMOUSE ))
{
choosing=0;
cancel = 1;
mvalo[0] = -1;
}
else if(val && (event==PADPLUSKEY || event==WHEELUPMOUSE))
{
numcuts++;
mvalo[0] = -1;
}
else if(val && (event==PADMINUS || event==WHEELDOWNMOUSE))
{
if(numcuts > 1){
numcuts--;
mvalo[0] = -1;
}
}
else if(val && event==SKEY)
{
if(smooth){smooth=0;}
else { smooth=1; }
mvalo[0] = -1;
}
else if(val){
holdnum = -1;
switch(event){
case PAD9:
case NINEKEY:
holdnum = 9; break;
case PAD8:
case EIGHTKEY:
holdnum = 8;break;
case PAD7:
case SEVENKEY:
holdnum = 7;break;
case PAD6:
case SIXKEY:
holdnum = 6;break;
case PAD5:
case FIVEKEY:
holdnum = 5;break;
case PAD4:
case FOURKEY:
holdnum = 4;break;
case PAD3:
case THREEKEY:
holdnum = 3; break;
case PAD2:
case TWOKEY:
holdnum = 2;break;
case PAD1:
case ONEKEY:
holdnum = 1; break;
case PAD0:
case ZEROKEY:
holdnum = 0;break;
case BACKSPACEKEY:
holdnum = -2;break;
}
if(holdnum >= 0 && numcuts*10 < 130){
if(keys == 0){ // first level numeric entry
if(holdnum > 0){
numcuts = holdnum;
keys++;
}
} else if(keys > 0){//highrt level numeric entry
numcuts *= 10;
numcuts += holdnum;
keys++;
}
} else if (holdnum == -2){// backspace
if (keys > 1){
numcuts /= 10;
keys--;
} else {
numcuts=1;
keys = 0;
}
}
mvalo[0] = -1;
break;
} // End Numeric Entry
} //End while(qtest())
} // End Choosing
if(cancel){
return;
}
/* clean selection */
for(eed=em->edges.first; eed; eed = eed->next){
EM_select_edge(eed,0);
}
/* select edge ring */
edgering_sel(em, nearest, 1, 0);
/* now cut the loops */
if(smooth){
fac= 1.0f;
// XXX if(fbutton(&fac, 0.0f, 5.0f, 10, 10, "Smooth:")==0) return;
fac= 0.292f*fac;
esubdivideflag(obedit, em, SELECT,fac,0,B_SMOOTH,numcuts,SUBDIV_SELECT_LOOPCUT);
} else {
esubdivideflag(obedit, em, SELECT,0,0,0,numcuts,SUBDIV_SELECT_LOOPCUT);
}
/* if this was a single cut, enter edgeslide mode */
if(numcuts == 1 && hasHidden == 0){
if(cuthalf)
EdgeSlide(em, op, 1,0.0);
else {
if(EdgeSlide(em, op, 0,0.0) == -1){
BIF_undo();
}
}
}
if(em->selectmode != selectmode){
em->selectmode = selectmode;
EM_selectmode_set(em);
}
// DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
return;
#endif
}
/* *************** LOOP SELECT ************* */
#if 0
static short edgeFaces(EditMesh *em, EditEdge *e)
{
EditFace *search=NULL;
short count = 0;
search = em->faces.first;
while(search){
if((search->e1 == e || search->e2 == e) || (search->e3 == e || search->e4 == e))
count++;
search = search->next;
}
return count;
}
#endif
/* ***************** TRAIL ************************
Read a trail of mouse coords and return them as an array of CutCurve structs
len returns number of mouse coords read before commiting with RETKEY
It is up to the caller to free the block when done with it,
XXX Is only used here, so local inside this file (ton)
*/
#define TRAIL_POLYLINE 1 /* For future use, They don't do anything yet */
#define TRAIL_FREEHAND 2
#define TRAIL_MIXED 3 /* (1|2) */
#define TRAIL_AUTO 4
#define TRAIL_MIDPOINTS 8
typedef struct CutCurve {
float x;
float y;
} CutCurve;
/* ******************************************************************** */
/* Knife Subdivide Tool. Subdivides edges intersected by a mouse trail
drawn by user.
Currently mapped to KKey when in MeshEdit mode.
Usage:
Hit Shift K, Select Centers or Exact
Hold LMB down to draw path, hit RETKEY.
ESC cancels as expected.
Contributed by Robert Wenzlaff (Det. Thorn).
2.5 revamp:
- non modal (no menu before cutting)
- exit on mouse release
- polygon/segment drawing can become handled by WM cb later
*/
#define KNIFE_EXACT 1
#define KNIFE_MIDPOINT 2
#define KNIFE_MULTICUT 3
static EnumPropertyItem knife_items[]= {
{KNIFE_EXACT, "EXACT", 0, "Exact", ""},
{KNIFE_MIDPOINT, "MIDPOINTS", 0, "Midpoints", ""},
{KNIFE_MULTICUT, "MULTICUT", 0, "Multicut", ""},
{0, NULL, 0, NULL, NULL}
};
/* seg_intersect() Determines if and where a mouse trail intersects an EditEdge */
static float seg_intersect(EditEdge *e, CutCurve *c, int len, char mode, struct GHash *gh)
{
#define MAXSLOPE 100000
float x11, y11, x12=0, y12=0, x2max, x2min, y2max;
float y2min, dist, lastdist=0, xdiff2, xdiff1;
float m1, b1, m2, b2, x21, x22, y21, y22, xi;
float yi, x1min, x1max, y1max, y1min, perc=0;
float *scr;
float threshold = 0.0;
int i;
threshold = 0.000001; /*tolerance for vertex intersection*/
// XXX threshold = scene->toolsettings->select_thresh / 100;
/* Get screen coords of verts */
scr = BLI_ghash_lookup(gh, e->v1);
x21=scr[0];
y21=scr[1];
scr = BLI_ghash_lookup(gh, e->v2);
x22=scr[0];
y22=scr[1];
xdiff2=(x22-x21);
if (xdiff2) {
m2=(y22-y21)/xdiff2;
b2= ((x22*y21)-(x21*y22))/xdiff2;
}
else {
m2=MAXSLOPE; /* Verticle slope */
b2=x22;
}
/*check for *exact* vertex intersection first*/
if(mode!=KNIFE_MULTICUT){
for (i=0; i<len; i++){
if (i>0){
x11=x12;
y11=y12;
}
else {
x11=c[i].x;
y11=c[i].y;
}
x12=c[i].x;
y12=c[i].y;
/*test e->v1*/
if((x11 == x21 && y11 == y21) || (x12 == x21 && y12 == y21)){
e->v1->f1 = 1;
perc = 0;
return(perc);
}
/*test e->v2*/
else if((x11 == x22 && y11 == y22) || (x12 == x22 && y12 == y22)){
e->v2->f1 = 1;
perc = 0;
return(perc);
}
}
}
/*now check for edge interesect (may produce vertex intersection as well)*/
for (i=0; i<len; i++){
if (i>0){
x11=x12;
y11=y12;
}
else {
x11=c[i].x;
y11=c[i].y;
}
x12=c[i].x;
y12=c[i].y;
/* Perp. Distance from point to line */
if (m2!=MAXSLOPE) dist=(y12-m2*x12-b2);/* /sqrt(m2*m2+1); Only looking for */
/* change in sign. Skip extra math */
else dist=x22-x12;
if (i==0) lastdist=dist;
/* if dist changes sign, and intersect point in edge's Bound Box*/
if ((lastdist*dist)<=0){
xdiff1=(x12-x11); /* Equation of line between last 2 points */
if (xdiff1){
m1=(y12-y11)/xdiff1;
b1= ((x12*y11)-(x11*y12))/xdiff1;
}
else{
m1=MAXSLOPE;
b1=x12;
}
x2max=MAX2(x21,x22)+0.001; /* prevent missed edges */
x2min=MIN2(x21,x22)-0.001; /* due to round off error */
y2max=MAX2(y21,y22)+0.001;
y2min=MIN2(y21,y22)-0.001;
/* Found an intersect, calc intersect point */
if (m1==m2){ /* co-incident lines */
/* cut at 50% of overlap area*/
x1max=MAX2(x11, x12);
x1min=MIN2(x11, x12);
xi= (MIN2(x2max,x1max)+MAX2(x2min,x1min))/2.0;
y1max=MAX2(y11, y12);
y1min=MIN2(y11, y12);
yi= (MIN2(y2max,y1max)+MAX2(y2min,y1min))/2.0;
}
else if (m2==MAXSLOPE){
xi=x22;
yi=m1*x22+b1;
}
else if (m1==MAXSLOPE){
xi=x12;
yi=m2*x12+b2;
}
else {
xi=(b1-b2)/(m2-m1);
yi=(b1*m2-m1*b2)/(m2-m1);
}
/* Intersect inside bounding box of edge?*/
if ((xi>=x2min)&&(xi<=x2max)&&(yi<=y2max)&&(yi>=y2min)){
/*test for vertex intersect that may be 'close enough'*/
if(mode!=KNIFE_MULTICUT){
if(xi <= (x21 + threshold) && xi >= (x21 - threshold)){
if(yi <= (y21 + threshold) && yi >= (y21 - threshold)){
e->v1->f1 = 1;
perc = 0;
break;
}
}
if(xi <= (x22 + threshold) && xi >= (x22 - threshold)){
if(yi <= (y22 + threshold) && yi >= (y22 - threshold)){
e->v2->f1 = 1;
perc = 0;
break;
}
}
}
if ((m2<=1.0)&&(m2>=-1.0)) perc = (xi-x21)/(x22-x21);
else perc=(yi-y21)/(y22-y21); /*lower slope more accurate*/
//isect=32768.0*(perc+0.0000153); /* Percentage in 1/32768ths */
break;
}
}
lastdist=dist;
}
return(perc);
}
static float bm_seg_intersect(BMEdge *e, CutCurve *c, int len, char mode,
struct GHash *gh, int *isected)
{
#define MAXSLOPE 100000
float x11, y11, x12=0, y12=0, x2max, x2min, y2max;
float y2min, dist, lastdist=0, xdiff2, xdiff1;
float m1, b1, m2, b2, x21, x22, y21, y22, xi;
float yi, x1min, x1max, y1max, y1min, perc=0;
float *scr;
float threshold = 0.0;
int i;
//threshold = 0.000001; /*tolerance for vertex intersection*/
// XXX threshold = scene->toolsettings->select_thresh / 100;
/* Get screen coords of verts */
scr = BLI_ghash_lookup(gh, e->v1);
x21=scr[0];
y21=scr[1];
scr = BLI_ghash_lookup(gh, e->v2);
x22=scr[0];
y22=scr[1];
xdiff2=(x22-x21);
if (xdiff2) {
m2=(y22-y21)/xdiff2;
b2= ((x22*y21)-(x21*y22))/xdiff2;
}
else {
m2=MAXSLOPE; /* Verticle slope */
b2=x22;
}
*isected = 0;
/*check for *exact* vertex intersection first*/
if(mode!=KNIFE_MULTICUT){
for (i=0; i<len; i++){
if (i>0){
x11=x12;
y11=y12;
}
else {
x11=c[i].x;
y11=c[i].y;
}
x12=c[i].x;
y12=c[i].y;
/*test e->v1*/
if((x11 == x21 && y11 == y21) || (x12 == x21 && y12 == y21)){
perc = 0;
*isected = 1;
return(perc);
}
/*test e->v2*/
else if((x11 == x22 && y11 == y22) || (x12 == x22 && y12 == y22)){
perc = 0;
*isected = 2;
return(perc);
}
}
}
/*now check for edge interesect (may produce vertex intersection as well)*/
for (i=0; i<len; i++){
if (i>0){
x11=x12;
y11=y12;
}
else {
x11=c[i].x;
y11=c[i].y;
}
x12=c[i].x;
y12=c[i].y;
/* Perp. Distance from point to line */
if (m2!=MAXSLOPE) dist=(y12-m2*x12-b2);/* /sqrt(m2*m2+1); Only looking for */
/* change in sign. Skip extra math */
else dist=x22-x12;
if (i==0) lastdist=dist;
/* if dist changes sign, and intersect point in edge's Bound Box*/
if ((lastdist*dist)<=0){
xdiff1=(x12-x11); /* Equation of line between last 2 points */
if (xdiff1){
m1=(y12-y11)/xdiff1;
b1= ((x12*y11)-(x11*y12))/xdiff1;
}
else{
m1=MAXSLOPE;
b1=x12;
}
x2max=MAX2(x21,x22)+0.001; /* prevent missed edges */
x2min=MIN2(x21,x22)-0.001; /* due to round off error */
y2max=MAX2(y21,y22)+0.001;
y2min=MIN2(y21,y22)-0.001;
/* Found an intersect, calc intersect point */
if (m1==m2){ /* co-incident lines */
/* cut at 50% of overlap area*/
x1max=MAX2(x11, x12);
x1min=MIN2(x11, x12);
xi= (MIN2(x2max,x1max)+MAX2(x2min,x1min))/2.0;
y1max=MAX2(y11, y12);
y1min=MIN2(y11, y12);
yi= (MIN2(y2max,y1max)+MAX2(y2min,y1min))/2.0;
}
else if (m2==MAXSLOPE){
xi=x22;
yi=m1*x22+b1;
}
else if (m1==MAXSLOPE){
xi=x12;
yi=m2*x12+b2;
}
else {
xi=(b1-b2)/(m2-m1);
yi=(b1*m2-m1*b2)/(m2-m1);
}
/* Intersect inside bounding box of edge?*/
if ((xi>=x2min)&&(xi<=x2max)&&(yi<=y2max)&&(yi>=y2min)){
/*test for vertex intersect that may be 'close enough'*/
if(mode!=KNIFE_MULTICUT){
if(xi <= (x21 + threshold) && xi >= (x21 - threshold)){
if(yi <= (y21 + threshold) && yi >= (y21 - threshold)){
*isected = 1;
perc = 0;
break;
}
}
if(xi <= (x22 + threshold) && xi >= (x22 - threshold)){
if(yi <= (y22 + threshold) && yi >= (y22 - threshold)){
*isected = 2;
perc = 0;
break;
}
}
}
if ((m2<=1.0)&&(m2>=-1.0)) perc = (xi-x21)/(x22-x21);
else perc=(yi-y21)/(y22-y21); /*lower slope more accurate*/
//isect=32768.0*(perc+0.0000153); /* Percentage in 1/32768ths */
break;
}
}
lastdist=dist;
}
return(perc);
}
#define MAX_CUTS 256
static int knife_cut_exec(bContext *C, wmOperator *op)
{
Object *obedit= CTX_data_edit_object(C);
BMEditMesh *em= (((Mesh *)obedit->data))->edit_btmesh;
BMesh *bm = em->bm;
ARegion *ar= CTX_wm_region(C);
BMVert *bv;
BMIter iter;
BMEdge *be;
BMOperator bmop;
CutCurve curve[MAX_CUTS];
struct GHash *gh;
float isect=0.0;
float *scr, co[4];
int len=0, isected, flag, i;
short numcuts=1, mode= RNA_int_get(op->ptr, "type");
/* edit-object needed for matrix, and ar->regiondata for projections to work */
if (ELEM3(NULL, obedit, ar, ar->regiondata))
return OPERATOR_CANCELLED;
if (bm->totvertsel < 2) {
error("No edges are selected to operate on");
return OPERATOR_CANCELLED;;
}
/* get the cut curve */
RNA_BEGIN(op->ptr, itemptr, "path") {
RNA_float_get_array(&itemptr, "loc", (float *)&curve[len]);
len++;
if(len>= MAX_CUTS) break;
}
RNA_END;
if(len<2) {
return OPERATOR_CANCELLED;
}
/*the floating point coordinates of verts in screen space will be stored in a hash table according to the vertices pointer*/
gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
for(bv=BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);bv;bv=BMIter_Step(&iter)){
scr = MEM_mallocN(sizeof(float)*2, "Vertex Screen Coordinates");
VECCOPY(co, bv->co);
co[3]= 1.0;
mul_m4_v4(obedit->obmat, co);
project_float(ar, co, scr);
BLI_ghash_insert(gh, bv, scr);
}
BMO_Init_Op(&bmop, "esubd");
i = 0;
/*store percentage of edge cut for KNIFE_EXACT here.*/
for (be=BMIter_New(&iter, bm, BM_EDGES_OF_MESH, NULL); be; be=BMIter_Step(&iter)) {
if( BM_Selected(bm, be) ) {
isect= bm_seg_intersect(be, curve, len, mode, gh, &isected);
if (isect != 0.0f) {
if (mode != KNIFE_MULTICUT && mode != KNIFE_MIDPOINT) {
BMO_Insert_MapFloat(bm, &bmop,
"edgepercents",
be, isect);
}
BMO_SetFlag(bm, be, 1);
} else BMO_ClearFlag(bm, be, 1);
} else BMO_ClearFlag(bm, be, 1);
}
BMO_Flag_To_Slot(bm, &bmop, "edges", 1, BM_EDGE);
BMO_Set_Int(&bmop, "numcuts", numcuts);
flag = B_KNIFE;
if (mode == KNIFE_MIDPOINT) numcuts = 1;
BMO_Set_Int(&bmop, "flag", flag);
BMO_Set_Float(&bmop, "radius", 0);
BMO_Exec_Op(bm, &bmop);
BMO_Finish_Op(bm, &bmop);
BLI_ghash_free(gh, NULL, (GHashValFreeFP)WMEM_freeN);
DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
void MESH_OT_knife_cut(wmOperatorType *ot)
{
PropertyRNA *prop;
ot->name= "Knife Cut";
ot->description= "Cut selected edges and faces into parts.";
ot->idname= "MESH_OT_knife_cut";
ot->invoke= WM_gesture_lines_invoke;
ot->modal= WM_gesture_lines_modal;
ot->exec= knife_cut_exec;
ot->poll= EM_view3d_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_enum(ot->srna, "type", knife_items, KNIFE_EXACT, "Type", "");
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
/* internal */
RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
}
/* ******************************************************* */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -32,11 +32,14 @@
#ifndef MESH_INTERN_H
#define MESH_INTERN_H
#include "BLI_editVert.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "BKE_tessmesh.h"
#include "BLI_editVert.h"
struct bContext;
struct wmOperatorType;
struct ViewContext;
@ -57,10 +60,14 @@ ok: the EDBM module is for editmode bmesh stuff. in contrast, the
the BMEditMesh structure.
*/
/*calls a bmesh op, reporting errors to the user, doing conversions,
etc.*/
/*calls a bmesh op, reporting errors to the user, etc*/
int EDBM_CallOpf(struct BMEditMesh *em, struct wmOperator *op, char *fmt, ...);
/*calls a bmesh op, reporting errors to the user, etc.
selects an output slot specified by selslot*/
int EDBM_CallAndSelectOpf(struct BMEditMesh *em, struct wmOperator *op, char *selslot, char *fmt, ...);
/*same as above, but doesn't report errors.*/
int EDBM_CallOpfSilent(struct BMEditMesh *em, char *fmt, ...);
@ -83,15 +90,12 @@ void EDBM_stats_update(struct BMEditMesh *em);
/* ******************** editface.c */
int edgetag_context_check(Scene *scene, EditEdge *eed);
void edgetag_context_set(Scene *scene, EditEdge *eed, int val);
int edgetag_shortest_path(Scene *scene, EditMesh *em, EditEdge *source, EditEdge *target);
int edgetag_context_check(Scene *scene, BMEdge *eed);
void edgetag_context_set(Scene *scene, BMEdge *eed, int val);
int edgetag_shortest_path(Scene *scene, BMEditMesh *em, EditEdge *source, EditEdge *target);
/* ******************* editmesh.c */
void EM_beginEditMesh(struct Object *ob);
void EM_endEditMesh(struct Object *ob, EditMesh *em);
extern void free_editvert(EditMesh *em, EditVert *eve);
extern void free_editedge(EditMesh *em, EditEdge *eed);
extern void free_editface(EditMesh *em, EditFace *efa);

@ -96,8 +96,6 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_primitive_monkey_add);
WM_operatortype_append(MESH_OT_primitive_uv_sphere_add);
WM_operatortype_append(MESH_OT_primitive_ico_sphere_add);
WM_operatortype_append(MESH_OT_fgon_clear);
WM_operatortype_append(MESH_OT_fgon_make);
WM_operatortype_append(MESH_OT_duplicate);
WM_operatortype_append(MESH_OT_remove_doubles);
WM_operatortype_append(MESH_OT_extrude);
@ -292,9 +290,6 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MESH_OT_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MESH_OT_delete", DELKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MESH_OT_fgon_make", FKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "MESH_OT_fgon_clear", FKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
WM_keymap_add_item(keymap, "MESH_OT_knife_cut", LEFTMOUSE, KM_PRESS, 0, KKEY);
WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);

@ -56,6 +56,7 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_utildefines.h"
#include "BKE_tessmesh.h"
#include "RNA_define.h"
#include "RNA_access.h"
@ -74,13 +75,14 @@
#include "object_intern.h"
static int return_editmesh_indexar(EditMesh *em, int *tot, int **indexar, float *cent)
static int return_editmesh_indexar(BMEditMesh *em, int *tot, int **indexar, float *cent)
{
EditVert *eve;
BMVert *eve;
BMIter iter;
int *index, nr, totvert=0;
for(eve= em->verts.first; eve; eve= eve->next) {
if(eve->f & SELECT) totvert++;
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
if(BM_TestHFlag(eve, BM_SELECT)) totvert++;
}
if(totvert==0) return 0;
@ -89,8 +91,8 @@ static int return_editmesh_indexar(EditMesh *em, int *tot, int **indexar, float
nr= 0;
cent[0]= cent[1]= cent[2]= 0.0;
for(eve= em->verts.first; eve; eve= eve->next) {
if(eve->f & SELECT) {
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
if(BM_TestHFlag(eve, BM_SELECT)) {
*index= nr; index++;
add_v3_v3v3(cent, cent, eve->co);
}
@ -102,10 +104,11 @@ static int return_editmesh_indexar(EditMesh *em, int *tot, int **indexar, float
return totvert;
}
static int return_editmesh_vgroup(Object *obedit, EditMesh *em, char *name, float *cent)
static int return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *name, float *cent)
{
MDeformVert *dvert;
EditVert *eve;
BMVert *eve;
BMIter iter;
int i, totvert=0;
cent[0]= cent[1]= cent[2]= 0.0;
@ -113,8 +116,8 @@ static int return_editmesh_vgroup(Object *obedit, EditMesh *em, char *name, floa
if(obedit->actdef) {
/* find the vertices */
for(eve= em->verts.first; eve; eve= eve->next) {
dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
if(dvert) {
for(i=0; i<dvert->totweight; i++){
@ -136,25 +139,27 @@ static int return_editmesh_vgroup(Object *obedit, EditMesh *em, char *name, floa
return 0;
}
static void select_editmesh_hook(Object *ob, HookModifierData *hmd)
static void select_editbmesh_hook(Object *ob, HookModifierData *hmd)
{
Mesh *me= ob->data;
EditMesh *em= BKE_mesh_get_editmesh(me);
EditVert *eve;
BMEditMesh *em= me->edit_btmesh;
BMVert *eve;
BMIter iter;
int index=0, nr=0;
if (hmd->indexar == NULL)
return;
for(eve= em->verts.first; eve; eve= eve->next, nr++) {
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
if(nr==hmd->indexar[index]) {
eve->f |= SELECT;
BM_Select(em->bm, eve, 1);
if(index < hmd->totindex-1) index++;
}
}
EM_select_flush(em);
BKE_mesh_end_editmesh(me, em);
nr++;
}
EDBM_selectmode_flush(em);
}
static int return_editlattice_indexar(Lattice *editlatt, int *tot, int **indexar, float *cent)
@ -303,15 +308,13 @@ static int object_hook_index_array(Object *obedit, int *tot, int **indexar, char
case OB_MESH:
{
Mesh *me= obedit->data;
EditMesh *em = BKE_mesh_get_editmesh(me);
BMEditMesh *em = me->edit_btmesh;
/* check selected vertices first */
if( return_editmesh_indexar(em, tot, indexar, cent_r)) {
BKE_mesh_end_editmesh(me, em);
return 1;
} else {
int ret = return_editmesh_vgroup(obedit, em, name, cent_r);
BKE_mesh_end_editmesh(me, em);
return ret;
}
}
@ -380,7 +383,7 @@ static void object_hook_select(Object *ob, HookModifierData *hmd)
if (hmd->indexar == NULL)
return;
if(ob->type==OB_MESH) select_editmesh_hook(ob, hmd);
if(ob->type==OB_MESH) select_editbmesh_hook(ob, hmd);
else if(ob->type==OB_LATTICE) select_editlattice_hook(ob, hmd);
else if(ob->type==OB_CURVE) select_editcurve_hook(ob, hmd);
else if(ob->type==OB_SURF) select_editcurve_hook(ob, hmd);

@ -75,6 +75,7 @@
#include "BKE_scene.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
#include "BKE_tessmesh.h"
#include "WM_api.h"
#include "WM_types.h"
@ -105,7 +106,8 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
EditVert *eve;
BMVert *eve;
BMIter iter;
Curve *cu;
Nurb *nu;
BezTriple *bezt;
@ -117,22 +119,17 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
if(obedit->type==OB_MESH) {
Mesh *me= obedit->data;
EditMesh *em = BKE_mesh_get_editmesh(me);
BMEditMesh *em = me->edit_btmesh;
eve= em->verts.first;
while(eve) {
if(eve->f & 1) {
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
if (BM_TestHFlag(eve, BM_SELECT)) {
if(v1==0) v1= nr;
else if(v2==0) v2= nr;
else if(v3==0) v3= nr;
else if(v4==0) v4= nr;
else break;
}
nr++;
eve= eve->next;
}
BKE_mesh_end_editmesh(me, em);
}
else if(ELEM(obedit->type, OB_SURF, OB_CURVE)) {
ListBase *editnurb= curve_get_editcurve(obedit);

@ -53,6 +53,7 @@
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_utildefines.h"
#include "BKE_tessmesh.h"
#include "RNA_define.h"
#include "RNA_access.h"
@ -712,11 +713,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
/* BezTriple *bezt;
BPoint *bp; */
Nurb *nu, *nu1;
EditVert *eve;
float cent[3], centn[3], min[3], max[3], omat[3][3];
int a, total= 0;
int centermode = RNA_enum_get(op->ptr, "type");
int centermode = RNA_enum_get(op->ptr, "type");
/* keep track of what is changed */
int tot_change=0, tot_lib_error=0, tot_multiuser_arm_error=0;
MVert *mvert;
@ -732,14 +731,15 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
cent[0]= cent[1]= cent[2]= 0.0;
if(obedit) {
INIT_MINMAX(min, max);
if(obedit->type==OB_MESH) {
Mesh *me= obedit->data;
EditMesh *em = BKE_mesh_get_editmesh(me);
BMEditMesh *em = me->edit_btmesh;
BMVert *eve;
BMIter iter;
for(eve= em->verts.first; eve; eve= eve->next) {
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
if(v3d->around==V3D_CENTROID) {
total++;
VECADD(cent, cent, eve->co);
@ -758,14 +758,13 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
cent[2]= (min[2]+max[2])/2.0f;
}
for(eve= em->verts.first; eve; eve= eve->next) {
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
sub_v3_v3v3(eve->co, eve->co, cent);
}
recalc_editnormals(em);
EDBM_RecalcNormals(em);
tot_change++;
DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
BKE_mesh_end_editmesh(me, em);
}
}

@ -61,6 +61,7 @@
#include "BKE_paint.h"
#include "BKE_screen.h"
#include "BKE_utildefines.h"
#include "BKE_tessmesh.h"
#include "RE_pipeline.h"
@ -115,7 +116,7 @@
/* XXX */
static int simaFaceDraw_Check() {return 0;}
static int simaUVSel_Check() {return 0;}
static int simaUVSel_Check() { return 0;}
/* XXX */
/* proto */
@ -222,39 +223,32 @@ static void image_editvertex_buts(const bContext *C, uiBlock *block)
{
SpaceImage *sima= CTX_wm_space_image(C);
Object *obedit= CTX_data_edit_object(C);
BMEditMesh *em;
BMFace *efa;
MTexPoly *tf;
BMLoop *l;
MLoopUV *luv;
BMIter iter, liter;
static float ocent[2];
float cent[2]= {0.0, 0.0};
int imx= 256, imy= 256;
int nactive= 0, step, digits;
EditMesh *em;
EditFace *efa;
MTFace *tf;
image_transform_but_attr(sima, &imx, &imy, &step, &digits);
em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
for (efa= em->faces.first; efa; efa= efa->next) {
tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if (simaFaceDraw_Check(efa, tf)) {
em= ((Mesh *)obedit->data)->edit_btmesh;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
if (!simaFaceDraw_Check(efa, tf))
continue;
BM_ITER(l, &iter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
if (simaUVSel_Check(efa, tf, 0)) {
cent[0]+= tf->uv[0][0];
cent[1]+= tf->uv[0][1];
nactive++;
}
if (simaUVSel_Check(efa, tf, 1)) {
cent[0]+= tf->uv[1][0];
cent[1]+= tf->uv[1][1];
nactive++;
}
if (simaUVSel_Check(efa, tf, 2)) {
cent[0]+= tf->uv[2][0];
cent[1]+= tf->uv[2][1];
nactive++;
}
if (efa->v4 && simaUVSel_Check(efa, tf, 3)) {
cent[0]+= tf->uv[3][0];
cent[1]+= tf->uv[3][1];
if (simaUVSel_Check(efa, tf, luv)) {
cent[0] += luv->uv[0];
cent[1] += luv->uv[1];
nactive++;
}
}
@ -297,32 +291,23 @@ static void image_editvertex_buts(const bContext *C, uiBlock *block)
delta[1]= ocent[1]/imy - cent[1];
}
for (efa= em->faces.first; efa; efa= efa->next) {
tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if (simaFaceDraw_Check(efa, tf)) {
if (simaUVSel_Check(efa, tf, 0)) {
tf->uv[0][0]+= delta[0];
tf->uv[0][1]+= delta[1];
}
if (simaUVSel_Check(efa, tf, 1)) {
tf->uv[1][0]+= delta[0];
tf->uv[1][1]+= delta[1];
}
if (simaUVSel_Check(efa, tf, 2)) {
tf->uv[2][0]+= delta[0];
tf->uv[2][1]+= delta[1];
}
if (efa->v4 && simaUVSel_Check(efa, tf, 3)) {
tf->uv[3][0]+= delta[0];
tf->uv[3][1]+= delta[1];
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
if (!simaFaceDraw_Check(efa, tf))
continue;
BM_ITER(l, &iter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
if (simaUVSel_Check(efa, tf, luv)) {
luv->uv[0] += delta[0];
luv->uv[1] += delta[1];
}
}
}
WM_event_add_notifier(C, NC_IMAGE, sima->image);
}
BKE_mesh_end_editmesh(obedit->data, em);
}

@ -379,20 +379,19 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d
if(ob->type==OB_MESH) {
Mesh *me= ob->data;
EditMesh *em = BKE_mesh_get_editmesh(me);
EditVert *eve;
EditEdge *eed;
eve= em->verts.first;
while(eve) {
if(eve->f & SELECT) {
BMEditMesh *em = me->edit_btmesh;
BMVert *eve;
BMEdge *eed;
BMIter iter;
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
if(BM_TestHFlag(eve, BM_SELECT)) {
add_v3_v3v3(eve->co, eve->co, median);
}
eve= eve->next;
}
for(eed= em->edges.first; eed; eed= eed->next) {
if(eed->f & SELECT) {
BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
if(BM_TestHFlag(eed, BM_SELECT)) {
/* ensure the median can be set to zero or one */
if(ve_median[3]==0.0f) eed->crease= 0.0f;
else if(ve_median[3]==1.0f) eed->crease= 1.0f;
@ -403,9 +402,7 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d
}
}
recalc_editnormals(em);
BKE_mesh_end_editmesh(me, em);
EDBM_RecalcNormals(em);
}
else if(ob->type==OB_CURVE || ob->type==OB_SURF) {
Curve *cu= ob->data;

@ -172,7 +172,7 @@ void EDBM_backbuf_checkAndSelectVerts(BMEditMesh *em, int select)
}
}
void EM_backbuf_checkAndSelectEdges(BMEditMesh *em, int select)
void EDBM_backbuf_checkAndSelectEdges(BMEditMesh *em, int select)
{
BMEdge *eed;
BMIter iter;
@ -188,7 +188,7 @@ void EM_backbuf_checkAndSelectEdges(BMEditMesh *em, int select)
}
}
void EM_backbuf_checkAndSelectFaces(BMEditMesh *em, int select)
void EDBM_backbuf_checkAndSelectFaces(BMEditMesh *em, int select)
{
BMFace *efa;
BMIter iter;
@ -204,7 +204,7 @@ void EM_backbuf_checkAndSelectFaces(BMEditMesh *em, int select)
}
}
void EM_backbuf_checkAndSelectTFaces(Mesh *me, int select)
void EDBM_backbuf_checkAndSelectTFaces(Mesh *me, int select)
{
MFace *mface = me->mface;
int a;
@ -431,7 +431,7 @@ static void do_lasso_select_mesh__doSelectEdge(void *userData, BMEdge *eed, int
{
struct { ViewContext vc; rcti *rect; short (*mcords)[2], moves, select, pass, done; } *data = userData;
if (EM_check_backbuf(bm_solidoffs+index)) {
if (EDBM_check_backbuf(bm_solidoffs+index)) {
if (data->pass==0) {
if ( edge_fully_inside_rect(data->rect, x0, y0, x1, y1) &&
lasso_inside(data->mcords, data->moves, x0, y0) &&
@ -474,11 +474,11 @@ static void do_lasso_select_mesh(ViewContext *vc, short mcords[][2], short moves
data.done = 0;
data.pass = 0;
/* workaround: init mats first, EM_mask_init_backbuf_border can change
/* workaround: init mats first, EDBM_mask_init_backbuf_border can change
view matrix to pixel space, breaking edge select with backbuf .. */
// XXX not needed anymore, check here if selection is broken
//ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
bbsel= EM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
bbsel= EDBM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
if(vc->scene->toolsettings->selectmode & SCE_SELECT_VERTEX) {
if (bbsel) {
@ -501,13 +501,13 @@ static void do_lasso_select_mesh(ViewContext *vc, short mcords[][2], short moves
if(vc->scene->toolsettings->selectmode & SCE_SELECT_FACE) {
if (bbsel) {
EM_backbuf_checkAndSelectFaces(vc->em, select);
EDBM_backbuf_checkAndSelectFaces(vc->em, select);
} else {
mesh_foreachScreenFace(vc, do_lasso_select_mesh__doSelectFace, &data);
}
}
EM_free_backbuf();
EDBM_free_backbuf();
EDBM_selectmode_flush(vc->em);
}
@ -680,11 +680,11 @@ static void do_lasso_select_facemode(ViewContext *vc, short mcords[][2], short m
bm_vertoffs= me->totface+1; /* max index array */
lasso_select_boundbox(&rect, mcords, moves);
EM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
EDBM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
EM_backbuf_checkAndSelectTFaces(me, select);
EDBM_backbuf_checkAndSelectTFaces(me, select);
EM_free_backbuf();
EDBM_free_backbuf();
// XXX object_tface_flags_changed(ob, 0);
}
@ -1336,7 +1336,7 @@ static void do_mesh_box_select__doSelectEdge(void *userData, BMEdge *eed, int x0
{
struct { ViewContext vc; rcti *rect; short select, pass, done; } *data = userData;
if(EM_check_backbuf(bm_solidoffs+index)) {
if(EDBM_check_backbuf(bm_solidoffs+index)) {
if (data->pass==0) {
if (edge_fully_inside_rect(data->rect, x0, y0, x1, y1)) {
BM_Select_Edge(data->vc.em->bm, eed, data->select);
@ -1405,13 +1405,13 @@ static void do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exte
if(vc->scene->toolsettings->selectmode & SCE_SELECT_FACE) {
if(bbsel) {
EM_backbuf_checkAndSelectFaces(vc->em, select);
EDBM_backbuf_checkAndSelectFaces(vc->em, select);
} else {
mesh_foreachScreenFace(vc, do_mesh_box_select__doSelectFace, &data);
}
}
EM_free_backbuf();
EDBM_free_backbuf();
EDBM_selectmode_flush(vc->em);
}
@ -1459,7 +1459,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
Mesh *me= obedit->data;
vc.em= me->edit_btmesh;
do_mesh_box_select(&vc, &rect, selecting, extend);
// if (EM_texFaceCheck())
// if (EDBM_texFaceCheck())
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
}
@ -1834,7 +1834,7 @@ static void mesh_circle_select(ViewContext *vc, int selecting, short *mval, floa
if(vc->scene->toolsettings->selectmode & SCE_SELECT_EDGE) {
if (bbsel) {
EM_backbuf_checkAndSelectEdges(vc->em, selecting==LEFTMOUSE);
EDBM_backbuf_checkAndSelectEdges(vc->em, selecting==LEFTMOUSE);
} else {
mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, 0);
}
@ -1842,7 +1842,7 @@ static void mesh_circle_select(ViewContext *vc, int selecting, short *mval, floa
if(vc->scene->toolsettings->selectmode & SCE_SELECT_FACE) {
if(bbsel) {
EM_backbuf_checkAndSelectFaces(vc->em, selecting==LEFTMOUSE);
EDBM_backbuf_checkAndSelectFaces(vc->em, selecting==LEFTMOUSE);
} else {
mesh_foreachScreenFace(vc, mesh_circle_doSelectFace, &data);
}

@ -1329,11 +1329,11 @@ void calculateCenter(TransInfo *t)
/* EDIT MODE ACTIVE EDITMODE ELEMENT */
if (t->obedit && t->obedit->type == OB_MESH) {
EditSelection ese;
EditMesh *em = BKE_mesh_get_editmesh(t->obedit->data);
BMEditSelection ese;
BMEditMesh *em = ((Mesh*)t->obedit->data)->edit_btmesh;
if (EM_get_actSelection(em, &ese)) {
EM_editselection_center(t->center, &ese);
if (EDBM_get_actSelection(em, &ese)) {
EDBM_editselection_center(em, t->center, &ese);
calculateCenter2D(t);
break;
}

@ -990,7 +990,7 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit
select= 1;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_em_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
a = 0;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@ -1174,7 +1174,7 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[
MEM_freeN(stack);
MEM_freeN(flag);
EDBM_free_uv_vert_map(vmap);
EM_free_index_arrays();
EDBM_free_index_arrays(em);
}
/* ******************** align operator **************** */
@ -1352,7 +1352,7 @@ static int stitch_exec(bContext *C, wmOperator *op)
a = 0;
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
vlist= EM_get_uv_map_vert(vmap, a);
vlist= EDBM_get_uv_map_vert(vmap, a);
while(vlist) {
newuv[0]= 0; newuv[1]= 0;
@ -1504,7 +1504,7 @@ static int select_inverse_exec(bContext *C, wmOperator *op)
}
else {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf = CustomData_em_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
if(!uvedit_face_visible(scene, ima, efa, tf))
continue;
@ -1859,7 +1859,7 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
/* deselect */
if(select==0) {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_em_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
if(!uvedit_face_visible(scene, ima, efa, tf))
continue;
@ -1913,7 +1913,7 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
/* select sticky uvs */
if(sticky != SI_STICKY_DISABLE) {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_em_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
if(!uvedit_face_visible(scene, ima, efa, tf))
continue;