[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29553] branches/soc-2010-nicks: Added:
Nick Samarin
nicks1987 at bigmir.net
Sat Jun 19 01:48:52 CEST 2010
Revision: 29553
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29553
Author: nicks
Date: 2010-06-19 01:48:52 +0200 (Sat, 19 Jun 2010)
Log Message:
-----------
Added:
- obstacle culling for correct simulation in 3d
- flag for steering actuator termination on reaching target
- path recalculation period
- advance by waypoints (for path following)
Modified Paths:
--------------
branches/soc-2010-nicks/release/scripts/ui/properties_game.py
branches/soc-2010-nicks/source/blender/blenkernel/intern/scene.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_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-06-18 23:13:24 UTC (rev 29552)
+++ branches/soc-2010-nicks/release/scripts/ui/properties_game.py 2010-06-18 23:48:52 UTC (rev 29553)
@@ -544,6 +544,9 @@
wide_ui = context.region.width > narrowui
layout.prop(gs, "obstacle_simulation", text = "Type")
+ if gs.obstacle_simulation != 'None':
+ layout.prop(gs, "level_height", text="Level height")
+
classes = [
PHYSICS_PT_game_physics,
Modified: branches/soc-2010-nicks/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/soc-2010-nicks/source/blender/blenkernel/intern/scene.c 2010-06-18 23:13:24 UTC (rev 29552)
+++ branches/soc-2010-nicks/source/blender/blenkernel/intern/scene.c 2010-06-18 23:48:52 UTC (rev 29553)
@@ -473,6 +473,7 @@
sce->gm.matmode = GAME_MAT_MULTITEX;
sce->gm.obstacleSimulation= OBSTSIMULATION_NONE;
+ sce->gm.levelHeight = 2.f;
sound_create_scene(sce);
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-06-18 23:13:24 UTC (rev 29552)
+++ branches/soc-2010-nicks/source/blender/editors/space_logic/logic_window.c 2010-06-18 23:48:52 UTC (rev 29553)
@@ -4276,6 +4276,10 @@
row = uiLayoutRow(layout, 0);
uiItemR(row, ptr, "acceleration", 0, NULL, 0);
uiItemR(row, ptr, "turnspeed", 0, NULL, 0);
+ 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);
}
Modified: branches/soc-2010-nicks/source/blender/makesdna/DNA_actuator_types.h
===================================================================
--- branches/soc-2010-nicks/source/blender/makesdna/DNA_actuator_types.h 2010-06-18 23:13:24 UTC (rev 29552)
+++ branches/soc-2010-nicks/source/blender/makesdna/DNA_actuator_types.h 2010-06-18 23:48:52 UTC (rev 29553)
@@ -215,12 +215,14 @@
} bArmatureActuator;
typedef struct bSteeringActuator {
- char pad[4];
+ char pad[7];
+ char flag;
int type; /* 0=seek, 1=flee, 2=path following */
float dist;
float velocity;
float acceleration;
float turnspeed;
+ int updateTime;
struct Object *target;
struct Object *navmesh;
} bSteeringActuator;
@@ -518,6 +520,8 @@
#define ACT_STEERING_SEEK 0
#define ACT_STEERING_FLEE 1
#define ACT_STEERING_PATHFOLLOWING 2
+/* steeringactuator->flag */
+#define ACT_STEERING_SELFTERMINATED 1
#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-06-18 23:13:24 UTC (rev 29552)
+++ branches/soc-2010-nicks/source/blender/makesdna/DNA_scene_types.h 2010-06-18 23:48:52 UTC (rev 29553)
@@ -451,11 +451,12 @@
* bit 3: (gameengine): Activity culling is enabled.
* bit 5: (gameengine) : enable Bullet DBVT tree for view frustrum culling
*/
- short mode, flag, matmode, pad[6];
+ short mode, flag, matmode/*, pad[2]*/;
short occlusionRes; /* resolution of occlusion Z buffer in pixel */
short physicsEngine;
short ticrate, maxlogicstep, physubstep, maxphystep;
short obstacleSimulation;
+ float levelHeight;
/* standalone player */
struct GameFraming framing;
Modified: branches/soc-2010-nicks/source/blender/makesrna/intern/rna_actuator.c
===================================================================
--- branches/soc-2010-nicks/source/blender/makesrna/intern/rna_actuator.c 2010-06-18 23:13:24 UTC (rev 29552)
+++ branches/soc-2010-nicks/source/blender/makesrna/intern/rna_actuator.c 2010-06-18 23:48:52 UTC (rev 29553)
@@ -1897,6 +1897,17 @@
RNA_def_property_ui_text(prop, "Target Object", "Set target object");
RNA_def_property_update(prop, NC_LOGIC, NULL);
+ prop= RNA_def_property(srna, "selfterminated", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_STEERING_SELFTERMINATED);
+ 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, "updateperiod", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "updateTime");
+ RNA_def_property_ui_range(prop, -1, 100000, 1, 1);
+ RNA_def_property_ui_text(prop, "Update period", "Path update period");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
prop= RNA_def_property(srna, "navmesh", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_pointer_sdna(prop, NULL, "navmesh");
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-18 23:13:24 UTC (rev 29552)
+++ branches/soc-2010-nicks/source/blender/makesrna/intern/rna_scene.c 2010-06-18 23:48:52 UTC (rev 29553)
@@ -1760,6 +1760,13 @@
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);
+
+ prop= RNA_def_property(srna, "level_height", PROP_FLOAT, PROP_ACCELERATION);
+ RNA_def_property_float_sdna(prop, NULL, "levelHeight");
+ RNA_def_property_range(prop, 0.0f, 200.0f);
+ 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);
+
}
static void rna_def_scene_render_layer(BlenderRNA *brna)
Modified: branches/soc-2010-nicks/source/gameengine/Converter/KX_ConvertActuators.cpp
===================================================================
--- branches/soc-2010-nicks/source/gameengine/Converter/KX_ConvertActuators.cpp 2010-06-18 23:13:24 UTC (rev 29552)
+++ branches/soc-2010-nicks/source/gameengine/Converter/KX_ConvertActuators.cpp 2010-06-18 23:48:52 UTC (rev 29553)
@@ -1057,10 +1057,12 @@
break;
}
+ bool selfTerminated = (stAct->flag & ACT_STEERING_SELFTERMINATED) !=0;
KX_SteeringActuator *tmpstact
= new KX_SteeringActuator(gameobj, mode, targetob, navmeshob,stAct->dist,
- stAct->velocity, stAct->acceleration, stAct->turnspeed,
- scene->GetObstacleSimulation());
+ stAct->velocity, stAct->acceleration, stAct->turnspeed,
+ selfTerminated, stAct->updateTime,
+ scene->GetObstacleSimulation());
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-06-18 23:13:24 UTC (rev 29552)
+++ branches/soc-2010-nicks/source/gameengine/Ketsji/KX_NavMeshObject.cpp 2010-06-18 23:48:52 UTC (rev 29553)
@@ -333,32 +333,53 @@
if (!m_navMesh)
return;
MT_Vector3 color(0.f, 0.f, 0.f);
-
- for (int i = 0; i < m_navMesh->getPolyDetailCount(); ++i)
+
+ enum RenderMode {DETAILED_TRIS, WALLS};
+ static const RenderMode renderMode = DETAILED_TRIS;
+ switch (renderMode)
{
- const dtStatPoly* p = m_navMesh->getPoly(i);
- const dtStatPolyDetail* pd = m_navMesh->getPolyDetail(i);
+ case WALLS :
+ for (int pi=0; pi<m_navMesh->getPolyCount(); pi++)
+ {
+ const dtStatPoly* poly = m_navMesh->getPoly(pi);
- for (int j = 0; j < pd->ntris; ++j)
+ for (int i = 0, j = (int)poly->nv-1; i < (int)poly->nv; j = i++)
+ {
+ if (poly->n[j]) continue;
+ const float* vj = m_navMesh->getVertex(poly->v[j]);
+ const float* vi = m_navMesh->getVertex(poly->v[i]);
+ KX_RasterizerDrawDebugLine(MT_Vector3(vj[0], vj[2], vj[1]), MT_Vector3(vi[0], vi[2], vi[1]), color);
+ }
+ }
+ break;
+ case DETAILED_TRIS :
+ for (int i = 0; i < m_navMesh->getPolyDetailCount(); ++i)
{
- const unsigned char* t = m_navMesh->getDetailTri(pd->tbase+j);
- MT_Vector3 tri[3];
- for (int k = 0; k < 3; ++k)
+ const dtStatPoly* p = m_navMesh->getPoly(i);
+ const dtStatPolyDetail* pd = m_navMesh->getPolyDetail(i);
+
+ for (int j = 0; j < pd->ntris; ++j)
{
- const float* v;
- if (t[k] < p->nv)
- v = m_navMesh->getVertex(p->v[t[k]]);
- else
- v = m_navMesh->getDetailVertex(pd->vbase+(t[k]-p->nv));
- float pos[3];
- vcopy(pos, v);
- flipAxes(pos);
- tri[k].setValue(pos);
+ const unsigned char* t = m_navMesh->getDetailTri(pd->tbase+j);
+ MT_Vector3 tri[3];
+ for (int k = 0; k < 3; ++k)
+ {
+ const float* v;
+ if (t[k] < p->nv)
+ v = m_navMesh->getVertex(p->v[t[k]]);
+ else
+ v = m_navMesh->getDetailVertex(pd->vbase+(t[k]-p->nv));
+ float pos[3];
+ vcopy(pos, v);
+ flipAxes(pos);
+ tri[k].setValue(pos);
+ }
+
+ for (int k=0; k<3; k++)
+ KX_RasterizerDrawDebugLine(tri[k], tri[(k+1)%3], color);
}
-
- for (int k=0; k<3; k++)
- KX_RasterizerDrawDebugLine(tri[k], tri[(k+1)%3], color);
}
+ break;
}
}
Modified: branches/soc-2010-nicks/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp
===================================================================
--- branches/soc-2010-nicks/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp 2010-06-18 23:13:24 UTC (rev 29552)
+++ branches/soc-2010-nicks/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp 2010-06-18 23:48:52 UTC (rev 29553)
@@ -166,7 +166,8 @@
return 0;
}
-KX_ObstacleSimulation::KX_ObstacleSimulation()
+KX_ObstacleSimulation::KX_ObstacleSimulation(MT_Scalar levelHeight)
+: m_levelHeight(levelHeight)
{
}
@@ -285,12 +286,51 @@
else if (m_obstacles[i]->m_shape==KX_OBSTACLE_CIRCLE)
{
KX_RasterizerDrawDebugCircle(m_obstacles[i]->m_pos, m_obstacles[i]->m_rad, bluecolor,
- normal.normalized(), SECTORS_NUM);
+ normal, SECTORS_NUM);
}
}
}
-KX_ObstacleSimulationTOI::KX_ObstacleSimulationTOI():
+static MT_Point3 nearestPointToObstacle(MT_Point3& pos ,KX_Obstacle* obstacle)
+{
+ switch (obstacle->m_shape)
+ {
+ case KX_OBSTACLE_SEGMENT :
+ {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list