2.5 Modifiers: mesh deform, boolean and decimation work again.

This commit is contained in:
Brecht Van Lommel 2009-11-05 18:05:55 +00:00
parent bdfa652605
commit 1e40adddc7
11 changed files with 40 additions and 48 deletions

@ -8,5 +8,5 @@ incs = 'intern ../container ../moto/include ../memutil'
if (env['OURPLATFORM'] == 'win32-mingw'):
env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype='core', priority=26 )
else:
env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype='core', priority=20 )
env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype='core', priority=200 )

@ -5,4 +5,4 @@ sources = env.Glob('intern/*.cpp')
incs = '. ../moto/include ../container ../memutil'
env.BlenderLib ('bf_decimation', sources, Split(incs) , [], libtype=['core'], priority = [10] )
env.BlenderLib ('bf_decimation', sources, Split(incs) , [], libtype=['core'], priority = [200] )

@ -526,8 +526,8 @@ DerivedMesh *NewBooleanDerivedMesh_intern(
CSG_FreeVertexDescriptor(&vd_o);
CSG_FreeFaceDescriptor(&fd_o);
}
// else
// XXX error("Unknown internal error in boolean");
else
printf("Unknown internal error in boolean");
CSG_FreeBooleanOperation(bool_op);

@ -82,7 +82,7 @@
#include "BKE_anim.h"
#include "BKE_action.h"
#include "BKE_bmesh.h"
// XXX #include "BKE_booleanops.h"
#include "BKE_booleanops.h"
#include "BKE_cloth.h"
#include "BKE_collision.h"
#include "BKE_cdderivedmesh.h"
@ -113,18 +113,12 @@
#include "BKE_shrinkwrap.h"
#include "BKE_simple_deform.h"
//XXX #include "LOD_DependKludge.h"
#include "LOD_decimation.h"
// XXX
static struct DerivedMesh *NewBooleanDerivedMesh() {return NULL;}
#include "CCGSubSurf.h"
#include "RE_shader_ext.h"
//XXX #include "BIF_meshlaplacian.h"
/* Utility */
static int is_last_displist(Object *ob)
@ -4138,11 +4132,11 @@ static DerivedMesh *decimateModifier_applyModifier(
ModifierData *md, Object *ob, DerivedMesh *derivedData,
int useRenderParams, int isFinalCalc)
{
// DecimateModifierData *dmd = (DecimateModifierData*) md;
DecimateModifierData *dmd = (DecimateModifierData*) md;
DerivedMesh *dm = derivedData, *result = NULL;
MVert *mvert;
MFace *mface;
// LOD_Decimation_Info lod;
LOD_Decimation_Info lod;
int totvert, totface;
int a, numTris;
@ -4164,8 +4158,6 @@ static DerivedMesh *decimateModifier_applyModifier(
goto exit;
}
// XXX
#if 0
lod.vertex_buffer= MEM_mallocN(3*sizeof(float)*totvert, "vertices");
lod.vertex_normal_buffer= MEM_mallocN(3*sizeof(float)*totvert, "normals");
lod.triangle_index_buffer= MEM_mallocN(3*sizeof(int)*numTris, "trias");
@ -4250,10 +4242,6 @@ static DerivedMesh *decimateModifier_applyModifier(
MEM_freeN(lod.vertex_buffer);
MEM_freeN(lod.vertex_normal_buffer);
MEM_freeN(lod.triangle_index_buffer);
#else
modifier_setError(md, "Modifier not working yet in 2.5.");
goto exit;
#endif
exit:
return result;
@ -6390,12 +6378,6 @@ static CustomDataMask booleanModifier_requiredDataMask(Object *ob, ModifierData
dataMask |= (1 << CD_MDEFORMVERT);
/* particles only need this if they are after a non deform modifier, and
* the modifier stack will only create them in that case. */
// dataMask |= CD_MASK_ORIGSPACE;
// dataMask |= CD_MASK_ORCO;
return dataMask;
}
@ -7866,17 +7848,17 @@ static void meshdeformModifier_do(
float (*vertexCos)[3], int numVerts)
{
MeshDeformModifierData *mmd = (MeshDeformModifierData*) md;
Mesh *me= ob->data;
Mesh *me= (mmd->object)? mmd->object->data: NULL;
EditMesh *em = (me)? BKE_mesh_get_editmesh(me): NULL;
DerivedMesh *tmpdm, *cagedm;
MDeformVert *dvert = NULL;
MDeformWeight *dw;
EditMesh *em = BKE_mesh_get_editmesh(me);
MVert *cagemvert;
float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4];
float weight, totweight, fac, co[3], *weights, (*dco)[3], (*bindcos)[3];
int a, b, totvert, totcagevert, defgrp_index;
if(!mmd->object || (!mmd->bindcos && !mmd->needbind))
if(!mmd->object || (!mmd->bindcos && !mmd->bindfunc))
return;
/* get cage derivedmesh */
@ -7914,7 +7896,7 @@ static void meshdeformModifier_do(
/* progress bar redraw can make this recursive .. */
if(!recursive) {
recursive = 1;
//XXX harmonic_coordinates_bind(mmd, vertexCos, numVerts, cagemat);
mmd->bindfunc(md->scene, mmd, (float*)vertexCos, numVerts, cagemat);
recursive = 0;
}
}

@ -69,7 +69,7 @@ static void waitcursor(int val) {}
static void progress_bar() {}
static void start_progress_bar() {}
static void end_progress_bar() {}
static void error() {}
static void error(char *str) { printf("error: %s\n", str); }
/* ************* XXX *************** */
@ -1698,7 +1698,7 @@ static void meshdeform_matrix_solve(MeshDeformBind *mdb)
nlDeleteContext(context);
}
void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd, float (*vertexcos)[3], int totvert, float cagemat[][4])
void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexcos, int totvert, float cagemat[][4])
{
MeshDeformBind mdb;
MDefBindInfluence *inf;
@ -1714,7 +1714,7 @@ void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd, float
memset(&mdb, 0, sizeof(MeshDeformBind));
/* get mesh and cage mesh */
mdb.vertexcos= vertexcos;
mdb.vertexcos= (float(*)[3])vertexcos;
mdb.totvert= totvert;
mdb.cagedm= mesh_create_derived_no_deform(scene, mmd->object, NULL, CD_MASK_BAREMESH);

@ -79,7 +79,7 @@ void rigid_deform_end(int cancel);
/* Harmonic Coordinates */
void harmonic_coordinates_bind(struct Scene *scene, struct MeshDeformModifierData *mmd,
float (*vertexcos)[3], int totvert, float cagemat[][4]);
float *vertexcos, int totvert, float cagemat[][4]);
#endif

