Revision: 29377
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29377
Author:   nicks
Date:     2010-06-10 02:19:06 +0200 (Thu, 10 Jun 2010)

Log Message:
-----------
Added parameters for obstacle avoidance simulation: for object - flag for 
creation representation in simulation(OB_HASOBSTACLE) and obstacle radius 
(obstacleRad), for scene - obstacle simulation type (obstacleSimulation); added 
ui for new parameters

Modified Paths:
--------------
    branches/soc-2010-nicks/release/scripts/ui/properties_game.py
    branches/soc-2010-nicks/source/blender/blenkernel/intern/object.c
    branches/soc-2010-nicks/source/blender/blenkernel/intern/scene.c
    branches/soc-2010-nicks/source/blender/makesdna/DNA_object_types.h
    branches/soc-2010-nicks/source/blender/makesdna/DNA_scene_types.h
    branches/soc-2010-nicks/source/blender/makesrna/intern/rna_object.c
    branches/soc-2010-nicks/source/blender/makesrna/intern/rna_scene.c
    
branches/soc-2010-nicks/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    branches/soc-2010-nicks/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp
    branches/soc-2010-nicks/source/gameengine/Ketsji/KX_Scene.cpp
    branches/soc-2010-nicks/source/gameengine/Ketsji/KX_Scene.h

Modified: branches/soc-2010-nicks/release/scripts/ui/properties_game.py
===================================================================
--- branches/soc-2010-nicks/release/scripts/ui/properties_game.py       
2010-06-09 21:27:44 UTC (rev 29376)
+++ branches/soc-2010-nicks/release/scripts/ui/properties_game.py       
2010-06-10 00:19:06 UTC (rev 29377)
@@ -194,8 +194,32 @@
         if wide_ui:
             col = split.column()
         col.prop(game, "collision_compound", text="Compound")
+               
+class PHYSICS_PT_game_obstacles(PhysicsButtonsPanel):
+    bl_label = "Create obstacle"
 
+    def poll(self, context):
+        game = context.object.game
+        rd = context.scene.render
+        return (game.physics_type in ('DYNAMIC', 'RIGID_BODY', 'SENSOR', 
'SOFT_BODY', 'STATIC')) and (rd.engine == 'BLENDER_GAME')
 
+    def draw_header(self, context):
+        game = context.active_object.game
+
+        self.layout.prop(game, "create_obstacle", text="")
+
+    def draw(self, context):
+        layout = self.layout
+
+        game = context.active_object.game
+        wide_ui = context.region.width > narrowui
+
+        layout.active = game.create_obstacle
+
+        split = layout.split()
+        col = split.column()
+        col.prop(game, "obstacle_radius", text="Radius")
+
 class RenderButtonsPanel(bpy.types.Panel):
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
@@ -510,10 +534,21 @@
             col.label(text="Logic Steps:")
             col.prop(gs, "logic_step_max", text="Max")
 
+class WORLD_PT_game_physics_obstacles(WorldButtonsPanel):
+    bl_label = "Obstacle simulation"
 
+    def draw(self, context):
+        layout = self.layout
+
+        gs = context.scene.game_data
+        wide_ui = context.region.width > narrowui
+
+        layout.prop(gs, "obstacle_simulation", text = "Type")
+
 classes = [
     PHYSICS_PT_game_physics,
     PHYSICS_PT_game_collision_bounds,
+    PHYSICS_PT_game_obstacles,
 
     RENDER_PT_game,
     RENDER_PT_game_player,
@@ -525,7 +560,8 @@
     WORLD_PT_game_context_world,
     WORLD_PT_game_world,
     WORLD_PT_game_mist,
-    WORLD_PT_game_physics]
+    WORLD_PT_game_physics,
+    WORLD_PT_game_physics_obstacles]
 
 
 def register():

Modified: branches/soc-2010-nicks/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/soc-2010-nicks/source/blender/blenkernel/intern/object.c   
2010-06-09 21:27:44 UTC (rev 29376)
+++ branches/soc-2010-nicks/source/blender/blenkernel/intern/object.c   
2010-06-10 00:19:06 UTC (rev 29377)
@@ -1028,6 +1028,7 @@
        ob->margin = 0.0;
        /* ob->pad3 == Contact Processing Threshold */
        ob->m_contactProcessingThreshold = 1.;
+       ob->obstacleRad = 1.;
        
        /* NT fluid sim defaults */
        ob->fluidsimFlag = 0;

