diff options
-rw-r--r-- | doc/python_api/rst/bge_types/bge.types.KX_RaySensor.rst | 6 | ||||
-rw-r--r-- | doc/python_api/rst/bge_types/bge.types.KX_TouchSensor.rst | 6 | ||||
-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 |
6 files changed, 22 insertions, 4 deletions
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_RaySensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_RaySensor.rst index 2ff989729f5..f182a84409f 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_RaySensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_RaySensor.rst @@ -51,6 +51,12 @@ base class --- :class:`SCA_ISensor` :type: list [x, y, z] + .. attribute:: hitMaterial + + The material of the object in the face hit by the ray. (read-only). + + :type: string + .. attribute:: rayDirection The direction from the ray (in worldcoordinates). (read-only). diff --git a/doc/python_api/rst/bge_types/bge.types.KX_TouchSensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_TouchSensor.rst index fd8f319f6f3..876d14bc6c8 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_TouchSensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_TouchSensor.rst @@ -39,3 +39,9 @@ base class --- :class:`SCA_ISensor` :type: :class:`CListValue` of :class:`KX_GameObject` + .. attribute:: hitMaterial + + The material of the object in the face hit by the ray. (read-only). + + :type: string + 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, |