From 951a4934b08ab2621a627b1adb74cdf518c53a19 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 26 Jul 2005 02:44:59 +0000 Subject: [PATCH] - added wave modifier & removed old wave effect - added decimate modifier & removed old decimate interface (currently lacks warning about destroying data, and there needs to be a way for modifiers to return errors back to the interface) - allow applyModifier to return NULL to indicate error - unfortunately new decimate modifier means it does not know exact number of faces in mesh (other modifiers may come before) and so instead interface uses a percentage. if people need exact face count slider then I will have to think of some hack to fit this in. note that it does display the output face count so its possible to tweak the pct to get what you want regardless. - removed python Wave object If you are bored now how much easier it is to implement something like decimate as a modifier. Very few changes to interface, very few entry points. --- source/blender/blenkernel/BKE_effect.h | 2 - .../blender/blenkernel/intern/DerivedMesh.c | 16 +- source/blender/blenkernel/intern/deform.c | 17 - source/blender/blenkernel/intern/effect.c | 72 --- source/blender/blenkernel/intern/mesh.c | 2 - source/blender/blenkernel/intern/modifier.c | 248 +++++++ source/blender/blenloader/intern/readfile.c | 24 +- source/blender/blenloader/intern/writefile.c | 3 - source/blender/makesdna/DNA_effect_types.h | 1 - source/blender/makesdna/DNA_mesh_types.h | 3 - source/blender/makesdna/DNA_modifier_types.h | 20 + source/blender/python/SConscript | 1 - source/blender/python/api2_2x/Effect.c | 14 +- source/blender/python/api2_2x/Types.c | 1 - source/blender/python/api2_2x/Types.h | 2 +- source/blender/python/api2_2x/Wave.c | 605 ------------------ source/blender/python/api2_2x/Wave.h | 98 --- source/blender/src/buttons_editing.c | 250 -------- source/blender/src/buttons_object.c | 50 +- source/blender/src/drawobject.c | 23 +- 20 files changed, 328 insertions(+), 1124 deletions(-) delete mode 100644 source/blender/python/api2_2x/Wave.c delete mode 100644 source/blender/python/api2_2x/Wave.h diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h index a1bc5967b0b..f371220bab5 100644 --- a/source/blender/blenkernel/BKE_effect.h +++ b/source/blender/blenkernel/BKE_effect.h @@ -53,8 +53,6 @@ void deselectall_eff(struct Object *ob); struct PartEff *give_parteff(struct Object *ob); void where_is_particle(struct PartEff *paf, struct Particle *pa, float ctime, float *vec); void build_particle_system(struct Object *ob); -void init_wave_deform(struct WaveEff *wav); -void calc_wave_deform(struct WaveEff *wav, float ctime, float *co); /* particle deflector */ #define PE_WIND_AS_SPEED 0x00000001 diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index e33de2baf8d..3b00fb034a0 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1309,14 +1309,18 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], DerivedM * by the modifier apply function, which will also free the DerivedMesh if * it exists. */ - dm = mti->applyModifier(md, ob, dm, deformedVerts, useRenderParams, !inputVertexCos); + DerivedMesh *ndm = mti->applyModifier(md, ob, dm, deformedVerts, useRenderParams, !inputVertexCos); - if (deformedVerts) { - if (deformedVerts!=inputVertexCos) { - MEM_freeN(deformedVerts); + if (ndm) { + dm = ndm; + + if (deformedVerts) { + if (deformedVerts!=inputVertexCos) { + MEM_freeN(deformedVerts); + } + deformedVerts = NULL; } - deformedVerts = NULL; - } + } } } diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 91e8f3e2b7b..c99b3986059 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -249,23 +249,6 @@ void mesh_modifier(Object *ob, float (**vertexCos_r)[3]) } } - if(ob->effect.first) { - WaveEff *wav; - float ctime = bsystem_time(ob, 0, (float)G.scene->r.cfra, 0.0); - int a; - - for (wav= ob->effect.first; wav; wav= wav->next) { - if(wav->type==EFF_WAVE) { - if (!vertexCos) vertexCos = mesh_getVertexCos(me, NULL); - init_wave_deform(wav); - - for(a=0; atotvert; a++) { - calc_wave_deform(wav, ctime, vertexCos[a]); - } - } - } - } - if((ob->softflag & OB_SB_ENABLE) && !(ob->softflag & OB_SB_POSTDEF)) { if (!vertexCos) vertexCos = mesh_getVertexCos(me, NULL); sbObjectStep(ob, (float)G.scene->r.cfra, vertexCos); diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 00869089155..af23cf70ce9 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -84,7 +84,6 @@ Effect *add_effect(int type) { Effect *eff=0; PartEff *paf; - WaveEff *wav; int a; switch(type) { @@ -107,21 +106,6 @@ Effect *add_effect(int type) paf->defvec[2]= 1.0f; paf->nabla= 0.05f; - break; - - case EFF_WAVE: - wav= MEM_callocN(sizeof(WaveEff), "neweff"); - eff= (Effect *)wav; - - wav->flag |= (WAV_X+WAV_Y+WAV_CYCL); - - wav->height= 0.5f; - wav->width= 1.5f; - wav->speed= 0.5f; - wav->narrow= 1.5f; - wav->lifetime= 0.0f; - wav->damp= 10.0f; - break; } @@ -1403,62 +1387,6 @@ void build_particle_system(Object *ob) rng_free(rng); } -/* ************* WAVE **************** */ - -void init_wave_deform(WaveEff *wav) { - wav->minfac= (float)(1.0/exp(wav->width*wav->narrow*wav->width*wav->narrow)); - if(wav->damp==0) wav->damp= 10.0f; -} - -void calc_wave_deform(WaveEff *wav, float ctime, float *co) -{ - /* co is in local coords */ - float lifefac, x, y, amplit; - - /* actually this should not happen */ - if((wav->flag & (WAV_X+WAV_Y))==0) return; - - lifefac= wav->height; - - if( wav->lifetime!=0.0) { - x= ctime - wav->timeoffs; - if(x>wav->lifetime) { - - lifefac= x-wav->lifetime; - - if(lifefac > wav->damp) lifefac= 0.0; - else lifefac= (float)(wav->height*(1.0 - sqrt(lifefac/wav->damp))); - } - } - if(lifefac==0.0) return; - - x= co[0]-wav->startx; - y= co[1]-wav->starty; - - if(wav->flag & WAV_X) { - if(wav->flag & WAV_Y) amplit= (float)sqrt( (x*x + y*y)); - else amplit= x; - } - else amplit= y; - - /* this way it makes nice circles */ - amplit-= (ctime-wav->timeoffs)*wav->speed; - - if(wav->flag & WAV_CYCL) { - amplit = (float)fmod(amplit-wav->width, 2.0*wav->width) + wav->width; - } - - /* GAUSSIAN */ - - if(amplit> -wav->width && amplitwidth) { - - amplit = amplit*wav->narrow; - amplit= (float)(1.0/exp(amplit*amplit) - wav->minfac); - - co[2]+= lifefac*amplit; - } -} - int SoftBodyDetectCollision(float opco[3], float npco[3], float colco[3], float facenormal[3], float *damp, float force[3], int mode, float cur_time, unsigned int par_layer,struct Object *vertexowner) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 65ac43739da..41e9d0b4c70 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -236,8 +236,6 @@ Mesh *copy_mesh(Mesh *me) men->key= copy_key(me->key); if(men->key) men->key->from= (ID *)men; - men->decimated = NULL; - return men; } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 064248611cd..f47cbae9455 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -1,4 +1,5 @@ #include "string.h" +#include "math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" @@ -9,6 +10,7 @@ #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_effect_types.h" #include "DNA_scene_types.h" #include "BLI_editVert.h" @@ -23,6 +25,9 @@ #include "BKE_mesh.h" #include "depsgraph_private.h" +#include "LOD_DependKludge.h" +#include "LOD_decimation.h" + #include "CCGSubSurf.h" /***/ @@ -704,6 +709,235 @@ static void *mirrorModifier_applyModifierEM(ModifierData *md, Object *ob, void * } } +/* Decimate */ + +static void decimateModifier_initData(ModifierData *md) +{ + DecimateModifierData *dmd = (DecimateModifierData*) md; + + dmd->percent = 1.0; +} + +static void *decimateModifier_applyModifier(ModifierData *md, Object *ob, void *derivedData, float (*vertexCos)[3], int useRenderParams, int isFinalCalc) +{ + DecimateModifierData *dmd = (DecimateModifierData*) md; + DerivedMesh *dm = derivedData; + Mesh *me = ob->data; + MVert *mvert; + MFace *mface; + DispListMesh *ndlm=NULL, *dlm=NULL; + LOD_Decimation_Info lod; + int totvert, totface; + int *tib=NULL; + int a, numTris; + + if (dm) { + dlm = dm->convertToDispListMesh(dm); + mvert = dlm->mvert; + mface = dlm->mface; + totvert = dlm->totvert; + totface = dlm->totface; + } else { + mvert = me->mvert; + mface = me->mface; + totvert = me->totvert; + totface = me->totface; + } + + numTris = 0; + for (a=0; av3) { + numTris++; + if (mf->v4) numTris++; + } + } + + if(numTris<3) { + // ("You must have more than 3 input faces selected."); + return NULL; + } + + 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"); + lod.vertex_num= me->totvert; + lod.face_num= numTris; + + for(a=0; aco); + } + + vbNo[0] = mv->no[0]/32767.0f; + vbNo[1] = mv->no[1]/32767.0f; + vbNo[2] = mv->no[2]/32767.0f; + } + + numTris = 0; + for(a=0; av3) { + int *tri = &lod.triangle_index_buffer[3*numTris++]; + tri[0]= mf->v1; + tri[1]= mf->v2; + tri[2]= mf->v3; + + if(mf->v4) { + tri = &lod.triangle_index_buffer[3*numTris++]; + tri[0]= mf->v1; + tri[1]= mf->v3; + tri[2]= mf->v4; + } + } + } + + dmd->faceCount = 0; + if(LOD_LoadMesh(&lod) ) { + if( LOD_PreprocessMesh(&lod) ) { + + /* we assume the decim_faces tells how much to reduce */ + + while(lod.face_num > numTris*dmd->percent) { + if( LOD_CollapseEdge(&lod)==0) break; + } + + ndlm= MEM_callocN(sizeof(DispListMesh), "dispmesh"); + ndlm->mvert= MEM_callocN(lod.vertex_num*sizeof(MVert), "mvert"); + ndlm->mface= MEM_callocN(lod.face_num*sizeof(MFace), "mface"); + ndlm->totvert= lod.vertex_num; + ndlm->totface= dmd->faceCount = lod.face_num; + + for(a=0; amvert[a]; + float *vbCo = &lod.vertex_buffer[a*3]; + + VECCOPY(mv->co, vbCo); + } + + for(a=0; amface[a]; + int *tri = &lod.triangle_index_buffer[a*3]; + mf->v1 = tri[0]; + mf->v2 = tri[1]; + mf->v3 = tri[2]; + test_index_mface(mf, 3); + } + } + else { + // No memory + } + + LOD_FreeDecimationData(&lod); + } + else { + // Non-manifold mesh + } + + MEM_freeN(lod.vertex_buffer); + MEM_freeN(lod.vertex_normal_buffer); + MEM_freeN(lod.triangle_index_buffer); + + if (dlm) displistmesh_free(dlm); + + if (ndlm) { + if (dm) dm->release(dm); + + mesh_calc_normals(ndlm->mvert, ndlm->totvert, ndlm->mface, ndlm->totface, &ndlm->nors); + + return derivedmesh_from_displistmesh(ndlm); + } else { + return NULL; + } +} + +/* Wave */ + +static void waveModifier_initData(ModifierData *md) +{ + WaveModifierData *wmd = (WaveModifierData*) md; // whadya know, moved here from Iraq + + wmd->flag |= (WAV_X+WAV_Y+WAV_CYCL); + + wmd->height= 0.5f; + wmd->width= 1.5f; + wmd->speed= 0.5f; + wmd->narrow= 1.5f; + wmd->lifetime= 0.0f; + wmd->damp= 10.0f; +} + +static int waveModifier_dependsOnTime(ModifierData *md) +{ + return 1; +} + +static void waveModifier_deformVerts(ModifierData *md, Object *ob, void *derivedData, float (*vertexCos)[3], int numVerts) +{ + WaveModifierData *wmd = (WaveModifierData*) md; + float ctime = bsystem_time(ob, 0, (float)G.scene->r.cfra, 0.0); + float minfac = (float)(1.0/exp(wmd->width*wmd->narrow*wmd->width*wmd->narrow)); + float lifefac = wmd->height; + + if(wmd->damp==0) wmd->damp= 10.0f; + + if(wmd->lifetime!=0.0) { + float x= ctime - wmd->timeoffs; + + if(x>wmd->lifetime) { + lifefac= x-wmd->lifetime; + + if(lifefac > wmd->damp) lifefac= 0.0; + else lifefac= (float)(wmd->height*(1.0 - sqrt(lifefac/wmd->damp))); + } + } + + if(lifefac!=0.0) { + int i; + + for (i=0; istartx; + float y= co[1]-wmd->starty; + float amplit; + + if(wmd->flag & WAV_X) { + if(wmd->flag & WAV_Y) amplit= (float)sqrt( (x*x + y*y)); + else amplit= x; + } + else amplit= y; + + /* this way it makes nice circles */ + amplit-= (ctime-wmd->timeoffs)*wmd->speed; + + if(wmd->flag & WAV_CYCL) { + amplit = (float)fmod(amplit-wmd->width, 2.0*wmd->width) + wmd->width; + } + + /* GAUSSIAN */ + if(amplit> -wmd->width && amplitwidth) { + amplit = amplit*wmd->narrow; + amplit= (float)(1.0/exp(amplit*amplit) - minfac); + + co[2]+= lifefac*amplit; + } + } + } +} + +static void waveModifier_deformVertsEM(ModifierData *md, Object *ob, void *editData, void *derivedData, float (*vertexCos)[3], int numVerts) +{ + waveModifier_deformVerts(md, ob, NULL, vertexCos, numVerts); +} + + /***/ static ModifierTypeInfo typeArr[NUM_MODIFIER_TYPES]; @@ -773,6 +1007,20 @@ ModifierTypeInfo *modifierType_get_info(ModifierType type) mti->applyModifier = mirrorModifier_applyModifier; mti->applyModifierEM = mirrorModifier_applyModifierEM; + mti = INIT_TYPE(Decimate); + mti->type = eModifierTypeType_Nonconstructive; + mti->flags = eModifierTypeFlag_AcceptsMesh; + mti->initData = decimateModifier_initData; + mti->applyModifier = decimateModifier_applyModifier; + + mti = INIT_TYPE(Wave); + mti->type = eModifierTypeType_OnlyDeform; + mti->flags = eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_SupportsEditmode; + mti->initData = waveModifier_initData; + mti->dependsOnTime = waveModifier_dependsOnTime; + mti->deformVerts = waveModifier_deformVerts; + mti->deformVertsEM = waveModifier_deformVertsEM; + typeArrInit = 0; #undef INIT_TYPE } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 39a9f9456d4..b910fb9b3c4 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2077,8 +2077,7 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) mesh->bb= NULL; mesh->oc= 0; mesh->dface= NULL; - mesh->decimated= NULL; - + if (mesh->tface) { TFace *tfaces= mesh->tface; int i; @@ -2323,7 +2322,28 @@ static void direct_link_object(FileData *fd, Object *ob) paf->keys= 0; } if(paf->type==EFF_WAVE) { + WaveEff *wav = (WaveEff*) paf; + PartEff *next = paf->next; + WaveModifierData *wmd = (WaveModifierData*) modifier_new(eModifierType_Wave); + wmd->damp = wav->damp; + wmd->flag = wav->flag; + wmd->height = wav->height; + wmd->lifetime = wav->lifetime; + wmd->narrow = wav->narrow; + wmd->speed = wav->speed; + wmd->startx = wav->startx; + wmd->starty = wav->startx; + wmd->timeoffs = wav->timeoffs; + wmd->width = wav->width; + + BLI_addtail(&ob->modifiers, wmd); + + BLI_remlink(&ob->effect, paf); + MEM_freeN(paf); + + paf = next; + continue; } if(paf->type==EFF_BUILD) { BuildEff *baf = (BuildEff*) paf; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 3b14f11a8cd..61c7911ffca 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -406,9 +406,6 @@ static void write_effects(WriteData *wd, ListBase *lb) case EFF_PARTICLE: writestruct(wd, DATA, "PartEff", 1, eff); break; - case EFF_WAVE: - writestruct(wd, DATA, "WaveEff", 1, eff); - break; default: writedata(wd, DATA, MEM_allocN_len(eff), eff); } diff --git a/source/blender/makesdna/DNA_effect_types.h b/source/blender/makesdna/DNA_effect_types.h index dc3118b7f73..299756edfe1 100644 --- a/source/blender/makesdna/DNA_effect_types.h +++ b/source/blender/makesdna/DNA_effect_types.h @@ -51,7 +51,6 @@ /* eff->flag */ #define EFF_SELECT 1 -#define EFF_CYCLIC 2 /* paf->stype */ #define PAF_NORMAL 0 diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 1b183c3cb39..f6f16b94f3a 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -80,9 +80,6 @@ typedef struct Mesh { struct MSticky *msticky; struct Mesh *texcomesh; - /* hacky place to store temporary decimated mesh */ - struct DispListMesh *decimated; - struct OcInfo *oc; /* not written in file */ void *sumohandle; diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index c4c5227fa73..66732fe0dc4 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -12,6 +12,8 @@ typedef enum ModifierType { eModifierType_Curve, eModifierType_Build, eModifierType_Mirror, + eModifierType_Decimate, + eModifierType_Wave, NUM_MODIFIER_TYPES } ModifierType; @@ -71,4 +73,22 @@ typedef struct MirrorModifierData { float tolerance; } MirrorModifierData; +typedef struct DecimateModifierData { + ModifierData modifier; + + float percent; + int faceCount; +} DecimateModifierData; + +typedef struct WaveModifierData { + ModifierData modifier; + + short flag, pad; + + float startx, starty, height, width; + float narrow, speed, damp; + + float timeoffs, lifetime; +} WaveModifierData; + #endif diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index bd39ae498c6..44f88d5d92f 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -39,7 +39,6 @@ source_files = ['BPY_interface.c', 'api2_2x/Sound.c', 'api2_2x/Sys.c', 'api2_2x/Types.c', - 'api2_2x/Wave.c', 'api2_2x/Window.c', 'api2_2x/World.c', 'api2_2x/Image.c', diff --git a/source/blender/python/api2_2x/Effect.c b/source/blender/python/api2_2x/Effect.c index c49dd53257c..6ea892e506c 100644 --- a/source/blender/python/api2_2x/Effect.c +++ b/source/blender/python/api2_2x/Effect.c @@ -35,7 +35,6 @@ #include "BKE_global.h" #include "BKE_main.h" #include "Particle.h" -#include "Wave.h" #include "gen_utils.h" /*****************************************************************************/ @@ -100,9 +99,7 @@ PyObject *M_Effect_New( PyObject * self, PyObject * args ) return Py_None; /* if( !PyArg_ParseTuple( args, "s", &btype ) ) return ( EXPP_ReturnPyObjError( PyExc_TypeError, - "expected type argument(wave,build or particle)" ) ); - if( !strcmp( btype, "wave" ) ) - type = EFF_WAVE; + "expected type argument(particle)" ) ); if( !strcmp( btype, "particle" ) ) type = EFF_PARTICLE; if( type == -1 ) @@ -232,7 +229,6 @@ PyObject *M_Effect_Get( PyObject * self, PyObject * args ) /*****************************************************************************/ -PyObject *Wave_Init( void ); PyObject *Particle_Init( void ); PyObject *Effect_Init( void ) @@ -243,7 +239,6 @@ PyObject *Effect_Init( void ) submodule = Py_InitModule3( "Blender.Effect", M_Effect_methods, 0 ); dict = PyModule_GetDict( submodule ); - PyDict_SetItemString( dict, "Wave", Wave_Init( ) ); PyDict_SetItemString( dict, "Particle", Particle_Init( ) ); return ( submodule ); } @@ -319,8 +314,6 @@ void EffectDeAlloc( BPy_Effect * self ) PyObject *EffectGetAttr( BPy_Effect * self, char *name ) { switch ( self->effect->type ) { - case EFF_WAVE: - return WaveGetAttr( ( BPy_Wave * ) self, name ); case EFF_PARTICLE: return ParticleGetAttr( ( BPy_Particle * ) self, name ); } @@ -338,8 +331,6 @@ PyObject *EffectGetAttr( BPy_Effect * self, char *name ) int EffectSetAttr( BPy_Effect * self, char *name, PyObject * value ) { switch ( self->effect->type ) { - case EFF_WAVE: - return WaveSetAttr( ( BPy_Wave * ) self, name, value ); case EFF_PARTICLE: return ParticleSetAttr( ( BPy_Particle * ) self, name, value ); } @@ -355,7 +346,6 @@ int EffectSetAttr( BPy_Effect * self, char *name, PyObject * value ) int EffectPrint(BPy_Effect *self, FILE *fp, int flags) { if (self->effect->type == EFF_PARTICLE)puts("Effect Particle"); -if (self->effect->type == EFF_WAVE)puts("Effect Wave"); return 0; } @@ -371,8 +361,6 @@ PyObject *EffectRepr( BPy_Effect * self ) char *str = ""; if( self->effect->type == EFF_PARTICLE ) str = "Effect Particle"; - if( self->effect->type == EFF_WAVE ) - str = "Effect Wave"; return PyString_FromString( str ); } diff --git a/source/blender/python/api2_2x/Types.c b/source/blender/python/api2_2x/Types.c index 54555a32b08..f8b24468a14 100644 --- a/source/blender/python/api2_2x/Types.c +++ b/source/blender/python/api2_2x/Types.c @@ -75,7 +75,6 @@ void types_InitAll( void ) Text_Type.ob_type = &PyType_Type; Text3d_Type.ob_type = &PyType_Type; Texture_Type.ob_type = &PyType_Type; - Wave_Type.ob_type = &PyType_Type; World_Type.ob_type = &PyType_Type; buffer_Type.ob_type = &PyType_Type; constant_Type.ob_type = &PyType_Type; diff --git a/source/blender/python/api2_2x/Types.h b/source/blender/python/api2_2x/Types.h index e75f4a78a0a..ede21369fe0 100644 --- a/source/blender/python/api2_2x/Types.h +++ b/source/blender/python/api2_2x/Types.h @@ -49,7 +49,7 @@ extern PyTypeObject Object_Type; extern PyTypeObject Particle_Type; extern PyTypeObject Scene_Type, RenderData_Type; extern PyTypeObject Text_Type, Text3d_Type, Texture_Type; -extern PyTypeObject Wave_Type, World_Type; +extern PyTypeObject World_Type; extern PyTypeObject property_Type; extern PyTypeObject buffer_Type, constant_Type, euler_Type; extern PyTypeObject matrix_Type, quaternion_Type, rgbTuple_Type, vector_Type; diff --git a/source/blender/python/api2_2x/Wave.c b/source/blender/python/api2_2x/Wave.c deleted file mode 100644 index 5b0abacc782..00000000000 --- a/source/blender/python/api2_2x/Wave.c +++ /dev/null @@ -1,605 +0,0 @@ -/* - * $Id$ - * - * ***** BEGIN GPL/BL DUAL 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. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. - * - * 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) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * This is a new part of Blender. - * - * Contributor(s): Jacques Guignot - * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** - */ - -#include "Wave.h" /*This must come first*/ - -#include "DNA_object_types.h" -#include "BKE_effect.h" -#include "BKE_global.h" -#include "BKE_main.h" -#include "gen_utils.h" - -/******* prototypes **********/ -PyObject *Wave_Init( void ); - -/*****************************************************************************/ -/* Python BPy_Wave methods table: */ -/*****************************************************************************/ -static PyMethodDef BPy_Wave_methods[] = { - {"getType", ( PyCFunction ) Effect_getType, - METH_NOARGS, "() - Return Effect type"}, - {"setType", ( PyCFunction ) Effect_setType, - METH_VARARGS, "() - Set Effect type"}, - {"getFlag", ( PyCFunction ) Effect_getFlag, - METH_NOARGS, "() - Return Effect flag"}, - {"setFlag", ( PyCFunction ) Effect_setFlag, - METH_VARARGS, "() - Set Effect flag"}, - {"getStartx", ( PyCFunction ) Wave_getStartx, - METH_NOARGS, "()-Return Wave startx"}, - {"setStartx", ( PyCFunction ) Wave_setStartx, METH_VARARGS, - "()- Sets Wave startx"}, - {"getStarty", ( PyCFunction ) Wave_getStarty, - METH_NOARGS, "()-Return Wave starty"}, - {"setStarty", ( PyCFunction ) Wave_setStarty, METH_VARARGS, - "()- Sets Wave starty"}, - {"getHeight", ( PyCFunction ) Wave_getHeight, - METH_NOARGS, "()-Return Wave height"}, - {"setHeight", ( PyCFunction ) Wave_setHeight, METH_VARARGS, - "()- Sets Wave height"}, - {"getWidth", ( PyCFunction ) Wave_getWidth, - METH_NOARGS, "()-Return Wave width"}, - {"setWidth", ( PyCFunction ) Wave_setWidth, METH_VARARGS, - "()- Sets Wave width"}, - {"getNarrow", ( PyCFunction ) Wave_getNarrow, - METH_NOARGS, "()-Return Wave narrow"}, - {"setNarrow", ( PyCFunction ) Wave_setNarrow, METH_VARARGS, - "()- Sets Wave narrow"}, - {"getSpeed", ( PyCFunction ) Wave_getSpeed, - METH_NOARGS, "()-Return Wave speed"}, - {"setSpeed", ( PyCFunction ) Wave_setSpeed, METH_VARARGS, - "()- Sets Wave speed"}, - {"getMinfac", ( PyCFunction ) Wave_getMinfac, - METH_NOARGS, "()-Return Wave minfac"}, - {"setMinfac", ( PyCFunction ) Wave_setMinfac, METH_VARARGS, - "()- Sets Wave minfac"}, - {"getDamp", ( PyCFunction ) Wave_getDamp, - METH_NOARGS, "()-Return Wave damp"}, - {"setDamp", ( PyCFunction ) Wave_setDamp, METH_VARARGS, - "()- Sets Wave damp"}, - {"getTimeoffs", ( PyCFunction ) Wave_getTimeoffs, - METH_NOARGS, "()-Return Wave timeoffs"}, - {"setTimeoffs", ( PyCFunction ) Wave_setTimeoffs, METH_VARARGS, - "()- Sets Wave timeoffs"}, - {"getLifetime", ( PyCFunction ) Wave_getLifetime, - METH_NOARGS, "()-Return Wave lifetime"}, - {"setLifetime", ( PyCFunction ) Wave_setLifetime, METH_VARARGS, - "()- Sets Wave lifetime"}, - {NULL, NULL, 0, NULL} -}; - - - - -/*****************************************************************************/ -/* Python Wave_Type structure definition: */ -/*****************************************************************************/ -PyTypeObject Wave_Type = { - PyObject_HEAD_INIT( NULL ) - 0, - "Wave", - sizeof( BPy_Wave ), - 0, - /* methods */ - ( destructor ) WaveDeAlloc, /* tp_dealloc */ - ( printfunc ) WavePrint, /* tp_print */ - ( getattrfunc ) WaveGetAttr, /* tp_getattr */ - ( setattrfunc ) WaveSetAttr, /* tp_setattr */ - 0, /* tp_compare */ - ( reprfunc ) WaveRepr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_as_hash */ - 0, 0, 0, 0, 0, 0, - 0, /* tp_doc */ - 0, 0, 0, 0, 0, 0, - BPy_Wave_methods, /* tp_methods */ - 0, /* tp_members */ -}; - - -/*****************************************************************************/ -/* The following string definitions are used for documentation strings. */ -/* In Python these will be written to the console when doing a */ -/* Blender.Wave.__doc__ */ -/*****************************************************************************/ -static char M_Wave_doc[] = "The Blender Wave module\n\n\ -This module provides access to **Object Data** in Blender.\n\ -Functions :\n\ - New(opt name) : creates a new wave object with the given name (optional)\n\ - Get(name) : retreives a wave with the given name (mandatory)\n\ - get(name) : same as Get. Kept for compatibility reasons"; -static char M_Wave_New_doc[] = ""; -static char M_Wave_Get_doc[] = "xxx"; -/*****************************************************************************/ -/* Python method structure definition for Blender.Wave module: */ -/*****************************************************************************/ -struct PyMethodDef M_Wave_methods[] = { - {"New", ( PyCFunction ) M_Wave_New, METH_VARARGS, M_Wave_New_doc}, - {"Get", M_Wave_Get, METH_VARARGS, M_Wave_Get_doc}, - {"get", M_Wave_Get, METH_VARARGS, M_Wave_Get_doc}, - {NULL, NULL, 0, NULL} -}; - - - -/* -Sta x et Sta y : là où débute la vague - -X, Y : la vague se propagera dans les directions X et/ou Y - -Cycl : la vague se répétera ou ne se produira qu'une fois - -Speed, Height, Width, Narrow : joues avec ces paramètres, je - te fais confiance. Ils interagissent et s'influencent alors - mieux vaut y aller un à la fois et qu'un peu à la fois. - -Time sta: la frame où l'effet commence à se produire. - -Lifetime: durée en frames de l'effet. - -Damptime: le temps, en frames, que met une vague à mourir. -*/ - -/*****************************************************************************/ -/* Function: M_Wave_New */ -/* Python equivalent: Blender.Effect.Wave.New */ -/*****************************************************************************/ -PyObject *M_Wave_New( PyObject * self, PyObject * args ) -{ - int type = EFF_WAVE; - BPy_Effect *pyeffect; - Effect *bleffect = 0; - - bleffect = add_effect( type ); - if( bleffect == NULL ) - return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, - "couldn't create Effect Data in Blender" ) ); - - pyeffect = ( BPy_Effect * ) PyObject_NEW( BPy_Effect, &Effect_Type ); - - - if( pyeffect == NULL ) - return ( EXPP_ReturnPyObjError( PyExc_MemoryError, - "couldn't create Effect Data object" ) ); - - pyeffect->effect = bleffect; - - return ( PyObject * ) pyeffect; -} - -/*****************************************************************************/ -/* Function: M_Wave_Get */ -/* Python equivalent: Blender.Effect.Wave.Get */ -/*****************************************************************************/ -PyObject *M_Wave_Get( PyObject * self, PyObject * args ) -{ - /*arguments : string object name - int : position of effect in the obj's effect list */ - char *name = 0; - Object *object_iter; - Effect *eff; - BPy_Wave *wanted_eff; - int num, i; - - if( !PyArg_ParseTuple( args, "si", &name, &num ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected string int argument" ) ); - - object_iter = G.main->object.first; - if( !object_iter ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "Scene contains no object" ) ); - - while( object_iter ) { - if( strcmp( name, object_iter->id.name + 2 ) ) { - object_iter = object_iter->id.next; - continue; - } - - - if( object_iter->effect.first != NULL ) { - eff = object_iter->effect.first; - for( i = 0; i < num; i++ ) { - if( eff->type != EFF_WAVE ) - continue; - eff = eff->next; - if( !eff ) - return ( EXPP_ReturnPyObjError - ( PyExc_AttributeError, - "bject" ) ); - } - wanted_eff = - ( BPy_Wave * ) PyObject_NEW( BPy_Wave, - &Wave_Type ); - wanted_eff->wave = eff; - return ( PyObject * ) wanted_eff; - } - object_iter = object_iter->id.next; - } - Py_INCREF( Py_None ); - return Py_None; -} - -/*****************************************************************************/ -/* Function: Wave_Init */ -/*****************************************************************************/ -PyObject *Wave_Init( void ) -{ - PyObject *submodule; - - Wave_Type.ob_type = &PyType_Type; - submodule = - Py_InitModule3( "Blender.Wave", M_Wave_methods, M_Wave_doc ); - return ( submodule ); -} - -/*****************************************************************************/ -/* Python BPy_Wave methods: */ -/*****************************************************************************/ - -PyObject *Wave_getStartx( BPy_Wave * self ) -{ - WaveEff *ptr = ( WaveEff * ) self->wave; - return PyFloat_FromDouble( ptr->startx ); -} - -PyObject *Wave_setStartx( BPy_Wave * self, PyObject * args ) -{ - WaveEff *ptr = ( WaveEff * ) self->wave; - float val = 0; - if( !PyArg_ParseTuple( args, "f", &val ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected float argument" ) ); - ptr->startx = val; - Py_INCREF( Py_None ); - return Py_None; -} - -PyObject *Wave_getStarty( BPy_Wave * self ) -{ - WaveEff *ptr = ( WaveEff * ) self->wave; - return PyFloat_FromDouble( ptr->starty ); -} - -PyObject *Wave_setStarty( BPy_Wave * self, PyObject * args ) -{ - WaveEff *ptr = ( WaveEff * ) self->wave; - float val = 0; - if( !PyArg_ParseTuple( args, "f", &val ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected float argument" ) ); - ptr->starty = val; - Py_INCREF( Py_None ); - return Py_None; -} - -PyObject *Wave_getHeight( BPy_Wave * self ) -{ - WaveEff *ptr = ( WaveEff * ) self->wave; - return PyFloat_FromDouble( ptr->height ); -} - -PyObject *Wave_setHeight( BPy_Wave * self, PyObject * args ) -{ - WaveEff *ptr = ( WaveEff * ) self->wave; - float val = 0; - if( !PyArg_ParseTuple( args, "f", &val ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected float argument" ) ); - ptr->height = val; - Py_INCREF( Py_None ); - return Py_None; -} - -PyObject *Wave_getWidth( BPy_Wave * self ) -{ - WaveEff *ptr = ( WaveEff * ) self->wave; - return PyFloat_FromDouble( ptr->width ); -} - -PyObject *Wave_setWidth( BPy_Wave * self, PyObject * args ) -{ - float val = 0; - WaveEff *ptr; - if( !PyArg_ParseTuple( args, "f", &val ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected float argument" ) ); - ptr = ( WaveEff * ) self->wave; - ptr->width = val; - Py_INCREF( Py_None ); - return Py_None; -} - -PyObject *Wave_getNarrow( BPy_Wave * self ) -{ - WaveEff *ptr = ( WaveEff * ) self->wave; - return PyFloat_FromDouble( ptr->narrow ); -} - -PyObject *Wave_setNarrow( BPy_Wave * self, PyObject * args ) -{ - float val = 0; - WaveEff *ptr; - if( !PyArg_ParseTuple( args, "f", &val ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected float argument" ) ); - ptr = ( WaveEff * ) self->wave; - ptr->narrow = val; - Py_INCREF( Py_None ); - return Py_None; -} - -PyObject *Wave_getSpeed( BPy_Wave * self ) -{ - WaveEff *ptr = ( WaveEff * ) self->wave; - return PyFloat_FromDouble( ptr->speed ); -} - -PyObject *Wave_setSpeed( BPy_Wave * self, PyObject * args ) -{ - float val = 0; - WaveEff *ptr; - if( !PyArg_ParseTuple( args, "f", &val ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected float argument" ) ); - ptr = ( WaveEff * ) self->wave; - ptr->speed = val; - Py_INCREF( Py_None ); - return Py_None; -} - -PyObject *Wave_getMinfac( BPy_Wave * self ) -{ - WaveEff *ptr = ( WaveEff * ) self->wave; - return PyFloat_FromDouble( ptr->minfac ); -} - -PyObject *Wave_setMinfac( BPy_Wave * self, PyObject * args ) -{ - float val = 0; - WaveEff *ptr; - if( !PyArg_ParseTuple( args, "f", &val ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected float argument" ) ); - ptr = ( WaveEff * ) self->wave; - ptr->minfac = val; - Py_INCREF( Py_None ); - return Py_None; -} - - - -PyObject *Wave_getDamp( BPy_Wave * self ) -{ - WaveEff *ptr = ( WaveEff * ) self->wave; - return PyFloat_FromDouble( ptr->damp ); -} - -PyObject *Wave_setDamp( BPy_Wave * self, PyObject * args ) -{ - WaveEff *ptr; - float val = 0; - if( !PyArg_ParseTuple( args, "f", &val ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected float argument" ) ); - ptr = ( WaveEff * ) self->wave; - ptr->damp = val; - Py_INCREF( Py_None ); - return Py_None; -} - -PyObject *Wave_getTimeoffs( BPy_Wave * self ) -{ - WaveEff *ptr = ( WaveEff * ) self->wave; - return PyFloat_FromDouble( ptr->timeoffs ); -} - -PyObject *Wave_setTimeoffs( BPy_Wave * self, PyObject * args ) -{ - float val = 0; - WaveEff *ptr; - if( !PyArg_ParseTuple( args, "f", &val ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected float argument" ) ); - ptr = ( WaveEff * ) self->wave; - ptr->timeoffs = val; - Py_INCREF( Py_None ); - return Py_None; -} - -PyObject *Wave_getLifetime( BPy_Wave * self ) -{ - WaveEff *ptr = ( WaveEff * ) self->wave; - return PyFloat_FromDouble( ptr->lifetime ); -} - -PyObject *Wave_setLifetime( BPy_Wave * self, PyObject * args ) -{ - float val = 0; - WaveEff *ptr; - if( !PyArg_ParseTuple( args, "f", &val ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected float argument" ) ); - ptr = ( WaveEff * ) self->wave; - ptr->lifetime = val; - Py_INCREF( Py_None ); - return Py_None; -} - -/*****************************************************************************/ -/* Function: WaveDeAlloc */ -/* Description: This is a callback function for the BPy_Wave type. It is */ -/* the destructor function. */ -/*****************************************************************************/ -void WaveDeAlloc( BPy_Wave * self ) -{ - WaveEff *ptr = ( WaveEff * ) self->wave; - PyObject_DEL( ptr ); -} - -/*****************************************************************************/ -/* Function: WaveGetAttr */ -/* Description: This is a callback function for the BPy_Wave type. It is */ -/* the function that accesses BPy_Wave "member variables" and */ -/* methods. */ -/*****************************************************************************/ - -PyObject *WaveGetAttr( BPy_Wave * self, char *name ) -{ - if( !strcmp( name, "lifetime" ) ) - return Wave_getLifetime( self ); - else if( !strcmp( name, "timeoffs" ) ) - return Wave_getTimeoffs( self ); - else if( !strcmp( name, "damp" ) ) - return Wave_getDamp( self ); - else if( !strcmp( name, "minfac" ) ) - return Wave_getMinfac( self ); - else if( !strcmp( name, "speed" ) ) - return Wave_getSpeed( self ); - else if( !strcmp( name, "narrow" ) ) - return Wave_getNarrow( self ); - else if( !strcmp( name, "width" ) ) - return Wave_getWidth( self ); - else if( !strcmp( name, "height" ) ) - return Wave_getHeight( self ); - else if( !strcmp( name, "startx" ) ) - return Wave_getStartx( self ); - else if( !strcmp( name, "starty" ) ) - return Wave_getStarty( self ); - return Py_FindMethod( BPy_Wave_methods, ( PyObject * ) self, name ); -} - -/*****************************************************************************/ -/* Function: WaveSetAttr */ -/* Description: This is a callback function for the BPy_Wave type. It is the */ -/* function that sets Wave Data attributes (member variables). */ -/*****************************************************************************/ -int WaveSetAttr( BPy_Wave * self, char *name, PyObject * value ) -{ - PyObject *valtuple; - PyObject *error = NULL; - - valtuple = Py_BuildValue( "(N)", value ); - - if( !valtuple ) - return EXPP_ReturnIntError( PyExc_MemoryError, - "ParticleSetAttr: couldn't create PyTuple" ); - - if( !strcmp( name, "lifetime" ) ) - error = Wave_setLifetime( self, valtuple ); - else if( !strcmp( name, "timeoffs" ) ) - error = Wave_setTimeoffs( self, valtuple ); - else if( !strcmp( name, "damp" ) ) - error = Wave_setDamp( self, valtuple ); - else if( !strcmp( name, "minfac" ) ) - error = Wave_setMinfac( self, valtuple ); - else if( !strcmp( name, "speed" ) ) - error = Wave_setSpeed( self, valtuple ); - else if( !strcmp( name, "narrow" ) ) - error = Wave_setNarrow( self, valtuple ); - else if( !strcmp( name, "width" ) ) - error = Wave_setWidth( self, valtuple ); - else if( !strcmp( name, "height" ) ) - error = Wave_setHeight( self, valtuple ); - else if( !strcmp( name, "startx" ) ) - error = Wave_setStartx( self, valtuple ); - else if( !strcmp( name, "starty" ) ) - error = Wave_setStarty( self, valtuple ); - - - else { - Py_DECREF( valtuple ); - - if( ( strcmp( name, "Types" ) == 0 ) || - ( strcmp( name, "Modes" ) == 0 ) ) - return ( EXPP_ReturnIntError( PyExc_AttributeError, - "constant dictionary -- cannot be changed" ) ); - - else - return ( EXPP_ReturnIntError( PyExc_KeyError, - "attribute not found" ) ); - } - - Py_DECREF(valtuple); - - if( error != Py_None ) - return -1; - - Py_DECREF( Py_None ); - return 0; -} - -/*****************************************************************************/ -/* Function: WavePrint */ -/* Description: This is a callback function for the BPy_Wave type. It */ -/* builds a meaninful string to 'print' wave objects. */ -/*****************************************************************************/ -int WavePrint( BPy_Wave * self, FILE * fp, int flags ) -{ - - printf( "I'm a wave...Cool, no?" ); - return 0; -} - -/*****************************************************************************/ -/* Function: WaveRepr */ -/* Description: This is a callback function for the BPy_Wave type. It */ -/* builds a meaninful string to represent wave objects. */ -/*****************************************************************************/ -PyObject *WaveRepr( BPy_Wave * self ) -{ - return 0; -} - -PyObject *WaveCreatePyObject( struct Effect * wave ) -{ - BPy_Wave *blen_object; - - - blen_object = ( BPy_Wave * ) PyObject_NEW( BPy_Wave, &Wave_Type ); - - if( blen_object == NULL ) { - return ( NULL ); - } - blen_object->wave = wave; - return ( ( PyObject * ) blen_object ); - -} - -int WaveCheckPyObject( PyObject * py_obj ) -{ - return ( py_obj->ob_type == &Wave_Type ); -} - - -struct Wave *WaveFromPyObject( PyObject * py_obj ) -{ - BPy_Wave *blen_obj; - - blen_obj = ( BPy_Wave * ) py_obj; - return ( ( struct Wave * ) blen_obj->wave ); - -} diff --git a/source/blender/python/api2_2x/Wave.h b/source/blender/python/api2_2x/Wave.h deleted file mode 100644 index 194642d36a1..00000000000 --- a/source/blender/python/api2_2x/Wave.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * $Id$ - * - * ***** BEGIN GPL/BL DUAL 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. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. - * - * 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) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * This is a new part of Blender. - * - * Contributor(s): Jacques Guignot - * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** - */ - -#ifndef EXPP_WAVE_H -#define EXPP_WAVE_H - -#include -#include "Effect.h" - -extern PyTypeObject Wave_Type; - -#define BPy_Wave_Check(v) ((v)->ob_type==&Wave_Type) - -/* Python BPy_Wave structure definition */ -typedef struct { - PyObject_HEAD /* required py macro */ - Effect * wave; -} BPy_Wave; - - -/*****************************************************************************/ -/* Python API function prototypes for the Wave module. */ -/*****************************************************************************/ -PyObject *M_Wave_New( PyObject * self, PyObject * args ); -PyObject *M_Wave_Get( PyObject * self, PyObject * args ); - - -/*****************************************************************************/ -/* Python BPy_Wave methods declarations: */ -/*****************************************************************************/ -PyObject *Effect_getType( BPy_Effect * self ); -PyObject *Effect_setType( BPy_Effect * self, PyObject * args ); -PyObject *Effect_getFlag( BPy_Effect * self ); -PyObject *Effect_setFlag( BPy_Effect * self, PyObject * args ); -PyObject *Wave_getStartx( BPy_Wave * self ); -PyObject *Wave_setStartx( BPy_Wave * self, PyObject * a ); -PyObject *Wave_getStarty( BPy_Wave * self ); -PyObject *Wave_setStarty( BPy_Wave * self, PyObject * a ); -PyObject *Wave_getHeight( BPy_Wave * self ); -PyObject *Wave_setHeight( BPy_Wave * self, PyObject * a ); -PyObject *Wave_getWidth( BPy_Wave * self ); -PyObject *Wave_setWidth( BPy_Wave * self, PyObject * a ); -PyObject *Wave_getNarrow( BPy_Wave * self ); -PyObject *Wave_setNarrow( BPy_Wave * self, PyObject * a ); -PyObject *Wave_getSpeed( BPy_Wave * self ); -PyObject *Wave_setSpeed( BPy_Wave * self, PyObject * a ); -PyObject *Wave_getMinfac( BPy_Wave * self ); -PyObject *Wave_setMinfac( BPy_Wave * self, PyObject * a ); -PyObject *Wave_getDamp( BPy_Wave * self ); -PyObject *Wave_setDamp( BPy_Wave * self, PyObject * a ); -PyObject *Wave_getTimeoffs( BPy_Wave * self ); -PyObject *Wave_setTimeoffs( BPy_Wave * self, PyObject * a ); -PyObject *Wave_getLifetime( BPy_Wave * self ); -PyObject *Wave_setLifetime( BPy_Wave * self, PyObject * a ); - -/*****************************************************************************/ -/* Python Wave_Type callback function prototypes: */ -/*****************************************************************************/ -void WaveDeAlloc( BPy_Wave * msh ); -int WavePrint( BPy_Wave * msh, FILE * fp, int flags ); -int WaveSetAttr( BPy_Wave * msh, char *name, PyObject * v ); -PyObject *WaveGetAttr( BPy_Wave * msh, char *name ); -PyObject *WaveRepr( BPy_Wave * msh ); -PyObject *WaveCreatePyObject( struct Effect *wave ); -int WaveCheckPyObject( PyObject * py_obj ); -struct Wave *WaveFromPyObject( PyObject * py_obj ); - - -#endif /* EXPP_WAVE_H */ diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 1fd83a4b2d4..f92a9666b53 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -148,9 +148,6 @@ #include "BSE_buttons.h" #include "BSE_seqaudio.h" -#include "LOD_DependKludge.h" -#include "LOD_decimation.h" - #include "RE_renderconverter.h" // make_sticky #include "butspace.h" // own module @@ -170,224 +167,6 @@ extern ListBase editNurb; /* *************************** static functions prototypes ****************** */ VFont *exist_vfont(char *str); -/* *************************** MESH DECIMATE ******************************** */ - -/* should be removed from this c file (ton) */ - -static int decimate_count_tria(Object *ob) -{ - int tottria; - MFace *mface; - Mesh *me; - int a; - - me= ob->data; - - /* count number of trias, since decimator doesnt allow quads */ - tottria= 0; - mface= me->mface; - for(a=0; atotface; a++, mface++) { - if(mface->v4) tottria++; - if(mface->v3) tottria++; - } - - return tottria; -} - -static void decimate_faces(void) -{ - Object *ob; - Mesh *me; - MVert *mvert; - MFace *mface; - LOD_Decimation_Info lod; - float *vb=NULL; - float *vnb=NULL; - int *tib=NULL; - int a, tottria; - - /* we assume the active object being decimated */ - ob= OBACT; - if(ob==NULL || ob->type!=OB_MESH) return; - me= ob->data; - - /* add warning for vertex col and tfaces */ - if(me->tface || me->mcol || me->dvert || me->medge) { - if(okee("This will remove UV coordinates, vertexcolors, deform weights and edge data")==0) return; - if(me->tface) MEM_freeN(me->tface); - if(me->mcol) MEM_freeN(me->mcol); - if(me->dvert) free_dverts(me->dvert, me->totvert); - me->tface= NULL; - me->mcol= NULL; - me->dvert= NULL; - } - - /* count number of trias, since decimator doesnt allow quads */ - tottria= decimate_count_tria(ob); - - if(tottria<3) { - error("You must have more than 3 input faces selected."); - return; - } - /* allocate and init */ - lod.vertex_buffer= MEM_mallocN(3*sizeof(float)*me->totvert, "vertices"); - lod.vertex_normal_buffer= MEM_mallocN(3*sizeof(float)*me->totvert, "normals"); - lod.triangle_index_buffer= MEM_mallocN(3*sizeof(int)*tottria, "trias"); - lod.vertex_num= me->totvert; - lod.face_num= tottria; - - /* fill vertex buffer */ - vb= lod.vertex_buffer; - vnb= lod.vertex_normal_buffer; - mvert= me->mvert; - for(a=0; atotvert; a++, mvert++, vb+=3, vnb+=3) { - VECCOPY(vb, mvert->co); - VECCOPY(vnb, mvert->no); - Normalise(vnb); - } - - /* fill index buffer */ - mface= me->mface; - tib= lod.triangle_index_buffer; - for(a=0; atotface; a++, mface++) { - if(mface->v4) { - tib[0]= mface->v1; - tib[1]= mface->v3; - tib[2]= mface->v4; - tib+= 3; - } - if(mface->v3) { - tib[0]= mface->v1; - tib[1]= mface->v2; - tib[2]= mface->v3; - tib+= 3; - } - } - - if(LOD_LoadMesh(&lod) ) { - if( LOD_PreprocessMesh(&lod) ) { - DispListMesh *dlm; - MFace *mfaceint; - - /* we assume the decim_faces tells how much to reduce */ - - while(lod.face_num > decim_faces) { - if( LOD_CollapseEdge(&lod)==0) break; - } - - /* ok, put back the stuff in a displist */ - if (me->decimated) { - displistmesh_free(me->decimated); - } - - dlm= me->decimated= MEM_callocN(sizeof(DispListMesh), "dispmesh"); - dlm->mvert= MEM_callocN(lod.vertex_num*sizeof(MVert), "mvert"); - dlm->mface= MEM_callocN(lod.face_num*sizeof(MFace), "mface"); - dlm->totvert= lod.vertex_num; - dlm->totface= lod.face_num; - - mvert= dlm->mvert; - vb= lod.vertex_buffer; - for(a=0; aco, vb); - } - - mfaceint= dlm->mface; - tib= lod.triangle_index_buffer; - for(a=0; av1= tib[0]; - mfaceint->v2= tib[1]; - mfaceint->v3= tib[2]; - } - } - else error("No memory"); - - LOD_FreeDecimationData(&lod); - } - else error("No manifold Mesh"); - - MEM_freeN(lod.vertex_buffer); - MEM_freeN(lod.vertex_normal_buffer); - MEM_freeN(lod.triangle_index_buffer); - - allqueue(REDRAWVIEW3D, 0); -} - - - -static void decimate_cancel(void) -{ - Object *ob; - - ob= OBACT; - if(ob) { - if (ob->type==OB_MESH) { - Mesh *me = ob->data; - - if (me->decimated) { - displistmesh_free(me->decimated); - me->decimated = NULL; - } - } - } - allqueue(REDRAWVIEW3D, 0); -} - -static void decimate_apply(void) -{ - Object *ob; - MFace *mface; - MFace *mfaceint; - int a; - - if(G.obedit) return; - - ob= OBACT; - if(ob && ob->type==OB_MESH) { - Mesh *me = ob->data; - - if (me->decimated) { - DispListMesh *dlm= me->decimated; - - // vertices - if(me->mvert) MEM_freeN(me->mvert); - me->mvert= dlm->mvert; - dlm->mvert= NULL; - me->totvert= dlm->totvert; - - // edges - if(me->medge) MEM_freeN(me->medge); - me->medge = NULL; - me->totedge = 0; - - // faces - if(me->mface) MEM_freeN(me->mface); - me->mface= MEM_callocN(dlm->totface*sizeof(MFace), "mface"); - me->totface= dlm->totface; - mface= me->mface; - mfaceint= dlm->mface; - for(a=0; atotface; a++, mface++, mfaceint++) { - mface->v1= mfaceint->v1; - mface->v2= mfaceint->v2; - mface->v3= mfaceint->v3; - test_index_mface(mface, 3); - } - - displistmesh_free(me->decimated); - me->decimated= NULL; - - G.obedit= ob; - make_editMesh(); - load_editMesh(); - free_editMesh(G.editMesh); - G.obedit= NULL; - - BIF_undo_push("Apply decimation"); - } - else error("Not a decimated Mesh"); - } -} - /* *************** */ void do_common_editbuts(unsigned short event) // old name, is a mix of object and editing events.... @@ -701,25 +480,6 @@ static void editing_panel_mesh_type(Object *ob, Mesh *me) uiBlockEndAlign(block); - /* decimator */ - if(G.obedit==NULL) { - int tottria= decimate_count_tria(ob); - Mesh *me = ob->data; - - if (!me->decimated) { - decim_faces= tottria; - } - - uiBlockBeginAlign(block); - uiBlockSetCol(block, TH_BUT_SETTING1); - uiDefButI(block, NUM,B_DECIM_FACES, "Decimator:", 175,180,230,19, &decim_faces, 4.0, tottria, 10, 10, "Defines the number of triangular faces to decimate the active Mesh object to"); - uiBlockSetCol(block, TH_AUTO); - uiDefBut(block, BUT,B_DECIM_APPLY, "Apply", 175,160,110,19, 0, 0, 0, 0, 0, "Applies the decimation to the active Mesh object"); - uiDefBut(block, BUT,B_DECIM_CANCEL, "Cancel", 285,160,120,19, 0, 0, 0, 0, 0, "Restores the Mesh to its original number of faces"); - uiBlockEndAlign(block); - } - - uiDefIDPoinBut(block, test_meshpoin_but, 0, "TexMesh: ", 175,124,230,19, &me->texcomesh, "Enter the name of a Meshblock"); if(me->key) { @@ -2061,16 +1821,6 @@ void do_meshbuts(unsigned short event) allqueue(REDRAWVIEW3D, 0); break; - case B_DECIM_FACES: - decimate_faces(); - break; - case B_DECIM_CANCEL: - decimate_cancel(); - break; - case B_DECIM_APPLY: - decimate_apply(); - break; - case B_SLOWERDRAW: slowerdraw(); break; diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 3584d75c8f6..9f221889f6a 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -1835,7 +1835,7 @@ static void modifiers_applyModifier(void *obv, void *mdv) dm = mesh_create_derived_for_modifier(ob, md); if (!dm) { - error("Modifier is not active, skipping apply"); + error("Modifier is disabled or returned error, skipping apply"); return; } @@ -1923,6 +1923,29 @@ static void object_panel_modifiers(Object *ob) uiDefButI(block, ROW, B_MAKEDISP, "X", 550, 360, 20,19, &mmd->axis, 1, 0, 0, 0, "Specify the axis to mirror about"); uiDefButI(block, ROW, B_MAKEDISP, "Y", 570, 360, 20,19, &mmd->axis, 1, 1, 0, 0, "Specify the axis to mirror about"); uiDefButI(block, ROW, B_MAKEDISP, "Z", 590, 360, 20,19, &mmd->axis, 1, 2, 0, 0, "Specify the axis to mirror about"); + } else if (md->type==eModifierType_Decimate) { + DecimateModifierData *dmd = (DecimateModifierData*) md; + uiDefButF(block, NUM, B_MAKEDISP, "Percent:", 550,380,150,19, &dmd->percent, 0.0, 1.0, 0, 0, "Defines the percentage of triangles to reduce to"); + sprintf(str, "Face Count: %d", dmd->faceCount); + uiDefBut(block, LABEL, 1, str, 550, 360, 150,19, NULL, 0.0, 0.0, 0, 0, "Displays the current number of faces in the decimated mesh"); + } else if (md->type==eModifierType_Wave) { + WaveModifierData *wmd = (WaveModifierData*) md; + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, WAV_X, B_MAKEDISP, "X", 550,380,45,19, &wmd->flag, 0, 0, 0, 0, "Enable X axis motion"); + uiDefButBitS(block, TOG, WAV_Y, B_MAKEDISP, "Y", 600,380,45,19, &wmd->flag, 0, 0, 0, 0, "Enable Y axis motion"); + uiDefButBitS(block, TOG, WAV_CYCL, B_MAKEDISP, "Cycl", 650,380,60,19, &wmd->flag, 0, 0, 0, 0, "Enable cyclic wave effect"); + uiDefButF(block, NUM, B_MAKEDISP, "Time sta:", 550,360,150,19, &wmd->timeoffs, -1000.0, 1000.0, 100, 0, "Specify startingframe of the wave"); + uiDefButF(block, NUM, B_MAKEDISP, "Lifetime:", 550,340,150,19, &wmd->lifetime, -1000.0, 1000.0, 100, 0, "Specify the lifespan of the wave"); + uiDefButF(block, NUM, B_MAKEDISP, "Damptime:", 550,320,150,19, &wmd->damp, -1000.0, 1000.0, 100, 0, "Specify the dampingtime of the wave"); + uiBlockBeginAlign(block); + uiDefButF(block, NUM, B_MAKEDISP, "Sta x:", 550,280,113,19, &wmd->startx, -100.0, 100.0, 100, 0, "Starting position for the X axis"); + uiDefButF(block, NUM, B_MAKEDISP, "Sta y:", 665,280,105,19, &wmd->starty, -100.0, 100.0, 100, 0, "Starting position for the Y axis"); + uiBlockBeginAlign(block); + uiDefButF(block, NUMSLI, B_MAKEDISP, "Speed:", 550,260,220,19, &wmd->speed, -2.0, 2.0, 0, 0, "Specify the wave speed"); + uiDefButF(block, NUMSLI, B_MAKEDISP, "Heigth:", 550,240,220,19, &wmd->height, -2.0, 2.0, 0, 0, "Specify the amplitude of the wave"); + uiDefButF(block, NUMSLI, B_MAKEDISP, "Width:", 550,220,220,19, &wmd->width, 0.0, 5.0, 0, 0, "Specify the width of the wave"); + uiDefButF(block, NUMSLI, B_MAKEDISP, "Narrow:", 550,200,220,19, &wmd->narrow, 0.0, 10.0, 0, 0, "Specify how narrow the wave follows"); + uiBlockEndAlign(block); } uiBlockEndAlign(block); @@ -1975,30 +1998,7 @@ static void object_panel_effects(Object *ob) if(eff) { uiDefButS(block, MENU, B_CHANGEEFFECT, "Particles %x1|Wave %x2", 895,187,107,27, &eff->buttype, 0, 0, 0, 0, "Set effect type"); - if(eff->type==EFF_WAVE) { - WaveEff *wav; - - wav= (WaveEff *)eff; - uiBlockBeginAlign(block); - uiDefButS(block, TOG|BIT|1, B_CALCEFFECT, "X", 782,135,54,23, &wav->flag, 0, 0, 0, 0, "Enable X axis motion"); - uiDefButS(block, TOG|BIT|2, B_CALCEFFECT, "Y", 840,135,47,23, &wav->flag, 0, 0, 0, 0, "Enable Y axis motion"); - uiDefButS(block, TOG|BIT|3, B_CALCEFFECT, "Cycl", 890,135,111,23, &wav->flag, 0, 0, 0, 0, "Enable cyclic wave effect"); - uiBlockBeginAlign(block); - uiDefButF(block, NUM, B_CALCEFFECT, "Sta x:", 550,135,113,24, &wav->startx, -100.0, 100.0, 100, 0, "Starting position for the X axis"); - uiDefButF(block, NUM, B_CALCEFFECT, "Sta y:", 665,135,104,24, &wav->starty, -100.0, 100.0, 100, 0, "Starting position for the Y axis"); - uiBlockBeginAlign(block); - uiDefButF(block, NUMSLI, B_CALCEFFECT, "Speed:", 550,100,216,20, &wav->speed, -2.0, 2.0, 0, 0, "Specify the wave speed"); - uiDefButF(block, NUMSLI, B_CALCEFFECT, "Heigth:", 550,80,216,20, &wav->height, -2.0, 2.0, 0, 0, "Specify the amplitude of the wave"); - uiDefButF(block, NUMSLI, B_CALCEFFECT, "Width:", 550,60,216,20, &wav->width, 0.0, 5.0, 0, 0, "Specify the width of the wave"); - uiDefButF(block, NUMSLI, B_CALCEFFECT, "Narrow:", 550,40,216,20, &wav->narrow, 0.0, 10.0, 0, 0, "Specify how narrow the wave follows"); - uiBlockBeginAlign(block); - uiDefButF(block, NUM, B_CALCEFFECT, "Time sta:", 780,100,219,20, &wav->timeoffs, -1000.0, 1000.0, 100, 0, "Specify startingframe of the wave"); - - uiDefButF(block, NUM, B_CALCEFFECT, "Lifetime:", 780,80,219,20, &wav->lifetime, -1000.0, 1000.0, 100, 0, "Specify the lifespan of the wave"); - uiDefButF(block, NUM, B_CALCEFFECT, "Damptime:", 780,60,219,20, &wav->damp, -1000.0, 1000.0, 100, 0, "Specify the dampingtime of the wave"); - uiBlockEndAlign(block); - } - else if(eff->type==EFF_PARTICLE) { + if(eff->type==EFF_PARTICLE) { PartEff *paf; paf= (PartEff *)eff; diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 0e8be4cedcb..328683070d0 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -1752,28 +1752,7 @@ static void draw_mesh_fancy(Object *ob, DerivedMesh *baseDM, DerivedMesh *dm, in // Unwanted combination. if (G.f&G_FACESELECT) draw_wire = 0; - // This is only for objects from the decimator and - // is a temporal solution, a reconstruction of the - // displist system should take care of it (zr/ton) - if(me->decimated) { - DispListMesh *dlm = me->decimated; - MVert *mvert= dlm->mvert; - MFace *mface= dlm->mface; - int i; - - for (i=0; itotface; i++, mface++) { - glBegin(GL_LINE_LOOP); - glVertex3fv(mvert[mface->v1].co); - glVertex3fv(mvert[mface->v2].co); - if (mface->v3) { - glVertex3fv(mvert[mface->v3].co); - if (mface->v4) - glVertex3fv(mvert[mface->v4].co); - } - glEnd(); - } - } - else if(dt==OB_BOUNDBOX) { + if(dt==OB_BOUNDBOX) { draw_bounding_volume(ob); } else if(hasHaloMat || (me->totface==0 && (!me->medge || me->totedge==0))) {