Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Samarin <nicks1987@bigmir.net>2010-08-11 00:48:28 +0400
committerNick Samarin <nicks1987@bigmir.net>2010-08-11 00:48:28 +0400
commit3a8f3dd3f5e843ef8abad41996ebe5f7041e3807 (patch)
tree41390eb56e14df0beb83285f0f7cf71ce49e6ee5 /source/gameengine/Ketsji/KX_ObstacleSimulation.h
parent7ec16a7c6e44cc5cb5dd52a2d49dec5dbe712efc (diff)
reworked obstacle simulation in order to have two realizations: with "cell" and "ray" sampling
Diffstat (limited to 'source/gameengine/Ketsji/KX_ObstacleSimulation.h')
-rw-r--r--source/gameengine/Ketsji/KX_ObstacleSimulation.h65
1 files changed, 29 insertions, 36 deletions
diff --git a/source/gameengine/Ketsji/KX_ObstacleSimulation.h b/source/gameengine/Ketsji/KX_ObstacleSimulation.h
index 559c4f8caf8..d926e8deb71 100644
--- a/source/gameengine/Ketsji/KX_ObstacleSimulation.h
+++ b/source/gameengine/Ketsji/KX_ObstacleSimulation.h
@@ -76,22 +76,6 @@ struct KX_Obstacle
KX_GameObject* m_gameObj;
};
typedef std::vector<KX_Obstacle*> KX_Obstacles;
-/*
-struct RVO
-{
- inline RVO() : ns(0) {}
- float spos[MAX_RVO_SAMPLES*2];
- float scs[MAX_RVO_SAMPLES];
- float spen[MAX_RVO_SAMPLES];
-
- float svpen[MAX_RVO_SAMPLES];
- float svcpen[MAX_RVO_SAMPLES];
- float sspen[MAX_RVO_SAMPLES];
- float stpen[MAX_RVO_SAMPLES];
-
- int ns;
-};
-*/
class KX_ObstacleSimulation
{
@@ -101,7 +85,7 @@ protected:
MT_Scalar m_levelHeight;
bool m_enableVisualization;
- virtual KX_Obstacle* CreateObstacle(KX_GameObject* gameobj);
+ KX_Obstacle* CreateObstacle(KX_GameObject* gameobj);
public:
KX_ObstacleSimulation(MT_Scalar levelHeight, bool enableVisualization);
virtual ~KX_ObstacleSimulation();
@@ -117,36 +101,45 @@ public:
virtual void AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
MT_Vector3& velocity, MT_Scalar maxDeltaSpeed,MT_Scalar maxDeltaAngle);
-}; /* end of class KX_ObstacleSimulation*/
-
-static const int AVOID_MAX_STEPS = 128;
-struct TOICircle
-{
- TOICircle() : n(0), minToi(0), maxToi(1) {}
- float toi[AVOID_MAX_STEPS]; // Time of impact (seconds)
- float toie[AVOID_MAX_STEPS]; // Time of exit (seconds)
- float dir[AVOID_MAX_STEPS]; // Direction (radians)
- int n; // Number of samples
- float minToi, maxToi; // Min/max TOI (seconds)
-};
-
+};
class KX_ObstacleSimulationTOI: public KX_ObstacleSimulation
{
protected:
- int m_avoidSteps; // Number of sample steps
+ int m_maxSamples; // Number of sample steps
float m_minToi; // Min TOI
float m_maxToi; // Max TOI
- float m_angleWeight; // Sample selection angle weight
+ float m_velWeight; // Sample selection angle weight
+ float m_curVelWeight; // Sample selection current velocity weight
float m_toiWeight; // Sample selection TOI weight
float m_collisionWeight; // Sample selection collision weight
- std::vector<TOICircle*> m_toiCircles; // TOI circles (one per active agent)
- virtual KX_Obstacle* CreateObstacle(KX_GameObject* gameobj);
+ virtual void sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
+ const float maxDeltaAngle) = 0;
public:
KX_ObstacleSimulationTOI(MT_Scalar levelHeight, bool enableVisualization);
- ~KX_ObstacleSimulationTOI();
virtual void AdjustObstacleVelocity(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
- MT_Vector3& velocity, MT_Scalar maxDeltaSpeed,MT_Scalar maxDeltaAngle);
+ MT_Vector3& velocity, MT_Scalar maxDeltaSpeed,MT_Scalar maxDeltaAngle);
+};
+
+class KX_ObstacleSimulationTOI_rays: public KX_ObstacleSimulationTOI
+{
+protected:
+ virtual void sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
+ const float maxDeltaAngle);
+public:
+ KX_ObstacleSimulationTOI_rays(MT_Scalar levelHeight, bool enableVisualization);
+};
+
+class KX_ObstacleSimulationTOI_cells: public KX_ObstacleSimulationTOI
+{
+protected:
+ float m_bias;
+ bool m_adaptive;
+ int m_sampleRadius;
+ virtual void sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj,
+ const float maxDeltaAngle);
+public:
+ KX_ObstacleSimulationTOI_cells(MT_Scalar levelHeight, bool enableVisualization);
};
#endif