@ -42,6 +42,7 @@ struct ViewContext;
struct RegionView3D;
struct SK_Sketch;
struct IDProperty;
struct MeshDeformModifierData;
typedef struct EditBone
{
@ -162,6 +163,10 @@ char * BIF_nameBoneTemplate(const struct bContext *C);
void BDR_drawSketch(const struct bContext *vc);
int BDR_drawSketchNames(struct ViewContext *vc);
/* meshlaplacian.c */
void harmonic_coordinates_bind(struct Scene *scene, struct MeshDeformModifierData *mmd,
float *vertexcos, int totvert, float cagemat[][4]);
#endif /* ED_ARMATURE_H */

@ -65,6 +65,7 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "ED_armature.h"
#include "ED_screen.h"
#include "WM_api.h"
@ -779,7 +780,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
int mode= mmd->modifier.mode;
/* force modifier to run, it will call binding routine */
mmd->needbind= 1;
mmd->bindfunc= harmonic_coordinates_bind;
mmd->modifier.mode |= eModifierMode_Realtime;
if(ob->type == OB_MESH) {
@ -796,7 +797,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
makeDispListCurveTypes(scene, ob, 0);
}
mmd->needbind= 0;
mmd->bindfunc= NULL;
mmd->modifier.mode= mode;
}