Modified: branches/soc-2010-nicks/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/soc-2010-nicks/source/blender/blenkernel/intern/scene.c    
2010-06-09 21:27:44 UTC (rev 29376)
+++ branches/soc-2010-nicks/source/blender/blenkernel/intern/scene.c    
2010-06-10 00:19:06 UTC (rev 29377)
@@ -472,6 +472,8 @@
        sce->gm.flag = GAME_DISPLAY_LISTS;
        sce->gm.matmode = GAME_MAT_MULTITEX;
 
+       sce->gm.obstacleSimulation= OBSTSIMULATION_NONE;
+
        sound_create_scene(sce);
 
        return sce;

Modified: branches/soc-2010-nicks/source/blender/makesdna/DNA_object_types.h
===================================================================
--- branches/soc-2010-nicks/source/blender/makesdna/DNA_object_types.h  
2010-06-09 21:27:44 UTC (rev 29376)
+++ branches/soc-2010-nicks/source/blender/makesdna/DNA_object_types.h  
2010-06-10 00:19:06 UTC (rev 29377)
@@ -182,6 +182,8 @@
        float max_vel; /* clamp the maximum velocity 0.0 is disabled */
        float min_vel; /* clamp the maximum velocity 0.0 is disabled */
        float m_contactProcessingThreshold;
+       float obstacleRad;
+       char pad0[4];
        
        short rotmode;          /* rotation mode - uses defines set out in 
DNA_action_types.h for PoseChannel rotations... */
        
@@ -465,6 +467,7 @@
 #define OB_OCCLUDER            0x40000
 #define OB_SENSOR              0x80000
 #define OB_NAVMESH             0x100000
+#define OB_HASOBSTACLE 0x200000
 
 /* ob->gameflag2 */
 #define OB_NEVER_DO_ACTIVITY_CULLING   1

Modified: branches/soc-2010-nicks/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/soc-2010-nicks/source/blender/makesdna/DNA_scene_types.h   
2010-06-09 21:27:44 UTC (rev 29376)
+++ branches/soc-2010-nicks/source/blender/makesdna/DNA_scene_types.h   
2010-06-10 00:19:06 UTC (rev 29377)
@@ -451,10 +451,11 @@
         * bit 3: (gameengine): Activity culling is enabled.
         * bit 5: (gameengine) : enable Bullet DBVT tree for view frustrum 
culling
        */
-       short mode, flag, matmode, pad[3];
+       short mode, flag, matmode, pad[6];
        short occlusionRes;             /* resolution of occlusion Z buffer in 
pixel */
        short physicsEngine;
        short ticrate, maxlogicstep, physubstep, maxphystep;
+       short obstacleSimulation;
 
        /*  standalone player */
        struct GameFraming framing;
@@ -488,6 +489,10 @@
 #define WOPHY_ODE              4
 #define WOPHY_BULLET   5
 
+/* obstacleSimulation */
+#define OBSTSIMULATION_NONE            0
+#define OBSTSIMULATION_TOI             1
+
 /* GameData.flag */
 #define GAME_ENABLE_ALL_FRAMES                         (1 << 1)
 #define GAME_SHOW_DEBUG_PROPS                          (1 << 2)

Modified: branches/soc-2010-nicks/source/blender/makesrna/intern/rna_object.c
===================================================================
--- branches/soc-2010-nicks/source/blender/makesrna/intern/rna_object.c 
2010-06-09 21:27:44 UTC (rev 29376)
+++ branches/soc-2010-nicks/source/blender/makesrna/intern/rna_object.c 
2010-06-10 00:19:06 UTC (rev 29377)
@@ -1269,6 +1269,15 @@
        RNA_def_property_pointer_sdna(prop, NULL, "bsoft");
        RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for 
Bullet soft body simulation");
 
