- for some reason mesh_create_derived_no_deform took the raw data (not

an object) but this is not going to work... I can't remember the reason
   I did it this way in the first place either! oops! regardless, switch
   to all mesh_ derived accessors taking object argument. there is still
   a bug in render orco calculation though. (hunt hunt)
 - removed python files that should have been ditched in previous commit
This commit is contained in:
2005-07-20 04:44:02 +00:00
parent 259c7b6cad
commit 38e0d79e68
8 changed files with 28 additions and 481 deletions

View File

@@ -153,8 +153,8 @@ DerivedMesh *mesh_get_derived_final(struct Object *ob, int *needsFree_r);
DerivedMesh *mesh_get_derived_deform(struct Object *ob, int *needsFree_r);
DerivedMesh *mesh_create_derived_render(struct Object *ob);
DerivedMesh *mesh_create_derived_no_deform(struct Mesh *me, float (*vertCos)[3]);
DerivedMesh *mesh_create_derived_no_deform_render(struct Mesh *me, float (*vertCos)[3]);
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]);
DerivedMesh *editmesh_get_derived(void);
DerivedMesh *editmesh_get_derived_proxy(void);

View File

@@ -58,7 +58,6 @@ typedef enum {
eModifierTypeFlag_AcceptsMesh = (1<<0),
eModifierTypeFlag_AcceptsCVs = (1<<1),
eModifierTypeFlag_SupportsMapping = (1<<2),
eModifierTypeFlag_RequiresObject = (1<<3),
} ModifierTypeFlag;
typedef struct ModifierTypeInfo {
@@ -95,15 +94,14 @@ typedef struct ModifierTypeInfo {
int (*dependsOnTime)(struct ModifierData *md);
/* Only for deform types, should apply the deformation
* to the given vertex array. Object is guaranteed to be
* non-NULL.
* to the given vertex array.
*/
void (*deformVerts)(struct ModifierData *md, struct Object *ob, float (*vertexCos)[3], int numVerts);
/* For non-deform types: apply the modifier and return a new derived
* data object (type is dependent on object type). If the _derivedData_
* argument is non-NULL then the modifier should read the object data
* from the derived object instead of the _data_ object.
* from the derived object instead of the actual object data.
*
* If the _vertexCos_ argument is non-NULL then the modifier should read
* the vertex coordinates from that (even if _derivedData_ is non-NULL).
@@ -116,13 +114,8 @@ typedef struct ModifierTypeInfo {
*
* The modifier is expected to release (or reuse) the _derivedData_ argument
* if non-NULL. The modifier *MAY NOT* share the _vertexCos_ argument.
*
* It is possible for _ob_ to be NULL if the modifier type is not flagged
* to require an object. A NULL _ob_ occurs when original coordinate data
* is requested for an object.
*/
void *(*applyModifier)(struct ModifierData *md, void *data, struct Object *ob,
void *derivedData, float (*vertexCos)[3], int useRenderParams);
void *(*applyModifier)(struct ModifierData *md, struct Object *ob, void *derivedData, float (*vertexCos)[3], int useRenderParams);
} ModifierTypeInfo;
ModifierTypeInfo *modifierType_get_info(ModifierType type);

View File

@@ -994,9 +994,10 @@ DerivedMesh *derivedmesh_from_displistmesh(DispListMesh *dlm)
/***/
static void mesh_calc_modifiers(Mesh *me, Object *ob, float (*inputVertexCos)[3], DerivedMesh **deform_r, DerivedMesh **final_r, int useRenderParams, int useDeform)
static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], DerivedMesh **deform_r, DerivedMesh **final_r, int useRenderParams, int useDeform)
{
ModifierData *md= ob?ob->modifiers.first:NULL;
Mesh *me = ob->data;
ModifierData *md= ob->modifiers.first;
float (*deformedVerts)[3];
DerivedMesh *dm;
int a, numVerts = me->totvert;
@@ -1040,8 +1041,7 @@ static void mesh_calc_modifiers(Mesh *me, Object *ob, float (*inputVertexCos)[3]
}
/* Now apply all remaining modifiers. If useDeform is off then skip
* OnlyDeform ones. If we have no _ob_ and the modifier requires one
* also skip.
* OnlyDeform ones.
*/
dm = NULL;
for (; md; md=md->next) {
@@ -1049,7 +1049,6 @@ static void mesh_calc_modifiers(Mesh *me, Object *ob, float (*inputVertexCos)[3]
if (!(md->mode&(1<<useRenderParams))) continue;
if (mti->type==eModifierTypeType_OnlyDeform && !useDeform) continue;
if (!ob && (mti->flags&eModifierTypeFlag_RequiresObject)) continue;
if (mti->isDisabled(md)) continue;
/* How to apply modifier depends on (a) what we already have as
@@ -1082,7 +1081,7 @@ static void mesh_calc_modifiers(Mesh *me, Object *ob, float (*inputVertexCos)[3]
* by the modifier apply function, which will also free the DerivedMesh if
* it exists.
*/
dm = mti->applyModifier(md, me, ob, dm, deformedVerts, useRenderParams);
dm = mti->applyModifier(md, ob, dm, deformedVerts, useRenderParams);
if (deformedVerts) {
if (deformedVerts!=inputVertexCos) {
@@ -1105,7 +1104,7 @@ static void mesh_calc_modifiers(Mesh *me, Object *ob, float (*inputVertexCos)[3]
smd.renderLevels = me->subdivr;
smd.subdivType = me->subsurftype;
dm = mti->applyModifier(&smd.modifier, me, ob, dm, deformedVerts, useRenderParams);
dm = mti->applyModifier(&smd.modifier, ob, dm, deformedVerts, useRenderParams);
if (deformedVerts) {
if (deformedVerts!=inputVertexCos) {
@@ -1182,7 +1181,7 @@ static void clear_and_build_mesh_data(Object *ob, int mustBuildForMesh)
}
if (ob!=G.obedit || mustBuildForMesh) {
mesh_calc_modifiers(ob->data, ob, NULL, &ob->derivedDeform, &ob->derivedFinal, 0, 1);
mesh_calc_modifiers(ob, NULL, &ob->derivedDeform, &ob->derivedFinal, 0, 1);
INIT_MINMAX(min, max);
@@ -1227,25 +1226,25 @@ DerivedMesh *mesh_create_derived_render(Object *ob)
{
DerivedMesh *final;
mesh_calc_modifiers(ob->data, ob, NULL, NULL, &final, 1, 1);
mesh_calc_modifiers(ob, NULL, NULL, &final, 1, 1);
return final;
}
DerivedMesh *mesh_create_derived_no_deform(Mesh *me, float (*vertCos)[3])
DerivedMesh *mesh_create_derived_no_deform(Object *ob, float (*vertCos)[3])
{
DerivedMesh *final;
mesh_calc_modifiers(me, NULL, vertCos, NULL, &final, 0, 0);
mesh_calc_modifiers(ob, vertCos, NULL, &final, 0, 0);
return final;
}
DerivedMesh *mesh_create_derived_no_deform_render(Mesh *me, float (*vertCos)[3])
DerivedMesh *mesh_create_derived_no_deform_render(Object *ob, float (*vertCos)[3])
{
DerivedMesh *final;
mesh_calc_modifiers(me, NULL, vertCos, NULL, &final, 1, 0);
mesh_calc_modifiers(ob, vertCos, NULL, &final, 1, 0);
return final;
}

View File

@@ -422,8 +422,9 @@ void mesh_get_texspace(Mesh *me, float *loc_r, float *rot_r, float *size_r)
if (size_r) VECCOPY(size_r, me->size);
}
static float *make_orco_mesh_internal(Mesh *me, int render)
static float *make_orco_mesh_internal(Object *ob, int render)
{
Mesh *me = ob->data;
float (*orcoData)[3];
int a, totvert;
float loc[3], size[3];
@@ -458,9 +459,9 @@ static float *make_orco_mesh_internal(Mesh *me, int render)
/* Apply orco-changing modifiers */
if (render) {
dm = mesh_create_derived_no_deform_render(me, vcos);
dm = mesh_create_derived_no_deform_render(ob, vcos);
} else {
dm = mesh_create_derived_no_deform(me, vcos);
dm = mesh_create_derived_no_deform(ob, vcos);
}
totvert = dm->getNumVerts(dm);
@@ -483,12 +484,12 @@ static float *make_orco_mesh_internal(Mesh *me, int render)
float *mesh_create_orco_render(Object *ob)
{
return make_orco_mesh_internal(ob->data, 1);
return make_orco_mesh_internal(ob, 1);
}
float *mesh_create_orco(Object *ob)
{
return make_orco_mesh_internal(ob->data, 0);
return make_orco_mesh_internal(ob, 0);
}
/** rotates the vertices of a face in case v[2] or v[3] (vertex index)

View File

@@ -123,11 +123,11 @@ static int subsurfModifier_isDisabled(ModifierData *md)
return 0;
}
static void *subsurfModifier_applyModifier(ModifierData *md, void *data, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int useRenderParams)
static void *subsurfModifier_applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int useRenderParams)
{
SubsurfModifierData *smd = (SubsurfModifierData*) md;
int levels = useRenderParams?smd->renderLevels:smd->levels;
Mesh *me = data;
Mesh *me = ob->data;
if (dm) {
DispListMesh *dlm = dm->convertToDispListMesh(dm); // XXX what if verts were shared
@@ -173,7 +173,7 @@ static int buildModifier_dependsOnTime(ModifierData *md)
return 1;
}
static void *buildModifier_applyModifier(ModifierData *md, void *data, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int useRenderParams)
static void *buildModifier_applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int useRenderParams)
{
BuildModifierData *bmd = (BuildModifierData*) md;
DispListMesh *dlm=NULL, *ndlm = MEM_callocN(sizeof(*ndlm), "build_dlm");
@@ -197,7 +197,7 @@ static void *buildModifier_applyModifier(ModifierData *md, void *data, Object *o
totedge = dlm->totedge;
totface = dlm->totface;
} else {
Mesh *me = data;
Mesh *me = ob->data;
mvert = me->mvert;
medge = me->medge;
mface = me->mface;