diff options
author | Nick Samarin <nicks1987@bigmir.net> | 2010-06-16 04:23:24 +0400 |
---|---|---|
committer | Nick Samarin <nicks1987@bigmir.net> | 2010-06-16 04:23:24 +0400 |
commit | 700c32e73833205830b062a13270e4a45668cad0 (patch) | |
tree | f8d684cdb2e487442cbff49abd8305e6f779a5d5 /source/gameengine/Ketsji/KX_NavMeshObject.cpp | |
parent | 147e8d01ebd7b04d81e2094669d8bc9b0f005f19 (diff) |
- registration obstacle in game object
- creation obstacle on object replication (including navmesh object)
- creation object transform for navigation mesh directly from blender object instead of using SGNode world transform (because SGNode doesn't exists yet when building navmesh on ProcessReplica)
Diffstat (limited to 'source/gameengine/Ketsji/KX_NavMeshObject.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_NavMeshObject.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.cpp b/source/gameengine/Ketsji/KX_NavMeshObject.cpp index 31c46865f4a..6c2301b6d8c 100644 --- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp +++ b/source/gameengine/Ketsji/KX_NavMeshObject.cpp @@ -42,6 +42,7 @@ extern "C" { #include "Value.h" #include "Recast.h" #include "DetourStatNavMeshBuilder.h" +#include "KX_ObstacleSimulation.h" static const int MAX_PATH_LEN = 256; static const float polyPickExt[3] = {2, 4, 2}; @@ -91,7 +92,13 @@ CValue* KX_NavMeshObject::GetReplica() void KX_NavMeshObject::ProcessReplica() { KX_GameObject::ProcessReplica(); + BuildNavMesh(); + KX_Scene* scene = KX_GetActiveScene(); + KX_ObstacleSimulation* obssimulation = scene->GetObstacleSimulation(); + if (obssimulation) + obssimulation->AddObstaclesForNavMesh(this); + } bool KX_NavMeshObject::BuildVertIndArrays(RAS_MeshObject* meshobj, float *&vertices, int& nverts, @@ -171,7 +178,16 @@ bool KX_NavMeshObject::BuildNavMesh() return false; //prepare vertices and indices - MT_Transform worldTransform = GetSGNode()->GetWorldTransform(); + struct Object* blenderobject = GetBlenderObject(); + MT_Point3 posobj; + posobj.setValue(blenderobject->loc[0]+blenderobject->dloc[0], + blenderobject->loc[1]+blenderobject->dloc[1], + blenderobject->loc[2]+blenderobject->dloc[2]); + MT_Vector3 eulxyzobj(blenderobject->rot); + MT_Vector3 scaleobj(blenderobject->size); + MT_Matrix3x3 rotMatrix(eulxyzobj); + MT_Transform worldTransform(posobj, rotMatrix.scaled(scaleobj[0], scaleobj[1], scaleobj[2])); + MT_Point3 pos; for (int i=0; i<nverts; i++) { |