Revision: 30389
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30389
Author:   nicks
Date:     2010-07-15 20:41:29 +0200 (Thu, 15 Jul 2010)

Log Message:
-----------
- added options to enable visualization for obstacle simulation and steering 
actuator
- added python attributes for parameters of steering actuator

Modified Paths:
--------------
    branches/soc-2010-nicks/release/scripts/ui/properties_game.py
    branches/soc-2010-nicks/source/blender/blenlib/BLI_math_vector.h
    branches/soc-2010-nicks/source/blender/blenlib/intern/math_vector_inline.c
    branches/soc-2010-nicks/source/blender/editors/space_logic/logic_window.c
    branches/soc-2010-nicks/source/blender/makesdna/DNA_actuator_types.h
    branches/soc-2010-nicks/source/blender/makesdna/DNA_scene_types.h
    branches/soc-2010-nicks/source/blender/makesrna/intern/rna_actuator.c
    branches/soc-2010-nicks/source/blender/makesrna/intern/rna_scene.c
    branches/soc-2010-nicks/source/gameengine/Converter/KX_ConvertActuators.cpp
    branches/soc-2010-nicks/source/gameengine/Ketsji/KX_NavMeshObject.cpp
    branches/soc-2010-nicks/source/gameengine/Ketsji/KX_NavMeshObject.h
    branches/soc-2010-nicks/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp
    branches/soc-2010-nicks/source/gameengine/Ketsji/KX_ObstacleSimulation.h
    branches/soc-2010-nicks/source/gameengine/Ketsji/KX_Scene.cpp
    branches/soc-2010-nicks/source/gameengine/Ketsji/KX_SteeringActuator.cpp
    branches/soc-2010-nicks/source/gameengine/Ketsji/KX_SteeringActuator.h

Modified: branches/soc-2010-nicks/release/scripts/ui/properties_game.py
===================================================================
--- branches/soc-2010-nicks/release/scripts/ui/properties_game.py       
2010-07-15 18:34:25 UTC (rev 30388)
+++ branches/soc-2010-nicks/release/scripts/ui/properties_game.py       
2010-07-15 18:41:29 UTC (rev 30389)
@@ -557,7 +557,8 @@
 
         layout.prop(gs, "obstacle_simulation", text = "Type")
         if gs.obstacle_simulation != 'None':
-            layout.prop(gs, "level_height", text="Level height")
+            layout.prop(gs, "level_height")
+            layout.prop(gs, "show_obstacle_simulation")
                        
 
 classes = [

Modified: branches/soc-2010-nicks/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- branches/soc-2010-nicks/source/blender/blenlib/BLI_math_vector.h    
2010-07-15 18:34:25 UTC (rev 30388)
+++ branches/soc-2010-nicks/source/blender/blenlib/BLI_math_vector.h    
2010-07-15 18:41:29 UTC (rev 30389)
@@ -121,7 +121,7 @@
 MINLINE int is_zero_v3(float a[3]);
 MINLINE int is_one_v3(float a[3]);
 
-MINLINE int equals_v3v3(float a[3], float b[3]);
+MINLINE int equals_v3v3(const float a[3],const float b[3]);
 MINLINE int compare_v3v3(float a[3], float b[3], float limit);
 MINLINE int compare_len_v3v3(float a[3], float b[3], float limit);
 

Modified: 
branches/soc-2010-nicks/source/blender/blenlib/intern/math_vector_inline.c
===================================================================
--- branches/soc-2010-nicks/source/blender/blenlib/intern/math_vector_inline.c  
2010-07-15 18:34:25 UTC (rev 30388)
+++ branches/soc-2010-nicks/source/blender/blenlib/intern/math_vector_inline.c  
2010-07-15 18:41:29 UTC (rev 30389)
@@ -404,7 +404,7 @@
        return (v[0] == 1 && v[1] == 1 && v[2] == 1);
 }
 
