diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2014-01-24 08:10:04 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2014-01-24 08:10:45 +0400 |
commit | 67f1fd25ee6361df5f84e254eea103fe7952125f (patch) | |
tree | f4ce1a7de5059810b192ffe3b506ff9f95c53917 /source | |
parent | 52f2c8aec5e29ed81fd81ebfd8f9965c470a765a (diff) |
game engine: implement hitMaterial for collision and ray sensors
Reviewed By: moguri, kupoman
Differential Revision: https://developer.blender.org/D167
Diffstat (limited to 'source')
-rw-r--r-- | source/gameengine/Ketsji/KX_RaySensor.cpp | 7 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_RaySensor.h | 1 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_TouchSensor.cpp | 5 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_TouchSensor.h | 1 |
4 files changed, 10 insertions, 4 deletions
diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index afd39557130..84e615b61ab 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -64,9 +64,8 @@ KX_RaySensor::KX_RaySensor(class SCA_EventManager* eventmgr, m_bXRay(bXRay), m_distance(distance), m_scene(ketsjiScene), - m_axis(axis) - - + m_axis(axis), + m_hitMaterial("") { Init(); } @@ -144,6 +143,7 @@ bool KX_RaySensor::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void m_hitNormal[1] = result->m_hitNormal[1]; m_hitNormal[2] = result->m_hitNormal[2]; + m_hitMaterial = (client->m_auxilary_info ? (char*)client->m_auxilary_info : ""); } // no multi-hit search yet return true; @@ -356,6 +356,7 @@ PyAttributeDef KX_RaySensor::Attributes[] = { KX_PYATTRIBUTE_FLOAT_ARRAY_RO("hitPosition", KX_RaySensor, m_hitPosition, 3), KX_PYATTRIBUTE_FLOAT_ARRAY_RO("rayDirection", KX_RaySensor, m_rayDirection, 3), KX_PYATTRIBUTE_FLOAT_ARRAY_RO("hitNormal", KX_RaySensor, m_hitNormal, 3), + KX_PYATTRIBUTE_STRING_RO("hitMaterial", KX_RaySensor, m_hitMaterial), KX_PYATTRIBUTE_RO_FUNCTION("hitObject", KX_RaySensor, pyattr_get_hitobject), { NULL } //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h index ca14867e892..09e99fe0013 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.h +++ b/source/gameengine/Ketsji/KX_RaySensor.h @@ -56,6 +56,7 @@ class KX_RaySensor : public SCA_ISensor SCA_IObject* m_hitObject; float m_hitNormal[3]; float m_rayDirection[3]; + STR_String m_hitMaterial; public: KX_RaySensor(class SCA_EventManager* eventmgr, diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index b231a2191ed..3ff6587e837 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -102,7 +102,8 @@ KX_TouchSensor::KX_TouchSensor(SCA_EventManager* eventmgr,KX_GameObject* gameobj :SCA_ISensor(gameobj,eventmgr), m_touchedpropname(touchedpropname), m_bFindMaterial(bFindMaterial), -m_bTouchPulse(bTouchPulse) +m_bTouchPulse(bTouchPulse), +m_hitMaterial("") /*m_sumoObj(sumoObj),*/ { // KX_TouchEventManager* touchmgr = (KX_TouchEventManager*) eventmgr; @@ -281,6 +282,7 @@ bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll } m_bTriggered = true; m_hitObject = gameobj; + m_hitMaterial = (client->m_auxilary_info ? (char*)client->m_auxilary_info : ""); //printf("KX_TouchSensor::HandleCollision\n"); } @@ -324,6 +326,7 @@ PyAttributeDef KX_TouchSensor::Attributes[] = { KX_PYATTRIBUTE_STRING_RW("propName",0,MAX_PROP_NAME,false,KX_TouchSensor,m_touchedpropname), KX_PYATTRIBUTE_BOOL_RW("useMaterial",KX_TouchSensor,m_bFindMaterial), KX_PYATTRIBUTE_BOOL_RW("usePulseCollision",KX_TouchSensor,m_bTouchPulse), + KX_PYATTRIBUTE_STRING_RO("hitMaterial", KX_TouchSensor, m_hitMaterial), KX_PYATTRIBUTE_RO_FUNCTION("hitObject", KX_TouchSensor, pyattr_get_object_hit), KX_PYATTRIBUTE_RO_FUNCTION("hitObjectList", KX_TouchSensor, pyattr_get_object_hit_list), { NULL } //Sentinel diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h index 6bd606db8eb..0edca44296a 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.h +++ b/source/gameengine/Ketsji/KX_TouchSensor.h @@ -73,6 +73,7 @@ protected: SCA_IObject* m_hitObject; class CListValue* m_colliders; + STR_String m_hitMaterial; public: KX_TouchSensor(class SCA_EventManager* eventmgr, |