From 4c0bcbf4da991e3a8fe5b01bebbb3dc54fe183f8 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Mon, 5 May 2008 17:26:33 +0000 Subject: fix for bad indexing found by Cyril Brulebois Its making the identity matrix so I just removed the initalizing values that were out of bounds. Kent --- source/blender/blenkernel/intern/constraint.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 88ae02cd418..f60e39769a2 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1104,9 +1104,9 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh /* identity matrix - don't do anything if the two axes are the same */ else { m[0][0]= m[1][1]= m[2][2]= 1.0; - m[0][1]= m[0][2]= m[0][3]= 0.0; - m[1][0]= m[1][2]= m[1][3]= 0.0; - m[2][0]= m[2][1]= m[2][3]= 0.0; + m[0][1]= m[0][2]= 0.0; + m[1][0]= m[1][2]= 0.0; + m[2][0]= m[2][1]= 0.0; } } -- cgit v1.2.3 From b36fe51c7d85b5ea761d4ba9121001efb75b5c30 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Mon, 5 May 2008 17:29:11 +0000 Subject: Fixed some indentation, I stumbled across (spaces vs tabs) and also removed return 0 from a void stub. Kent --- .../blenkernel/bad_level_call_stubs/stubs.c | 2 +- .../Converter/BL_BlenderDataConversion.cpp | 103 +++++++++++---------- 2 files changed, 53 insertions(+), 52 deletions(-) diff --git a/source/blender/blenkernel/bad_level_call_stubs/stubs.c b/source/blender/blenkernel/bad_level_call_stubs/stubs.c index 291dd70c801..c913820205b 100644 --- a/source/blender/blenkernel/bad_level_call_stubs/stubs.c +++ b/source/blender/blenkernel/bad_level_call_stubs/stubs.c @@ -355,7 +355,7 @@ TimeMarker *get_frame_marker(int frame){return 0;}; /* editseq.c */ Sequence *get_forground_frame_seq(int frame){return 0;}; -void set_last_seq(Sequence *seq){return 0;}; +void set_last_seq(Sequence *seq){}; /* modifier.c stub */ void harmonic_coordinates_bind(struct MeshDeformModifierData *mmd, diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 08e9e36c048..089af9a68e7 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2176,70 +2176,71 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i); struct Object* blenderobject = converter->FindBlenderObject(gameobj); - int nummeshes = gameobj->GetMeshCount(); - RAS_MeshObject* meshobj = 0; - ListBase *conlist; - bConstraint *curcon; - conlist = get_active_constraints2(blenderobject); - if (conlist) { - for (curcon = (bConstraint *)conlist->first; curcon; curcon=(bConstraint *)curcon->next) { - if (curcon->type==CONSTRAINT_TYPE_RIGIDBODYJOINT){ - bRigidBodyJointConstraint *dat=(bRigidBodyJointConstraint *)curcon->data; - //if (dat->tar) - if (!dat->child){ - PHY_IPhysicsController* physctr2 = 0; - if (dat->tar) - { - KX_GameObject *gotar=getGameOb(dat->tar->id.name,sumolist); - if (gotar && gotar->GetPhysicsController()) - physctr2 = (PHY_IPhysicsController*) gotar->GetPhysicsController()->GetUserData(); - } + ListBase *conlist; + bConstraint *curcon; + conlist = get_active_constraints2(blenderobject); - if (gameobj->GetPhysicsController()) - { - float radsPerDeg = 6.283185307179586232f / 360.f; + if (conlist) { + for (curcon = (bConstraint *)conlist->first; curcon; curcon=(bConstraint *)curcon->next) { + if (curcon->type==CONSTRAINT_TYPE_RIGIDBODYJOINT){ + + bRigidBodyJointConstraint *dat=(bRigidBodyJointConstraint *)curcon->data; + + if (!dat->child){ + + PHY_IPhysicsController* physctr2 = 0; + + if (dat->tar) + { + KX_GameObject *gotar=getGameOb(dat->tar->id.name,sumolist); + if (gotar && gotar->GetPhysicsController()) + physctr2 = (PHY_IPhysicsController*) gotar->GetPhysicsController()->GetUserData(); + } - PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData(); - //we need to pass a full constraint frame, not just axis + if (gameobj->GetPhysicsController()) + { + float radsPerDeg = 6.283185307179586232f / 360.f; + + PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData(); + //we need to pass a full constraint frame, not just axis - //localConstraintFrameBasis - MT_Matrix3x3 localCFrame(MT_Vector3(radsPerDeg*dat->axX,radsPerDeg*dat->axY,radsPerDeg*dat->axZ)); - MT_Vector3 axis0 = localCFrame.getColumn(0); - MT_Vector3 axis1 = localCFrame.getColumn(1); - MT_Vector3 axis2 = localCFrame.getColumn(2); + //localConstraintFrameBasis + MT_Matrix3x3 localCFrame(MT_Vector3(radsPerDeg*dat->axX,radsPerDeg*dat->axY,radsPerDeg*dat->axZ)); + MT_Vector3 axis0 = localCFrame.getColumn(0); + MT_Vector3 axis1 = localCFrame.getColumn(1); + MT_Vector3 axis2 = localCFrame.getColumn(2); - int constraintId = kxscene->GetPhysicsEnvironment()->createConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX,(float)dat->pivY,(float)dat->pivZ, + int constraintId = kxscene->GetPhysicsEnvironment()->createConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX, + (float)dat->pivY,(float)dat->pivZ, (float)axis0.x(),(float)axis0.y(),(float)axis0.z(), (float)axis1.x(),(float)axis1.y(),(float)axis1.z(), - (float)axis2.x(),(float)axis2.y(),(float)axis2.z() - ); - if (constraintId) + (float)axis2.x(),(float)axis2.y(),(float)axis2.z()); + if (constraintId) + { + //if it is a generic 6DOF constraint, set all the limits accordingly + if (dat->type == PHY_GENERIC_6DOF_CONSTRAINT) { - //if it is a generic 6DOF constraint, set all the limits accordingly - if (dat->type == PHY_GENERIC_6DOF_CONSTRAINT) + int dof; + int dofbit=1; + for (dof=0;dof<6;dof++) { - int dof; - int dofbit=1; - for (dof=0;dof<6;dof++) + if (dat->flag & dofbit) { - if (dat->flag & dofbit) - { - kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]); - } else - { - //minLimit > maxLimit means free(disabled limit) for this degree of freedom - kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1); - } - dofbit<<=1; + kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]); + } else + { + //minLimit > maxLimit means free(disabled limit) for this degree of freedom + kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1); } + dofbit<<=1; } } } - } - } - } - } - + } + } + } + } + } } templist->Release(); -- cgit v1.2.3 From d5ffcda5dcad9c2037f38b965114916566cbd4a7 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 May 2008 17:41:14 +0000 Subject: Fix for bug #10347: particles reset with orbit around selection option, was doing unnecessary dependency graph calls. --- source/blender/src/transform_conversions.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c index f3fec3cfec7..8859194ff9c 100644 --- a/source/blender/src/transform_conversions.c +++ b/source/blender/src/transform_conversions.c @@ -3072,6 +3072,10 @@ static void set_trans_object_base_flags(TransInfo *t) */ Base *base; + /* don't do it if we're not actually going to recalculate anything */ + if(t->mode == TFM_DUMMY) + return; + /* makes sure base flags and object flags are identical */ copy_baseflags(); -- cgit v1.2.3 From 95ed34be4a6bf71e14740ed6232033443484dd86 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 May 2008 17:43:13 +0000 Subject: Fix for bug #10444: environment map crash with qmc. --- source/blender/render/intern/source/envmap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 26151ff8b91..12d0efa59e8 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -158,6 +158,7 @@ static Render *envmap_render_copy(Render *re, EnvMap *env) envre->totinstance= re->totinstance; envre->instancetable= re->instancetable; envre->objectinstance= re->objectinstance; + envre->qmcsamplers= re->qmcsamplers; return envre; } @@ -178,6 +179,7 @@ static void envmap_free_render_copy(Render *envre) envre->raytree= NULL; envre->instancetable.first= envre->instancetable.last= NULL; envre->objectinstance= NULL; + envre->qmcsamplers= NULL; RE_FreeRender(envre); } -- cgit v1.2.3 From b6f5679cf5707c2027f6629e8f61c24d14bd54e9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 May 2008 21:10:32 +0000 Subject: Fix for bug #10542: changing particle visualisation type from object to something else didn't work correct. Fix for bug #10478: particle system point cache problem. --- source/blender/blenkernel/intern/particle_system.c | 3 +++ source/blender/src/buttons_object.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 9dd21cdda4e..596c381b896 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4763,6 +4763,9 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier psys_update_path_cache(ob,psmd,psys,framenr); } + cache->simframe= framenr; + cache->flag |= PTCACHE_SIMULATION_VALID; + return; } else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) { diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 37becdc8912..0cfc2047aec 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -3010,6 +3010,16 @@ void do_effects_panels(unsigned short event) case B_PART_INIT_CHILD: case B_PART_RECALC_CHILD: if(psys) { + nr=0; + for(psys=ob->particlesystem.first; psys; psys=psys->next){ + if(ELEM(psys->part->draw_as,PART_DRAW_OB,PART_DRAW_GR)) + nr++; + } + if(nr) + ob->transflag |= OB_DUPLIPARTS; + else + ob->transflag &= ~OB_DUPLIPARTS; + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWBUTSOBJECT, 0); -- cgit v1.2.3 From 1989e757b0138488c7ee7adc7f2058d43a3f3397 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 5 May 2008 21:33:06 +0000 Subject: Add support for GLEXT in MSVC project files - continued: also support BlenderPlayer and release config --- projectfiles_vc7/gameengine/blenderhook/KX_blenderhook.vcproj | 2 +- projectfiles_vc7/gameengine/ketsji/KX_ketsji.vcproj | 6 +++--- projectfiles_vc7/gameengine/rasterizer/RAS_rasterizer.vcproj | 6 +++--- .../rasterizer/openglrasterizer/RAS_openglrasterizer.vcproj | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/projectfiles_vc7/gameengine/blenderhook/KX_blenderhook.vcproj b/projectfiles_vc7/gameengine/blenderhook/KX_blenderhook.vcproj index bc4204eaa44..c54666c08cd 100644 --- a/projectfiles_vc7/gameengine/blenderhook/KX_blenderhook.vcproj +++ b/projectfiles_vc7/gameengine/blenderhook/KX_blenderhook.vcproj @@ -75,7 +75,7 @@ Name="VCCLCompilerTool" InlineFunctionExpansion="1" AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\bmfont\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenloader;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\ketsji;..\..\..\source\gameengine\network;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Physics\Sumo;..\..\..\source\gameengine\Physics\common;..\..\..\source\gameengine\network\loopbacknetwork;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\Physics\Sumo\Fuzzics\include" - PreprocessorDefinitions="NDEBUG;WIN32;_LIB;USE_SUMO_SOLID" + PreprocessorDefinitions="NDEBUG;WIN32;_LIB;USE_SUMO_SOLID;WITH_GLEXT" StringPooling="TRUE" BasicRuntimeChecks="0" RuntimeLibrary="0" diff --git a/projectfiles_vc7/gameengine/ketsji/KX_ketsji.vcproj b/projectfiles_vc7/gameengine/ketsji/KX_ketsji.vcproj index d85fb6c3482..2b7a24ed7ad 100644 --- a/projectfiles_vc7/gameengine/ketsji/KX_ketsji.vcproj +++ b/projectfiles_vc7/gameengine/ketsji/KX_ketsji.vcproj @@ -180,7 +180,7 @@ Name="VCCLCompilerTool" InlineFunctionExpansion="1" AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\build\msvc_7\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet" - PreprocessorDefinitions="NDEBUG;WIN32;_LIB;USE_SUMO_SOLID" + PreprocessorDefinitions="NDEBUG;WIN32;_LIB;USE_SUMO_SOLID;WITH_GLEXT" StringPooling="TRUE" RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" @@ -233,7 +233,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\build\msvc_7\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet" - PreprocessorDefinitions="JANCODEPANCO;WIN32;_LIB;EXP_PYTHON_EMBEDDING;_DEBUG;USE_SUMO_SOLID" + PreprocessorDefinitions="JANCODEPANCO;WIN32;_LIB;EXP_PYTHON_EMBEDDING;_DEBUG;USE_SUMO_SOLID;WITH_GLEXT" BasicRuntimeChecks="3" RuntimeLibrary="1" DefaultCharIsUnsigned="TRUE" @@ -285,7 +285,7 @@ Name="VCCLCompilerTool" InlineFunctionExpansion="1" AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\build\msvc_7\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet" - PreprocessorDefinitions="NDEBUG;WIN32;_LIB;USE_SUMO_SOLID" + PreprocessorDefinitions="NDEBUG;WIN32;_LIB;USE_SUMO_SOLID;WITH_GLEXT" StringPooling="TRUE" RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" diff --git a/projectfiles_vc7/gameengine/rasterizer/RAS_rasterizer.vcproj b/projectfiles_vc7/gameengine/rasterizer/RAS_rasterizer.vcproj index f4801b58bc8..40a92a5c181 100644 --- a/projectfiles_vc7/gameengine/rasterizer/RAS_rasterizer.vcproj +++ b/projectfiles_vc7/gameengine/rasterizer/RAS_rasterizer.vcproj @@ -126,7 +126,7 @@ Name="VCCLCompilerTool" InlineFunctionExpansion="1" AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\source\kernel\gen_system" - PreprocessorDefinitions="NDEBUG,WIN32,_LIB" + PreprocessorDefinitions="NDEBUG;WIN32;_LIB;WITH_GLEXT" StringPooling="TRUE" RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" @@ -230,7 +230,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\source\kernel\gen_system" - PreprocessorDefinitions="_DEBUG,WIN32,_LIB" + PreprocessorDefinitions="_DEBUG;WIN32;_LIB;WITH_GLEXT" BasicRuntimeChecks="3" RuntimeLibrary="1" DefaultCharIsUnsigned="TRUE" @@ -282,7 +282,7 @@ Name="VCCLCompilerTool" InlineFunctionExpansion="1" AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\source\kernel\gen_system" - PreprocessorDefinitions="NDEBUG,WIN32,_LIB" + PreprocessorDefinitions="NDEBUG;WIN32;_LIB;WITH_GLEXT" StringPooling="TRUE" RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" diff --git a/projectfiles_vc7/gameengine/rasterizer/openglrasterizer/RAS_openglrasterizer.vcproj b/projectfiles_vc7/gameengine/rasterizer/openglrasterizer/RAS_openglrasterizer.vcproj index b96cf78daf5..b21c0fff7ee 100644 --- a/projectfiles_vc7/gameengine/rasterizer/openglrasterizer/RAS_openglrasterizer.vcproj +++ b/projectfiles_vc7/gameengine/rasterizer/openglrasterizer/RAS_openglrasterizer.vcproj @@ -178,7 +178,7 @@ Name="VCCLCompilerTool" InlineFunctionExpansion="1" AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer" - PreprocessorDefinitions="NDEBUG,WIN32,_LIB" + PreprocessorDefinitions="NDEBUG;WIN32;_LIB;WITH_GLEXT" StringPooling="TRUE" RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" @@ -230,7 +230,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer" - PreprocessorDefinitions="_DEBUG,WIN32,_LIB" + PreprocessorDefinitions="_DEBUG;WIN32;_LIB;WITH_GLEXT" BasicRuntimeChecks="3" RuntimeLibrary="1" DefaultCharIsUnsigned="TRUE" @@ -282,7 +282,7 @@ Name="VCCLCompilerTool" InlineFunctionExpansion="1" AdditionalIncludeDirectories="..\..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\source\kernel\gen_system;..\..\..\..\source\gameengine\Rasterizer" - PreprocessorDefinitions="NDEBUG,WIN32,_LIB" + PreprocessorDefinitions="NDEBUG;WIN32;_LIB;WITH_GLEXT" StringPooling="TRUE" RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" -- cgit v1.2.3 From 2b1797d07bfd4549b3c74a127aeb1fa8460dfb87 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Mon, 5 May 2008 22:08:50 +0000 Subject: == FFMPEG == Fixes: [#10703] loading an .avi captured by dosbox causes a segfault We shouldn't try to close a codec, if we haven't managed to open one... :) --- source/blender/imbuf/intern/util.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 4f2a1da5580..632a471ecd0 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -305,13 +305,11 @@ static int isffmpeg (char *filename) { /* Find the decoder for the video stream */ pCodec=avcodec_find_decoder(pCodecCtx->codec_id); if(pCodec==NULL) { - avcodec_close(pCodecCtx); av_close_input_file(pFormatCtx); return 0; } if(avcodec_open(pCodecCtx, pCodec)<0) { - avcodec_close(pCodecCtx); av_close_input_file(pFormatCtx); return 0; } -- cgit v1.2.3 From ee87af1e16f4aef7a8427b55100f545168608c9d Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 6 May 2008 07:10:30 +0000 Subject: Bugfixes: * NLA scaling was being incorrectly handled with fractional values. This was caused by clamping to integers instead of floats when making sure the scale value was positive. * Added checks to help prevent some weird cases that may sometimes occur and cause problems --- source/blender/blenkernel/intern/action.c | 6 +++--- source/blender/src/drawnla.c | 33 +++++++++++++++++-------------- source/blender/src/editnla.c | 9 +++++++-- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index c4df1db7627..5fb3d6f869a 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -489,11 +489,11 @@ static float get_actionstrip_frame(bActionStrip *strip, float cframe, int invert { float length, actlength, repeat, scale; - if(strip->repeat == 0.0f) strip->repeat = 1.0f; + if (strip->repeat == 0.0f) strip->repeat = 1.0f; repeat = (strip->flag & ACTSTRIP_USESTRIDE) ? (1.0f) : (strip->repeat); - if(strip->scale == 0.0f) strip->scale= 1.0f; - scale = abs(strip->scale); /* scale must be positive (for now) */ + if (strip->scale == 0.0f) strip->scale= 1.0f; + scale = fabs(strip->scale); /* scale must be positive (for now) */ actlength = strip->actend-strip->actstart; if (actlength == 0.0f) actlength = 1.0f; diff --git a/source/blender/src/drawnla.c b/source/blender/src/drawnla.c index fba55f7f308..c0cd11d27a1 100644 --- a/source/blender/src/drawnla.c +++ b/source/blender/src/drawnla.c @@ -490,39 +490,42 @@ void do_nlabuts(unsigned short event) allqueue (REDRAWNLA, 0); allqueue (REDRAWVIEW3D, 0); break; - case B_NLA_SCALE: + case B_NLA_SCALE: /* adjust end-frame when scale is changed */ { float actlen= strip->actend - strip->actstart; float mapping= strip->scale * strip->repeat; - strip->end = (actlen * mapping) + strip->start; + if (mapping != 0.0f) + strip->end = (actlen * mapping) + strip->start; + else + printf("NLA Scale Error: Scale = %0.4f, Repeat = %0.4f \n", strip->scale, strip->repeat); - allqueue (REDRAWNLA, 0); - allqueue (REDRAWIPO, 0); - allqueue (REDRAWACTION, 0); - allqueue (REDRAWVIEW3D, 0); + allqueue(REDRAWNLA, 0); + allqueue(REDRAWIPO, 0); + allqueue(REDRAWACTION, 0); + allqueue(REDRAWVIEW3D, 0); } break; - case B_NLA_SCALE2: + case B_NLA_SCALE2: /* adjust scale when end-frame is changed */ { float actlen= strip->actend - strip->actstart; float len= strip->end - strip->start; strip->scale= len / (actlen * strip->repeat); - allqueue (REDRAWNLA, 0); - allqueue (REDRAWIPO, 0); - allqueue (REDRAWACTION, 0); - allqueue (REDRAWVIEW3D, 0); + allqueue(REDRAWNLA, 0); + allqueue(REDRAWIPO, 0); + allqueue(REDRAWACTION, 0); + allqueue(REDRAWVIEW3D, 0); } break; case B_NLA_LOCK: synchronize_action_strips(); - allqueue (REDRAWNLA, 0); - allqueue (REDRAWIPO, 0); - allqueue (REDRAWACTION, 0); - allqueue (REDRAWVIEW3D, 0); + allqueue(REDRAWNLA, 0); + allqueue(REDRAWIPO, 0); + allqueue(REDRAWACTION, 0); + allqueue(REDRAWVIEW3D, 0); break; case B_NLA_MOD_ADD: diff --git a/source/blender/src/editnla.c b/source/blender/src/editnla.c index 6d9adda85d0..d758f34949a 100644 --- a/source/blender/src/editnla.c +++ b/source/blender/src/editnla.c @@ -188,11 +188,16 @@ void shift_nlastrips_down(void) { void synchronize_action_strips(void) { Base *base; + Object *ob; bActionStrip *strip; for (base=G.scene->base.first; base; base=base->next) { + /* get object first */ + ob= base->object; + /* step 1: adjust strip-lengths */ - for (strip = base->object->nlastrips.last; strip; strip=strip->prev) { + // FIXME: this seems very buggy + for (strip = ob->nlastrips.last; strip; strip=strip->prev) { if (strip->flag & ACTSTRIP_LOCK_ACTION) { float actstart, actend; @@ -212,7 +217,7 @@ void synchronize_action_strips(void) } /* step 2: adjust blendin/out values for each strip if option is turned on */ - for (strip= base->object->nlastrips.first; strip; strip=strip->next) { + for (strip= ob->nlastrips.first; strip; strip=strip->next) { if (strip->flag & ACTSTRIP_AUTO_BLENDS) { bActionStrip *prev= strip->prev; bActionStrip *next= strip->next; -- cgit v1.2.3 From 04d2a8badc165e91e9db664962dac3794ee5fc0e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 6 May 2008 08:35:19 +0000 Subject: Fix for bug #10734: mirror modifier crash with no axis enabled for mirroring around. --- source/blender/blenkernel/intern/modifier.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 0cd6035b9dc..ca95d9edc06 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -1506,7 +1506,8 @@ static DerivedMesh *mirrorModifier_applyModifier( result = mirrorModifier__doMirror(mmd, ob, derivedData, 0); - CDDM_calc_normals(result); + if(result != derivedData) + CDDM_calc_normals(result); return result; } -- cgit v1.2.3 From 3ba9069c040d6d3682d1421f89a061236ed8cd88 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Tue, 6 May 2008 09:43:28 +0000 Subject: Fixes Makefiles for mac_compat_glext.h by updating some include paths. Kent --- source/gameengine/BlenderRoutines/Makefile | 1 + source/gameengine/GamePlayer/common/Makefile | 1 + source/gameengine/GamePlayer/ghost/Makefile | 2 ++ source/gameengine/Rasterizer/Makefile | 2 ++ source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile | 1 + 5 files changed, 7 insertions(+) diff --git a/source/gameengine/BlenderRoutines/Makefile b/source/gameengine/BlenderRoutines/Makefile index 2339b840679..64a17f44a84 100644 --- a/source/gameengine/BlenderRoutines/Makefile +++ b/source/gameengine/BlenderRoutines/Makefile @@ -65,6 +65,7 @@ CPPFLAGS += -I../Network CPPFLAGS += -I../Network/LoopBackNetwork CPPFLAGS += -I../Physics/common CPPFLAGS += -I../Physics/Sumo +CPPFLAGS += -I. ifeq ($(OS),windows) CPPFLAGS += -I../../blender diff --git a/source/gameengine/GamePlayer/common/Makefile b/source/gameengine/GamePlayer/common/Makefile index 254896e60e5..508dee18755 100644 --- a/source/gameengine/GamePlayer/common/Makefile +++ b/source/gameengine/GamePlayer/common/Makefile @@ -60,6 +60,7 @@ CPPFLAGS += -I../../../gameengine/Converter CPPFLAGS += -I../../../gameengine/Expressions CPPFLAGS += -I../../../gameengine/GameLogic CPPFLAGS += -I../../../gameengine/Converter +CPPFLAGS += -I../../../gameengine/BlenderRoutines CPPFLAGS += -I../../../gameengine/Ketsji CPPFLAGS += -I../../../gameengine/Ketsji/KXNetwork CPPFLAGS += -I../../../gameengine/Network diff --git a/source/gameengine/GamePlayer/ghost/Makefile b/source/gameengine/GamePlayer/ghost/Makefile index 8a3d194cbd7..d5aae181396 100644 --- a/source/gameengine/GamePlayer/ghost/Makefile +++ b/source/gameengine/GamePlayer/ghost/Makefile @@ -69,6 +69,8 @@ CPPFLAGS += -I../../../blender/imbuf CPPFLAGS += -I../../../blender/makesdna CPPFLAGS += -I../../../blender/readblenfile +CPPFLAGS += -I../../../gameengine/BlenderRoutines + # kernel? GEN? stuff CPPFLAGS += -I../../../kernel/gen_system CPPFLAGS += -I../../../kernel/gen_messaging diff --git a/source/gameengine/Rasterizer/Makefile b/source/gameengine/Rasterizer/Makefile index 9cde6069167..d544056e8ae 100644 --- a/source/gameengine/Rasterizer/Makefile +++ b/source/gameengine/Rasterizer/Makefile @@ -39,6 +39,8 @@ CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I../../kernel/gen_system +CPPFLAGS += -I../BlenderRoutines + ifeq ($(OS),darwin) CPPFLAGS += -fpascal-strings endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile index b0d79dcc897..1a88c51dc25 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile @@ -40,6 +40,7 @@ CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I../../../kernel/gen_system +CPPFLAGS += -I../../BlenderRoutines CPPFLAGS += -I.. ifeq ($(OS),darwin) CPPFLAGS += -fpascal-strings -- cgit v1.2.3 From 722f24d15357275ee3efed33fa03f9b27909a604 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 6 May 2008 15:31:17 +0000 Subject: Fix for bug: drawing x-ray and transparency with sets didn't work well, now it draws those type of objects from sets also at the end. --- source/blender/include/BSE_drawview.h | 2 +- source/blender/src/drawobject.c | 4 ++-- source/blender/src/drawview.c | 29 +++++++++++++---------------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/source/blender/include/BSE_drawview.h b/source/blender/include/BSE_drawview.h index 09ce87015d9..be1f5581be7 100644 --- a/source/blender/include/BSE_drawview.h +++ b/source/blender/include/BSE_drawview.h @@ -46,7 +46,7 @@ void do_viewbuts(unsigned short event); /* View3DAfter->type */ #define V3D_XRAY 1 #define V3D_TRANSP 2 -void add_view3d_after(struct View3D *v3d, struct Base *base, int type); +void add_view3d_after(struct View3D *v3d, struct Base *base, int type, int flag); void backdrawview3d(int test); void check_backbuf(void); diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index aec0e112b32..181f797dbc9 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -2485,7 +2485,7 @@ static int draw_mesh_object(Base *base, int dt, int flag) } /* init_gl_materials did the proper checking if this is needed */ - if(has_alpha) add_view3d_after(G.vd, base, V3D_TRANSP); + if(has_alpha) add_view3d_after(G.vd, base, V3D_TRANSP, flag); return retval; } @@ -4663,7 +4663,7 @@ void draw_object(Base *base, int flag) if(!(G.f & G_PARTICLEEDIT)) { /* xray and transp are set when it is drawing the 2nd/3rd pass */ if(!G.vd->xray && !G.vd->transp && (ob->dtx & OB_DRAWXRAY)) { - add_view3d_after(G.vd, base, V3D_XRAY); + add_view3d_after(G.vd, base, V3D_XRAY, flag); return; } } diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index b01b7bc151c..1acb7c4373f 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -2663,21 +2663,22 @@ static void view3d_blockhandlers(ScrArea *sa) typedef struct View3DAfter { struct View3DAfter *next, *prev; struct Base *base; - int type; + int type, flag; } View3DAfter; /* temp storage of Objects that need to be drawn as last */ -void add_view3d_after(View3D *v3d, Base *base, int type) +void add_view3d_after(View3D *v3d, Base *base, int type, int flag) { View3DAfter *v3da= MEM_callocN(sizeof(View3DAfter), "View 3d after"); BLI_addtail(&v3d->afterdraw, v3da); v3da->base= base; v3da->type= type; + v3da->flag= flag; } /* clears zbuffer and draws it over */ -static void view3d_draw_xray(View3D *v3d, int flag) +static void view3d_draw_xray(View3D *v3d) { View3DAfter *v3da, *next; int doit= 0; @@ -2692,7 +2693,7 @@ static void view3d_draw_xray(View3D *v3d, int flag) for(v3da= v3d->afterdraw.first; v3da; v3da= next) { next= v3da->next; if(v3da->type==V3D_XRAY) { - draw_object(v3da->base, flag); + draw_object(v3da->base, v3da->flag); BLI_remlink(&v3d->afterdraw, v3da); MEM_freeN(v3da); } @@ -2702,7 +2703,7 @@ static void view3d_draw_xray(View3D *v3d, int flag) } /* disables write in zbuffer and draws it over */ -static void view3d_draw_transp(View3D *v3d, int flag) +static void view3d_draw_transp(View3D *v3d) { View3DAfter *v3da, *next; @@ -2712,7 +2713,7 @@ static void view3d_draw_transp(View3D *v3d, int flag) for(v3da= v3d->afterdraw.first; v3da; v3da= next) { next= v3da->next; if(v3da->type==V3D_TRANSP) { - draw_object(v3da->base, flag); + draw_object(v3da->base, v3da->flag); BLI_remlink(&v3d->afterdraw, v3da); MEM_freeN(v3da); } @@ -3102,9 +3103,7 @@ void drawview3dspace(ScrArea *sa, void *spacedata) } } - /* Transp and X-ray afterdraw stuff */ - view3d_draw_xray(v3d, DRAW_CONSTCOLOR); // clears zbuffer if it is used! - view3d_draw_transp(v3d, DRAW_CONSTCOLOR); + /* Transp and X-ray afterdraw stuff for sets is done later */ } /* then draw not selected and the duplis, but skip editmode object */ @@ -3150,8 +3149,8 @@ void drawview3dspace(ScrArea *sa, void *spacedata) if(G.scene->radio) RAD_drawall(v3d->drawtype>=OB_SOLID); /* Transp and X-ray afterdraw stuff */ - view3d_draw_xray(v3d, 0); // clears zbuffer if it is used! - view3d_draw_transp(v3d, 0); + view3d_draw_xray(v3d); // clears zbuffer if it is used! + view3d_draw_transp(v3d); if(!retopo && sculptparticle && (obact && (OBACT->dtx & OB_DRAWXRAY))) { if(G.f & G_SCULPTMODE) @@ -3327,9 +3326,7 @@ void drawview3d_render(struct View3D *v3d, int winx, int winy, float winmat[][4] } } - /* Transp and X-ray afterdraw stuff */ - view3d_draw_xray(v3d, DRAW_CONSTCOLOR); // clears zbuffer if it is used! - view3d_draw_transp(v3d, DRAW_CONSTCOLOR); + /* Transp and X-ray afterdraw stuff for sets is done later */ } /* first not selected and duplis */ @@ -3367,8 +3364,8 @@ void drawview3d_render(struct View3D *v3d, int winx, int winy, float winmat[][4] if(G.scene->radio) RAD_drawall(v3d->drawtype>=OB_SOLID); /* Transp and X-ray afterdraw stuff */ - view3d_draw_xray(v3d, 0); // clears zbuffer if it is used! - view3d_draw_transp(v3d, 0); + view3d_draw_xray(v3d); // clears zbuffer if it is used! + view3d_draw_transp(v3d); if(v3d->flag & V3D_CLIPPING) view3d_clr_clipping(); -- cgit v1.2.3 From 4255f3c7abe5c0bc7e9d2bc407ec6671e6ae6c45 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 May 2008 17:54:55 +0000 Subject: made python add mesh module respect blenders user settings for editmode and view align. added sys.cleanpath() was a patch in the tracker but blender's internal path cleaning is now more general and can be used from python. --- release/scripts/bpymodules/BPyAddMesh.py | 22 ++++++++++++++-------- source/blender/python/api2_2x/Blender.c | 8 ++++++-- source/blender/python/api2_2x/Sys.c | 28 +++++++++++++++++++++++++++- source/blender/python/api2_2x/doc/Sys.py | 11 ++++++++++- 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/release/scripts/bpymodules/BPyAddMesh.py b/release/scripts/bpymodules/BPyAddMesh.py index 6ffb394320a..bd3ee845d21 100644 --- a/release/scripts/bpymodules/BPyAddMesh.py +++ b/release/scripts/bpymodules/BPyAddMesh.py @@ -16,13 +16,17 @@ def add_mesh_simple(name, verts, edges, faces): scn = bpy.data.scenes.active if scn.lib: return ob_act = scn.objects.active - + + is_editmode = EditMode() + cursor = GetCursorPos() - try: quat = Blender.Mathutils.Quaternion(GetViewQuat()) - except: quat = None + quat = None + if is_editmode or Blender.Get('add_view_align'): # Aligning seems odd for editmode, but blender does it, oh well + try: quat = Blender.Mathutils.Quaternion(GetViewQuat()) + except: pass # Exist editmode for non mesh types - if ob_act and ob_act.type != 'Mesh' and EditMode(): + if ob_act and ob_act.type != 'Mesh' and is_editmode: EditMode(0) # We are in mesh editmode @@ -65,8 +69,9 @@ def add_mesh_simple(name, verts, edges, faces): # Mesh with no data, unlikely me.edges.extend(edges) me.faces.extend(faces) - - EditMode(1) + + if is_editmode or Blender.Get('add_editmode'): + EditMode(1) else: @@ -90,8 +95,9 @@ def add_mesh_simple(name, verts, edges, faces): ob_act.setMatrix(mat) ob_act.loc = cursor - - EditMode(1) + + if is_editmode or Blender.Get('add_editmode'): + EditMode(1) def write_mesh_script(filepath, me): diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index daba0c36fdf..7c2895d96be 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -545,8 +545,12 @@ static PyObject *Blender_Get( PyObject * self, PyObject * value ) else if(StringEqual( str, "compressfile" )) ret = PyInt_FromLong( (U.flag & USER_FILECOMPRESS) >> 15 ); else if(StringEqual( str, "mipmap" )) - ret = PyInt_FromLong( (U.gameflags & USER_DISABLE_MIPMAP) == 0 ); - else + ret = PyInt_FromLong( (U.gameflags & USER_DISABLE_MIPMAP)!=0 ); + else if(StringEqual( str, "add_view_align" )) + ret = PyInt_FromLong( ((U.flag & USER_ADD_VIEWALIGNED)!=0) ); + else if(StringEqual( str, "add_editmode" )) + ret = PyInt_FromLong( ((U.flag & USER_ADD_EDITMODE)!=0) ); + else return EXPP_ReturnPyObjError( PyExc_AttributeError, "unknown attribute" ); if (ret) return ret; diff --git a/source/blender/python/api2_2x/Sys.c b/source/blender/python/api2_2x/Sys.c index 9de4e344e8c..3863cc12227 100644 --- a/source/blender/python/api2_2x/Sys.c +++ b/source/blender/python/api2_2x/Sys.c @@ -58,6 +58,7 @@ static PyObject *M_sys_exists( PyObject * self, PyObject * value ); static PyObject *M_sys_time( PyObject * self ); static PyObject *M_sys_sleep( PyObject * self, PyObject * args ); static PyObject *M_sys_expandpath( PyObject *self, PyObject *value); +static PyObject *M_sys_cleanpath( PyObject *self, PyObject *value); /*****************************************************************************/ /* The following string definitions are used for documentation strings. */ @@ -120,10 +121,13 @@ static char M_sys_expandpath_doc[] = (path) - the string path to convert.\n\n\ Note: internally Blender paths can contain two special character sequences:\n\ - '//' (at start) for base path directory (the current .blend's dir path);\n\ -- '#' (at ending) for current frame number.\n\n\ +- '#' characters in the filename will be replaced by the frame number.\n\n\ This function expands these to their actual content, returning a valid path.\n\ If the special chars are not found in the given path, it is simply returned."; +static char M_sys_cleanpath_doc[] = +"(path) - Removes parts of a path that are not needed paths such as '../foo/../bar/' and '//./././'"; + /*****************************************************************************/ /* Python method structure definition for Blender.sys module: */ /*****************************************************************************/ @@ -139,6 +143,7 @@ struct PyMethodDef M_sys_methods[] = { {"sleep", M_sys_sleep, METH_VARARGS, M_sys_sleep_doc}, {"time", ( PyCFunction ) M_sys_time, METH_NOARGS, M_sys_time_doc}, {"expandpath", M_sys_expandpath, METH_O, M_sys_expandpath_doc}, + {"cleanpath", M_sys_cleanpath, METH_O, M_sys_cleanpath_doc}, {NULL, NULL, 0, NULL} }; @@ -396,3 +401,24 @@ static PyObject *M_sys_expandpath( PyObject * self, PyObject * value ) return PyString_FromString(expanded); } + +static PyObject *M_sys_cleanpath( PyObject * self, PyObject * value ) +{ + char *path = PyString_AsString(value); + char cleaned[FILE_MAXDIR + FILE_MAXFILE]; + int trailing_slash = 0; + if (!path) + return EXPP_ReturnPyObjError( PyExc_TypeError, + "expected string argument" ); + if (strstr(path, "/") || strstr(path, "\\")) { + trailing_slash = 1; + } + BLI_strncpy(cleaned, path, FILE_MAXDIR + FILE_MAXFILE); + BLI_cleanup_file(NULL, cleaned); + + if (trailing_slash) { + BLI_add_slash(cleaned); + } + + return PyString_FromString(cleaned); +} diff --git a/source/blender/python/api2_2x/doc/Sys.py b/source/blender/python/api2_2x/doc/Sys.py index f1efeeb2344..d7c62f2cb02 100644 --- a/source/blender/python/api2_2x/doc/Sys.py +++ b/source/blender/python/api2_2x/doc/Sys.py @@ -153,7 +153,7 @@ def expandpath (path): Internally, Blender recognizes two special character sequences in paths: - '//' (used at the beginning): means base path -- the current .blend file's dir; - - '#' (used at the end): means current frame number. + - '#' characters in the filename will be replaced by the frame number. The expanded string can be passed to generic python functions that don't understand Blender's internal relative paths. @note: this function is also useful for obtaining the name of the image @@ -165,3 +165,12 @@ def expandpath (path): @rtype: string @return: the expanded (if necessary) path. """ + +def cleanpath (path): + """ + Clean the given 'path' by removing unneeded components such as "/./" and "/test/../" + @type path: string + @param path: a path name. + @rtype: string + @return: the cleaned (if necessary) path. + """ -- cgit v1.2.3 From c0d981f6db057fbe8c5a9483382bab1e20572e38 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 May 2008 18:57:24 +0000 Subject: patches [#10529] -p command line option fix [#8844] Glossy controls Python API --- source/blender/python/api2_2x/Material.c | 88 +++++++++++++++++++++++++++ source/blender/python/api2_2x/doc/Material.py | 12 ++++ source/creator/creator.c | 1 + 3 files changed, 101 insertions(+) diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c index 79deb29bafa..818c58109f3 100644 --- a/source/blender/python/api2_2x/Material.c +++ b/source/blender/python/api2_2x/Material.c @@ -128,6 +128,14 @@ #define EXPP_MAT_FRESNELMIRR_MAX 5.0 #define EXPP_MAT_FRESNELMIRRFAC_MIN 1.0 #define EXPP_MAT_FRESNELMIRRFAC_MAX 5.0 +#define EXPP_MAT_RAYMIRRGLOSS_MIN 0.0 +#define EXPP_MAT_RAYMIRRGLOSS_MAX 1.0 +#define EXPP_MAT_RAYMIRRGLOSSSAMPLES_MIN 0 +#define EXPP_MAT_RAYMIRRGLOSSSAMPLES_MAX 255 +#define EXPP_MAT_RAYTRANSPGLOSS_MIN 0.0 +#define EXPP_MAT_RAYTRANSPGLOSS_MAX 1.0 +#define EXPP_MAT_RAYTRANSPGLOSSSAMPLES_MIN 0 +#define EXPP_MAT_RAYTRANSPGLOSSSAMPLES_MAX 255 #define EXPP_MAT_FILTER_MIN 0.0 #define EXPP_MAT_FILTER_MAX 1.0 #define EXPP_MAT_TRANSLUCENCY_MIN 0.0 @@ -516,6 +524,10 @@ static int Material_setIOR( BPy_Material * self, PyObject * value ); static int Material_setTransDepth( BPy_Material * self, PyObject * value ); static int Material_setFresnelTrans( BPy_Material * self, PyObject * value ); static int Material_setFresnelTransFac( BPy_Material * self, PyObject * value ); +static int Material_setGlossMirr( BPy_Material * self, PyObject * value ); +static int Material_setGlossMirrSamples( BPy_Material * self, PyObject * value ); +static int Material_setGlossTrans( BPy_Material * self, PyObject * value ); +static int Material_setGlossTransSamples( BPy_Material * self, PyObject * value ); static int Material_setRigidBodyFriction( BPy_Material * self, PyObject * value ); static int Material_setRigidBodyRestitution( BPy_Material * self, PyObject * value ); @@ -600,6 +612,10 @@ static PyObject *Material_getIOR( BPy_Material * self ); static PyObject *Material_getTransDepth( BPy_Material * self ); static PyObject *Material_getFresnelTrans( BPy_Material * self ); static PyObject *Material_getFresnelTransFac( BPy_Material * self ); +static PyObject *Material_getGlossMirr( BPy_Material * self ); +static PyObject *Material_getGlossMirrSamples( BPy_Material * self ); +static PyObject *Material_getGlossTrans( BPy_Material * self ); +static PyObject *Material_getGlossTransSamples( BPy_Material * self ); static PyObject *Material_getRigidBodyFriction( BPy_Material * self ); static PyObject *Material_getRigidBodyRestitution( BPy_Material * self ); @@ -720,6 +736,10 @@ static PyMethodDef BPy_Material_methods[] = { "() - Return fresnel power for refractions"}, {"getFresnelMirrFac", ( PyCFunction ) Material_getFresnelMirrFac, METH_NOARGS, "() - Return fresnel power for refractions factor"}, + {"getRayTransGloss", ( PyCFunction ) Material_getGlossTrans, METH_NOARGS, + "() - Return amount refraction glossiness"}, + {"getRayMirrGlossSamples", ( PyCFunction ) Material_getGlossMirrSamples, METH_NOARGS, + "() - Return amount mirror glossiness"}, {"getFilter", ( PyCFunction ) Material_getFilter, METH_NOARGS, "() - Return the amount of filtering when transparent raytrace is enabled"}, {"getTranslucency", ( PyCFunction ) Material_getTranslucency, METH_NOARGS, @@ -825,6 +845,10 @@ static PyMethodDef BPy_Material_methods[] = { "(f) - Set fresnel power for mirror - [0.0, 5.0]"}, {"setFresnelMirrFac", ( PyCFunction ) Matr_oldsetFresnelMirrFac, METH_VARARGS, "(f) - Set blend fac for mirror fresnel - [1.0, 5.0]"}, + {"setRayTransGloss", ( PyCFunction ) Material_setGlossTrans, METH_VARARGS, + "(f) - Set amount refraction glossiness - [0.0, 1.0]"}, + {"setRayMirrGlossSamples", ( PyCFunction ) Material_setGlossMirrSamples, METH_VARARGS, + "(f) - Set amount mirror glossiness - [0.0, 1.0]"}, {"setFilter", ( PyCFunction ) Matr_oldsetFilter, METH_VARARGS, "(f) - Set the amount of filtering when transparent raytrace is enabled"}, {"setTranslucency", ( PyCFunction ) Matr_oldsetTranslucency, METH_VARARGS, @@ -1030,6 +1054,22 @@ static PyGetSetDef BPy_Material_getseters[] = { (getter)Material_getRefracIndex, (setter)Material_setRefracIndex, "Material's Index of Refraction (applies to the \"Blinn\" Specular Shader only", NULL}, + {"glossMir", + (getter)Material_getGlossMirr, (setter)Material_setGlossMirr, + "Reflection glossiness", + NULL}, + {"sampGlossMir", + (getter)Material_getGlossMirrSamples, (setter)Material_setGlossMirrSamples, + "Reflection glossiness", + NULL}, + {"glossTra", + (getter)Material_getGlossTrans, (setter)Material_setGlossTrans, + "Refraction glossiness", + NULL}, + {"sampGlossTra", + (getter)Material_getGlossMirrSamples, (setter)Material_setGlossMirrSamples, + "Refraction glossiness", + NULL}, {"rgbCol", (getter)Material_getRGBCol, (setter)Material_setRGBCol, "Diffuse RGB color triplet", @@ -1578,6 +1618,26 @@ static PyObject *Material_getFresnelTransFac( BPy_Material * self ) return PyFloat_FromDouble( ( double ) self->material->fresnel_tra_i ); } +static PyObject *Material_getGlossMirr( BPy_Material * self ) +{ + return PyFloat_FromDouble( ( double ) self->material->gloss_mir ); +} + +static PyObject *Material_getGlossMirrSamples( BPy_Material * self ) +{ + return PyInt_FromLong( ( long ) self->material->samp_gloss_mir ); +} + +static PyObject *Material_getGlossTrans( BPy_Material * self ) +{ + return PyFloat_FromDouble( ( double ) self->material->gloss_tra ); +} + +static PyObject *Material_getGlossTransSamples( BPy_Material * self ) +{ + return PyInt_FromLong( ( long ) self->material->samp_gloss_tra ); +} + static PyObject* Material_getRigidBodyFriction( BPy_Material * self ) { return PyFloat_FromDouble( ( double ) self->material->friction ); @@ -2058,6 +2118,34 @@ static int Material_setFresnelTransFac( BPy_Material * self, PyObject * value ) EXPP_MAT_FRESNELTRANSFAC_MAX ); } +static int Material_setGlossMirr( BPy_Material * self, PyObject * value ) +{ + return EXPP_setFloatClamped ( value, &self->material->gloss_mir, + EXPP_MAT_RAYMIRRGLOSS_MIN, + EXPP_MAT_RAYMIRRGLOSS_MAX ); +} + +static int Material_setGlossMirrSamples( BPy_Material * self, PyObject * value ) +{ + return EXPP_setIValueClamped ( value, &self->material->samp_gloss_mir, + EXPP_MAT_RAYMIRRGLOSSSAMPLES_MIN, + EXPP_MAT_RAYMIRRGLOSSSAMPLES_MAX, 'h' ); +} + +static int Material_setGlossTrans( BPy_Material * self, PyObject * value ) +{ + return EXPP_setFloatClamped ( value, &self->material->gloss_tra, + EXPP_MAT_RAYTRANSPGLOSS_MIN, + EXPP_MAT_RAYTRANSPGLOSS_MAX ); +} + +static int Material_setGlossTransSamples( BPy_Material * self, PyObject * value ) +{ + return EXPP_setIValueClamped ( value, &self->material->samp_gloss_tra, + EXPP_MAT_RAYTRANSPGLOSSSAMPLES_MIN, + EXPP_MAT_RAYTRANSPGLOSSSAMPLES_MAX, 'h' ); +} + static int Material_setRigidBodyFriction( BPy_Material * self, PyObject * value ) { return EXPP_setFloatClamped ( value, &self->material->friction, diff --git a/source/blender/python/api2_2x/doc/Material.py b/source/blender/python/api2_2x/doc/Material.py index edcdbbb959b..a3496164cd1 100644 --- a/source/blender/python/api2_2x/doc/Material.py +++ b/source/blender/python/api2_2x/doc/Material.py @@ -237,6 +237,18 @@ class Material: @ivar rayMirr: Mirror reflection amount for raytrace. Value is clamped to the range [0.0,1.0]. @type rayMirr: float + @ivar glossMir: Amount of reflection glossy. + Value is clamped to the range [0.0,1.0]. + @type glossMir: float + @ivar sampGloss_mir: Reflection glossy samples. + Value is clamped to the range [1,1024]. + @type sampGloss_mir: int + @ivar glossTra: Amount of refraction glossy. + Value is clamped to the range [0.0,1.0]. + @type glossTra: float + @ivar sampGlossTra: Refraction glossy samples. + Value is clamped to the range [1,1024]. + @type sampGlossTra: int @ivar rayMirrDepth: Amount of raytrace inter-reflections. Value is clamped to the range [0,10]. @type rayMirrDepth: int diff --git a/source/creator/creator.c b/source/creator/creator.c index 2fd3a482a27..a4588bb4597 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -451,6 +451,7 @@ int main(int argc, char **argv) sizx= atoi(argv[a]); a++; sizy= atoi(argv[a]); + G.windowstate = G_WINDOWSTATE_BORDER; break; case 'd': -- cgit v1.2.3 From 917865b5049acaa2e13b7d40ebf879121c7e2148 Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Tue, 6 May 2008 19:29:37 +0000 Subject: == bugfix == [#10312] Append Link (image browser) bug if combined with Open window The only place where the special handling in newspace is relevenant is when opening it with the windowtype_pupmenu. All other overlaying windows( render in image space, scriptspace) should leave imagebrowser/filebrowser space alone. --- source/blender/include/BIF_imasel.h | 1 + source/blender/include/BSE_filesel.h | 1 + source/blender/src/filesel.c | 21 +++++++++++++++++++++ source/blender/src/headerbuttons.c | 2 ++ source/blender/src/imasel.c | 23 +++++++++++++++++++++++ source/blender/src/space.c | 35 ++--------------------------------- 6 files changed, 50 insertions(+), 33 deletions(-) diff --git a/source/blender/include/BIF_imasel.h b/source/blender/include/BIF_imasel.h index a3a3b7531d6..cbd547602e1 100644 --- a/source/blender/include/BIF_imasel.h +++ b/source/blender/include/BIF_imasel.h @@ -34,6 +34,7 @@ struct ScrArea; struct ID; void free_imasel(struct SpaceImaSel *simasel); +void reset_imaselspace(struct ScrArea *sa); void clever_numbuts_imasel(void); diff --git a/source/blender/include/BSE_filesel.h b/source/blender/include/BSE_filesel.h index 13e38d50c47..b46b2328ea4 100644 --- a/source/blender/include/BSE_filesel.h +++ b/source/blender/include/BSE_filesel.h @@ -54,6 +54,7 @@ void activate_databrowse(struct ID *id, int idcode, int fromcode, int retval, sh void activate_databrowse_args(struct ID *id, int idcode, int fromcode, short *menup, void (*func)(char *, void *, void *), void *arg1, void *arg2); void filesel_prevspace(void); +void reset_filespace(struct ScrArea *sa); void free_filesel_spec(char *dir); void winqreadfilespace(struct ScrArea *sa, void *spacedata, struct BWinEvent *evt); void main_to_filelist(struct SpaceFile *sfile); diff --git a/source/blender/src/filesel.c b/source/blender/src/filesel.c index 19372dcbee6..bfff2f10ab6 100644 --- a/source/blender/src/filesel.c +++ b/source/blender/src/filesel.c @@ -1299,6 +1299,27 @@ void activate_databrowse_args(struct ID *id, int idcode, int fromcode, short *me sfile->ipotype= fromcode; } +/* resets a previous file space type */ +/* is used when opening a filebrowser directly from windowtype_pupmenu, + since in that case we don't want any load/save/append/link action +*/ +void reset_filespace(ScrArea *sa) +{ + if (sa->spacetype == SPACE_FILE) { + SpaceFile *sfile= sa->spacedata.first; + + if(sfile->type==FILE_MAIN) { + freefilelist(sfile); + } else { + sfile->type= FILE_UNIX; + } + + sfile->returnfunc= NULL; + sfile->title[0]= 0; + if(sfile->filelist) test_flags_file(sfile); + } +} + void filesel_prevspace() { SpaceFile *sfile= curarea->spacedata.first; diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c index b91a8f74f80..81ad135f514 100644 --- a/source/blender/src/headerbuttons.c +++ b/source/blender/src/headerbuttons.c @@ -1434,6 +1434,8 @@ void do_global_buttons(unsigned short event) break; case B_NEWSPACE: newspace(curarea, curarea->butspacetype); + reset_filespace(curarea); + reset_imaselspace(curarea); break; case B_LOADTEMP: /* is button from space.c */ BIF_read_autosavefile(); diff --git a/source/blender/src/imasel.c b/source/blender/src/imasel.c index be9f489ea49..f502445d329 100644 --- a/source/blender/src/imasel.c +++ b/source/blender/src/imasel.c @@ -80,3 +80,26 @@ void free_imasel(SpaceImaSel *simasel) } } +/* resets a previous imagebrowser space type */ +/* is used when opening an imagebrowser directly from windowtype_pupmenu, + since in that case we don't want any load/save/append/link action +*/ +void reset_imaselspace(ScrArea *sa) +{ + if(sa->spacetype==SPACE_IMASEL) { + SpaceImaSel *simasel= sa->spacedata.first; + if(simasel->type==FILE_MAIN) { + if (simasel->files) { + BIF_filelist_free(simasel->files); + BIF_filelist_settype(simasel->files, FILE_MAIN); + } + } else { + if (simasel->files) { + simasel->type= FILE_UNIX; + BIF_filelist_settype(simasel->files, simasel->type); + } + } + simasel->returnfunc= NULL; + simasel->title[0]= 0; + } +} diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 41e539c3d1a..3cffed48224 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -5611,6 +5611,7 @@ static void init_imaselspace(ScrArea *sa) simasel->files = BIF_filelist_new(); } + /* ******************** SPACE: OOPS ********************** */ extern void drawoopsspace(ScrArea *sa, void *spacedata); @@ -6155,39 +6156,7 @@ void newspace(ScrArea *sa, int type) } } - - /* exception: filespace */ - if(sa->spacetype==SPACE_FILE) { - SpaceFile *sfile= sa->spacedata.first; - - if(sfile->type==FILE_MAIN) { - freefilelist(sfile); - } else { - sfile->type= FILE_UNIX; - } - - sfile->returnfunc= NULL; - sfile->title[0]= 0; - if(sfile->filelist) test_flags_file(sfile); - } - /* exception: imasel space */ - else if(sa->spacetype==SPACE_IMASEL) { - SpaceImaSel *simasel= sa->spacedata.first; - if(simasel->type==FILE_MAIN) { - if (simasel->files) { - BIF_filelist_free(simasel->files); - BIF_filelist_settype(simasel->files, FILE_MAIN); - } - } else { - if (simasel->files) { - simasel->type= FILE_UNIX; - BIF_filelist_settype(simasel->files, simasel->type); - } - } - simasel->returnfunc= NULL; - simasel->title[0]= 0; - } - else if(sa->spacetype==SPACE_OOPS) { + if(sa->spacetype==SPACE_OOPS) { SpaceOops *so= sa->spacedata.first; if(xtra && so->type!=SO_OUTLINER) { so->type= SO_OUTLINER; -- cgit v1.2.3 From 881802d8a385228a3b8af3b1b7ccb8512c96490b Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 6 May 2008 20:55:55 +0000 Subject: BGE patch #10492 approved: getLinearVelocity() now can provide local velocity as well. This patch is harmless and backward compatible; it can go safely into 2.46 release --- source/gameengine/Ketsji/KX_GameObject.cpp | 29 ++++++++++++++++++++++++----- source/gameengine/Ketsji/KX_GameObject.h | 3 ++- source/gameengine/PyDoc/KX_GameObject.py | 10 +++++++--- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 4c6ba448ebf..fb636b23082 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -581,16 +581,27 @@ void KX_GameObject::SetObjectColor(const MT_Vector4& rgbavec) -MT_Vector3 KX_GameObject::GetLinearVelocity() +MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) { MT_Vector3 velocity(0.0,0.0,0.0); - + MT_Matrix3x3 ori, locvel; + int i, j; if (m_pPhysicsController1) { velocity = m_pPhysicsController1->GetLinearVelocity(); + + if (local) + { + ori = GetSGNode()->GetWorldOrientation(); + + for(i=0; i < 3; i++) + for(j=0; j < 3; j++) + locvel[i][j]= velocity[i]*ori[i][j]; + for(i=0; i < 3; i++) + velocity[i] = locvel[0][i] + locvel[1][i] + locvel[2][i]; + } } - return velocity; - + return velocity; } @@ -948,7 +959,15 @@ PyObject* KX_GameObject::PyGetLinearVelocity(PyObject* self, PyObject* kwds) { // only can get the velocity if we have a physics object connected to us... - return PyObjectFrom(GetLinearVelocity()); + int local = 0; + if (PyArg_ParseTuple(args,"|i",&local)) + { + return PyObjectFrom(GetLinearVelocity((local!=0))); + } + else + { + return NULL; + } } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index da0cd69e129..b83d63e26bf 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -252,8 +252,9 @@ public: /** * Return the linear velocity of the game object. */ - MT_Vector3 + MT_Vector3 GetLinearVelocity( + bool local=false ); /** diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 31c9993e194..8ef82b4943b 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -58,15 +58,16 @@ class KX_GameObject: @rtype: 3x3 rotation matrix @return: The game object's rotation matrix """ - def getLinearVelocity(): + def getLinearVelocity(local): """ Gets the game object's linear velocity. This method returns the game object's velocity through it's centre of mass, ie no angular velocity component. - cf getVelocity() - + @type local: boolean + @param local: - False: you get the "global" velocity ie: relative to world orientation. + - True: you get the "local" velocity ie: relative to object orientation. @rtype: list [vx, vy, vz] @return: the object's linear velocity. """ @@ -138,6 +139,9 @@ class KX_GameObject: def setParent(parent): """ Sets this object's parent. + + @type parent: L{KX_GameObject} + @param parent: new parent object. """ def removeParent(): """ -- cgit v1.2.3 From 7d2e366e8ff0e58a469974d31d78b9d71ae30b52 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 May 2008 23:58:15 +0000 Subject: fix for [#10180] File Browser buttons disappear after clicking on Window Type button Spent some time looking into what this could break and it seems like a safe change. --- source/blender/src/interface.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index fb5b5e2f187..f324bf3b053 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -2328,6 +2328,7 @@ static int ui_do_but_ICONROW(uiBut *but) ListBase listb= {NULL, NULL}; uiBlock *block; int a; + short event; but->flag |= UI_SELECT; ui_draw_but(but); @@ -2348,13 +2349,17 @@ static int ui_do_but_ICONROW(uiBut *but) this is needs better implementation */ block->win= G.curscreen->mainwin; - uiDoBlocks(&listb, 0, 1); + event= uiDoBlocks(&listb, 0, 1); but->flag &= ~UI_SELECT; ui_check_but(but); ui_draw_but(but); - - return but->retval; + + if (event & UI_RETURN_OK) { + return but->retval; + } else { + return 0; + } } static int ui_do_but_ICONTEXTROW(uiBut *but) @@ -2363,7 +2368,7 @@ static int ui_do_but_ICONTEXTROW(uiBut *but) ListBase listb={NULL, NULL}; int width, a, xmax, ypos; MenuData *md; - + short event; but->flag |= UI_SELECT; ui_draw_but(but); ui_block_flush_back(but->block); // flush because this button creates own blocks loop @@ -2421,7 +2426,7 @@ static int ui_do_but_ICONTEXTROW(uiBut *but) uiBoundsBlock(block, 3); - uiDoBlocks(&listb, 0, 1); + event = uiDoBlocks(&listb, 0, 1); menudata_free(md); @@ -2429,10 +2434,12 @@ static int ui_do_but_ICONTEXTROW(uiBut *but) ui_check_but(but); ui_draw_but(but); - uibut_do_func(but); - - return but->retval; - + if (event & UI_RETURN_OK) { + uibut_do_func(but); + return but->retval; + } else { + return 0; + } } static int ui_do_but_IDPOIN(uiBut *but) -- cgit v1.2.3 From 4aa8dd0b633983b733d0655d583db8cc628a28ed Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 May 2008 00:37:38 +0000 Subject: fix for [#10290] Wire object hid in the back of soled obj. reverse wire draworder logic from r4059, wire-only meshes were not using a depth buffer which meant they would not be visible at all, if they were after an overlapping solid object in the scene (had this problem for peach too). --- source/blender/src/drawobject.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 181f797dbc9..561024fb74b 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -2425,19 +2425,23 @@ static void draw_mesh_fancy(Base *base, int dt, int flag) if (draw_wire) { /* If drawing wire and drawtype is not OB_WIRE then we are * overlaying the wires. + * + * UPDATE bug #10290 - With this wire-only objects can draw + * behind other objects depending on their order in the scene. 2x if 0's below. undo'ing zr's commit: r4059 */ - +#if 0 if (dt!=OB_WIRE) { bglPolygonOffset(1.0); glDepthMask(0); // disable write in zbuffer, selected edge wires show better } - +#endif dm->drawEdges(dm, (dt==OB_WIRE || totface==0)); - +#if 0 if (dt!=OB_WIRE) { glDepthMask(1); bglPolygonOffset(0.0); } +#endif } dm->release(dm); -- cgit v1.2.3 From 5e493eeb19572e4c70c1b4a9c283616995f2df8a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 May 2008 07:57:18 +0000 Subject: Setting frame in python allowed negative numbers (was casting to a short with no clamping!) disable capslock option isnt used anywhere. --- source/blender/python/api2_2x/Blender.c | 3 ++- source/blender/src/space.c | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index 7c2895d96be..4fc68d138e0 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -246,7 +246,8 @@ static PyObject *Blender_Set( PyObject * self, PyObject * args ) return EXPP_ReturnPyObjError( PyExc_ValueError, "expected an integer" ); - G.scene->r.cfra = (short)PyInt_AsLong( arg ) ; + G.scene->r.cfra = (int)PyInt_AsLong( arg ) ; + CLAMP(G.scene->r.cfra, 1, MAXFRAME); /* update all objects, so python scripts can export all objects in a scene without worrying about the view layers */ diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 3cffed48224..292b1f1bc1e 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -4163,16 +4163,17 @@ void drawinfospace(ScrArea *sa, void *spacedata) &(G.f), 0, 0, 0, 0, "Allow any .blend file to run scripts automatically (unsafe with blend files from an untrusted source)"); uiDefBut(block, LABEL,0,"Keyboard:", - (xpos+edgsp+(3*midsp)+(3*mpref)),y3label,mpref,buth, + (xpos+edgsp+(3*midsp)+(3*mpref)),y2label,mpref,buth, 0, 0, 0, 0, 0, ""); - + /* Not actually used anywhere! */ + /* uiDefButBitI(block, TOG, USER_NO_CAPSLOCK, B_U_CAPSLOCK, "Disable Caps Lock", (xpos+edgsp+(3*midsp)+(3*mpref)),y1,mpref,buth, &(U.flag), 0, 0, 0, 0, "Disables the Caps Lock key when entering text"); - + */ uiDefButBitI(block, TOG, USER_NONUMPAD, 0, "Emulate Numpad", - (xpos+edgsp+(3*midsp)+(3*mpref)),y2,mpref,buth, + (xpos+edgsp+(3*midsp)+(3*mpref)),y1,mpref,buth, &(U.flag), 0, 0, 0, 0, "Causes the 1 to 0 keys to act as the numpad (useful for laptops)"); -- cgit v1.2.3 From fa9b01908f97825c331b68425eba6b21e9fdfaa0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 May 2008 12:23:51 +0000 Subject: Bugfix: modified the tooltip to indicate that the maximum length option for particle paths applies to children. --- source/blender/src/buttons_object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 0cfc2047aec..9a749b6fbd9 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -4415,8 +4415,8 @@ static void object_panel_particle_visual(Object *ob) uiDefButS(block, NUM, B_PART_RECALC, "Steps:", butx,(buty+=buth),butw,buth, &part->draw_step, 0.0, 7.0, 0, 0, "How many steps paths are drawn with (power of 2)"); uiDefButS(block, NUM, B_PART_REDRAW, "Render:", butx,(buty-=buth),butw,buth, &part->ren_step, 0.0, 9.0, 0, 0, "How many steps paths are rendered with (power of 2)"); - uiDefButBitI(block, TOG, PART_ABS_LENGTH, B_PART_RECALC, "Abs Length", butx,(buty-=buth),butw,buth, &part->flag, 0, 0, 0, 0, "Use maximum length in absolute blender units"); - uiDefButF(block, NUM, B_PART_RECALC, "Max Length:", butx,(buty-=buth),butw,buth, &part->abslength, 0.0, 10000.0, 1, 3, "Absolute path length"); + uiDefButBitI(block, TOG, PART_ABS_LENGTH, B_PART_RECALC, "Abs Length", butx,(buty-=buth),butw,buth, &part->flag, 0, 0, 0, 0, "Use maximum length for children"); + uiDefButF(block, NUM, B_PART_RECALC, "Max Length:", butx,(buty-=buth),butw,buth, &part->abslength, 0.0, 10000.0, 1, 3, "Absolute maximum path length for children, in blender units"); uiDefButF(block, NUMSLI, B_PART_RECALC, "RLength:", butx,(buty-=buth),butw,buth, &part->randlength, 0.0, 1.0, 1, 3, "Give path length a random variation"); uiBlockEndAlign(block); -- cgit v1.2.3 From 529a8bb949412ac5cc7203fd583e4f0b28282ddf Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 May 2008 14:58:33 +0000 Subject: Fix for bug #10990: edge render AA issue. --- source/blender/render/intern/source/rendercore.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index a18a973979a..9357a060f62 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -849,7 +849,7 @@ static void convert_to_key_alpha(RenderPart *pa, float *rectf) } /* adds only alpha values */ -void edge_enhance_tile(RenderPart *pa, float *rectf) +void edge_enhance_tile(RenderPart *pa, float *rectf, int *rectz) { /* use zbuffer to define edges, add it to the image */ int y, x, col, *rz, *rz1, *rz2, *rz3; @@ -857,13 +857,13 @@ void edge_enhance_tile(RenderPart *pa, float *rectf) float *rf; /* shift values in zbuffer 4 to the right (anti overflows), for filter we need multiplying with 12 max */ - rz= pa->rectz; + rz= rectz; if(rz==NULL) return; for(y=0; yrecty; y++) for(x=0; xrectx; x++, rz++) (*rz)>>= 4; - rz1= pa->rectz; + rz1= rectz; rz2= rz1+pa->rectx; rz3= rz2+pa->rectx; @@ -903,7 +903,7 @@ void edge_enhance_tile(RenderPart *pa, float *rectf) } /* shift back zbuf values, we might need it still */ - rz= pa->rectz; + rz= rectz; for(y=0; yrecty; y++) for(x=0; xrectx; x++, rz++) (*rz)<<= 4; @@ -1012,7 +1012,7 @@ void make_pixelstructs(RenderPart *pa, ZSpan *zspan, int sample, void *data) if(sdata->rl->layflag & SCE_LAY_EDGE) if(R.r.mode & R_EDGE) - edge_enhance_tile(pa, sdata->edgerect); + edge_enhance_tile(pa, sdata->edgerect, zspan->rectz); } /* main call for shading Delta Accum, for OSA */ @@ -1189,7 +1189,7 @@ void zbufshade_tile(RenderPart *pa) if(rl->layflag & SCE_LAY_EDGE) { if(R.r.mode & R_EDGE) { edgerect= MEM_callocN(sizeof(float)*pa->rectx*pa->recty, "rectedge"); - edge_enhance_tile(pa, edgerect); + edge_enhance_tile(pa, edgerect, pa->rectz); } } -- cgit v1.2.3 From bda4e3d19f0861c6af633104ee56bba34961aaa4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 May 2008 15:38:40 +0000 Subject: * added support for exporting dupli objects * option to export modifier applied objects * option to export quads as tri's * added back compress option (will default to enabled if you use .x3dz as the extension) --- release/scripts/x3d_export.py | 273 +++++++++++++++++++--------- source/blender/blenkernel/intern/blender.c | 3 +- source/blender/makesdna/DNA_userdef_types.h | 5 +- source/blender/src/space.c | 4 +- 4 files changed, 191 insertions(+), 94 deletions(-) diff --git a/release/scripts/x3d_export.py b/release/scripts/x3d_export.py index ac4a8e9ca5b..b12ff67d8a6 100644 --- a/release/scripts/x3d_export.py +++ b/release/scripts/x3d_export.py @@ -57,6 +57,8 @@ import Blender from Blender import Object, Lamp, Draw, Image, Text, sys, Mesh from Blender.Scene import Render import math +import BPyObject +import BPyMesh # DEG2RAD=0.017453292519943295 @@ -68,14 +70,14 @@ MATWORLD= Blender.Mathutils.RotationMatrix(-90, 4, 'x') filename = Blender.Get('filename') _safeOverwrite = True -ARG='' + extension = '' ########################################################## # Functions for writing output file ########################################################## -class VRML2Export: +class x3d_class: def __init__(self, filename): #--- public you can change these --- @@ -101,7 +103,18 @@ class VRML2Export: self.meshNames={} # dictionary of meshNames self.indentLevel=0 # keeps track of current indenting self.filename=filename - self.file = open(filename, "w") + self.file = None + if filename.lower().endswith('.x3dz'): + try: + import gzip + self.file = gzip.open(filename, "w") + except: + print "failed to import compression modules, exporting uncompressed" + self.filename = filename[:-1] # remove trailing z + + if self.file == None: + self.file = open(self.filename, "w") + self.bNav=0 self.nodeID=0 self.namesReserved=[ "Anchor","Appearance","Arc2D","ArcClose2D","AudioClip","Background","Billboard", @@ -169,7 +182,7 @@ class VRML2Export: nameinline = nameinline+".x3d" self.file.write("url=\"%s\" />" % nameinline) self.file.write("\n\n") - ''' + def writeScript(self): textEditor = Blender.Text.Get() @@ -190,15 +203,17 @@ class VRML2Export: for j in xrange(nalllines): self.writeIndented(alllines[j] + "\n") self.writeIndented("\n") - - def writeViewpoint(self, ob, scene): + ''' + + def writeViewpoint(self, ob, mat, scene): context = scene.render ratio = float(context.imageSizeY())/float(context.imageSizeX()) lens = (360* (math.atan(ratio *16 / ob.data.getLens()) / math.pi))*(math.pi/180) lens = min(lens, math.pi) # get the camera location, subtract 90 degress from X to orient like X3D does - mat = ob.matrixWorld + # mat = ob.matrixWorld - mat is now passed! + loc = self.rotatePointForVRML(mat.translationPart()) rot = mat.toEuler() rot = (((rot[0]-90)*DEG2RAD), rot[1]*DEG2RAD, rot[2]*DEG2RAD) @@ -229,23 +244,11 @@ class VRML2Export: self.file.write("visibilityRange=\"%s\" />\n\n" % round(mparam[2],self.cp)) else: return - ''' + def writeNavigationInfo(self, scene): - allObj = [] - allObj = list(scene.objects) - headlight = "true" - vislimit = 0.0 - for ob in allObj: - objType=ob.type - if objType == "Camera": - vislimit = ob.data.clipEnd - elif objType == "Lamp": - headlight = "false" - self.file.write("\n\n") - ''' - def writeSpotLight(self, ob, lamp, world): + self.file.write('\n') + + def writeSpotLight(self, ob, mtx, lamp, world): safeName = self.cleanStr(ob.name) if world: ambi = world.amb @@ -259,12 +262,14 @@ class VRML2Export: beamWidth=((lamp.spotSize*math.pi)/180.0)*.37; cutOffAngle=beamWidth*1.3 - dx,dy,dz=self.computeDirection(ob) + dx,dy,dz=self.computeDirection(mtx) # note -dx seems to equal om[3][0] # note -dz seems to equal om[3][1] # note dy seems to equal om[3][2] - location=(ob.matrixWorld*MATWORLD).translationPart() + #location=(ob.matrixWorld*MATWORLD).translationPart() # now passed + location=(mtx*MATWORLD).translationPart() + radius = lamp.dist*math.cos(beamWidth) self.file.write("\n\n" % (round(location[0],3), round(location[1],3), round(location[2],3))) - def writeDirectionalLight(self, ob, lamp, world): + def writeDirectionalLight(self, ob, mtx, lamp, world): safeName = self.cleanStr(ob.name) if world: ambi = world.amb @@ -287,14 +292,14 @@ class VRML2Export: ambientIntensity = 0 intensity=min(lamp.energy/1.75,1.0) - (dx,dy,dz)=self.computeDirection(ob) + (dx,dy,dz)=self.computeDirection(mtx) self.file.write("\n\n" % (round(dx,4),round(dy,4),round(dz,4))) - def writePointLight(self, ob, lamp, world): + def writePointLight(self, ob, mtx, lamp, world): safeName = self.cleanStr(ob.name) if world: ambi = world.amb @@ -303,29 +308,30 @@ class VRML2Export: ambi = 0 ambientIntensity = 0 - location=(ob.matrixWorld*MATWORLD).translationPart() - intensity=min(lamp.energy/1.75,1.0) - radius = lamp.dist + # location=(ob.matrixWorld*MATWORLD).translationPart() # now passed + location= (mtx*MATWORLD).translationPart() + self.file.write("\n\n" % (round(location[0],3), round(location[1],3), round(location[2],3))) - - def writeNode(self, ob): + ''' + def writeNode(self, ob, mtx): obname=str(ob.name) if obname in self.namesStandard: return else: - dx,dy,dz = self.computeDirection(ob) - location=(ob.matrixWorld*MATWORLD).translationPart() + dx,dy,dz = self.computeDirection(mtx) + # location=(ob.matrixWorld*MATWORLD).translationPart() + location=(mtx*MATWORLD).translationPart() self.writeIndented("<%s\n" % obname,1) - self.writeIndented("# direction %s %s %s\n" % (round(dx,3),round(dy,3),round(dz,3))) - self.writeIndented("# location %s %s %s\n" % (round(location[0],3), round(location[1],3), round(location[2],3))) + self.writeIndented("direction=\"%s %s %s\"\n" % (round(dx,3),round(dy,3),round(dz,3))) + self.writeIndented("location=\"%s %s %s\"\n" % (round(location[0],3), round(location[1],3), round(location[2],3))) self.writeIndented("/>\n",-1) self.writeIndented("\n") - + ''' def secureName(self, name): name = name + str(self.nodeID) self.nodeID=self.nodeID+1 @@ -345,13 +351,13 @@ class VRML2Export: newname = name return "%s" % (newname) - def writeIndexedFaceSet(self, ob, world, normals = 0): + def writeIndexedFaceSet(self, ob, mesh, mtx, world, EXPORT_TRI = False): imageMap={} # set of used images sided={} # 'one':cnt , 'two':cnt vColors={} # 'multi':1 meshName = self.cleanStr(ob.name) - mesh=ob.getData(mesh=1) - meshME = self.cleanStr(mesh.name) + + meshME = self.cleanStr(ob.getData(mesh=1).name) # We dont care if its the mesh name or not if len(mesh.faces) == 0: return mode = 0 if mesh.faceUV: @@ -371,7 +377,7 @@ class VRML2Export: elif not mode & Mesh.FaceModes.DYNAMIC and self.collnode == 0: self.writeIndented("\n",1) self.collnode = 1 - + nIFSCnt=self.countIFSSetsNeeded(mesh, imageMap, sided, vColors) if nIFSCnt > 1: @@ -382,7 +388,8 @@ class VRML2Export: else: bTwoSided=0 - mtx = ob.matrixWorld * MATWORLD + # mtx = ob.matrixWorld * MATWORLD # mtx is now passed + mtx = mtx * MATWORLD loc= mtx.translationPart() sca= mtx.scalePart() @@ -456,12 +463,12 @@ class VRML2Export: elif hasImageTexture == 1: self.writeTextureCoordinates(mesh) #--- output coordinates - self.writeCoordinates(ob, mesh, meshName) + self.writeCoordinates(ob, mesh, meshName, EXPORT_TRI) self.writingcoords = 1 self.writingtexture = 1 self.writingcolor = 1 - self.writeCoordinates(ob, mesh, meshName) + self.writeCoordinates(ob, mesh, meshName, EXPORT_TRI) #--- output textureCoordinates if UV texture used if mesh.faceUV: @@ -498,17 +505,23 @@ class VRML2Export: self.file.write("\n") - def writeCoordinates(self, ob, mesh, meshName): + def writeCoordinates(self, ob, mesh, meshName, EXPORT_TRI = False): # create vertex list and pre rotate -90 degrees X for VRML if self.writingcoords == 0: self.file.write('coordIndex="') for face in mesh.faces: fv = face.v - if len(face)==4: - self.file.write("%i %i %i %i -1, " % (fv[0].index, fv[1].index, fv[2].index, fv[3].index)) + + if len(face)==3: + self.file.write("%i %i %i -1, " % (fv[0].index, fv[1].index, fv[2].index)) else: - self.file.write("%i %i %i -1, " % (fv[0].index, fv[1].index, fv[2].index)) + if EXPORT_TRI: + self.file.write("%i %i %i -1, " % (fv[0].index, fv[1].index, fv[2].index)) + self.file.write("%i %i %i -1, " % (fv[0].index, fv[2].index, fv[3].index)) + else: + self.file.write("%i %i %i %i -1, " % (fv[0].index, fv[1].index, fv[2].index, fv[3].index)) + self.file.write("\">\n") else: #-- vertices @@ -679,43 +692,74 @@ class VRML2Export: # export routine ########################################################## - def export(self, scene, world, alltextures): + def export(self, scene, world, alltextures,\ + EXPORT_APPLY_MODIFIERS = False,\ + EXPORT_TRI= False,\ + ): + print "Info: starting X3D export to " + self.filename + "..." self.writeHeader() - self.writeScript() - # self.writeNavigationInfo(scene) # This seems to position me in some strange area I cant see the model (with BS Contact) - Campbell + # self.writeScript() + self.writeNavigationInfo(scene) self.writeBackground(world, alltextures) self.writeFog(world) self.proto = 0 - for ob in scene.objects.context: - objType=ob.type - objName=ob.name - self.matonly = 0 - if objType == "Camera": - self.writeViewpoint(ob, scene) - elif objType == "Mesh": - self.writeIndexedFaceSet(ob, world, normals = 0) - elif objType == "Lamp": - data= ob.data - datatype=data.type - if datatype == Lamp.Types.Lamp: - self.writePointLight(ob, data, world) - elif datatype == Lamp.Types.Spot: - self.writeSpotLight(ob, data, world) - elif datatype == Lamp.Types.Sun: - self.writeDirectionalLight(ob, data, world) + + # COPIED FROM OBJ EXPORTER + if EXPORT_APPLY_MODIFIERS: + temp_mesh_name = '~tmp-mesh' + + # Get the container mesh. - used for applying modifiers and non mesh objects. + containerMesh = meshName = tempMesh = None + for meshName in Blender.NMesh.GetNames(): + if meshName.startswith(temp_mesh_name): + tempMesh = Mesh.Get(meshName) + if not tempMesh.users: + containerMesh = tempMesh + if not containerMesh: + containerMesh = Mesh.New(temp_mesh_name) + # -------------------------- + + + for ob_main in scene.objects.context: + for ob, ob_mat in BPyObject.getDerivedObjects(ob_main): + objType=ob.type + objName=ob.name + self.matonly = 0 + if objType == "Camera": + self.writeViewpoint(ob, ob_mat, scene) + elif objType in ("Mesh", "Curve", "Surf", "Text") : + if EXPORT_APPLY_MODIFIERS or objType != 'Mesh': + me= BPyMesh.getMeshFromObject(ob, containerMesh, EXPORT_APPLY_MODIFIERS, False, scene) + else: + me = ob.getData(mesh=1) + + self.writeIndexedFaceSet(ob, me, ob_mat, world, EXPORT_TRI = EXPORT_TRI) + elif objType == "Lamp": + data= ob.data + datatype=data.type + if datatype == Lamp.Types.Lamp: + self.writePointLight(ob, ob_mat, data, world) + elif datatype == Lamp.Types.Spot: + self.writeSpotLight(ob, ob_mat, data, world) + elif datatype == Lamp.Types.Sun: + self.writeDirectionalLight(ob, ob_mat, data, world) + else: + self.writeDirectionalLight(ob, ob_mat, data, world) + # do you think x3d could document what to do with dummy objects? + #elif objType == "Empty" and objName != "Empty": + # self.writeNode(ob, ob_mat) else: - self.writeDirectionalLight(ob, data, world) - elif objType == "Empty" and objName != "Empty": - self.writeNode(ob) - else: - #print "Info: Ignoring [%s], object type [%s] not handle yet" % (object.name,object.getType) - print "" + #print "Info: Ignoring [%s], object type [%s] not handle yet" % (object.name,object.getType) + pass - if ARG != 'selected': - self.writeScript() self.file.write("\n\n") + + if EXPORT_APPLY_MODIFIERS: + if containerMesh: + containerMesh.verts = None + self.cleanup() ########################################################## @@ -837,10 +881,10 @@ class VRML2Export: round(c.b/255.0,self.cp)) return s - def computeDirection(self, ob): + def computeDirection(self, mtx): x,y,z=(0,-1.0,0) # point down - ax,ay,az = (ob.matrixWorld*MATWORLD).toEuler() + ax,ay,az = (mtx*MATWORLD).toEuler() ax *= DEG2RAD ay *= DEG2RAD @@ -931,7 +975,36 @@ class VRML2Export: # Callbacks, needed before Main ########################################################## -def select_file(filename): +def x3d_export(filename, \ + EXPORT_APPLY_MODIFIERS= False,\ + EXPORT_TRI= False,\ + EXPORT_GZIP= False,\ + ): + + if EXPORT_GZIP: + if not filename.lower().endswith('.x3dz'): + filename = '.'.join(filename.split('.')[:-1]) + '.x3dz' + else: + if not filename.lower().endswith('.x3d'): + filename = '.'.join(filename.split('.')[:-1]) + '.x3d' + + + scene = Blender.Scene.GetCurrent() + world = scene.world + alltextures = Blender.Texture.Get() + + wrlexport=x3d_class(filename) + wrlexport.export(\ + scene,\ + world,\ + alltextures,\ + \ + EXPORT_APPLY_MODIFIERS = EXPORT_APPLY_MODIFIERS,\ + EXPORT_TRI = EXPORT_TRI,\ + ) + + +def x3d_export_ui(filename): if not filename.endswith(extension): filename += extension #if _safeOverwrite and sys.exists(filename): @@ -939,18 +1012,40 @@ def select_file(filename): #if(result != 1): # return - scene = Blender.Scene.GetCurrent() - world = scene.world - alltextures = Blender.Texture.Get() + # Get user options + EXPORT_APPLY_MODIFIERS = Draw.Create(1) + EXPORT_TRI = Draw.Create(0) + EXPORT_GZIP = Draw.Create( filename.lower().endswith('.x3dz') ) + + # Get USER Options + pup_block = [\ + ('Apply Modifiers', EXPORT_APPLY_MODIFIERS, 'Use transformed mesh data from each object.'),\ + ('Triangulate', EXPORT_TRI, 'Triangulate quads.'),\ + ('Compress', EXPORT_GZIP, 'GZip the resulting file, requires a full python install'),\ + ] + + if not Draw.PupBlock('Export...', pup_block): + return + + Blender.Window.EditMode(0) + Blender.Window.WaitCursor(1) + + x3d_export(filename,\ + EXPORT_APPLY_MODIFIERS = EXPORT_APPLY_MODIFIERS.val,\ + EXPORT_TRI = EXPORT_TRI.val,\ + EXPORT_GZIP = EXPORT_GZIP.val\ + ) + + Blender.Window.WaitCursor(0) - wrlexport=VRML2Export(filename) - wrlexport.export(scene, world, alltextures) ######################################################### # main routine ######################################################### + if __name__ == '__main__': - Blender.Window.FileSelector(select_file,"Export X3D", Blender.Get('filename').replace('.blend', '.x3d')) - # select_file('/shared/bed1.x3d') + Blender.Window.FileSelector(x3d_export_ui,"Export X3D", Blender.Get('filename').replace('.blend', '.x3d')) + + diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 230b7080b38..81f496e97d6 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -383,7 +383,8 @@ static void setup_app_data(BlendFileData *bfd, char *filename) /* special cases, override loaded flags: */ if (G.f & G_DEBUG) bfd->globalf |= G_DEBUG; else bfd->globalf &= ~G_DEBUG; - if (!(G.f & G_DOSCRIPTLINKS)) bfd->globalf &= ~G_DOSCRIPTLINKS; + + if ((U.flag & USER_DONT_DOSCRIPTLINKS)) bfd->globalf &= ~G_DOSCRIPTLINKS; G.f= bfd->globalf; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index c45571cb583..acc1651e9fa 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -224,7 +224,7 @@ extern UserDef U; /* from usiblender.c !!!! */ #define USER_DUPLILINK (1 << 6) #define USER_FSCOLLUM (1 << 7) #define USER_MAT_ON_OB (1 << 8) -#define USER_NO_CAPSLOCK (1 << 9) +/*#define USER_NO_CAPSLOCK (1 << 9)*/ /* not used anywhere */ #define USER_VIEWMOVE (1 << 10) #define USER_TOOLTIPS (1 << 11) #define USER_TWOBUTTONMOUSE (1 << 12) @@ -236,7 +236,8 @@ extern UserDef U; /* from usiblender.c !!!! */ #define USER_ADD_EDITMODE (1 << 18) #define USER_ADD_VIEWALIGNED (1 << 19) #define USER_RELPATHS (1 << 20) -#define USER_DRAGIMMEDIATE (1 << 21) +#define USER_DRAGIMMEDIATE (1 << 21) +#define USER_DONT_DOSCRIPTLINKS (1 << 22) /* viewzom */ #define USER_ZOOM_CONT 0 diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 292b1f1bc1e..e396e078739 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -4158,9 +4158,9 @@ void drawinfospace(ScrArea *sa, void *spacedata) (xpos+edgsp+(1*midsp)+(1*mpref)),y6label,mpref,buth, 0, 0, 0, 0, 0, ""); - uiDefButBitI(block, TOG, G_DOSCRIPTLINKS, REDRAWBUTSSCRIPT, "Enabled by Default", + uiDefButBitI(block, TOGN, USER_DONT_DOSCRIPTLINKS, REDRAWBUTSSCRIPT, "Enabled by Default", (xpos+edgsp+(1*mpref)+(1*midsp)),y5,mpref,buth, - &(G.f), 0, 0, 0, 0, "Allow any .blend file to run scripts automatically (unsafe with blend files from an untrusted source)"); + &(U.flag), 0, 0, 0, 0, "Allow any .blend file to run scripts automatically (unsafe with blend files from an untrusted source)"); uiDefBut(block, LABEL,0,"Keyboard:", (xpos+edgsp+(3*midsp)+(3*mpref)),y2label,mpref,buth, -- cgit v1.2.3 From ad5579ec92796d31d06f2d5287f2356efadb1788 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 May 2008 16:31:49 +0000 Subject: Fix for bug #9676: added warning that particles on multires are not supported on anything else than the first level. --- source/blender/blenkernel/intern/modifier.c | 9 +++++++++ source/blender/blenkernel/intern/particle.c | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index ca95d9edc06..2a8ba878c41 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5515,6 +5515,7 @@ static void particleSystemModifier_deformVerts( DerivedMesh *dm = derivedData; ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; ParticleSystem * psys=0; + Mesh *me; int needsFree=0; if(ob->particlesystem.first) @@ -5522,6 +5523,14 @@ static void particleSystemModifier_deformVerts( else return; + /* multires check */ + if(ob->type == OB_MESH) { + me= (Mesh*)ob->data; + if(me->mr && me->mr->current != 1) + modifier_setError(md, + "Particles only supported on first multires level."); + } + if(!psys_check_enabled(ob, psys)) return; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 1eb47fa3da0..2aa0d0ad0b8 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -250,10 +250,17 @@ int psys_in_edit_mode(ParticleSystem *psys) int psys_check_enabled(Object *ob, ParticleSystem *psys) { ParticleSystemModifierData *psmd; + Mesh *me; if(psys->flag & PSYS_DISABLED) return 0; + if(ob->type == OB_MESH) { + me= (Mesh*)ob->data; + if(me->mr && me->mr->current != 1) + return 0; + } + psmd= psys_get_modifier(ob, psys); if(psys->renderdata) { if(!(psmd->modifier.mode & eModifierMode_Render)) -- cgit v1.2.3 From 5da47ddd02352a0860be5899c3d03734e44d0151 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 May 2008 18:33:10 +0000 Subject: fps timer was starting off at 0 fps --- source/blender/src/drawview.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 1acb7c4373f..be009536022 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -3421,7 +3421,7 @@ static void draw_viewport_fps(ScrArea *sa) char printable[16]; int i, tot; - if (lredrawtime == redrawtime) + if (!lredrawtime || !redrawtime) return; printable[0] = '\0'; @@ -3569,7 +3569,7 @@ void inner_play_anim_loop(int init, int mode) last_cfra = -1; cached = cached_dynamics(PSFRA,PEFRA); - redrawtime = 1.0/FPS; + redrawtime = 0.0; redrawtime_index = REDRAW_FRAME_AVERAGE; while(redrawtime_index--) { -- cgit v1.2.3 From 1584d6a0069758d8b594b0e2c412677ab5a8f22f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 May 2008 19:25:43 +0000 Subject: Possible fix for #9691: blender failing to allocate memory when rendering particles on windows, now allocates smaller chunks of memory. --- source/blender/blenkernel/intern/particle.c | 85 +++++++++++++++++----------- source/blender/blenloader/intern/readfile.c | 2 + source/blender/makesdna/DNA_particle_types.h | 22 +++---- 3 files changed, 66 insertions(+), 43 deletions(-) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 2aa0d0ad0b8..fec3da752ff 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -152,6 +152,49 @@ char *psys_menu_string(Object *ob, int for_sb) return str; } + +/* we allocate path cache memory in chunks instead of a big continguous + * chunk, windows' memory allocater fails to find big blocks of memory often */ + +#define PATH_CACHE_BUF_SIZE 1024 + +static ParticleCacheKey **psys_alloc_path_cache_buffers(ListBase *bufs, int tot, int steps) +{ + LinkData *buf; + ParticleCacheKey **cache; + int i, totkey, totbufkey; + + tot= MAX2(tot, 1); + totkey = 0; + cache = MEM_callocN(tot*sizeof(void*), "PathCacheArray"); + + while(totkey < tot) { + totbufkey= MIN2(tot-totkey, PATH_CACHE_BUF_SIZE); + buf= MEM_callocN(sizeof(LinkData), "PathCacheLinkData"); + buf->data= MEM_callocN(sizeof(ParticleCacheKey)*totbufkey*steps, "ParticleCacheKey"); + + for(i=0; idata) + i*steps; + + totkey += totbufkey; + BLI_addtail(bufs, buf); + } + + return cache; +} + +static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *bufs) +{ + LinkData *buf; + + if(cache) + MEM_freeN(cache); + + for(buf= bufs->first; buf; buf=buf->next) + MEM_freeN(buf->data); + BLI_freelistN(bufs); +} + /************************************************/ /* Getting stuff */ /************************************************/ @@ -306,27 +349,16 @@ void free_keyed_keys(ParticleSystem *psys) } void free_child_path_cache(ParticleSystem *psys) { - if(psys->childcache){ - if(psys->childcache[0]) - MEM_freeN(psys->childcache[0]); - - MEM_freeN(psys->childcache); - - psys->childcache = NULL; - psys->totchildcache = 0; - } + psys_free_path_cache_buffers(psys->childcache, &psys->childcachebufs); + psys->childcache = NULL; + psys->totchildcache = 0; } void psys_free_path_cache(ParticleSystem *psys) { - if(psys->pathcache){ - if(psys->pathcache[0]) - MEM_freeN(psys->pathcache[0]); - - MEM_freeN(psys->pathcache); + psys_free_path_cache_buffers(psys->pathcache, &psys->pathcachebufs); + psys->pathcache= NULL; + psys->totcached= 0; - psys->pathcache = NULL; - psys->totcached = 0; - } free_child_path_cache(psys); } void psys_free_children(ParticleSystem *psys) @@ -2257,10 +2289,9 @@ void psys_cache_child_paths(Object *ob, ParticleSystem *psys, float cfra, int ed ParticleSettings *part = psys->part; ParticleThread *pthreads; ParticleThreadContext *ctx; - ParticleCacheKey **cache, *tcache; + ParticleCacheKey **cache; ListBase threads; int i, totchild, totparent, totthread; - unsigned long totchildstep; pthreads= psys_threads_create(ob, psys); @@ -2279,13 +2310,7 @@ void psys_cache_child_paths(Object *ob, ParticleSystem *psys, float cfra, int ed else { /* clear out old and create new empty path cache */ free_child_path_cache(psys); - - cache = psys->childcache = MEM_callocN(totchild*sizeof(void *), "Child path cache array"); - totchildstep= totchild*(ctx->steps + 1); - tcache = MEM_callocN(totchildstep*sizeof(ParticleCacheKey), "Child path cache"); - for(i=0; isteps + 1); - + psys->childcache= psys_alloc_path_cache_buffers(&psys->childcachebufs, totchild, ctx->steps+1); psys->totchildcache = totchild; } @@ -2372,12 +2397,8 @@ void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra, int editupda else { /* clear out old and create new empty path cache */ psys_free_path_cache(psys); - - /* allocate cache array for fast access and set pointers to contiguous mem block */ - cache = psys->pathcache = MEM_callocN(MAX2(1, totpart) * sizeof(void *), "Path cache array"); - cache[0] = MEM_callocN(totpart * (steps + 1) * sizeof(ParticleCacheKey), "Path cache"); - for(i=1; ipathcachebufs, totpart, steps+1); + psys->pathcache= cache; } if(edit==NULL && psys->soft && psys->softflag & OB_SB_ENABLE) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 24606bd822f..8d315ba37e1 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2615,6 +2615,8 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) psys->edit = 0; psys->pathcache = 0; psys->childcache = 0; + psys->pathcachebufs.first = psys->pathcachebufs.last = 0; + psys->childcachebufs.first = psys->childcachebufs.last = 0; psys->reactevents.first = psys->reactevents.last = 0; psys->pointcache= newdataadr(fd, psys->pointcache); diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 8122cdd9cc7..e5f781a3365 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -171,24 +171,24 @@ typedef struct ParticleSettings { typedef struct ParticleSystem{ struct ParticleSystem *next, *prev; - ParticleSettings *part; + ParticleSettings *part; /* particle settings */ - ParticleData *particles; + ParticleData *particles; /* (parent) particles */ + ChildParticle *child; /* child particles */ - ChildParticle *child; + struct ParticleEdit *edit; /* particle editmode (runtime) */ - struct ParticleEdit *edit; + struct ParticleCacheKey **pathcache; /* path cache (runtime) */ + struct ParticleCacheKey **childcache; /* child cache (runtime) */ + ListBase pathcachebufs, childcachebufs; /* buffers for the above */ - struct ParticleCacheKey **pathcache; - struct ParticleCacheKey **childcache; - - struct SoftBody *soft; + struct SoftBody *soft; /* hair softbody */ struct Object *target_ob; struct Object *keyed_ob; struct Object *lattice; - struct ListBase effectors, reactevents; + struct ListBase effectors, reactevents; /* runtime */ float imat[4][4]; /* used for duplicators */ float cfra; @@ -196,10 +196,10 @@ typedef struct ParticleSystem{ int flag, totpart, totchild, totcached, totchildcache, rt; short recalc, target_psys, keyed_psys, totkeyed, softflag, bakespace; - char bb_uvname[3][32]; + char bb_uvname[3][32]; /* billboard uv name */ /* if you change these remember to update array lengths to PSYS_TOT_VG! */ - short vgroup[11], vg_neg, rt3[2]; + short vgroup[11], vg_neg, rt3[2]; /* vertex groups */ /* temporary storage during render */ void *renderdata; -- cgit v1.2.3 From 3527c100652f029db7a0e5af27a16456ff5ae1df Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 May 2008 20:24:06 +0000 Subject: Fix for bug #10932: area light bug, points behind the lamp could also get lit. --- source/blender/render/intern/source/shadeoutput.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 9f14db2f425..0928042729a 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -477,8 +477,12 @@ static float area_lamp_energy_multisample(LampRen *lar, float *co, float *vn) float *jitlamp= lar->jitter, vec[3]; float area[4][3], intens= 0.0f; int a= lar->ray_totsamp; - - + + /* test if co is behind lamp */ + VECSUB(vec, co, lar->co); + if(INPR(vec, lar->vec) < 0.0f) + return 0.0f; + while(a--) { vec[0]= jitlamp[0]; vec[1]= jitlamp[1]; -- cgit v1.2.3 From 48f6c5b05feecb516a6bc4374fb75de709c626c4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 May 2008 20:34:34 +0000 Subject: was missing depgraph update for centering objects in editmode if they were unselected. ctrl+num keys for switching subsurf didnt work in editmode if the object wasnt selected. changed this to only operate on the editmode object. also disallow ctrl+num to change layers for values above 4. --- source/blender/src/editobject.c | 27 ++++++++++++++++++++------- source/blender/src/space.c | 33 +++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index cdc38ab1d2c..4029e031b63 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -1887,6 +1887,7 @@ void docenter(int centermode) recalc_editnormals(); tot_change++; + DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); } } @@ -3133,9 +3134,15 @@ void flip_subdivison(int level) mode= eModifierMode_Render|eModifierMode_Realtime; if(level == -1) { - for(base= G.scene->base.first; base; base= base->next) - if(((level==-1) && (TESTBASE(base))) || (TESTBASELIB(base))) - object_has_subdivision_particles(base->object, &havesubdiv, &havepart, 0); + if (G.obedit) { + object_has_subdivision_particles(G.obedit, &havesubdiv, &havepart, 0); + } else { + for(base= G.scene->base.first; base; base= base->next) { + if(((level==-1) && (TESTBASE(base))) || (TESTBASELIB(base))) { + object_has_subdivision_particles(base->object, &havesubdiv, &havepart, 0); + } + } + } } else havesubdiv= 1; @@ -3149,10 +3156,16 @@ void flip_subdivison(int level) } else if(havepart) particles= 1; - - for(base= G.scene->base.first; base; base= base->next) - if(((level==-1) && (TESTBASE(base))) || (TESTBASELIB(base))) - object_flip_subdivison_particles(base->object, &set, level, mode, particles, 0); + + if (G.obedit) { + object_flip_subdivison_particles(G.obedit, &set, level, mode, particles, 0); + } else { + for(base= G.scene->base.first; base; base= base->next) { + if(((level==-1) && (TESTBASE(base))) || (TESTBASELIB(base))) { + object_flip_subdivison_particles(base->object, &set, level, mode, particles, 0); + } + } + } countall(); allqueue(REDRAWVIEW3D, 0); diff --git a/source/blender/src/space.c b/source/blender/src/space.c index e396e078739..63836101d49 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -1745,25 +1745,42 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) if ( (G.obedit) && (G.obedit->type==OB_MESH) ) select_faces_by_numverts(5); } + + else if(G.qual==LR_CTRLKEY) {} else do_layer_buttons(4); break; case SIXKEY: - do_layer_buttons(5); break; + if(G.qual==LR_CTRLKEY) {} + else do_layer_buttons(5); + break; case SEVENKEY: - do_layer_buttons(6); break; + if(G.qual==LR_CTRLKEY) {} + else do_layer_buttons(6); + break; case EIGHTKEY: - do_layer_buttons(7); break; + if(G.qual==LR_CTRLKEY) {} + else do_layer_buttons(7); + break; case NINEKEY: - do_layer_buttons(8); break; + if(G.qual==LR_CTRLKEY) {} + else do_layer_buttons(8); + break; case ZEROKEY: - do_layer_buttons(9); break; + if(G.qual==LR_CTRLKEY) {} + else do_layer_buttons(9); + break; case MINUSKEY: - do_layer_buttons(10); break; + if(G.qual==LR_CTRLKEY) {} + else do_layer_buttons(10); + break; case EQUALKEY: - do_layer_buttons(11); break; + if(G.qual==LR_CTRLKEY) {} + else do_layer_buttons(11); + break; case ACCENTGRAVEKEY: - do_layer_buttons(-1); break; + do_layer_buttons(-1); + break; case SPACEKEY: if(G.qual == LR_CTRLKEY) { -- cgit v1.2.3 From 1c7c37deb73fb2997d4f9542f5cc02ea2058eee6 Mon Sep 17 00:00:00 2001 From: Stephen Swaney Date: Wed, 7 May 2008 21:21:15 +0000 Subject: modify script to use long opts; --name vs -n, for example. This makes epy_docgen.sh compatible with epy_docgen-3.sh. I am not sure why we would need both scripts. Perhaps someone with epdoc version 3 can test. --- source/blender/python/api2_2x/doc/epy_docgen.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/python/api2_2x/doc/epy_docgen.sh b/source/blender/python/api2_2x/doc/epy_docgen.sh index d709ee73190..d4f4463372f 100644 --- a/source/blender/python/api2_2x/doc/epy_docgen.sh +++ b/source/blender/python/api2_2x/doc/epy_docgen.sh @@ -7,6 +7,6 @@ # set posix locale so regex works properly for [A-Z]*.py LC_ALL=POSIX -epydoc -o BPY_API --url "http://www.blender.org" -t API_intro.py \ - -n "Blender" --no-private --no-frames \ +epydoc -o BPY_API --url "http://www.blender.org" --top API_intro.py \ + --name "Blender" --no-private --no-frames \ $( ls [A-Z]*.py ) -- cgit v1.2.3 From 2a8caaa6a0829826b21e83f3ec4734ffb8aa1af9 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Wed, 7 May 2008 22:26:47 +0000 Subject: [#10996] Wrong tooltip in "Fields" panel Also fixed typo and insuficiant length of label Longitudinal --- source/blender/src/buttons_object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 9a749b6fbd9..c71caa082e7 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -3422,9 +3422,9 @@ static void object_panel_fields(Object *ob) uiBlockEndAlign(block); } else{ - uiDefButS(block, MENU, B_FIELD_DEP, "Fall-off%t|Cone%x2|Tube%x1|Sphere%x0", 160,180,140,20, &pd->falloff, 0.0, 0.0, 0, 0, tipstr); + uiDefButS(block, MENU, B_FIELD_DEP, "Fall-off%t|Cone%x2|Tube%x1|Sphere%x0", 160,180,140,20, &pd->falloff, 0.0, 0.0, 0, 0, "Fall-off shape"); if(pd->falloff==PFIELD_FALL_TUBE) - uiDefBut(block, LABEL, 0, "Lognitudinal", 160,160,70,20, NULL, 0.0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Longitudinal", 160,160,140,20, NULL, 0.0, 0, 0, 0, ""); uiBlockBeginAlign(block); uiDefButBitS(block, TOG, PFIELD_POSZ, B_FIELD_CHANGE, "Pos", 160,140,40,20, &pd->flag, 0.0, 0, 0, 0, "Effect only in direction of positive Z axis"); uiDefButF(block, NUM, B_FIELD_CHANGE, "Fall-off: ", 200,140,100,20, &pd->f_power, 0, 10, 10, 0, "Falloff power (real gravitational falloff = 2)"); -- cgit v1.2.3 From 44cdc480de4e54a07da751625adc4aa9d67c3f48 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 7 May 2008 22:32:45 +0000 Subject: Fix BGE bug #6054: Camera actuator crashes Blender. The crash occurs when min,max << height (bad practice anyway). --- source/gameengine/Ketsji/KX_CameraActuator.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index cb3180cb05e..27f4870de10 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -155,14 +155,25 @@ static void Kx_VecUpMat3(float *vec, float mat[][3], short axis) mat[coz][0]= vec[0]; mat[coz][1]= vec[1]; mat[coz][2]= vec[2]; - Kx_Normalize((float *)mat[coz]); + if (Kx_Normalize((float *)mat[coz]) == 0.f) { + /* this is a very abnormal situation: the camera has reach the object center exactly + We will choose a completely arbitrary direction */ + mat[coz][0] = 1.0f; + mat[coz][1] = 0.0f; + mat[coz][2] = 0.0f; + } inp= mat[coz][2]; mat[coy][0]= - inp*mat[coz][0]; mat[coy][1]= - inp*mat[coz][1]; mat[coy][2]= 1.0 - inp*mat[coz][2]; - Kx_Normalize((float *)mat[coy]); + if (Kx_Normalize((float *)mat[coy]) == 0.f) { + /* the camera is vertical, chose the y axis arbitrary */ + mat[coy][0] = 0.f; + mat[coy][1] = 1.f; + mat[coy][2] = 0.f; + } Kx_Crossf(mat[cox], mat[coy], mat[coz]); -- cgit v1.2.3 From 12715ec0fac8f704d55fe9b0e60abc2ba40f76b2 Mon Sep 17 00:00:00 2001 From: Stephen Swaney Date: Wed, 7 May 2008 22:46:20 +0000 Subject: more shell script tweaking. Thanks to gsrb3d for hints. --- source/blender/python/api2_2x/doc/epy_docgen.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/blender/python/api2_2x/doc/epy_docgen.sh b/source/blender/python/api2_2x/doc/epy_docgen.sh index d4f4463372f..8cbebf82f8d 100644 --- a/source/blender/python/api2_2x/doc/epy_docgen.sh +++ b/source/blender/python/api2_2x/doc/epy_docgen.sh @@ -7,6 +7,5 @@ # set posix locale so regex works properly for [A-Z]*.py LC_ALL=POSIX -epydoc -o BPY_API --url "http://www.blender.org" --top API_intro.py \ - --name "Blender" --no-private --no-frames \ -$( ls [A-Z]*.py ) +epydoc -v -o BPY_API --url "http://www.blender.org" --top API_intro \ + --name "Blender" --no-private --no-frames [A-Z]*.py -- cgit v1.2.3 From 18b20396bc4563ba5e2b14fb232960211861a236 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 May 2008 07:33:20 +0000 Subject: this script isnt needed anymore thanks to stivs and gsr --- source/blender/python/api2_2x/doc/epy_docgen-3.sh | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 source/blender/python/api2_2x/doc/epy_docgen-3.sh diff --git a/source/blender/python/api2_2x/doc/epy_docgen-3.sh b/source/blender/python/api2_2x/doc/epy_docgen-3.sh deleted file mode 100644 index ce2bdfef0f8..00000000000 --- a/source/blender/python/api2_2x/doc/epy_docgen-3.sh +++ /dev/null @@ -1,12 +0,0 @@ -# epy_docgen.sh -# generates blender python doc using epydoc -# requires epydoc in your PATH. -# run from the doc directory containing the .py files -# usage: sh epy_docgen.sh - -# set posix locale so regex works properly for [A-Z]*.py -LC_ALL=POSIX - -epydoc -v -o BPY_API --url "http://www.blender.org" --top API_intro \ - --name "Blender" --no-private --no-frames \ -$( ls [A-Z]*.py ) -- cgit v1.2.3 From 205d06f5f4505a2ce0211869a36501fc19877666 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 8 May 2008 08:41:56 +0000 Subject: Fix for bug #11002: particle ipo clump did not allow negative values like the button in the user interface. --- source/blender/blenkernel/intern/ipo.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 0b9f7615bfa..321d4f1d37e 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1917,6 +1917,9 @@ void set_icu_vars(IpoCurve *icu) icu->ymin= 0.0; break; case PART_CLUMP: + icu->ymin= -1.0; + icu->ymax= 1.0; + break; case PART_DRAG: case PART_DAMP: case PART_LENGTH: @@ -1926,6 +1929,7 @@ void set_icu_vars(IpoCurve *icu) case PART_KINK_SHAPE: icu->ymin= -0.999; icu->ymax= 0.999; + break; } } else if(icu->blocktype==ID_CO) { -- cgit v1.2.3 From e71a6bd79ea1982dbed05468cc98def7093e9228 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 8 May 2008 08:59:36 +0000 Subject: NLA - Bugfix: Scale and Repeat fields in NLA Transform Properties panel will now ignore negative values instead of clamping them to a near-zero value, which can easily be confused with the strip being 'destroyed'. This shouldn't affect other interface elements, as this change has only been used here. (Note: negative scaling should be avoided) --- source/blender/include/BIF_interface.h | 1 + source/blender/src/drawnla.c | 6 +++--- source/blender/src/interface.c | 35 ++++++++++++++++++++++------------ source/blender/src/interface_draw.c | 8 +++++++- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/source/blender/include/BIF_interface.h b/source/blender/include/BIF_interface.h index 24747b9f220..fbd4e4ecd91 100644 --- a/source/blender/include/BIF_interface.h +++ b/source/blender/include/BIF_interface.h @@ -164,6 +164,7 @@ struct AutoComplete; #define BUT_TOGDUAL (33<<9) #define ICONTOGN (34<<9) #define FTPREVIEW (35<<9) +#define NUMABS (36<<9) #define BUTTYPE (63<<9) diff --git a/source/blender/src/drawnla.c b/source/blender/src/drawnla.c index c0cd11d27a1..083d10fd484 100644 --- a/source/blender/src/drawnla.c +++ b/source/blender/src/drawnla.c @@ -638,14 +638,14 @@ static void nla_panel_properties(short cntrl) // NLA_HANDLER_PROPERTIES uiBlockBeginAlign(block); // FIXME: repeat and scale are too cramped! - uiDefButF(block, NUM, B_NLA_SCALE, "Repeat:", 160,100,75,19, &strip->repeat, 0.001, 1000.0f, 100, 0, "Number of times the action should repeat"); + uiDefButF(block, NUMABS, B_NLA_SCALE, "Repeat:", 160,100,75,19, &strip->repeat, 0.001, 1000.0f, 100, 0, "Number of times the action should repeat"); if ((strip->actend - strip->actstart) < 1.0f) { uiBlockSetCol(block, TH_REDALERT); - uiDefButF(block, NUM, B_NLA_SCALE, "Scale:", 235,100,75,19, &strip->scale, 0.001, 1000.0f, 100, 0, "Please run Alt-S to fix up this error"); + uiDefButF(block, NUMABS, B_NLA_SCALE, "Scale:", 235,100,75,19, &strip->scale, 0.001, 1000.0f, 100, 0, "Please run Alt-S to fix up this error"); uiBlockSetCol(block, TH_AUTO); } else - uiDefButF(block, NUM, B_NLA_SCALE, "Scale:", 235,100,75,19, &strip->scale, 0.001, 1000.0f, 100, 0, "Amount the action should be scaled by"); + uiDefButF(block, NUMABS, B_NLA_SCALE, "Scale:", 235,100,75,19, &strip->scale, 0.001, 1000.0f, 100, 0, "Amount the action should be scaled by"); but= uiDefButC(block, TEX, B_NLA_PANEL, "OffsBone:", 160,80,150,19, strip->offs_bone, 0, 31.0f, 0, 0, "Name of Bone that defines offset for repeat"); uiButSetCompleteFunc(but, autocomplete_bone, (void *)ob); uiDefButBitS(block, TOG, ACTSTRIP_HOLDLASTFRAME, B_NLA_PANEL, "Hold", 160,60,75,19, &strip->flag, 0, 0, 0, 0, "Toggles whether to continue displaying the last frame past the end of the strip"); diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index f324bf3b053..7af6b67bfa3 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -472,7 +472,7 @@ static int ui_but_copy_paste(uiBut *but, char mode) if(mode=='v' && but->lock) return 0; poin= but->poin; - if ELEM3(but->type, NUM, NUMSLI, HSVSLI) { + if ELEM4(but->type, NUM, NUMABS, NUMSLI, HSVSLI) { if(poin==NULL); else if(mode=='c') { @@ -2100,7 +2100,8 @@ static int ui_act_as_text_but(uiBut *but) } if(but->pointype!=FLO) value= (int)value; - + + if(but->type==NUMABS) value= fabs(value); if(valuemax) value= max; @@ -3934,6 +3935,7 @@ static int ui_do_button(uiBlock *block, uiBut *but, uiEvent *uevent) break; case NUM: + case NUMABS: if(uevent->val) retval= ui_do_but_NUM(but); break; @@ -4253,13 +4255,13 @@ static void ui_but_next_edittext(uiBlock *block) but->flag &= ~(UI_ACTIVE|UI_SELECT); for(but= actbut->next; but; but= but->next) { - if(ELEM4(but->type, TEX, NUM, NUMSLI, HSVSLI)) { + if(ELEM5(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI)) { but->flag |= UI_ACTIVE; return; } } for(but= block->buttons.first; but!=actbut; but= but->next) { - if(ELEM4(but->type, TEX, NUM, NUMSLI, HSVSLI)) { + if(ELEM5(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI)) { but->flag |= UI_ACTIVE; return; } @@ -4282,13 +4284,13 @@ static void ui_but_prev_edittext(uiBlock *block) but->flag &= ~(UI_ACTIVE|UI_SELECT); for(but= actbut->prev; but; but= but->prev) { - if(ELEM4(but->type, TEX, NUM, NUMSLI, HSVSLI)) { + if(ELEM5(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI)) { but->flag |= UI_ACTIVE; return; } } for(but= block->buttons.last; but!=actbut; but= but->prev) { - if(ELEM4(but->type, TEX, NUM, NUMSLI, HSVSLI)) { + if(ELEM5(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI)) { but->flag |= UI_ACTIVE; return; } @@ -4643,7 +4645,7 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent, int movemouse_quit) //Really nasty... to update the num button from the same butblock for(bt= block->buttons.first; bt; bt= bt->next) { - if(bt->type == NUM) { + if(ELEM(bt->type, NUM, NUMABS)) { ui_check_but(bt); ui_draw_but(bt); } @@ -4669,7 +4671,7 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent, int movemouse_quit) for(bt= block->buttons.first; bt; bt= bt->next) { - if(bt->type == NUM) { + if(ELEM(bt->type, NUM, NUMABS)) { ui_check_but(bt); ui_draw_but(bt); } @@ -5442,8 +5444,15 @@ void ui_check_but(uiBut *but) case HSVSLI: value= ui_get_but_val(but); if(value < but->min) value= but->min; - if(value > but->max) value= but->max; - ui_set_but_val(but, value); + if(value > but->max) value= but->max; + ui_set_but_val(but, value); + break; + + case NUMABS: + value= fabs( ui_get_but_val(but) ); + if(value < but->min) value= but->min; + if(value > but->max) value= but->max; + ui_set_but_val(but, value); break; case ICONTOG: @@ -5485,6 +5494,7 @@ void ui_check_but(uiBut *but) case NUM: case NUMSLI: case HSVSLI: + case NUMABS: value= ui_get_but_val(but); @@ -5574,7 +5584,7 @@ void ui_check_but(uiBut *but) but->ofs= 0; while(but->strwidth > (int)okwidth ) { - if ELEM(but->type, NUM, TEX) { // only these cut off left + if ELEM3(but->type, NUM, NUMABS, TEX) { // only these cut off left but->ofs++; but->strwidth= but->aspect*BIF_GetStringWidth(but->font, but->drawstr+but->ofs, transopts); @@ -5618,6 +5628,7 @@ static int ui_auto_themecol(uiBut *but) case SLI: case NUM: case NUMSLI: + case NUMABS: case HSVSLI: return TH_BUT_NUM; case TEX: @@ -5894,7 +5905,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short but->pos= -1; /* cursor invisible */ - if(but->type==NUM) { /* add a space to name */ + if(ELEM(but->type, NUM, NUMABS)) { /* add a space to name */ slen= strlen(but->str); if(slen>0 && slenstr[slen-1]!=' ') { diff --git a/source/blender/src/interface_draw.c b/source/blender/src/interface_draw.c index 83a3c12bae7..83f1221b1fb 100644 --- a/source/blender/src/interface_draw.c +++ b/source/blender/src/interface_draw.c @@ -846,6 +846,7 @@ static void ui_default_flat(int type, int colorid, float asp, float x1, float y1 /* *** EXTRA DRAWING FOR SPECIFIC CONTROL TYPES *** */ switch(type) { case NUM: + case NUMABS: /* SIDE ARROWS */ /* left */ if(flag & UI_SELECT) { @@ -872,11 +873,12 @@ static void ui_default_slider(int colorid, float fac, float aspect, float x1, fl if(flag & UI_SELECT) BIF_ThemeColorShade(TH_BUT_NUM, -5); - else + else { if(flag & UI_ACTIVE) BIF_ThemeColorShade(TH_BUT_NUM, +35); else BIF_ThemeColorShade(TH_BUT_NUM, +25); + } glRectf(x1, ymid-yc, x2, ymid+yc); @@ -943,6 +945,7 @@ static void ui_draw_default(int type, int colorid, float aspect, float x1, float case TEX: case IDPOIN: case NUM: + case NUMABS: ui_default_flat(type, colorid, aspect, x1, y1, x2, y2, flag); break; case ICONROW: @@ -1026,6 +1029,7 @@ static void ui_draw_oldskool(int type, int colorid, float asp, float x1, float y /* special type decorations */ switch(type) { case NUM: + case NUMABS: if(flag & UI_SELECT) BIF_ThemeColorShade(colorid, -60); else BIF_ThemeColorShade(colorid, -30); ui_default_num_arrows(x1, y1, x2, y2); @@ -1176,6 +1180,7 @@ static void ui_draw_round(int type, int colorid, float asp, float x1, float y1, /* special type decorations */ switch(type) { case NUM: + case NUMABS: BIF_ThemeColorShade(colorid, curshade-60); ui_default_num_arrows(x1, y1, x2, y2); break; @@ -1285,6 +1290,7 @@ static void ui_draw_minimal(int type, int colorid, float asp, float x1, float y1 /* special type decorations */ switch(type) { case NUM: + case NUMABS: if(flag & UI_SELECT) BIF_ThemeColorShade(colorid, -60); else BIF_ThemeColorShade(colorid, -30); ui_default_num_arrows(x1, y1, x2, y2); -- cgit v1.2.3 From 3faf12770700a87eec348868b3c53d3080b6739e Mon Sep 17 00:00:00 2001 From: Remigiusz Fiedler Date: Thu, 8 May 2008 15:58:00 +0000 Subject: DXF-importer prepared for ProE files, which are outside of DXF-specification. --- release/scripts/bpymodules/dxfReader.py | 619 ++++++++++++++++---------------- 1 file changed, 309 insertions(+), 310 deletions(-) diff --git a/release/scripts/bpymodules/dxfReader.py b/release/scripts/bpymodules/dxfReader.py index d4a39cf63d6..df4ebc309e4 100644 --- a/release/scripts/bpymodules/dxfReader.py +++ b/release/scripts/bpymodules/dxfReader.py @@ -1,11 +1,12 @@ """This module provides a function for reading dxf files and parsing them into a useful tree of objects and data. - The convert function is called by the readDXF fuction to convert dxf strings into the correct data based - on their type code. readDXF expects a (full path) file name as input. + The convert function is called by the readDXF fuction to convert dxf strings into the correct data based + on their type code. readDXF expects a (full path) file name as input. """ # -------------------------------------------------------------------------- # DXF Reader v0.9 by Ed Blake (AKA Kitsu) +# 2008.05.08 modif.def convert() by Remigiusz Fiedler (AKA migius) # -------------------------------------------------------------------------- # ***** BEGIN GPL LICENSE BLOCK ***** # @@ -30,215 +31,215 @@ #from dxfImportObjects import * class Object: - """Empty container class for dxf objects""" - - def __init__(self, _type='', block=False): - """_type expects a string value.""" - self.type = _type - self.name = '' - self.data = [] - - def __str__(self): - if self.name: - return self.name - else: - return self.type - - def __repr__(self): - return str(self.data) - - def get_type(self, kind=''): - """Despite the name, this method actually returns all objects of type 'kind' from self.data.""" - if type: - objects = [] - for item in self.data: - if type(item) != list and item.type == kind: - # we want this type of object - objects.append(item) - elif type(item) == list and item[0] == kind: - # we want this type of data - objects.append(item[1]) - return objects - + """Empty container class for dxf objects""" + + def __init__(self, _type='', block=False): + """_type expects a string value.""" + self.type = _type + self.name = '' + self.data = [] + + def __str__(self): + if self.name: + return self.name + else: + return self.type + + def __repr__(self): + return str(self.data) + + def get_type(self, kind=''): + """Despite the name, this method actually returns all objects of type 'kind' from self.data.""" + if type: + objects = [] + for item in self.data: + if type(item) != list and item.type == kind: + # we want this type of object + objects.append(item) + elif type(item) == list and item[0] == kind: + # we want this type of data + objects.append(item[1]) + return objects + class InitializationError(Exception): pass class StateMachine: - """(finite) State Machine from the great David Mertz's great Charming Python article.""" - - def __init__(self): - self.handlers = [] - self.startState = None - self.endStates = [] - - def add_state(self, handler, end_state=0): - """All states and handlers are functions which return - a state and a cargo.""" - self.handlers.append(handler) - if end_state: - self.endStates.append(handler) - def set_start(self, handler): - """Sets the starting handler function.""" - self.startState = handler - - - def run(self, cargo=None): - if not self.startState: - raise InitializationError,\ - "must call .set_start() before .run()" - if not self.endStates: - raise InitializationError, \ - "at least one state must be an end_state" - handler = self.startState - while 1: - (newState, cargo) = handler(cargo) - #print cargo - if newState in self.endStates: - return newState(cargo) - #break - elif newState not in self.handlers: - raise RuntimeError, "Invalid target %s" % newState - else: - handler = newState + """(finite) State Machine from the great David Mertz's great Charming Python article.""" + + def __init__(self): + self.handlers = [] + self.startState = None + self.endStates = [] + + def add_state(self, handler, end_state=0): + """All states and handlers are functions which return + a state and a cargo.""" + self.handlers.append(handler) + if end_state: + self.endStates.append(handler) + def set_start(self, handler): + """Sets the starting handler function.""" + self.startState = handler + + + def run(self, cargo=None): + if not self.startState: + raise InitializationError,\ + "must call .set_start() before .run()" + if not self.endStates: + raise InitializationError, \ + "at least one state must be an end_state" + handler = self.startState + while 1: + (newState, cargo) = handler(cargo) + #print cargo + if newState in self.endStates: + return newState(cargo) + #break + elif newState not in self.handlers: + raise RuntimeError, "Invalid target %s" % newState + else: + handler = newState def get_name(data): - """Get the name of an object from its object data. - - Returns a pair of (data_item, name) where data_item is the list entry where the name was found - (the data_item can be used to remove the entry from the object data). Be sure to check - name not None before using the returned values! - """ - value = None - for item in data: - if item[0] == 2: - value = item[1] - break - return item, value + """Get the name of an object from its object data. + + Returns a pair of (data_item, name) where data_item is the list entry where the name was found + (the data_item can be used to remove the entry from the object data). Be sure to check + name not None before using the returned values! + """ + value = None + for item in data: + if item[0] == 2: + value = item[1] + break + return item, value def get_layer(data): - """Expects object data as input. - - Returns (entry, layer_name) where entry is the data item that provided the layer name. - """ - value = None - for item in data: - if item[0] == 8: - value = item[1] - break - return item, value + """Expects object data as input. + + Returns (entry, layer_name) where entry is the data item that provided the layer name. + """ + value = None + for item in data: + if item[0] == 8: + value = item[1] + break + return item, value def convert(code, value): - """Convert a string to the correct Python type based on its dxf code. - code types: - ints = 60-79, 170-179, 270-289, 370-389, 400-409, 1060-1070 - longs = 90-99, 420-429, 440-459, 1071 - floats = 10-39, 40-59, 110-139, 140-149, 210-239, 460-469, 1010-1059 - hex = 105, 310-379, 390-399 - strings = 0-9, 100, 102, 300-309, 410-419, 430-439, 470-479, 999, 1000-1009 - """ - if 59 < code < 80 or 169 < code < 180 or 269 < code < 290 or 369 < code < 390 or 399 < code < 410 or 1059 < code < 1071: - value = int(value) - elif 89 < code < 100 or 419 < code < 430 or 439 < code < 460 or code == 1071: - value = long(value) - elif 9 < code < 60 or 109 < code < 150 or 209 < code < 240 or 459 < code < 470 or 1009 < code < 1060: - value = float(value) - elif code == 105 or 309 < code < 380 or 389 < code < 400: - value = int(value, 16) # should be left as string? - else: # it's already a string so do nothing - pass - return value + """Convert a string to the correct Python type based on its dxf code. + code types: + ints = 60-79, 170-179, 270-289, 370-389, 400-409, 1060-1070 + longs = 90-99, 420-429, 440-459, 1071 + floats = 10-39, 40-59, 110-139, 140-149, 210-239, 460-469, 1010-1059 + hex = 105, 310-379, 390-399 + strings = 0-9, 100, 102, 300-309, 410-419, 430-439, 470-479, 999, 1000-1009 + """ + if 59 < code < 80 or 169 < code < 180 or 269 < code < 290 or 369 < code < 390 or 399 < code < 410 or 1059 < code < 1071: + value = int(float(value)) + elif 89 < code < 100 or 419 < code < 430 or 439 < code < 460 or code == 1071: + value = long(float(value)) + elif 9 < code < 60 or 109 < code < 150 or 209 < code < 240 or 459 < code < 470 or 1009 < code < 1060: + value = float(value) + elif code == 105 or 309 < code < 380 or 389 < code < 400: + value = int(value, 16) # should be left as string? + else: # it's already a string so do nothing + pass + return value def findObject(infile, kind=''): - """Finds the next occurance of an object.""" - obj = False - while 1: - line = infile.readline() - if not line: # readline returns '' at eof - return False - if not obj: # We're still looking for our object code - if line.lower().strip() == '0': - obj = True # found it - else: # we are in an object definition - if kind: # if we're looking for a particular kind - if line.lower().strip() == kind: - obj = Object(line.lower().strip()) - break - else: # otherwise take anything non-numeric - if line.lower().strip() not in string.digits: - obj = Object(line.lower().strip()) - break - obj = False # whether we found one or not it's time to start over - return obj + """Finds the next occurance of an object.""" + obj = False + while 1: + line = infile.readline() + if not line: # readline returns '' at eof + return False + if not obj: # We're still looking for our object code + if line.lower().strip() == '0': + obj = True # found it + else: # we are in an object definition + if kind: # if we're looking for a particular kind + if line.lower().strip() == kind: + obj = Object(line.lower().strip()) + break + else: # otherwise take anything non-numeric + if line.lower().strip() not in string.digits: + obj = Object(line.lower().strip()) + break + obj = False # whether we found one or not it's time to start over + return obj def handleObject(infile): - """Add data to an object until end of object is found.""" - line = infile.readline() - if line.lower().strip() == 'section': - return 'section' # this would be a problem - elif line.lower().strip() == 'endsec': - return 'endsec' # this means we are done with a section - else: # add data to the object until we find a new object - obj = Object(line.lower().strip()) - obj.name = obj.type - done = False - data = [] - while not done: - line = infile.readline() - if not data: - if line.lower().strip() == '0': - #we've found an object, time to return - return obj - else: - # first part is always an int - data.append(int(line.lower().strip())) - else: - data.append(convert(data[0], line.strip())) - obj.data.append(data) - data = [] + """Add data to an object until end of object is found.""" + line = infile.readline() + if line.lower().strip() == 'section': + return 'section' # this would be a problem + elif line.lower().strip() == 'endsec': + return 'endsec' # this means we are done with a section + else: # add data to the object until we find a new object + obj = Object(line.lower().strip()) + obj.name = obj.type + done = False + data = [] + while not done: + line = infile.readline() + if not data: + if line.lower().strip() == '0': + #we've found an object, time to return + return obj + else: + # first part is always an int + data.append(int(line.lower().strip())) + else: + data.append(convert(data[0], line.strip())) + obj.data.append(data) + data = [] def handleTable(table, infile): - """Special handler for dealing with nested table objects.""" - item, name = get_name(table.data) - if name: # We should always find a name - table.data.remove(item) - table.name = name.lower() - # This next bit is from handleObject - # handleObject should be generalized to work with any section like object - while 1: - obj = handleObject(infile) - if obj.type == 'table': - print "Warning: previous table not closed!" - return table - elif obj.type == 'endtab': - return table # this means we are done with the table - else: # add objects to the table until one of the above is found - table.data.append(obj) - - - + """Special handler for dealing with nested table objects.""" + item, name = get_name(table.data) + if name: # We should always find a name + table.data.remove(item) + table.name = name.lower() + # This next bit is from handleObject + # handleObject should be generalized to work with any section like object + while 1: + obj = handleObject(infile) + if obj.type == 'table': + print "Warning: previous table not closed!" + return table + elif obj.type == 'endtab': + return table # this means we are done with the table + else: # add objects to the table until one of the above is found + table.data.append(obj) + + + def handleBlock(block, infile): - """Special handler for dealing with nested table objects.""" - item, name = get_name(block.data) - if name: # We should always find a name - block.data.remove(item) - block.name = name - # This next bit is from handleObject - # handleObject should be generalized to work with any section like object - while 1: - obj = handleObject(infile) - if obj.type == 'block': - print "Warning: previous block not closed!" - return block - elif obj.type == 'endblk': - return block # this means we are done with the table - else: # add objects to the table until one of the above is found - block.data.append(obj) - - - + """Special handler for dealing with nested table objects.""" + item, name = get_name(block.data) + if name: # We should always find a name + block.data.remove(item) + block.name = name + # This next bit is from handleObject + # handleObject should be generalized to work with any section like object + while 1: + obj = handleObject(infile) + if obj.type == 'block': + print "Warning: previous block not closed!" + return block + elif obj.type == 'endblk': + return block # this means we are done with the table + else: # add objects to the table until one of the above is found + block.data.append(obj) + + + """These are the states/functions used in the State Machine. states: @@ -250,133 +251,131 @@ states: """ def start(cargo): - """Expects the infile as cargo, initializes the cargo.""" - #print "Entering start state!" - infile = cargo - drawing = Object('drawing') - section = findObject(infile, 'section') - if section: - return start_section, (infile, drawing, section) - else: - return error, (infile, "Failed to find any sections!") + """Expects the infile as cargo, initializes the cargo.""" + #print "Entering start state!" + infile = cargo + drawing = Object('drawing') + section = findObject(infile, 'section') + if section: + return start_section, (infile, drawing, section) + else: + return error, (infile, "Failed to find any sections!") def start_section(cargo): - """Expects [infile, drawing, section] as cargo, builds a nested section object.""" - #print "Entering start_section state!" - infile = cargo[0] - drawing = cargo[1] - section = cargo[2] - # read each line, if it is an object declaration go to object mode - # otherwise create a [index, data] pair and add it to the sections data. - done = False - data = [] - while not done: - line = infile.readline() - - if not data: # if we haven't found a dxf code yet - if line.lower().strip() == '0': - # we've found an object - while 1: # no way out unless we find an end section or a new section - obj = handleObject(infile) - if obj == 'section': # shouldn't happen - print "Warning: failed to close previous section!" - return end_section, (infile, drawing) - elif obj == 'endsec': # This section is over, look for the next - drawing.data.append(section) - return end_section, (infile, drawing) - elif obj.type == 'table': # tables are collections of data - obj = handleTable(obj, infile) # we need to find all there contents - section.data.append(obj) # before moving on - elif obj.type == 'block': # the same is true of blocks - obj = handleBlock(obj, infile) # we need to find all there contents - section.data.append(obj) # before moving on - else: # found another sub-object - section.data.append(obj) - else: - data.append(int(line.lower().strip())) - else: # we have our code, now we just need to convert the data and add it to our list. - data.append(convert(data[0], line.strip())) - section.data.append(data) - data = [] + """Expects [infile, drawing, section] as cargo, builds a nested section object.""" + #print "Entering start_section state!" + infile = cargo[0] + drawing = cargo[1] + section = cargo[2] + # read each line, if it is an object declaration go to object mode + # otherwise create a [index, data] pair and add it to the sections data. + done = False + data = [] + while not done: + line = infile.readline() + + if not data: # if we haven't found a dxf code yet + if line.lower().strip() == '0': + # we've found an object + while 1: # no way out unless we find an end section or a new section + obj = handleObject(infile) + if obj == 'section': # shouldn't happen + print "Warning: failed to close previous section!" + return end_section, (infile, drawing) + elif obj == 'endsec': # This section is over, look for the next + drawing.data.append(section) + return end_section, (infile, drawing) + elif obj.type == 'table': # tables are collections of data + obj = handleTable(obj, infile) # we need to find all there contents + section.data.append(obj) # before moving on + elif obj.type == 'block': # the same is true of blocks + obj = handleBlock(obj, infile) # we need to find all there contents + section.data.append(obj) # before moving on + else: # found another sub-object + section.data.append(obj) + else: + data.append(int(line.lower().strip())) + else: # we have our code, now we just need to convert the data and add it to our list. + data.append(convert(data[0], line.strip())) + section.data.append(data) + data = [] def end_section(cargo): - """Expects (infile, drawing) as cargo, searches for next section.""" - #print "Entering end_section state!" - infile = cargo[0] - drawing = cargo[1] - section = findObject(infile, 'section') - if section: - return start_section, (infile, drawing, section) - else: - return end, (infile, drawing) + """Expects (infile, drawing) as cargo, searches for next section.""" + #print "Entering end_section state!" + infile = cargo[0] + drawing = cargo[1] + section = findObject(infile, 'section') + if section: + return start_section, (infile, drawing, section) + else: + return end, (infile, drawing) def end(cargo): - """Expects (infile, drawing) as cargo, called when eof has been reached.""" - #print "Entering end state!" - infile = cargo[0] - drawing = cargo[1] - #infile.close() - return drawing + """Expects (infile, drawing) as cargo, called when eof has been reached.""" + #print "Entering end state!" + infile = cargo[0] + drawing = cargo[1] + #infile.close() + return drawing def error(cargo): - """Expects a (infile, string) as cargo, called when there is an error during processing.""" - #print "Entering error state!" - infile = cargo[0] - err = cargo[1] - infile.close() - print "There has been an error:" - print err - return False + """Expects a (infile, string) as cargo, called when there is an error during processing.""" + #print "Entering error state!" + infile = cargo[0] + err = cargo[1] + infile.close() + print "There has been an error:" + print err + return False def readDXF(filename, objectify): - """Given a file name try to read it as a dxf file. - - Output is an object with the following structure - drawing - header - header data - classes - class data - tables - table data - blocks - block data - entities - entity data - objects - object data - where foo data is a list of sub-objects. True object data - is of the form [code, data]. -""" - infile = open(filename) - - sm = StateMachine() - sm.add_state(error, True) - sm.add_state(end, True) - sm.add_state(start_section) - sm.add_state(end_section) - sm.add_state(start) - sm.set_start(start) - try: - drawing = sm.run(infile) - if drawing: - drawing.name = filename - for obj in drawing.data: - item, name = get_name(obj.data) - if name: - obj.data.remove(item) - obj.name = name.lower() - setattr(drawing, name.lower(), obj) - # Call the objectify function to cast - # raw objects into the right types of object - obj.data = objectify(obj.data) - #print obj.name - finally: - infile.close() - return drawing -if __name__ == "__main__": - filename = r".\examples\block-test.dxf" - drawing = readDXF(filename) - for item in drawing.entities.data: - print item + """Given a file name try to read it as a dxf file. + Output is an object with the following structure + drawing + header + header data + classes + class data + tables + table data + blocks + block data + entities + entity data + objects + object data + where foo data is a list of sub-objects. True object data + is of the form [code, data]. +""" + infile = open(filename) + sm = StateMachine() + sm.add_state(error, True) + sm.add_state(end, True) + sm.add_state(start_section) + sm.add_state(end_section) + sm.add_state(start) + sm.set_start(start) + try: + drawing = sm.run(infile) + if drawing: + drawing.name = filename + for obj in drawing.data: + item, name = get_name(obj.data) + if name: + obj.data.remove(item) + obj.name = name.lower() + setattr(drawing, name.lower(), obj) + # Call the objectify function to cast + # raw objects into the right types of object + obj.data = objectify(obj.data) + #print obj.name + finally: + infile.close() + return drawing +if __name__ == "__main__": + filename = r".\examples\block-test.dxf" + drawing = readDXF(filename) + for item in drawing.entities.data: + print item -- cgit v1.2.3 From 8fdc367e0d0f7edc341af7a1de4302bf46a051fd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 May 2008 16:33:55 +0000 Subject: 2.46 todo item, added back seam marking tools from UV-face mode. Since these conflict with loop select its now an option from the mesh tools panel. also made it possible to alt+rmb and alt+shift+rmb to mark other edge flags (creases, bevel weights, sharp edges) --- source/blender/include/BDR_editface.h | 5 +- source/blender/makesdna/DNA_scene_types.h | 11 +- source/blender/src/buttons_editing.c | 4 + source/blender/src/editface.c | 205 +++++++++++++++--------------- source/blender/src/editmesh_mods.c | 118 +++++++++++++---- 5 files changed, 214 insertions(+), 129 deletions(-) diff --git a/source/blender/include/BDR_editface.h b/source/blender/include/BDR_editface.h index fb6b65c3972..58b344981ca 100644 --- a/source/blender/include/BDR_editface.h +++ b/source/blender/include/BDR_editface.h @@ -32,6 +32,7 @@ struct MTFace; struct EditFace; +struct EditEdge; struct Mesh; struct MCol; @@ -53,6 +54,8 @@ void uv_autocalc_tface(void); void set_texturepaint(void); void get_same_uv(void); void seam_mark_clear_tface(short mode); - +int edgetag_shortest_path(struct EditEdge *source, struct EditEdge *target); +void edgetag_context_set(struct EditEdge *eed, int val); +int edgetag_context_check(struct EditEdge *eed); #endif /* BDR_EDITFACE_H */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index e0e8c351d2c..45833695ffe 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -437,7 +437,9 @@ typedef struct ToolSettings { char skgen_postpro_passes; char skgen_subdivisions[3]; - char pad3[5]; + /* Alt+RMB option */ + char edge_mode; + char pad3[4]; } ToolSettings; /* Used by all brushes to store their properties, which can be directly set @@ -783,6 +785,13 @@ typedef struct Scene { #define UVCALC_FILLHOLES 1 #define UVCALC_NO_ASPECT_CORRECT 2 /* would call this UVCALC_ASPECT_CORRECT, except it should be default with old file */ +/* toolsettings->edge_mode */ +#define EDGE_MODE_SELECT 0 +#define EDGE_MODE_TAG_SEAM 1 +#define EDGE_MODE_TAG_SHARP 2 +#define EDGE_MODE_TAG_CREASE 3 +#define EDGE_MODE_TAG_BEVEL 4 + /* toolsettings->particle flag */ #define PE_KEEP_LENGTHS 1 #define PE_LOCK_FIRST 2 diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index b02e89233e5..94a715162a0 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -5070,6 +5070,10 @@ static void editing_panel_mesh_tools1(Object *ob, Mesh *me) uiBlockEndAlign(block); + uiDefButBitS(block, TOG, B_MESH_X_MIRROR, B_DIFF, "X-axis mirror",1125,0,150,19, &G.scene->toolsettings->editbutflag, 0, 0, 0, 0, "While using transforms, mirrors the transformation"); + + uiDefButC(block, MENU, REDRAWBUTSEDIT, "Edge Alt-Select Mode%t|Loop Select%x0|Tag Edges (Seam)%x1|Tag Edges (Sharp)%x2|Tag Edges (Sharp)%x3|Tag Edges (Bevel)%x4",1125,88,150,19, &G.scene->toolsettings->edge_mode, 0, 0, 0, 0, "Operation to use when Alt+RMB on edges, Use Alt+Shift+RMB to tag the shortest path from the active edge"); + uiBlockBeginAlign(block); uiDefButBitI(block, TOG, G_ALLEDGES, 0, "All Edges", 1125, 22,150,19, &G.f, 0, 0, 0, 0, "Displays all edges in object mode without optimization"); uiDefButBitS(block, TOG, B_MESH_X_MIRROR, B_DIFF, "X-axis mirror",1125,0,150,19, &G.scene->toolsettings->editbutflag, 0, 0, 0, 0, "While using transforms, mirrors the transformation"); diff --git a/source/blender/src/editface.c b/source/blender/src/editface.c index c1665332be8..e74401cb622 100644 --- a/source/blender/src/editface.c +++ b/source/blender/src/editface.c @@ -870,14 +870,14 @@ int minmax_tface(float *min, float *max) return ok; } -#define ME_SEAM_DONE ME_SEAM_LAST /* reuse this flag */ +#define ME_SEAM_DONE 2 /* reuse this flag */ -static float seam_cut_cost(Mesh *me, int e1, int e2, int vert) +static float edgetag_cut_cost(EditMesh *em, int e1, int e2, int vert) { - MVert *v = me->mvert + vert; - MEdge *med1 = me->medge + e1, *med2 = me->medge + e2; - MVert *v1 = me->mvert + ((med1->v1 == vert)? med1->v2: med1->v1); - MVert *v2 = me->mvert + ((med2->v1 == vert)? med2->v2: med2->v1); + 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 ); float cost, d1[3], d2[3]; cost = VecLenf(v1->co, v->co); @@ -891,19 +891,19 @@ static float seam_cut_cost(Mesh *me, int e1, int e2, int vert) return cost; } -static void seam_add_adjacent(Mesh *me, Heap *heap, int mednum, int vertnum, int *nedges, int *edges, int *prevedge, float *cost) +static void edgetag_add_adjacent(EditMesh *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]; - MEdge *medadj = me->medge + adjnum; + EditEdge *eedadj = EM_get_edge_for_index(adjnum); float newcost; - if (medadj->flag & ME_SEAM_DONE) + if (eedadj->f2 & ME_SEAM_DONE) continue; - newcost = cost[mednum] + seam_cut_cost(me, mednum, adjnum, vertnum); + newcost = cost[mednum] + edgetag_cut_cost(em, mednum, adjnum, vertnum); if (cost[adjnum] > newcost) { cost[adjnum] = newcost; @@ -913,59 +913,93 @@ static void seam_add_adjacent(Mesh *me, Heap *heap, int mednum, int vertnum, int } } -static int seam_shortest_path(Mesh *me, int source, int target) +void edgetag_context_set(EditEdge *eed, int val) { + switch (G.scene->toolsettings->edge_mode) { + case EDGE_MODE_TAG_SEAM: + if (val) {eed->seam = 255;} + else {eed->seam = 0;} + break; + case EDGE_MODE_TAG_SHARP: + if (val) {eed->sharp = 1;} + else {eed->sharp = 0;} + break; + case EDGE_MODE_TAG_CREASE: + if (val) {eed->crease = 1.0f;} + else {eed->crease = 0.0f;} + break; + case EDGE_MODE_TAG_BEVEL: + if (val) {eed->bweight = 1.0f;} + else {eed->bweight = 0.0f;} + break; + } +} + +int edgetag_context_check(EditEdge *eed) +{ + switch (G.scene->toolsettings->edge_mode) { + case EDGE_MODE_TAG_SEAM: + return eed->seam ? 1 : 0; + case EDGE_MODE_TAG_SHARP: + return eed->sharp ? 1 : 0; + case EDGE_MODE_TAG_CREASE: + return eed->crease ? 1 : 0; + case EDGE_MODE_TAG_BEVEL: + return eed->bweight ? 1 : 0; + } + return 0; +} + + +int edgetag_shortest_path(EditEdge *source, EditEdge *target) +{ + EditMesh *em = G.editMesh; + EditEdge *eed; + EditVert *ev; + Heap *heap; EdgeHash *ehash; float *cost; - MEdge *med; - int a, *nedges, *edges, *prevedge, mednum = -1, nedgeswap = 0; - MFace *mf; + int a, totvert=0, totedge=0, *nedges, *edges, *prevedge, mednum = -1, nedgeswap = 0; - /* mark hidden edges as done, so we don't use them */ - ehash = BLI_edgehash_new(); - for (a=0, mf=me->mface; atotface; a++, mf++) { - if (!(mf->flag & ME_HIDE)) { - 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); - } - else - BLI_edgehash_insert(ehash, mf->v3, mf->v1, NULL); - } + /* we need the vert */ + for (ev= em->verts.first, totvert=0; ev; ev= ev->next) { + ev->tmp.l = totvert; + totvert++; } - for (a=0, med=me->medge; atotedge; a++, med++) - if (!BLI_edgehash_haskey(ehash, med->v1, med->v2)) - med->flag |= ME_SEAM_DONE; - - BLI_edgehash_free(ehash, NULL); + for (eed= em->edges.first; eed; eed = eed->next) { + eed->f2 = 0; + if (eed->h) { + eed->f2 |= ME_SEAM_DONE; + } + eed->tmp.l = totedge; + totedge++; + } /* alloc */ - nedges = MEM_callocN(sizeof(*nedges)*me->totvert+1, "SeamPathNEdges"); - edges = MEM_mallocN(sizeof(*edges)*me->totedge*2, "SeamPathEdges"); - prevedge = MEM_mallocN(sizeof(*prevedge)*me->totedge, "SeamPathPrevious"); - cost = MEM_mallocN(sizeof(*cost)*me->totedge, "SeamPathCost"); + nedges = MEM_callocN(sizeof(*nedges)*totvert+1, "SeamPathNEdges"); + edges = MEM_mallocN(sizeof(*edges)*totedge*2, "SeamPathEdges"); + prevedge = MEM_mallocN(sizeof(*prevedge)*totedge, "SeamPathPrevious"); + cost = MEM_mallocN(sizeof(*cost)*totedge, "SeamPathCost"); /* count edges, compute adjacent edges offsets and fill adjacent edges */ - for (a=0, med=me->medge; atotedge; a++, med++) { - nedges[med->v1+1]++; - nedges[med->v2+1]++; + for (eed= em->edges.first; eed; eed = eed->next) { + nedges[eed->v1->tmp.l+1]++; + nedges[eed->v2->tmp.l+1]++; } - for (a=1; atotvert; a++) { + for (a=1; amedge; atotedge; a++, med++) { - edges[nedges[med->v1+1]++] = a; - edges[nedges[med->v2+1]++] = a; + 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; cost[a] = 1e20f; prevedge[a] = -1; @@ -973,100 +1007,74 @@ static int seam_shortest_path(Mesh *me, int source, int target) /* 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)); - cost[source] = 0.0f; + BLI_heap_insert(heap, 0.0f, SET_INT_IN_POINTER(source->tmp.l)); + cost[source->tmp.l] = 0.0f; + + EM_init_index_arrays(1, 1, 0); + while (!BLI_heap_empty(heap)) { mednum = GET_INT_FROM_POINTER(BLI_heap_popmin(heap)); - med = me->medge + mednum; + eed = EM_get_edge_for_index( mednum ); - if (mednum == target) + if (mednum == target->tmp.l) break; - if (med->flag & ME_SEAM_DONE) + if (eed->f2 & ME_SEAM_DONE) continue; - med->flag |= ME_SEAM_DONE; + eed->f2 |= ME_SEAM_DONE; - seam_add_adjacent(me, heap, mednum, med->v1, nedges, edges, prevedge, cost); - seam_add_adjacent(me, heap, mednum, med->v2, nedges, edges, prevedge, cost); + 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); } + MEM_freeN(nedges); MEM_freeN(edges); MEM_freeN(cost); BLI_heap_free(heap, NULL); - for (a=0, med=me->medge; atotedge; a++, med++) - med->flag &= ~ME_SEAM_DONE; + for (eed= em->edges.first; eed; eed = eed->next) { + eed->f2 &= ~ME_SEAM_DONE; + } - if (mednum != target) { + if (mednum != target->tmp.l) { MEM_freeN(prevedge); + EM_free_index_arrays(); return 0; } /* follow path back to source and mark as seam */ - if (mednum == target) { + if (mednum == target->tmp.l) { short allseams = 1; - mednum = target; + mednum = target->tmp.l; do { - med = me->medge + mednum; - if (!(med->flag & ME_SEAM)) { + eed = EM_get_edge_for_index( mednum ); + if (!edgetag_context_check(eed)) { allseams = 0; break; } mednum = prevedge[mednum]; - } while (mednum != source); + } while (mednum != source->tmp.l); - mednum = target; + mednum = target->tmp.l; do { - med = me->medge + mednum; + eed = EM_get_edge_for_index( mednum ); if (allseams) - med->flag &= ~ME_SEAM; + edgetag_context_set(eed, 0); else - med->flag |= ME_SEAM; + edgetag_context_set(eed, 1); mednum = prevedge[mednum]; } while (mednum != -1); } MEM_freeN(prevedge); + EM_free_index_arrays(); return 1; } -static void seam_select(Mesh *me, short *mval, short path) -{ - unsigned int index = 0; - MEdge *medge, *med; - int a, lastindex = -1; - - if (!facesel_edge_pick(me, mval, &index)) - return; - - for (a=0, med=me->medge; atotedge; a++, med++) { - if (med->flag & ME_SEAM_LAST) { - lastindex = a; - med->flag &= ~ME_SEAM_LAST; - break; - } - } - - medge = me->medge + index; - if (!path || (lastindex == -1) || (index == lastindex) || - !seam_shortest_path(me, lastindex, index)) - medge->flag ^= ME_SEAM; - medge->flag |= ME_SEAM_LAST; - - G.f |= G_DRAWSEAMS; - - if (G.rt == 8) - unwrap_lscm(1); - - BIF_undo_push("Mark Seam"); - - object_tface_flags_changed(OBACT, 1); -} - void seam_edgehash_insert_face(EdgeHash *ehash, MFace *mf) { BLI_edgehash_insert(ehash, mf->v1, mf->v2, NULL); @@ -1154,11 +1162,6 @@ void face_select() me = get_mesh(ob); getmouseco_areawin(mval); - if (G.qual & LR_ALTKEY) { - seam_select(me, mval, (G.qual & LR_SHIFTKEY) != 0); - return; - } - if (!facesel_face_pick(me, mval, &index, 1)) return; msel= (((MFace*)me->mface)+index); diff --git a/source/blender/src/editmesh_mods.c b/source/blender/src/editmesh_mods.c index d1873d1fe56..84971e8ce0b 100644 --- a/source/blender/src/editmesh_mods.c +++ b/source/blender/src/editmesh_mods.c @@ -92,6 +92,7 @@ editmesh_mods.c, UI level access, no geometry changes #include "BDR_drawobject.h" #include "BDR_editobject.h" +#include "BDR_editface.h" #include "BSE_drawview.h" #include "BSE_edit.h" @@ -2062,6 +2063,7 @@ void loop_multiselect(int looptype) /* ***************** MAIN MOUSE SELECTION ************** */ /* just to have the functions nice together */ + static void mouse_mesh_loop(void) { EditEdge *eed; @@ -2070,36 +2072,100 @@ static void mouse_mesh_loop(void) eed= findnearestedge(&dist); if(eed) { + if (G.scene->toolsettings->edge_mode == EDGE_MODE_SELECT) { + if((G.qual & LR_SHIFTKEY)==0) EM_clear_flag_all(SELECT); - if((G.qual & LR_SHIFTKEY)==0) EM_clear_flag_all(SELECT); - - if((eed->f & SELECT)==0) select=1; - else if(G.qual & LR_SHIFTKEY) select=0; + if((eed->f & SELECT)==0) select=1; + else if(G.qual & LR_SHIFTKEY) select=0; - if(G.scene->selectmode & SCE_SELECT_FACE) { - faceloop_select(eed, select); - } - else if(G.scene->selectmode & SCE_SELECT_EDGE) { - if(G.qual == (LR_CTRLKEY | LR_ALTKEY) || G.qual == (LR_CTRLKEY | LR_ALTKEY |LR_SHIFTKEY)) - edgering_select(eed, select); - else if(G.qual & LR_ALTKEY) - edgeloop_select(eed, select); - } - else if(G.scene->selectmode & SCE_SELECT_VERTEX) { - if(G.qual == (LR_CTRLKEY | LR_ALTKEY) || G.qual == (LR_CTRLKEY | LR_ALTKEY |LR_SHIFTKEY)) - edgering_select(eed, select); - else if(G.qual & LR_ALTKEY) - edgeloop_select(eed, select); - } + if(G.scene->selectmode & SCE_SELECT_FACE) { + faceloop_select(eed, select); + } + else if(G.scene->selectmode & SCE_SELECT_EDGE) { + if(G.qual == (LR_CTRLKEY | LR_ALTKEY) || G.qual == (LR_CTRLKEY | LR_ALTKEY |LR_SHIFTKEY)) + edgering_select(eed, select); + else if(G.qual & LR_ALTKEY) + edgeloop_select(eed, select); + } + else if(G.scene->selectmode & SCE_SELECT_VERTEX) { + if(G.qual == (LR_CTRLKEY | LR_ALTKEY) || G.qual == (LR_CTRLKEY | LR_ALTKEY |LR_SHIFTKEY)) + edgering_select(eed, select); + else if(G.qual & LR_ALTKEY) + edgeloop_select(eed, select); + } - /* frontbuffer draw of last selected only */ - unified_select_draw(NULL, eed, NULL); + /* frontbuffer draw of last selected only */ + unified_select_draw(NULL, eed, NULL); - EM_selectmode_flush(); - countall(); - allqueue(REDRAWVIEW3D, 0); - if (EM_texFaceCheck()) - allqueue(REDRAWIMAGE, 0); + EM_selectmode_flush(); + countall(); + allqueue(REDRAWVIEW3D, 0); + if (EM_texFaceCheck()) + allqueue(REDRAWIMAGE, 0); + } else { /*(G.scene->toolsettings->edge_mode == EDGE_MODE_TAG_*)*/ + int act = (edgetag_context_check(eed)==0); + int path = 0; + + if (G.qual == (LR_SHIFTKEY | LR_ALTKEY) && G.editMesh->selected.last) { + EditSelection *ese = G.editMesh->selected.last; + + if(ese && ese->type == EDITEDGE) { + EditEdge *eed_act; + eed_act = (EditEdge*)ese->data; + if (eed_act != eed) { + /* If shift is pressed we need to use the last active edge, (if it exists) */ + if (edgetag_shortest_path(eed_act, eed)) { + EM_remove_selection(eed_act, EDITEDGE); + EM_select_edge(eed_act, 0); + path = 1; + } + } + } + } + if (path==0) { + edgetag_context_set(eed, act); /* switch the edge option */ + } + + if (act) { + if ((eed->f & SELECT)==0) { + EM_select_edge(eed, 1); + EM_selectmode_flush(); + countall(); + } + /* even if this is selected it may not be in the selection list */ + EM_store_selection(eed, EDITEDGE); + } else { + if (eed->f & SELECT) { + EM_select_edge(eed, 0); + /* logic is differnt from above here since if this was selected we dont know if its in the selection list or not */ + EM_remove_selection(eed, EDITEDGE); + + EM_selectmode_flush(); + countall(); + } + } + + switch (G.scene->toolsettings->edge_mode) { + case EDGE_MODE_TAG_SEAM: + G.f |= G_DRAWSEAMS; + break; + case EDGE_MODE_TAG_SHARP: + G.f |= G_DRAWSHARP; + break; + case EDGE_MODE_TAG_CREASE: + G.f |= G_DRAWCREASES; + break; + case EDGE_MODE_TAG_BEVEL: + G.f |= G_DRAWBWEIGHTS; + break; + } + + unified_select_draw(NULL, eed, NULL); + + DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); + allqueue(REDRAWVIEW3D, 0); + } + } } -- cgit v1.2.3 From 106974a9d2d5caa5188322507980e3d57d2e3517 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Thu, 8 May 2008 18:38:21 +0000 Subject: Fixing up the webplugin defines for the Makefiles. Now you can do one of the following to disable it: export NAN_NO_PLUGIN=true export WITH_BF_WEBPLUGIN=false or export WITH_BF_WEBPLUGIN=true to enable building it. (Its set to false by default) Kent --- source/Makefile | 10 ++++------ source/gameengine/GamePlayer/Makefile | 2 +- source/nan_definitions.mk | 6 +++++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/source/Makefile b/source/Makefile index e5dffbf532d..5ebff3bbbf5 100644 --- a/source/Makefile +++ b/source/Makefile @@ -315,12 +315,10 @@ ifeq ($(WITH_BF_BLENDERPLAYER), true) endif ifeq ($(WITH_BF_WEBPLUGIN), true) - ifneq ($(NAN_NO_PLUGIN), true) - BINTARGETS += plugin - ifeq ($(OS),linux) - ifeq ($(CPU),i386) - BINTARGETS += xplink - endif + BINTARGETS += plugin + ifeq ($(OS),linux) + ifeq ($(CPU),i386) + BINTARGETS += xplink endif endif endif diff --git a/source/gameengine/GamePlayer/Makefile b/source/gameengine/GamePlayer/Makefile index 747a82fc333..c4f78f23117 100644 --- a/source/gameengine/GamePlayer/Makefile +++ b/source/gameengine/GamePlayer/Makefile @@ -34,7 +34,7 @@ SOURCEDIR = source/gameengine/GamePlayer DIR = $(OCGDIR)/gameengine/GamePlayer DIRS = common ghost -ifneq ($(NAN_NO_PLUGIN),true) +ifeq ($(WITH_BF_WEBPLUGIN),true) ifeq ($(OS),$(findstring $(OS), "freebsd irix windows")) ifneq ($(FREE_WINDOWS),true) DIRS += netscape diff --git a/source/nan_definitions.mk b/source/nan_definitions.mk index 43345817f2e..e19d10dba64 100644 --- a/source/nan_definitions.mk +++ b/source/nan_definitions.mk @@ -64,7 +64,11 @@ all debug:: export WITH_BF_STATICOPENGL ?= false export WITH_BF_BLENDERGAMEENGINE ?= true export WITH_BF_BLENDERPLAYER ?= true - export WITH_BF_WEBPLUGIN ?= false + ifeq ($(NAN_NO_PLUGIN), true) + export WITH_BF_WEBPLUGIN = false + else + export WITH_BF_WEBPLUGIN ?= false + endif export NAN_MOTO ?= $(LCGDIR)/moto ifeq ($(FREE_WINDOWS), true) -- cgit v1.2.3