@ -508,8 +508,7 @@ typedef struct MeshDeformModifierData {
struct Object *object; /* mesh object */
char defgrp_name[32]; /* optional vertexgroup name */
short gridsize, needbind;
short flag, pad;
short gridsize, flag, pad[2];
/* variables filled in when bound */
float *bindweights, *bindcos; /* computed binding weights */
@ -522,6 +521,10 @@ typedef struct MeshDeformModifierData {
float dyncellmin[3]; /* offset of the dynamic bind grid */
float dyncellwidth; /* width of dynamic bind cell */
float bindmat[4][4]; /* matrix of cage at binding time */
/* runtime */
void (*bindfunc)(struct Scene *scene, struct MeshDeformModifierData *mmd,
float *vertexcos, int totvert, float cagemat[][4]);
} MeshDeformModifierData;
typedef enum {

@ -795,7 +795,7 @@ static void rna_def_modifier_wave(BlenderRNA *brna)
prop= RNA_def_property(srna, "start_position_object", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "objectcenter");
RNA_def_property_ui_text(prop, "Start Position Object", "");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
@ -824,7 +824,7 @@ static void rna_def_modifier_wave(BlenderRNA *brna)
prop= RNA_def_property(srna, "texture_coordinates_object", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "map_object");
RNA_def_property_ui_text(prop, "Texture Coordinates Object", "");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop= RNA_def_property(srna, "speed", PROP_FLOAT, PROP_NONE);
@ -1196,7 +1196,7 @@ static void rna_def_modifier_displace(BlenderRNA *brna)
prop= RNA_def_property(srna, "texture_coordinate_object", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "map_object");
RNA_def_property_ui_text(prop, "Texture Coordinate Object", "");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
}
@ -1257,7 +1257,7 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna)
prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_pointer_funcs(prop, "rna_UVProjector_object_get", "rna_UVProjector_object_set", NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
RNA_def_property_ui_text(prop, "Object", "Object to use as projector transform.");
}
@ -1330,7 +1330,7 @@ static void rna_def_modifier_cast(BlenderRNA *brna)
prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Object", "Control object: if available, its location determines the center of the effect");
RNA_def_property_pointer_funcs(prop, NULL, "rna_CastModifier_object_set", NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop= RNA_def_property(srna, "x", PROP_BOOLEAN, PROP_NONE);
@ -1397,7 +1397,7 @@ static void rna_def_modifier_meshdeform(BlenderRNA *brna)
prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Object", "Mesh object to deform with.");
RNA_def_property_pointer_funcs(prop, NULL, "rna_MeshDeformModifier_object_set", NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop= RNA_def_property(srna, "is_bound", PROP_BOOLEAN, PROP_NONE);
@ -1459,7 +1459,7 @@ static void rna_def_modifier_particleinstance(BlenderRNA *brna)
prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "ob");
RNA_def_property_ui_text(prop, "Object", "Object that has the particle system.");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop= RNA_def_property(srna, "particle_system_number", PROP_INT, PROP_NONE);
@ -1723,14 +1723,14 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna)
prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Target", "Mesh target to shrink to.");
RNA_def_property_pointer_funcs(prop, NULL, "rna_ShrinkwrapModifier_target_set", NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop= RNA_def_property(srna, "auxiliary_target", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "auxTarget");
RNA_def_property_ui_text(prop, "Auxiliary Target", "Additional mesh target to shrink to.");
RNA_def_property_pointer_funcs(prop, NULL, "rna_ShrinkwrapModifier_auxiliary_target_set", NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
@ -1834,7 +1834,7 @@ static void rna_def_modifier_mask(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "ob_arm");
RNA_def_property_ui_text(prop, "Armature", "Armature to use as source of bones to mask.");
RNA_def_property_pointer_funcs(prop, NULL, "rna_MaskModifier_armature_set", NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
@ -1879,7 +1879,7 @@ static void rna_def_modifier_simpledeform(BlenderRNA *brna)
prop= RNA_def_property(srna, "origin", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Origin", "Origin of modifier space coordinates.");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop= RNA_def_property(srna, "relative", PROP_BOOLEAN, PROP_NONE);

@ -380,6 +380,7 @@ IF(UNIX)
bf_dds
bf_readblenfile
bf_collada
blender_BSP
blender_bop
bf_kernel
bf_decimation