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:
Diffstat (limited to 'source/gameengine/Ketsji/KX_RayCast.h')
-rw-r--r--source/gameengine/Ketsji/KX_RayCast.h60
1 files changed, 18 insertions, 42 deletions
diff --git a/source/gameengine/Ketsji/KX_RayCast.h b/source/gameengine/Ketsji/KX_RayCast.h
index c3084c997a1..607dabd8afc 100644
--- a/source/gameengine/Ketsji/KX_RayCast.h
+++ b/source/gameengine/Ketsji/KX_RayCast.h
@@ -30,14 +30,12 @@
#ifndef __KX_RAYCAST_H__
#define __KX_RAYCAST_H__
-#include "PHY_IPhysicsEnvironment.h"
-#include "PHY_IPhysicsController.h"
-#include "MT_Point3.h"
-#include "MT_Vector3.h"
+class MT_Point3;
+class MT_Vector3;
+class KX_IPhysicsController;
+class PHY_IPhysicsEnvironment;
-class RAS_MeshObject;
struct KX_ClientObjectInfo;
-class KX_IPhysicsController;
/**
* Defines a function for doing a ray cast.
@@ -51,27 +49,17 @@ class KX_IPhysicsController;
*
* Returns true if a client was accepted, false if nothing found.
*/
-class KX_RayCast : public PHY_IRayCastFilterCallback
+class KX_RayCast
{
+protected:
+ KX_RayCast() {};
public:
- bool m_hitFound;
- MT_Point3 m_hitPoint;
- MT_Vector3 m_hitNormal;
- const RAS_MeshObject* m_hitMesh;
- int m_hitPolygon;
-
- KX_RayCast(KX_IPhysicsController* ignoreController, bool faceNormal);
virtual ~KX_RayCast() {}
- /**
- * The physic environment returns the ray casting result through this function
- */
- virtual void reportHit(PHY_RayCastResult* result);
-
/** ray test callback.
* either override this in your class, or use a callback wrapper.
*/
- virtual bool RayHit(KX_ClientObjectInfo* client) = 0;
+ virtual bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal) const = 0;
/**
* Callback wrapper.
@@ -83,11 +71,13 @@ public:
/// Public interface.
/// Implement bool RayHit in your class to receive ray callbacks.
- static bool RayTest(
+ static bool RayTest(KX_IPhysicsController* physics_controller,
PHY_IPhysicsEnvironment* physics_environment,
- const MT_Point3& frompoint,
+ const MT_Point3& _frompoint,
const MT_Point3& topoint,
- KX_RayCast& callback);
+ MT_Point3& result_point,
+ MT_Vector3& result_normal,
+ const KX_RayCast& callback);
};
@@ -96,32 +86,18 @@ template<class T> class KX_RayCast::Callback : public KX_RayCast
T *self;
void *data;
public:
- Callback(T *_self, KX_IPhysicsController* controller=NULL, void *_data = NULL, bool faceNormal=false)
- : KX_RayCast(controller, faceNormal),
- self(_self),
+ Callback(T *_self, void *_data = NULL)
+ : self(_self),
data(_data)
{
}
~Callback() {}
-
- virtual bool RayHit(KX_ClientObjectInfo* client)
- {
- return self->RayHit(client, this, data);
- }
-
- virtual bool needBroadphaseRayCast(PHY_IPhysicsController* controller)
+
+ virtual bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal) const
{
- KX_ClientObjectInfo* info = static_cast<KX_ClientObjectInfo*>(controller->getNewClientInfo());
-
- if (!info)
- {
- MT_assert(info && "Physics controller with no client object info");
- return false;
- }
- return self->NeedRayCast(info);
+ return self->RayHit(client, hit_point, hit_normal, data);
}
-
};