[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15595] branches/apricot: Apricot Branch
Revision: 15595 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15595 Author: blendix Date: 2008-07-15 23:59:46 +0200 (Tue, 15 Jul 2008) Log Message: --- Apricot Branch == * Made in game switching of GLSL options work. There is still a one frame flicker that needs to be fixed. * Added access to the estimated average framerate in the game engine: GameLogic.getAverageFrameRate(). * Added acces to the blender build info from python: Blender.Get("buildinfo") * Various GLSL optimizations to allow more constant folding in the glsl compiler, use glsl shadow functions to do shadow, instead of own code, and fix an issue with opengl texture color range. Modified Paths: -- branches/apricot/release/scripts/sysinfo.py branches/apricot/source/blender/gpu/GPU_material.h branches/apricot/source/blender/gpu/intern/gpu_codegen.c branches/apricot/source/blender/gpu/intern/gpu_extensions.c branches/apricot/source/blender/gpu/intern/gpu_material.c branches/apricot/source/blender/gpu/intern/gpu_shader_material.glsl branches/apricot/source/blender/gpu/intern/gpu_shader_material.glsl.c branches/apricot/source/blender/python/CMakeLists.txt branches/apricot/source/blender/python/SConscript branches/apricot/source/blender/python/api2_2x/Blender.c branches/apricot/source/blender/python/api2_2x/Makefile branches/apricot/source/blender/src/drawobject.c branches/apricot/source/blender/src/drawview.c branches/apricot/source/gameengine/Ketsji/BL_BlenderShader.cpp branches/apricot/source/gameengine/Ketsji/BL_BlenderShader.h branches/apricot/source/gameengine/Ketsji/KX_KetsjiEngine.cpp branches/apricot/source/gameengine/Ketsji/KX_KetsjiEngine.h branches/apricot/source/gameengine/Ketsji/KX_PythonInit.cpp branches/apricot/source/gameengine/Ketsji/KX_Scene.cpp branches/apricot/source/gameengine/PyDoc/GameLogic.py branches/apricot/source/gameengine/Rasterizer/RAS_BucketManager.cpp branches/apricot/source/gameengine/Rasterizer/RAS_BucketManager.h Modified: branches/apricot/release/scripts/sysinfo.py === --- branches/apricot/release/scripts/sysinfo.py 2008-07-15 21:08:39 UTC (rev 15594) +++ branches/apricot/release/scripts/sysinfo.py 2008-07-15 21:59:46 UTC (rev 15595) @@ -94,6 +94,8 @@ output.write(header + "\n\n") +output.write("%s\n\n" % Blender.Get('buildinfo')) + output.write("Platform: %s\n\n\n" % sys.platform) output.write("Python:\n==\n\n") Modified: branches/apricot/source/blender/gpu/GPU_material.h === --- branches/apricot/source/blender/gpu/GPU_material.h 2008-07-15 21:08:39 UTC (rev 15594) +++ branches/apricot/source/blender/gpu/GPU_material.h 2008-07-15 21:59:46 UTC (rev 15595) @@ -70,6 +70,7 @@ GPU_MAT4 = 16, GPU_TEX1D = 1001, GPU_TEX2D = 1002, + GPU_SHADOW2D = 1003, GPU_ATTRIB = 3001 } GPUType; Modified: branches/apricot/source/blender/gpu/intern/gpu_codegen.c === --- branches/apricot/source/blender/gpu/intern/gpu_codegen.c2008-07-15 21:08:39 UTC (rev 15594) +++ branches/apricot/source/blender/gpu/intern/gpu_codegen.c2008-07-15 21:59:46 UTC (rev 15595) @@ -71,7 +71,6 @@ typedef enum GPUDataSource { GPU_SOURCE_VEC_UNIFORM, - GPU_SOURCE_ARRAY_UNIFORM, GPU_SOURCE_BUILTIN, GPU_SOURCE_TEX_PIXEL, GPU_SOURCE_TEX, @@ -131,7 +130,6 @@ GPUNode *node; int type; /* datatype */ - int arraysize; /* number of elements in an array */ int source; /* data source */ int id; /* unique id as created by code generator */ @@ -140,6 +138,7 @@ int bindtex;/* input is responsible for binding the texture? */ int definetex; /* input is responsible for defining the pixel? */ int textarget; /* GL_TEXTURE_* */ + int textype;/* datatype */ struct Image *ima; /* image */ struct ImageUser *iuser;/* image user */ @@ -267,6 +266,8 @@ } } + if(!type && gpu_str_prefix(code, "sampler2DShadow")) + type= GPU_SHADOW2D; if(!type && gpu_str_prefix(code, "sampler1D")) type= GPU_TEX1D; if(!type && gpu_str_prefix(code, "sampler2D")) @@ -323,6 +324,8 @@ BLI_dynstr_append(ds, "sampler1D"); else if(function->paramtype[a] == GPU_TEX2D)
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15594] branches/soc-2008-jaguarandi: Last commit fixed the file contents..
Revision: 15594 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15594 Author: jaguarandi Date: 2008-07-15 23:08:39 +0200 (Tue, 15 Jul 2008) Log Message: --- Last commit fixed the file contents.. but some svn props were missing. So I fixed the problem with merges instead of copying files over. Also trunk/blender/release/scripts/scripttemplate_ipo_gen.py from revision 14530 was missing. (that was fixed) svn merge -r 15590:15551 https://svn.blender.org/svnroot/bf-blender/branches/soc-2008-jaguarandi (revert changes to the point where the merge was incorrect) svn merge -r 15552:15572 https://svn.blender.org/svnroot/bf-blender/branches/soc-2008-jaguarandi (apply branch modifications) svn merge -r 15392:15590 https://svn.blender.org/svnroot/bf-blender/trunk/blender (merge from trunk) Revision Links: -- http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14530 Modified Paths: -- branches/soc-2008-jaguarandi/source/gameengine/Ketsji/KX_NearSensor.cpp branches/soc-2008-jaguarandi/source/gameengine/Ketsji/KX_RadarSensor.cpp branches/soc-2008-jaguarandi/source/gameengine/Rasterizer/Makefile Added Paths: --- branches/soc-2008-jaguarandi/release/scripts/scripttemplate_ipo_gen.py branches/soc-2008-jaguarandi/source/blender/blenlib/BLI_mempool.h branches/soc-2008-jaguarandi/source/blender/blenlib/intern/BLI_mempool.c branches/soc-2008-jaguarandi/source/blender/render/intern/include/sunsky.h branches/soc-2008-jaguarandi/source/blender/render/intern/source/sunsky.c branches/soc-2008-jaguarandi/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp branches/soc-2008-jaguarandi/source/gameengine/GameLogic/SCA_ActuatorEventManager.h branches/soc-2008-jaguarandi/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp branches/soc-2008-jaguarandi/source/gameengine/GameLogic/SCA_ActuatorSensor.h Removed Paths: - branches/soc-2008-jaguarandi/release/scripts/scripttemplate_ipo_gen.py branches/soc-2008-jaguarandi/source/blender/blenlib/BLI_mempool.h branches/soc-2008-jaguarandi/source/blender/blenlib/intern/BLI_mempool.c branches/soc-2008-jaguarandi/source/blender/render/intern/include/sunsky.h branches/soc-2008-jaguarandi/source/blender/render/intern/source/sunsky.c branches/soc-2008-jaguarandi/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp branches/soc-2008-jaguarandi/source/gameengine/GameLogic/SCA_ActuatorEventManager.h branches/soc-2008-jaguarandi/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp branches/soc-2008-jaguarandi/source/gameengine/GameLogic/SCA_ActuatorSensor.h Deleted: branches/soc-2008-jaguarandi/release/scripts/scripttemplate_ipo_gen.py === --- branches/soc-2008-jaguarandi/release/scripts/scripttemplate_ipo_gen.py 2008-07-15 21:07:13 UTC (rev 15593) +++ branches/soc-2008-jaguarandi/release/scripts/scripttemplate_ipo_gen.py 2008-07-15 21:08:39 UTC (rev 15594) @@ -1,92 +0,0 @@ -#!BPY -""" -Name: 'Camera/Object Example' -Blender: 245 -Group: 'ScriptTemplate' -Tooltip: 'Script template for setting the camera direction' -""" - -from Blender import Window -import bpy - -script_data = \ -'''#!BPY -""" -Name: 'My Ipo Script' -Blender: 245 -Group: 'Animation' -Tooltip: 'Put some useful info here' -""" - -# Add a licence here if you wish to re-distribute, we recommend the GPL - -from Blender import Ipo, Mathutils, Window -import bpy, BPyMessages - -def makeRandomIpo(object, firstFrame, numberOfFrames, frameStep): - # Create an new Ipo Curve of name myIpo and type Object - myIpo = bpy.data.ipos.new('myIpo', 'Object') - - # Create LocX, LocY, and LocZ Ipo curves in our new Curve Object - # and store them so we can access them later - myIpo_x = myIpo.addCurve('LocX') - myIpo_y = myIpo.addCurve('LocY') - myIpo_z = myIpo.addCurve('LocZ') - - # What value we want to scale our random value by - ipoScale = 4 - - # This Calculates the End Frame for use in an xrange() expression - endFrame = firstFrame + (numberOfFrames * frameStep) + frameStep - - for frame in xrange(firstFrame, endFrame, frameStep): - - # Use the Mathutils Rand() function to get random numbers - ipoValue_x = Mathutils.Rand(-1, 1) * ipoScale - ipoValue_y = Mathutils.Rand(-1, 1) * ipoScale - ipoValue_z = Mathutils.Rand(-1, 1) * ipoScale - - # Append to the Ipo curve at location frame, with the value ipoValue_x - # Note that we should pass the append function a tuple or a BezTriple - myIpo_x.append((frame, ipoValue_x)) - - # Similar to above - myIpo_y.append((frame, ipoV
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15593] branches/harmonic-skeleton/source/ blender: More merging goodness
Revision: 15593 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15593 Author: theeth Date: 2008-07-15 23:07:13 +0200 (Tue, 15 Jul 2008) Log Message: --- More merging goodness fix adjacency list inline instead of having to rebuild fully reweight joined graphs properly Modified Paths: -- branches/harmonic-skeleton/source/blender/blenlib/BLI_graph.h branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c branches/harmonic-skeleton/source/blender/src/reeb.c Modified: branches/harmonic-skeleton/source/blender/blenlib/BLI_graph.h === --- branches/harmonic-skeleton/source/blender/blenlib/BLI_graph.h 2008-07-15 20:05:23 UTC (rev 15592) +++ branches/harmonic-skeleton/source/blender/blenlib/BLI_graph.h 2008-07-15 21:07:13 UTC (rev 15593) @@ -76,6 +76,7 @@ int BLI_hasAdjacencyList(BGraph *rg); void BLI_buildAdjacencyList(BGraph *rg); void BLI_rebuildAdjacencyList(BGraph* rg); +void BLI_rebuildAdjacencyListForNode(BGraph* rg, BNode *node); void BLI_freeAdjacencyList(BGraph *rg); int BLI_FlagSubgraphs(BGraph *graph); Modified: branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c === --- branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c 2008-07-15 20:05:23 UTC (rev 15592) +++ branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c 2008-07-15 21:07:13 UTC (rev 15593) @@ -90,12 +90,6 @@ node->flag++; } -void BLI_rebuildAdjacencyList(BGraph *rg) -{ - BLI_freeAdjacencyList(rg); - BLI_buildAdjacencyList(rg); -} - void BLI_buildAdjacencyList(BGraph *rg) { BNode *node; @@ -129,6 +123,38 @@ } } +void BLI_rebuildAdjacencyListForNode(BGraph* rg, BNode *node) +{ + BArc *arc; + + if (node->arcs != NULL) + { + MEM_freeN(node->arcs); + } + + node->arcs = MEM_callocN((node->degree) * sizeof(BArc*), "adjacency list"); + + /* temporary use to indicate the first index available in the lists */ + node->flag = 0; + + for(arc = rg->arcs.first; arc; arc= arc->next) + { + if (arc->head == node) + { + addArcToNodeAdjacencyList(arc->head, arc); + } + else if (arc->tail == node) + { + addArcToNodeAdjacencyList(arc->tail, arc); + } + } + + if (node->degree != node->flag) + { + printf("error in node [%p]. Added only %i arcs out of %i\n", node, node->flag, node->degree); + } +} + void BLI_freeAdjacencyList(BGraph *rg) { BNode *node; Modified: branches/harmonic-skeleton/source/blender/src/reeb.c === --- branches/harmonic-skeleton/source/blender/src/reeb.c2008-07-15 20:05:23 UTC (rev 15592) +++ branches/harmonic-skeleton/source/blender/src/reeb.c2008-07-15 21:07:13 UTC (rev 15593) @@ -328,7 +328,7 @@ copyArc(cp_rg, arc); } - BLI_rebuildAdjacencyList((BGraph*)cp_rg); + BLI_buildAdjacencyList((BGraph*)cp_rg); return cp_rg; } @@ -1063,30 +1063,51 @@ void reweightArc(ReebArc *arc, ReebNode *start_node, float start_weight) { - float delta_weight = arc->tail->weight - arc->head->weight; + ReebNode *node; + float old_weight; + float end_weight = start_weight + (arc->tail->weight - arc->head->weight); + int i; if (arc->tail == start_node) { flipArc(arc); } + node = arc->tail; + + for (i = 0; i < node->degree; i++) + { + ReebArc *next_arc = node->arcs[i]; + + if (next_arc != arc) /* prevent backtracking */ + { + reweightArc(next_arc, node, end_weight); + } + } + + old_weight = arc->head->weight; /* backup head weight, other arcs need it intact, it will be fixed by the source arc */ + arc->head->weight = start_weight; - arc->tail->weight = start_weight + delta_weight; + arc->tail->weight = end_weight; reweightBuckets(arc); resizeArcBuckets(arc); fillArcEmptyBuckets(arc); - /* recurse here */ + arc->head->weight = old_weight; } void reweightSubgraph(ReebGraph *rg, ReebNode *start_node, float start_weight) { - ReebArc *arc; - - arc = start_node->arcs[0]; - - reweightArc(arc, start_node, start_weight); + int i; + + for (i = 0; i < start_node->degree; i++) + { + ReebArc *next_arc = start_node->arcs[i]; + +
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15592] trunk/blender/source/gameengine: BGE patch: DUPLIGROUP option supported in BGE.
Revision: 15592 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15592 Author: ben2610 Date: 2008-07-15 22:05:23 +0200 (Tue, 15 Jul 2008) Log Message: --- BGE patch: DUPLIGROUP option supported in BGE. Blender duplicates groups in the 3D view at the location of objects having the DUPLIGROUP option set. This feature is now supported in the BGE: the groups will be instantiated as in the 3D view when the scene is converted. This is useful to populate a scene with multiple enemies without having to actually duplicate the objects in the blend file. Notes: * The BGE applies the same criteria to instantiate the group as Blender to display them: if you see the group in the 3D view, it will be instantiated in the BGE. * Groups are instantiated as if the object having the DUPLIGROUP option (usually an empty) executed an AddObject actuator on the top objects of the group (objects without parent). * As a result, only intra-group parent relationship is supported: the BGE will not instantiate objects that have parents outside the group. * Intra-group logic bricks connections are preserved between the duplicated objects, even between the top objects of the group. * For best result, the state engine of the objects in the group should be self-contained: logic bricks should only have intra-group connections. Use messages to communicate with state engines outside the group. * Nested groups are supported: if one or more objects in the group have the DUPLIGROUP option set, the corresponding groups will be instantiated at the corresponding position and orientation. * Nested groups are instantiated as separate groups, not as one big group. * Linked groups are supported as well as groups containing objects from the active layers. * There is a difference in the way Blender displays the groups in the 3D view and how BGE instantiates them: Blender does not take into account the parent relationship in the group and displays the objects as if they were all children of the object having the DUPLIGROUP option. That's correct for the top objects of the group but not for the children. Hence the orientation of the children objects may be different in the BGE. * An AddGroup actuator will be added in a future release. Modified Paths: -- trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp trunk/blender/source/gameengine/Ketsji/KX_GameObject.h trunk/blender/source/gameengine/Ketsji/KX_RadarSensor.cpp trunk/blender/source/gameengine/Ketsji/KX_Scene.cpp trunk/blender/source/gameengine/Ketsji/KX_Scene.h Modified: trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp === --- trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp 2008-07-15 19:38:48 UTC (rev 15591) +++ trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp 2008-07-15 20:05:23 UTC (rev 15592) @@ -1847,7 +1847,10 @@ int aspect_width; int aspect_height; vector inivel,iniang; - + set grouplist; // list of groups to be converted + set allblobj; // all objects converted + set groupobj; // objects from groups (never in active layer) + if (alwaysUseExpandFraming) { frame_type = RAS_FrameSettings::e_frame_extend; aspect_width = canvas->GetWidth(); @@ -1919,6 +1922,8 @@ for (SETLOOPER(blenderscene, base)) { Object* blenderobject = base->object; + allblobj.insert(blenderobject); + KX_GameObject* gameobj = gameobject_from_blenderobject( base->object, kxscene, @@ -2046,7 +2051,9 @@ gameobj->NodeUpdateGS(0,true); gameobj->Bucketize(); - + + if (gameobj->IsDupliGroup()) + grouplist.insert(blenderobject->dup_group); } else { @@ -2073,6 +2080,188 @@ } + if (!grouplist.empty()) + { + // now convert the group referenced by dupli group object + // keep track of all groups already converted + set allgrouplist = grouplist; + set tempglist; + // recurse + while (!grouplist.empty()) + { + set::iterator git; + tempglist.clear(); + tempglist.swap(grouplist); + for (git=tempglist.begin()
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15591] branches/harmonic-skeleton/source/ blender: Optimization method selectable at runtime
Revision: 15591 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15591 Author: theeth Date: 2008-07-15 21:38:48 +0200 (Tue, 15 Jul 2008) Log Message: --- Optimization method selectable at runtime Start multi resolution match from node, not arc (solve problem with Rinky) various uglyness being cleaned up or factored out Modified Paths: -- branches/harmonic-skeleton/source/blender/blenlib/BLI_graph.h branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c branches/harmonic-skeleton/source/blender/makesdna/DNA_scene_types.h branches/harmonic-skeleton/source/blender/src/autoarmature.c branches/harmonic-skeleton/source/blender/src/buttons_editing.c branches/harmonic-skeleton/source/blender/src/reeb.c Modified: branches/harmonic-skeleton/source/blender/blenlib/BLI_graph.h === --- branches/harmonic-skeleton/source/blender/blenlib/BLI_graph.h 2008-07-15 18:57:10 UTC (rev 15590) +++ branches/harmonic-skeleton/source/blender/blenlib/BLI_graph.h 2008-07-15 19:38:48 UTC (rev 15591) @@ -80,6 +80,8 @@ int BLI_FlagSubgraphs(BGraph *graph); +#define SHAPE_RADIX 10 /* each shape level is encoded this base */ + int BLI_subtreeShape(BNode *node, BArc *rootArc, int include_root); float BLI_subtreeLength(BNode *node, BArc *rootArc); void BLI_calcGraphLength(BGraph *graph); Modified: branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c === --- branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c 2008-07-15 18:57:10 UTC (rev 15590) +++ branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c 2008-07-15 19:38:48 UTC (rev 15591) @@ -354,7 +354,7 @@ } } - return 10 * depth + 1; + return SHAPE_RADIX * depth + 1; } } Modified: branches/harmonic-skeleton/source/blender/makesdna/DNA_scene_types.h === --- branches/harmonic-skeleton/source/blender/makesdna/DNA_scene_types.h 2008-07-15 18:57:10 UTC (rev 15590) +++ branches/harmonic-skeleton/source/blender/makesdna/DNA_scene_types.h 2008-07-15 19:38:48 UTC (rev 15591) @@ -441,8 +441,9 @@ char skgen_postpro_passes; char skgen_subdivisions[3]; char skgen_multi_level; + char skgen_optimisation_method; - char tpad[7]; + char tpad[6]; /* Alt+RMB option */ char edge_mode; Modified: branches/harmonic-skeleton/source/blender/src/autoarmature.c === --- branches/harmonic-skeleton/source/blender/src/autoarmature.c 2008-07-15 18:57:10 UTC (rev 15590) +++ branches/harmonic-skeleton/source/blender/src/autoarmature.c 2008-07-15 19:38:48 UTC (rev 15591) @@ -34,6 +34,8 @@ #include "MEM_guardedalloc.h" +#include "PIL_time.h" + #include "DNA_ID.h" #include "DNA_armature_types.h" #include "DNA_mesh_types.h" @@ -578,6 +580,8 @@ printf("\n"); } +#define MAX_COST 100 /* FIX ME */ + static float costDistance(ReebArcIterator *iter, float *vec0, float *vec1, int i0, int i1) { EmbedBucket *bucket = NULL; @@ -613,7 +617,7 @@ } else { - return FLT_MAX; + return MAX_COST; } return G.scene->toolsettings->skgen_retarget_distance_weight * max_dist; @@ -624,9 +628,34 @@ } } -static float costAngle(float original_angle, float current_angle) +static float costAngle(float original_angle, float vec_first[3], float vec_second[3], float length1, float length2) { - return 0; + if (G.scene->toolsettings->skgen_retarget_angle_weight > 0) + { + float current_angle; + + if (length1 > 0 && length2 > 0) + { + current_angle = saacos(Inpf(vec_first, vec_second)); + + if (original_angle > 0) + { + return G.scene->toolsettings->skgen_retarget_angle_weight * fabs((current_angle - original_angle) / original_angle); + } + else + { + return G.scene->toolsettings->skgen_retarget_angle_weight * fabs(current_angle); + } + } + else + { + return G.scene->toolsettings->skgen_retarget_angle_weight * M_PI; + } + } + else + { + return 0; + } } static float costLength(float original_length, float current_length) @@ -638,8 +667,7 @@ stat
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15590] trunk/blender/source/gameengine/ Ketsji: BGE bug fix (good for 2.47): radar and near sensor did not filter correctly the collisioning objects
Revision: 15590 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15590 Author: ben2610 Date: 2008-07-15 20:57:10 +0200 (Tue, 15 Jul 2008) Log Message: --- BGE bug fix (good for 2.47): radar and near sensor did not filter correctly the collisioning objects based on ACTOR flag when the parent object was added dynamically. This could result in a very big performance decrease. Modified Paths: -- trunk/blender/source/gameengine/Ketsji/KX_NearSensor.cpp trunk/blender/source/gameengine/Ketsji/KX_RadarSensor.cpp Modified: trunk/blender/source/gameengine/Ketsji/KX_NearSensor.cpp === --- trunk/blender/source/gameengine/Ketsji/KX_NearSensor.cpp2008-07-15 18:12:08 UTC (rev 15589) +++ trunk/blender/source/gameengine/Ketsji/KX_NearSensor.cpp2008-07-15 18:57:10 UTC (rev 15590) @@ -135,9 +135,6 @@ void KX_NearSensor::ReParent(SCA_IObject* parent) { - - SCA_ISensor::ReParent(parent); - m_client_info->m_gameobject = static_cast(parent); m_client_info->m_sensors.push_back(this); @@ -151,6 +148,7 @@ */ ((KX_GameObject*)GetParent())->GetSGNode()->ComputeWorldTransforms(NULL); SynchronizeTransform(); + SCA_ISensor::ReParent(parent); } Modified: trunk/blender/source/gameengine/Ketsji/KX_RadarSensor.cpp === --- trunk/blender/source/gameengine/Ketsji/KX_RadarSensor.cpp 2008-07-15 18:12:08 UTC (rev 15589) +++ trunk/blender/source/gameengine/Ketsji/KX_RadarSensor.cpp 2008-07-15 18:57:10 UTC (rev 15590) @@ -92,6 +92,10 @@ if (replica->m_physCtrl) { replica->m_physCtrl = replica->m_physCtrl->GetReplica(); + if (replica->m_physCtrl) + { + replica->m_physCtrl->setNewClientInfo(replica->m_client_info); + } } //todo: make sure replication works fine! ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15589] trunk/blender/source/gameengine/ Rasterizer/Makefile: Updated so things compile.
Revision: 15589 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15589 Author: sirdude Date: 2008-07-15 20:12:08 +0200 (Tue, 15 Jul 2008) Log Message: --- Updated so things compile. (Missing includes needed) Kent Modified Paths: -- trunk/blender/source/gameengine/Rasterizer/Makefile Modified: trunk/blender/source/gameengine/Rasterizer/Makefile === --- trunk/blender/source/gameengine/Rasterizer/Makefile 2008-07-15 17:03:59 UTC (rev 15588) +++ trunk/blender/source/gameengine/Rasterizer/Makefile 2008-07-15 18:12:08 UTC (rev 15589) @@ -41,7 +41,10 @@ CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I../../kernel/gen_system CPPFLAGS += -I../BlenderRoutines +CPPFLAGS += -I../Expressions +CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) + ifeq ($(OS),darwin) CPPFLAGS += -fpascal-strings endif ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15588] branches/soc-2008-quorn: Made suggestions case-insensitive which also puts _ prefixed items at the bottom .
Revision: 15588 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15588 Author: quorn Date: 2008-07-15 19:03:59 +0200 (Tue, 15 Jul 2008) Log Message: --- Made suggestions case-insensitive which also puts _ prefixed items at the bottom. Improvements have also been made to the way the list works, when it should disappear/update/confirm, etc. Modified Paths: -- branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py branches/soc-2008-quorn/source/blender/blenkernel/intern/suggestions.c branches/soc-2008-quorn/source/blender/src/drawtext.c Modified: branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py === --- branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py 2008-07-15 16:57:21 UTC (rev 15587) +++ branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py 2008-07-15 17:03:59 UTC (rev 15588) @@ -26,7 +26,7 @@ """Use this method when sorting a list of suggestions. """ - return cmp(x[0], y[0]) + return cmp(x[0].upper(), y[0].upper()) def cached_generate_tokens(txt, since=1): """A caching version of generate tokens for multiple parsing of the same Modified: branches/soc-2008-quorn/source/blender/blenkernel/intern/suggestions.c === --- branches/soc-2008-quorn/source/blender/blenkernel/intern/suggestions.c 2008-07-15 16:57:21 UTC (rev 15587) +++ branches/soc-2008-quorn/source/blender/blenkernel/intern/suggestions.c 2008-07-15 17:03:59 UTC (rev 15588) @@ -22,13 +22,14 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Ian Thompson. * * * END GPL LICENSE BLOCK * */ #include #include +#include #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" @@ -36,9 +37,19 @@ #include "BKE_text.h" #include "BKE_suggestions.h" -static SuggList suggestions= {NULL, NULL, NULL, NULL}; +static SuggList suggestions= {NULL, NULL, NULL, NULL, NULL}; static Text *suggText = NULL; +static SuggItem *lastInsert= NULL; +static suggest_cmp(const char *first, const char *second, int len) { + int cmp, i; + for (cmp=0, i=0; iprev = suggestions.last; suggestions.last->next = newitem; suggestions.last = newitem; } + suggestions.selected = NULL; } void suggest_prefix(const char *prefix) { SuggItem *match, *first, *last; - int cmp, len = strlen(prefix); + int cmp, len = strlen(prefix), i; if (!suggestions.first) return; if (len==0) { @@ -87,7 +98,7 @@ first = last = NULL; for (match=suggestions.first; match; match=match->next) { - cmp = strncmp(prefix, match->name, len); + cmp = suggest_cmp(prefix, match->name, len); if (cmp==0) { if (!first) first = match; @@ -103,7 +114,7 @@ suggestions.selected = suggestions.firstmatch = first; suggestions.lastmatch = last; } else { - suggestions.selected = suggestions.firstmatch = suggestions.lastmatch = NULL; + suggestions.firstmatch = suggestions.lastmatch = NULL; } } Modified: branches/soc-2008-quorn/source/blender/src/drawtext.c === --- branches/soc-2008-quorn/source/blender/src/drawtext.c 2008-07-15 16:57:21 UTC (rev 15587) +++ branches/soc-2008-quorn/source/blender/src/drawtext.c 2008-07-15 17:03:59 UTC (rev 15588) @@ -108,7 +108,7 @@ static int check_identifier(char ch); static void get_suggest_prefix(Text *text); -static void confirm_suggestion(Text *text); +static void confirm_suggestion(Text *text, int skipleft); static void *last_txt_find_string= NULL; static double last_check_time= 0; @@ -1026,7 +1026,7 @@ last = suggest_last(); sel = suggest_get_selected(); - if (!sel || !last || !first) + if (!last || !first) return 0; /* Count the visible lines to the cursor */ @@ -1100,7 +1100,10 @@ BIF_ThemeColor(TH_BACK); glRecti(x, y, x+boxw, y-boxh); + /* Set the top 'item' of the visible list */ for (i=0, item=sel; i<3 && item && item!=first; i++, item=item->prev); + if (!item) + item = first; for (i=0; inext) { @@ -1653,15 +1656,15 @@ len= text->curc-i; if (len > 255) { printf("Suggestion prefix too long\n"); - return; + len = 255; } strncpy(tmp, line+i, len); tmp[len]= '\0'; suggest_prefix(tmp); } -static void confirm_suggestion(Text *text) { - int i, len; +static void confirm_suggestio
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15587] branches/soc-2008-quorn/release/ scripts: Missed some error types and cases from previous commit
Revision: 15587 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15587 Author: quorn Date: 2008-07-15 18:57:21 +0200 (Tue, 15 Jul 2008) Log Message: --- Missed some error types and cases from previous commit Modified Paths: -- branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py branches/soc-2008-quorn/release/scripts/textplugin_suggest.py Modified: branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py === --- branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py 2008-07-15 12:55:20 UTC (rev 15586) +++ branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py 2008-07-15 16:57:21 UTC (rev 15587) @@ -235,8 +235,7 @@ # Handle special case of 'import *' if impname == '*': parent = get_module(fromname) - for symbol, attr in parent.__dict__.items(): - imports[symbol] = attr + imports.update(parent.__dict__) else: # Try importing the name as a module @@ -246,12 +245,12 @@ else: module = get_module(impname) imports[symbol] = module - except (ImportError, ValueError): + except (ImportError, ValueError, AttributeError, TypeError): # Try importing name as an attribute of the parent try: module = __import__(fromname, globals(), locals(), [impname]) imports[symbol] = getattr(module, impname) - except (ImportError, ValueError, AttributeError): + except (ImportError, ValueError, AttributeError, TypeError): pass # More to import from the same module? @@ -286,7 +285,6 @@ step = 0 for type, string, start, end, line in tokens: - print string # Look for 'def' if step == 0: Modified: branches/soc-2008-quorn/release/scripts/textplugin_suggest.py === --- branches/soc-2008-quorn/release/scripts/textplugin_suggest.py 2008-07-15 12:55:20 UTC (rev 15586) +++ branches/soc-2008-quorn/release/scripts/textplugin_suggest.py 2008-07-15 16:57:21 UTC (rev 15587) @@ -16,10 +16,20 @@ OK = False def check_membersuggest(line, c): - return c > 0 and line[c-1] == '.' + pos = line.rfind('.', 0, c) + if pos == -1: + return False + for s in line[pos+1:c]: + if not s.isalnum() and not s == '_': + return False + return True def check_imports(line, c): - return line.rfind('import ', 0, c) == c-7 or line.rfind('from ', 0, c) == c-5 + if line.rfind('import ', 0, c) == c-7: + return True + if line.rfind('from ', 0, c) == c-5: + return True + return False def main(): txt = bpy.data.texts.active ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15586] branches/soc-2008-quorn/release/ scripts: Text plugin script updates: Better error handling, variable parsing, token caching for repeat parsin
Revision: 15586 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15586 Author: quorn Date: 2008-07-15 14:55:20 +0200 (Tue, 15 Jul 2008) Log Message: --- Text plugin script updates: Better error handling, variable parsing, token caching for repeat parsing of the same document. Fixed joining of multiline statements and context detection. Modified Paths: -- branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py branches/soc-2008-quorn/release/scripts/textplugin_imports.py branches/soc-2008-quorn/release/scripts/textplugin_membersuggest.py branches/soc-2008-quorn/release/scripts/textplugin_suggest.py Modified: branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py === --- branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py 2008-07-15 12:54:57 UTC (rev 15585) +++ branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py 2008-07-15 12:55:20 UTC (rev 15586) @@ -1,6 +1,7 @@ -import bpy, sys +import bpy import __builtin__, tokenize -from tokenize import generate_tokens +from Blender.sys import time +from tokenize import generate_tokens, TokenError # TODO: Remove the dependency for a full Python installation. Currently only the # tokenize module is required @@ -17,15 +18,33 @@ 'raise', 'continue', 'finally', 'is', 'return', 'def', 'for', 'lambda', 'try' ] +# Used to cache the return value of generate_tokens +_token_cache = None +_cache_update = 0 def suggest_cmp(x, y): - """Use this method when sorting a list for suggestions""" + """Use this method when sorting a list of suggestions. + """ return cmp(x[0], y[0]) +def cached_generate_tokens(txt, since=1): + """A caching version of generate tokens for multiple parsing of the same + document within a given timescale. + """ + + global _token_cache, _cache_update + + if _cache_update < time() - since: + txt.reset() + _token_cache = [g for g in generate_tokens(txt.readline)] + _cache_update = time() + return _token_cache + def get_module(name): - """Returns the module specified by its name. This module is imported and as - such will run any initialization code specified within the module.""" + """Returns the module specified by its name. The module itself is imported + by this method and, as such, any initialization code will be executed. + """ mod = __import__(name) components = name.split('.') @@ -34,11 +53,21 @@ return mod def is_module(m): - """Taken from the inspect module of the standard Python installation""" + """Taken from the inspect module of the standard Python installation. + """ return isinstance(m, type(bpy)) def type_char(v): + """Returns the character used to signify the type of a variable. Use this + method to identify the type character for an item in a suggestion list. + + The following values are returned: + 'm' if the parameter is a module + 'f' if the parameter is callable + 'v' if the parameter is variable or otherwise indeterminable + """ + if is_module(v): return 'm' elif callable(v): @@ -46,8 +75,8 @@ else: return 'v' -def get_context(line, cursor): - """Establishes the context of the cursor in the given line +def get_context(txt): + """Establishes the context of the cursor in the given Blender Text object Returns one of: NORMAL - Cursor is in a normal context @@ -57,28 +86,43 @@ """ + l, cursor = txt.getCursorPos() + lines = txt.asLines()[:l+1] + # Detect context (in string or comment) in_str = 0 # 1-single quotes, 2-double quotes - for i in range(cursor): - if not in_str: - if line[i] == "'": in_str = 1 - elif line[i] == '"': in_str = 2 - elif line[i] == '#': return 3 # In a comment so quit + for line in lines: + if l == 0: + end = cursor else: - if in_str == 1: - if line[i] == "'": - in_str = 0 - # In again if ' escaped, out again if \ escaped, and so on - for a in range(1, i+1): - if line[i-a] == '\\': in_str = 1-in_str - else: break - elif in_str == 2: -
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15585] branches/soc-2008-jaguarandi: There was a problem with the last merge :S
Revision: 15585 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15585 Author: jaguarandi Date: 2008-07-15 14:54:57 +0200 (Tue, 15 Jul 2008) Log Message: --- There was a problem with the last merge :S Somehow it didnt finished and didnt added some files under the svn control (found thanks to lguillaume that reported some files were missing) Last merge fixed and also merged modifications up to revision 15584. I checked the diff svn diff --new . --old https://svn.blender.org/svnroot/bf-blender/trunk/blender And everything seems to be right now Revision Links: -- http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15584 Modified Paths: -- branches/soc-2008-jaguarandi/CMakeLists.txt branches/soc-2008-jaguarandi/intern/bsp/intern/BSP_CSGMesh.cpp branches/soc-2008-jaguarandi/intern/container/CTR_TaggedIndex.h branches/soc-2008-jaguarandi/intern/decimation/intern/LOD_ManMesh2.cpp branches/soc-2008-jaguarandi/intern/elbeem/intern/solver_init.cpp branches/soc-2008-jaguarandi/intern/ghost/intern/GHOST_SystemWin32.cpp branches/soc-2008-jaguarandi/intern/ghost/intern/GHOST_WindowWin32.cpp branches/soc-2008-jaguarandi/source/blender/imbuf/intern/openexr/openexr_api.cpp branches/soc-2008-jaguarandi/source/blender/render/intern/source/zbuf.c branches/soc-2008-jaguarandi/source/blender/src/buttons_editing.c branches/soc-2008-jaguarandi/source/blender/src/buttons_scene.c branches/soc-2008-jaguarandi/source/blender/src/transform_conversions.c branches/soc-2008-jaguarandi/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp branches/soc-2008-jaguarandi/source/gameengine/GameLogic/SCA_PythonController.cpp branches/soc-2008-jaguarandi/source/gameengine/GamePlayer/ActiveX/BlenderPlayerCtl.cpp branches/soc-2008-jaguarandi/source/gameengine/GamePlayer/ghost/GPG_Application.cpp branches/soc-2008-jaguarandi/source/gameengine/GamePlayer/netscape/src/ketsji/KXH_ketsji_hooks.cpp branches/soc-2008-jaguarandi/source/gameengine/Ketsji/KX_KetsjiEngine.cpp branches/soc-2008-jaguarandi/source/gameengine/Ketsji/KX_PythonInit.cpp branches/soc-2008-jaguarandi/source/gameengine/Ketsji/KX_PythonInit.h branches/soc-2008-jaguarandi/source/gameengine/Ketsji/KX_SoundActuator.cpp Added Paths: --- branches/soc-2008-jaguarandi/release/scripts/scripttemplate_ipo_gen.py branches/soc-2008-jaguarandi/source/blender/blenlib/BLI_mempool.h branches/soc-2008-jaguarandi/source/blender/blenlib/intern/BLI_mempool.c branches/soc-2008-jaguarandi/source/blender/render/intern/include/sunsky.h branches/soc-2008-jaguarandi/source/blender/render/intern/source/sunsky.c branches/soc-2008-jaguarandi/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp branches/soc-2008-jaguarandi/source/gameengine/GameLogic/SCA_ActuatorEventManager.h branches/soc-2008-jaguarandi/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp branches/soc-2008-jaguarandi/source/gameengine/GameLogic/SCA_ActuatorSensor.h Modified: branches/soc-2008-jaguarandi/CMakeLists.txt === --- branches/soc-2008-jaguarandi/CMakeLists.txt 2008-07-15 09:19:56 UTC (rev 15584) +++ branches/soc-2008-jaguarandi/CMakeLists.txt 2008-07-15 12:54:57 UTC (rev 15585) @@ -197,10 +197,17 @@ ENDIF(UNIX) IF(WIN32) + INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake) - + SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows) + # Setup 64bit and 64bit windows systems + IF(CMAKE_CL_64) +message("64 bit compiler detected.") +SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64) + ENDIF(CMAKE_CL_64) + SET(PYTHON ${LIBDIR}/python) SET(PYTHON_VERSION 2.5) SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}") @@ -214,12 +221,20 @@ SET(OPENAL_LIB openal_static) SET(OPENAL_LIBPATH ${OPENAL}/lib) - SET(PNG_LIB libpng_st) + IF(CMAKE_CL_64) + SET(PNG_LIB libpng) + ELSE(CMAKE_CL_64) + SET(PNG_LIB libpng_st) + ENDIF(CMAKE_CL_64) SET(JPEG_LIB libjpeg) SET(ZLIB ${LIBDIR}/zlib) SET(ZLIB_INC ${ZLIB}/include) - SET(ZLIB_LIB libz) + IF(CMAKE_CL_64) + SET(ZLIB_LIB zlib) + ELSE(CMAKE_CL_64) + SET(ZLIB_LIB libz) + ENDIF(CMAKE_CL_64) SET(ZLIB_LIBPATH ${ZLIB}/lib) SET(PTHREADS ${LIBDIR}/pthreads) @@ -302,7 +317,11 @@ SET(WINTAB_INC ${LIBDIR}/wintab/include) - SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib") + IF(CMAKE_CL_64) + SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib;MSVCRT.lib ") + ELSE(CMAKE_CL_64) + SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ") + ENDIF(CMAKE_CL_64) SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ") ENDIF(WIN32) Modified: branches/soc-2008-jaguarandi/intern/bsp/intern/BSP_CSGMesh.cpp
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15584] branches/soc-2008-quorn/source/ blender/python/BPY_extern.h: make gcc happy
Revision: 15584 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15584 Author: campbellbarton Date: 2008-07-15 11:19:56 +0200 (Tue, 15 Jul 2008) Log Message: --- make gcc happy Modified Paths: -- branches/soc-2008-quorn/source/blender/python/BPY_extern.h Modified: branches/soc-2008-quorn/source/blender/python/BPY_extern.h === --- branches/soc-2008-quorn/source/blender/python/BPY_extern.h 2008-07-15 07:34:46 UTC (rev 15583) +++ branches/soc-2008-quorn/source/blender/python/BPY_extern.h 2008-07-15 09:19:56 UTC (rev 15584) @@ -48,6 +48,7 @@ struct bConstraintOb; /* DNA_constraint_types.h */ struct bConstraintTarget; /* DNA_constraint_types.h*/ struct Script; /* DNA_screen_types.h */ +struct BPyMenu; #ifdef __cplusplus extern "C" { #endif ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15583] branches/soc-2008-quorn/release/ scripts: Created a BPy module BPyTextPlugin to centralize functions used across the text plugin scripts .
Revision: 15583 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15583 Author: quorn Date: 2008-07-15 09:34:46 +0200 (Tue, 15 Jul 2008) Log Message: --- Created a BPy module BPyTextPlugin to centralize functions used across the text plugin scripts. Also created two more scripts to handle imports and member suggestions. Modified Paths: -- branches/soc-2008-quorn/release/scripts/textplugin_suggest.py Added Paths: --- branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py branches/soc-2008-quorn/release/scripts/textplugin_imports.py branches/soc-2008-quorn/release/scripts/textplugin_membersuggest.py Added: branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py === --- branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py (rev 0) +++ branches/soc-2008-quorn/release/scripts/bpymodules/BPyTextPlugin.py 2008-07-15 07:34:46 UTC (rev 15583) @@ -0,0 +1,271 @@ +import bpy, sys +import __builtin__, tokenize +from tokenize import generate_tokens +# TODO: Remove the dependency for a full Python installation. Currently only the +# tokenize module is required + +# Context types +NORMAL = 0 +SINGLE_QUOTE = 1 +DOUBLE_QUOTE = 2 +COMMENT = 3 + +# Python keywords +KEYWORDS = ['and', 'del', 'from', 'not', 'while', 'as', 'elif', 'global', + 'or', 'with', 'assert', 'else', 'if', 'pass', 'yield', + 'break', 'except', 'import', 'print', 'class', 'exec', 'in', + 'raise', 'continue', 'finally', 'is', 'return', 'def', 'for', + 'lambda', 'try' ] + + +def suggest_cmp(x, y): + """Use this method when sorting a list for suggestions""" + + return cmp(x[0], y[0]) + +def get_module(name): + """Returns the module specified by its name. This module is imported and as + such will run any initialization code specified within the module.""" + + mod = __import__(name) + components = name.split('.') + for comp in components[1:]: + mod = getattr(mod, comp) + return mod + +def is_module(m): + """Taken from the inspect module of the standard Python installation""" + + return isinstance(m, type(bpy)) + +def type_char(v): + if is_module(v): + return 'm' + elif callable(v): + return 'f' + else: + return 'v' + +def get_context(line, cursor): + """Establishes the context of the cursor in the given line + + Returns one of: + NORMAL - Cursor is in a normal context + SINGLE_QUOTE - Cursor is inside a single quoted string + DOUBLE_QUOTE - Cursor is inside a double quoted string + COMMENT - Cursor is inside a comment + + """ + + # Detect context (in string or comment) + in_str = 0 # 1-single quotes, 2-double quotes + for i in range(cursor): + if not in_str: + if line[i] == "'": in_str = 1 + elif line[i] == '"': in_str = 2 + elif line[i] == '#': return 3 # In a comment so quit + else: + if in_str == 1: + if line[i] == "'": + in_str = 0 + # In again if ' escaped, out again if \ escaped, and so on + for a in range(1, i+1): + if line[i-a] == '\\': in_str = 1-in_str + else: break + elif in_str == 2: + if line[i] == '"': + in_str = 0 + # In again if " escaped, out again if \ escaped, and so on + for a in range(1, i+1): + if line[i-a] == '\\': in_str = 2-in_str + else: break + return in_str + +def current_line(txt): + """Extracts the Python script line at the cursor in the Blender Text object + provided and cursor position within this line as the tuple pair (line, + cursor)""" + + (lineindex, cursor) = txt.getCursorPos() + lines = txt.asLines() + line = lines[lineindex] + + # Join previous lines to this line if spanning + i = lineindex - 1 + while i > 0: + earlier = lines[i].rstrip() + if earlier.endswith('\\'): + line = earlier[:-1] + ' ' + line + cursor += len(earlier) + i -= 1 + + # Join later lines while th
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15582] branches/soc-2008-quorn: Any script can now register a unique key combination as part of its bpy header .
Revision: 15582 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15582 Author: quorn Date: 2008-07-15 09:04:31 +0200 (Tue, 15 Jul 2008) Log Message: --- Any script can now register a unique key combination as part of its bpy header. For a supported space type, the user may press this shortcut to invoke the script. Space types that are to support shortcuts like this should call BPY_menu_do_shortcut(...) from the event queue read method (See winqreadtextspace in drawtext.c for example) Modified Paths: -- branches/soc-2008-quorn/release/scripts/textplugin_suggest.py branches/soc-2008-quorn/source/blender/include/BIF_keyval.h branches/soc-2008-quorn/source/blender/python/BPY_extern.h branches/soc-2008-quorn/source/blender/python/BPY_interface.c branches/soc-2008-quorn/source/blender/python/BPY_menus.c branches/soc-2008-quorn/source/blender/python/BPY_menus.h branches/soc-2008-quorn/source/blender/src/drawtext.c branches/soc-2008-quorn/source/blender/src/keyval.c Modified: branches/soc-2008-quorn/release/scripts/textplugin_suggest.py === --- branches/soc-2008-quorn/release/scripts/textplugin_suggest.py 2008-07-15 05:33:12 UTC (rev 15581) +++ branches/soc-2008-quorn/release/scripts/textplugin_suggest.py 2008-07-15 07:04:31 UTC (rev 15582) @@ -3,6 +3,7 @@ Name: 'Suggest' Blender: 243 Group: 'TextPlugin' +Shortcut: 'Ctrl+Space' Tooltip: 'Suggests completions for the word at the cursor in a python script' """ @@ -72,6 +73,70 @@ return line[c-a:c].split('.') +def getImports(txt): + imports = [] + + # Unfortunately, tokenize may fail if the script leaves brackets or strings + # open. For now we return an empty list until I have a better idea. Maybe + # parse manually. + try: + tokens = getTokens(txt) + except: + return [] + + for i in range(1, len(tokens)): + + # Handle all import statements + if tokens[i-1][TK_TOKEN] == 'import': + + # Find 'from' if it exists + fr = -1 + for a in range(1, i): + if tokens[i-a][TK_TYPE] == token.NEWLINE: break + if tokens[i-a][TK_TOKEN] == 'from': + fr = i-a + break + + # Handle: import ___[.___][,___[.___]] + if fr<0: + parent = '' + + # Handle: from ___[.___] import ___[,___] + else: # fr>=0: + parent = ''.join([t[TK_TOKEN] for t in tokens[fr+1:i-1]]) + + module = '' + while i < len(tokens)-1: + if tokens[i][TK_TYPE] == token.NAME: + + # Get the module name + module = module + tokens[i][TK_TOKEN] + + if tokens[i+1][TK_TOKEN] == '.': + module += '.' + i += 1 + else: + # Add the module name and parent to the dict + imports.append((module, parent)) + module = '' + + elif tokens[i][TK_TOKEN]!=',': + break + + i += 1 + + # Process imports for: from ___ import * + for imp,frm in imports: + print imp, frm + if frm == '': + try: __import__(imp) + except: print '^ERR^' + else: + try: __import__(frm, globals(), locals(), [imp]) + except: print '^ERR^' + + + # Returns a list of tuples of symbol names and their types (name, type) where # type is one of: # m (module/class) Has its own members (includes classes) Modified: branches/soc-2008-quorn/source/blender/include/BIF_keyval.h === --- branches/soc-2008-quorn/source/blender/include/BIF_keyval.h 2008-07-15 05:33:12 UTC (rev 15581) +++ branches/soc-2008-quorn/source/blender/include/BIF_keyval.h 2008-07-15 07:04:31 UTC (rev 15582) @@ -31,6 +31,9