-MINLINE int equals_v3v3(float *v1, float *v2)
+MINLINE int equals_v3v3(const float *v1,const  float *v2)
 {
        return ((v1[0]==v2[0]) && (v1[1]==v2[1]) && (v1[2]==v2[2]));
 }

Modified: 
branches/soc-2010-nicks/source/blender/editors/space_logic/logic_window.c
===================================================================
--- branches/soc-2010-nicks/source/blender/editors/space_logic/logic_window.c   
2010-07-15 18:34:25 UTC (rev 30388)
+++ branches/soc-2010-nicks/source/blender/editors/space_logic/logic_window.c   
2010-07-15 18:41:29 UTC (rev 30389)
@@ -4324,7 +4324,11 @@
        row = uiLayoutRow(layout, 0);
        uiItemR(row, ptr, "selfterminated", 0, NULL, 0);
        if (RNA_enum_get(ptr, "mode")==ACT_STEERING_PATHFOLLOWING)
+       {
                uiItemR(row, ptr, "updateperiod", 0, NULL, 0);  
+               row = uiLayoutRow(layout, 0);
+       }
+       uiItemR(row, ptr, "enablevisualization", 0, NULL, 0);   
 }
 
 

Modified: branches/soc-2010-nicks/source/blender/makesdna/DNA_actuator_types.h
===================================================================
--- branches/soc-2010-nicks/source/blender/makesdna/DNA_actuator_types.h        
2010-07-15 18:34:25 UTC (rev 30388)
+++ branches/soc-2010-nicks/source/blender/makesdna/DNA_actuator_types.h        
2010-07-15 18:41:29 UTC (rev 30389)
@@ -522,6 +522,7 @@
 #define ACT_STEERING_PATHFOLLOWING   2
 /* steeringactuator->flag */
 #define ACT_STEERING_SELFTERMINATED   1
+#define ACT_STEERING_ENABLEVISUALIZATION   2
 
 #endif
 

Modified: branches/soc-2010-nicks/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/soc-2010-nicks/source/blender/makesdna/DNA_scene_types.h   
2010-07-15 18:34:25 UTC (rev 30388)
+++ branches/soc-2010-nicks/source/blender/makesdna/DNA_scene_types.h   
2010-07-15 18:41:29 UTC (rev 30389)
@@ -516,6 +516,7 @@
 #define GAME_GLSL_NO_EXTRA_TEX                         (1 << 11)
 #define GAME_IGNORE_DEPRECATION_WARNINGS       (1 << 12)
 #define GAME_ENABLE_ANIMATION_RECORD           (1 << 13)
+#define GAME_SHOW_OBSTACLE_SIMULATION          (1 << 14)
 
 /* GameData.matmode */
 #define GAME_MAT_TEXFACE       0

