diff options
author | Porteries Tristan <republicthunderbolt9@gmail.com> | 2015-07-24 21:28:39 +0300 |
---|---|---|
committer | Porteries Tristan <republicthunderbolt9@gmail.com> | 2015-07-25 10:43:06 +0300 |
commit | 9939c189001566e1cfdbb09ecffdec177920b31a (patch) | |
tree | 6251a2acf318ace7329b937492a85e90bffcabfb /source/gameengine/Ketsji/KX_TouchSensor.cpp | |
parent | e301cf3ec2cb8caa544032238cf7a1e7bb5e2523 (diff) |
BGE: Fix T35288 Touch/Ray/Mouse sensor and Constraint actuator with material check doesn't work.
Now we look at all materials instead of the first. So m_auxilary_info is useless and removed.
Diffstat (limited to 'source/gameengine/Ketsji/KX_TouchSensor.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_TouchSensor.cpp | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index 5cb1d5f3620..593d3e844e8 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -41,6 +41,8 @@ #include "PHY_IPhysicsController.h" +#include "RAS_MeshObject.h" + #include <iostream> #include "PHY_IPhysicsEnvironment.h" @@ -219,14 +221,17 @@ bool KX_TouchSensor::BroadPhaseSensorFilterCollision(void*obj1,void*obj2) bool found = m_touchedpropname.IsEmpty(); if (!found) { - if (m_bFindMaterial) - { - if (client_info->m_auxilary_info) - { - found = (!strcmp(m_touchedpropname.Ptr(), (char*)client_info->m_auxilary_info)); + if (m_bFindMaterial) { + for (unsigned int i = 0; i < otherobj->GetMeshCount(); ++i) { + RAS_MeshObject *meshObj = otherobj->GetMesh(i); + for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) { + found = strcmp(m_touchedpropname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0; + if (found) + break; + } } - } else - { + } + else { found = (otherobj->GetProperty(m_touchedpropname) != NULL); } } @@ -255,16 +260,22 @@ bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll { bool found = m_touchedpropname.IsEmpty(); + bool hitMaterial = false; if (!found) { - if (m_bFindMaterial) - { - if (client_info->m_auxilary_info) - { - found = (!strcmp(m_touchedpropname.Ptr(), (char*)client_info->m_auxilary_info)); + if (m_bFindMaterial) { + for (unsigned int i = 0; i < gameobj->GetMeshCount(); ++i) { + RAS_MeshObject *meshObj = gameobj->GetMesh(i); + for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) { + found = strcmp(m_touchedpropname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0; + if (found) { + hitMaterial = true; + break; + } + } } - } else - { + } + else { found = (gameobj->GetProperty(m_touchedpropname) != NULL); } } @@ -278,7 +289,7 @@ bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll } m_bTriggered = true; m_hitObject = gameobj; - m_hitMaterial = (client_info->m_auxilary_info ? (char*)client_info->m_auxilary_info : ""); + m_hitMaterial = hitMaterial; //printf("KX_TouchSensor::HandleCollision\n"); } |