+       prop= RNA_def_property(srna, "create_obstacle", PROP_BOOLEAN, 
PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_HASOBSTACLE);
+       RNA_def_property_ui_text(prop, "Create obstacle", "Create 
representation for obstacle simulation");
+
+       prop= RNA_def_property(srna, "obstacle_radius", PROP_FLOAT, 
PROP_NONE|PROP_UNIT_LENGTH);
+       RNA_def_property_float_sdna(prop, NULL, "obstacleRad");
+       RNA_def_property_range(prop, 0.0, 1000.0);
+       RNA_def_property_ui_text(prop, "Obstacle Radius", "Radius of object 
representation in obstacle simulation");
+
        /* state */
 
        prop= RNA_def_property(srna, "state", PROP_BOOLEAN, PROP_LAYER_MEMBER);

Modified: branches/soc-2010-nicks/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- branches/soc-2010-nicks/source/blender/makesrna/intern/rna_scene.c  
2010-06-09 21:27:44 UTC (rev 29376)
+++ branches/soc-2010-nicks/source/blender/makesrna/intern/rna_scene.c  
2010-06-10 00:19:06 UTC (rev 29377)
@@ -1511,6 +1511,11 @@
                {GAME_MAT_GLSL, "GLSL", 0, "GLSL", "OpenGL shading language 
shaders"},
                {0, NULL, 0, NULL, NULL}};
 
+       static EnumPropertyItem obstacle_simulation_items[] = {
+               {OBSTSIMULATION_NONE, "NONE", 0, "None", ""},
+               {OBSTSIMULATION_TOI, "TOI", 0, "TOI", ""},
+               {0, NULL, 0, NULL, NULL}};
+
        srna= RNA_def_struct(brna, "SceneGameData", NULL);
        RNA_def_struct_sdna(srna, "GameData");
        RNA_def_struct_nested(brna, srna, "Scene");
@@ -1748,6 +1753,13 @@
        RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", 
GAME_GLSL_NO_EXTRA_TEX);
        RNA_def_property_ui_text(prop, "GLSL Extra Textures", "Use extra 
textures like normal or specular maps for GLSL rendering");
        RNA_def_property_update(prop, NC_SCENE|NA_EDITED, NULL);
+
+       /* obstacle simulation */
+       prop= RNA_def_property(srna, "obstacle_simulation", PROP_ENUM, 
PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "obstacleSimulation");
+       RNA_def_property_enum_items(prop, obstacle_simulation_items);
+       RNA_def_property_ui_text(prop, "Obstacle simulation", "Simulation used 
for obstacle avoidance in the game engine");
+       RNA_def_property_update(prop, NC_SCENE, NULL);
 }
 
 static void rna_def_scene_render_layer(BlenderRNA *brna)

Modified: 
branches/soc-2010-nicks/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- 
branches/soc-2010-nicks/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    2010-06-09 21:27:44 UTC (rev 29376)
+++ 
branches/soc-2010-nicks/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    2010-06-10 00:19:06 UTC (rev 29377)
@@ -2647,7 +2647,8 @@
                for ( i=0;i<objectlist->GetCount();i++)
                {
                        KX_GameObject* gameobj = 
static_cast<KX_GameObject*>(objectlist->GetValue(i));
-                       if (gameobj->IsDynamic())
+                       struct Object* blenderobject = 
gameobj->GetBlenderObject();
+                       if (blenderobject->gameflag & OB_HASOBSTACLE)
                        {
                                obssimulation->AddObstacleForObj(gameobj);
                        }

Modified: 
branches/soc-2010-nicks/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp
===================================================================
--- branches/soc-2010-nicks/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp  
2010-06-09 21:27:44 UTC (rev 29376)
+++ branches/soc-2010-nicks/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp  
2010-06-10 00:19:06 UTC (rev 29377)
@@ -36,9 +36,12 @@
 #include "KX_NavMeshObject.h"
 #include "KX_PythonInit.h"
 #include "DNA_object_types.h"
-#include "math.h"
-#define M_PI       3.14159265358979323846
+#include <math.h>
 
+#ifndef M_PI
+#define M_PI           3.14159265358979323846
+#endif
+
 int sweepCircleCircle(const MT_Vector3& pos0, const MT_Scalar r0, const 
MT_Vector2& v,
                                          const MT_Vector3& pos1, const 
MT_Scalar r1,
                                          float& tmin, float& tmax)
@@ -168,7 +171,7 @@
        struct Object* blenderobject = gameobj->GetBlenderObject();
        obstacle->m_type = KX_OBSTACLE_OBJ;
        obstacle->m_shape = KX_OBSTACLE_CIRCLE;
-       obstacle->m_rad = blenderobject->inertia; //.todo use radius of 
collision shape bound sphere 
+       obstacle->m_rad = blenderobject->obstacleRad;
        obstacle->m_gameObj = gameobj;
        
 }
@@ -235,12 +238,21 @@
 void KX_ObstacleSimulation::DrawObstacles()
 {
        static const MT_Vector3 bluecolor(0,0,1);
+       static const MT_Vector3 normal(0.,0.,1.);
+       static const int SECTORS_NUM = 32;
        for (size_t i=0; i<m_obstacles.size(); i++)
        {
                if (m_obstacles[i]->m_shape==KX_OBSTACLE_SEGMENT)
                {
                        KX_RasterizerDrawDebugLine(m_obstacles[i]->m_pos, 
m_obstacles[i]->m_pos2, bluecolor);
                }
+/*
+               else if (m_obstacles[i]->m_shape==KX_OBSTACLE_CIRCLE)
+               {

@@ 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