Modified: branches/soc-2010-nicks/source/blender/makesrna/intern/rna_actuator.c
===================================================================
--- branches/soc-2010-nicks/source/blender/makesrna/intern/rna_actuator.c       
2010-07-15 18:34:25 UTC (rev 30388)
+++ branches/soc-2010-nicks/source/blender/makesrna/intern/rna_actuator.c       
2010-07-15 18:41:29 UTC (rev 30389)
@@ -1926,6 +1926,11 @@
        RNA_def_property_ui_text(prop, "Self terminated", "Terminate when 
target is reached");
        RNA_def_property_update(prop, NC_LOGIC, NULL);
 
+       prop= RNA_def_property(srna, "enablevisualization", PROP_BOOLEAN, 
PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", 
ACT_STEERING_ENABLEVISUALIZATION);
+       RNA_def_property_ui_text(prop, "Visualize", "Enable debug 
visualization");
+       RNA_def_property_update(prop, NC_LOGIC, NULL);
+
        prop= RNA_def_property(srna, "updateperiod", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "updateTime");
        RNA_def_property_ui_range(prop, -1, 100000, 1, 1);

Modified: branches/soc-2010-nicks/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- branches/soc-2010-nicks/source/blender/makesrna/intern/rna_scene.c  
2010-07-15 18:34:25 UTC (rev 30388)
+++ branches/soc-2010-nicks/source/blender/makesrna/intern/rna_scene.c  
2010-07-15 18:41:29 UTC (rev 30389)
@@ -1862,6 +1862,10 @@
        RNA_def_property_ui_text(prop, "Level height", "Max difference in 
heights of obstacles to enable their interaction");
        RNA_def_property_update(prop, NC_SCENE, NULL);
 
+       prop= RNA_def_property(srna, "show_obstacle_simulation", PROP_BOOLEAN, 
PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", 
GAME_SHOW_OBSTACLE_SIMULATION);
+       RNA_def_property_ui_text(prop, "Visualization", "Enable debug 
visualization for obstacle simulation");
+
        /* Recast Settings */
        prop= RNA_def_property(srna, "recast_data", PROP_POINTER, PROP_NONE);
        RNA_def_property_flag(prop, PROP_NEVER_NULL);

Modified: 
branches/soc-2010-nicks/source/gameengine/Converter/KX_ConvertActuators.cpp
===================================================================
--- branches/soc-2010-nicks/source/gameengine/Converter/KX_ConvertActuators.cpp 
2010-07-15 18:34:25 UTC (rev 30388)
+++ branches/soc-2010-nicks/source/gameengine/Converter/KX_ConvertActuators.cpp 
2010-07-15 18:41:29 UTC (rev 30389)
@@ -1058,11 +1058,12 @@
                                }
 
                                bool selfTerminated = (stAct->flag & 
ACT_STEERING_SELFTERMINATED) !=0;
+                               bool enableVisualization = (stAct->flag & 
ACT_STEERING_ENABLEVISUALIZATION) !=0;
                                KX_SteeringActuator *tmpstact
                                        = new KX_SteeringActuator(gameobj, 
mode, targetob, navmeshob,stAct->dist, 
                                                                
stAct->velocity, stAct->acceleration, stAct->turnspeed, 
                                                                selfTerminated, 
stAct->updateTime,
-                                                               
scene->GetObstacleSimulation());
+                                                               
scene->GetObstacleSimulation(), enableVisualization);
                                baseact = tmpstact;
                                break;
                        }

Modified: branches/soc-2010-nicks/source/gameengine/Ketsji/KX_NavMeshObject.cpp
===================================================================
--- branches/soc-2010-nicks/source/gameengine/Ketsji/KX_NavMeshObject.cpp       
2010-07-15 18:34:25 UTC (rev 30388)
+++ branches/soc-2010-nicks/source/gameengine/Ketsji/KX_NavMeshObject.cpp       
2010-07-15 18:41:29 UTC (rev 30389)
@@ -446,6 +446,13 @@
 
 bool KX_NavMeshObject::BuildNavMesh()
 {
+       if (m_navMesh)
+       {
+               delete m_navMesh;
+               m_navMesh = NULL;
+       }
+
+
        if (GetMeshCount()==0)
                return false;
 
@@ -628,25 +635,23 @@
        return m_navMesh;
 }
 
-void KX_NavMeshObject::DrawNavMesh()
+void KX_NavMeshObject::DrawNavMesh(NavMeshRenderMode renderMode)
 {
        if (!m_navMesh)
                return;
        MT_Vector3 color(0.f, 0.f, 0.f);
        
-       enum RenderMode {POLYS ,DETAILED_TRIS, WALLS};
-       static const RenderMode renderMode = DETAILED_TRIS;// DETAILED_TRIS 
POLYS
        switch (renderMode)
        {
-       case POLYS :
-       case WALLS : 
+       case RM_POLYS :
+       case RM_WALLS : 
                for (int pi=0; pi<m_navMesh->getPolyCount(); pi++)
                {
                        const dtStatPoly* poly = m_navMesh->getPoly(pi);
 
                        for (int i = 0, j = (int)poly->nv-1; i < (int)poly->nv; 
j = i++)
                        {       
-                               if (poly->n[j] && renderMode==WALLS) 
+                               if (poly->n[j] && renderMode==RM_WALLS) 
                                        continue;
                                const float* vif = 
m_navMesh->getVertex(poly->v[i]);
                                const float* vjf = 
m_navMesh->getVertex(poly->v[j]);
@@ -658,7 +663,7 @@
                        }
                }
                break;
-       case DETAILED_TRIS : 
+       case RM_TRIS : 
                for (int i = 0; i < m_navMesh->getPolyDetailCount(); ++i)
                {
                        const dtStatPoly* p = m_navMesh->getPoly(i);
@@ -800,7 +805,7 @@
        Methods,
        0,
        0,
-       &CValue::Type,
+       &KX_GameObject::Type,
        0,0,0,0,0,0,
        py_base_new
 };
@@ -814,6 +819,7 @@
        KX_PYMETHODTABLE(KX_NavMeshObject, findPath),
        KX_PYMETHODTABLE(KX_NavMeshObject, raycast),
        KX_PYMETHODTABLE(KX_NavMeshObject, draw),
+       KX_PYMETHODTABLE(KX_NavMeshObject, rebuild),
        {NULL,NULL} //Sentinel
 };
 
@@ -854,11 +860,31 @@
        return PyFloat_FromDouble(hit);
 }
 
-KX_PYMETHODDEF_DOC_NOARGS(KX_NavMeshObject, draw,
-                                  "draw(): navigation mesh debug drawing\n")
+KX_PYMETHODDEF_DOC(KX_NavMeshObject, draw,
+                                  "draw(mode): navigation mesh debug drawing\n"
+                                  "mode: WALLS, POLYS, TRIS\n")
 {
-       DrawNavMesh();
+       char* mode;
+       NavMeshRenderMode renderMode = RM_TRIS;
+       if (PyArg_ParseTuple(args,"s:rebuild",&mode))
+       {
+               STR_String mode_str(mode);
+               if (mode_str.IsEqualNoCase("WALLS"))
+                       renderMode = RM_WALLS;
+               else if (mode_str.IsEqualNoCase("POLYS"))
+                       renderMode = RM_POLYS;
+               else if (mode_str.IsEqualNoCase("TRIS"))
+                       renderMode = RM_TRIS;
+       }
+       DrawNavMesh(renderMode);
        Py_RETURN_NONE;
 }
 
+KX_PYMETHODDEF_DOC_NOARGS(KX_NavMeshObject, rebuild,
+                                                 "rebuild(): rebuild 
navigation mesh\n")
+{
+       BuildNavMesh();
+       Py_RETURN_NONE;
+}
+
 #endif // DISABLE_PYTHON
\ No newline at end of file

Modified: branches/soc-2010-nicks/source/gameengine/Ketsji/KX_NavMeshObject.h
===================================================================
--- branches/soc-2010-nicks/source/gameengine/Ketsji/KX_NavMeshObject.h 
2010-07-15 18:34:25 UTC (rev 30388)
+++ branches/soc-2010-nicks/source/gameengine/Ketsji/KX_NavMeshObject.h 
2010-07-15 18:41:29 UTC (rev 30389)
@@ -60,7 +60,9 @@
        dtStatNavMesh* GetNavMesh();
        int FindPath(const MT_Point3& from, const MT_Point3& to, float* path, 
int maxPathLen);
        float Raycast(const MT_Point3& from, const MT_Point3& to);
-       void DrawNavMesh();
+
+       enum NavMeshRenderMode {RM_WALLS, RM_POLYS, RM_TRIS};
+       void DrawNavMesh(NavMeshRenderMode mode);
        void DrawPath(const float *path, int pathLen, const MT_Vector3& color);
 
        MT_Point3 TransformToLocalCoords(const MT_Point3& wpos);

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to