diff options
author | Campbell Barton <ideasman42@gmail.com> | 2006-09-17 09:15:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2006-09-17 09:15:56 +0400 |
commit | d89240ba121fec2d5d2fb3526fece5dec172e105 (patch) | |
tree | 55bd45892ebfadcd64faeeffc0b8d9f96dca551d /source | |
parent | e472a3d8521f5c9b90498dcff8784ddeb678bae0 (diff) |
added mesh_create_derived_view(ob) to DerivedMesh.c
exactly the same as mesh_create_derived_render(ob) except it uses the view modifier settings.
Added an optional arg to getFromObject to 'render' so you can choose to get the mesh displayed in the 3d view or generate one with render settings.
Solved bug 4612 getFromObject now works with soft body meshes (error was caused by getting the derived mesh from a copy of the object)
removed workaround for softbody bug in object_apply_def.py
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_DerivedMesh.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 9 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Mesh.c | 27 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Mesh.py | 4 |
4 files changed, 22 insertions, 19 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index fdba213ce6e..d09cb458ba4 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -395,6 +395,7 @@ DerivedMesh *mesh_get_derived_deform(struct Object *ob, int *needsFree_r); DerivedMesh *mesh_create_derived_for_modifier(struct Object *ob, struct ModifierData *md); DerivedMesh *mesh_create_derived_render(struct Object *ob); +DerivedMesh *mesh_create_derived_view(struct Object *ob); /* same as above but wont use render settings */ DerivedMesh *mesh_create_derived_no_deform(struct Object *ob, float (*vertCos)[3]); DerivedMesh *mesh_create_derived_no_deform_render(struct Object *ob, float (*vertCos)[3]); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 79cac1b4657..339958e2041 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -3345,6 +3345,15 @@ DerivedMesh *mesh_create_derived_render(Object *ob) return final; } +DerivedMesh *mesh_create_derived_view(Object *ob) +{ + DerivedMesh *final; + + mesh_calc_modifiers(ob, NULL, NULL, &final, 0, 1, 0); + + return final; +} + DerivedMesh *mesh_create_derived_no_deform(Object *ob, float (*vertCos)[3]) { DerivedMesh *final; diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c index 7aed521c504..abb32ab85fb 100644 --- a/source/blender/python/api2_2x/Mesh.c +++ b/source/blender/python/api2_2x/Mesh.c @@ -5591,9 +5591,9 @@ static PyObject *Mesh_getFromObject( BPy_Mesh * self, PyObject * args ) DispListMesh *dlm; DerivedMesh *dm; Object *tmpobj = NULL; - int cage = 0, i; + int cage = 0, render = 0, i; - if( !PyArg_ParseTuple( args, "s|i", &name, &cage ) ) + if( !PyArg_ParseTuple( args, "s|i", &name, &cage, &render ) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string and optional integer arguments" ); @@ -5664,34 +5664,25 @@ static PyObject *Mesh_getFromObject( BPy_Mesh * self, PyObject * args ) break; case OB_MESH: /* copies object and modifiers (but not the data) */ - tmpobj= copy_object( ob ); - tmpmesh = tmpobj->data; - tmpmesh->id.us--; - if (cage) { /* copies the data */ - tmpobj->data = copy_mesh( tmpmesh ); - G.totmesh++; - tmpmesh = tmpobj->data; - + tmpmesh = copy_mesh( ob->data ); /* if not getting the original caged mesh, get final derived mesh */ } else { - /* Make a dummy mesh, saves copying */ - tmpmesh = add_mesh( ); - G.totmesh++; - /* Write the display mesh into the dummy mesh */ - dm = mesh_create_derived_render( tmpobj ); + if (render) + dm = mesh_create_derived_render( ob ); + else + dm = mesh_create_derived_view( ob ); + dlm = dm->convertToDispListMesh( dm, 0 ); + tmpmesh = add_mesh( ); displistmesh_to_mesh( dlm, tmpmesh ); dm->release( dm ); } - /* take control of mesh before object is freed */ - tmpobj->data = NULL; - free_libblock_us( &G.main->object, tmpobj ); break; default: return EXPP_ReturnPyObjError( PyExc_AttributeError, diff --git a/source/blender/python/api2_2x/doc/Mesh.py b/source/blender/python/api2_2x/doc/Mesh.py index a2e8f1e66ec..584b9c32ab8 100644 --- a/source/blender/python/api2_2x/doc/Mesh.py +++ b/source/blender/python/api2_2x/doc/Mesh.py @@ -746,7 +746,7 @@ class Mesh: @type texMesh: Mesh or None """ - def getFromObject(name,cage=0): + def getFromObject(name,cage=0, render=0): """ Replace the mesh's existing data with the raw mesh data from a Blender Object. This method supports all the geometry based objects (mesh, text, @@ -762,6 +762,8 @@ class Mesh: @param name: name of the Blender object which contains the geometry data. @type cage: int @param cage: determines whether the original vertices or derived vertices + @type render: int + @param render: determines whether the render setting for modifiers will be used or not. (for objects with modifiers) are used. The default is derived vertices. """ |