diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2015-09-24 18:24:20 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2015-09-24 18:24:20 +0300 |
commit | 27b3ea622f8bd313a8e2827dfec752bf2125566c (patch) | |
tree | f212e49d224ce8e1cfc3b17a64ae524711494391 /source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | |
parent | 372dff8d1dc7e24d4b2cd37de245588ecfce8bfa (diff) | |
parent | de80e687689032cb85179a1f7e89750573631d5d (diff) |
Merge remote-tracking branch 'origin/master' into cycles_camera_nodescycles_camera_nodes
Note: the branch currently crashes in blender_camera_nodes.cpp:
BL::NodeTree b_ntree = b_data.node_groups[nodes_tree_name];
The crash was introduced in:
cb7cf523e5c000609f32a382e2c0fcc57f635a42
Conflicts:
intern/cycles/SConscript
intern/cycles/blender/addon/__init__.py
intern/cycles/blender/addon/properties.py
intern/cycles/blender/blender_camera.cpp
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/svm/svm.h
intern/cycles/kernel/svm/svm_types.h
intern/cycles/render/camera.cpp
intern/cycles/render/camera.h
Diffstat (limited to 'source/gameengine/Ketsji/KX_MouseFocusSensor.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index a9f6bb0d2ff..46f27e1a2df 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -36,10 +36,13 @@ # pragma warning(disable:4786) #endif +#include <stdio.h> + #include "MT_Point3.h" #include "RAS_FramingManager.h" #include "RAS_ICanvas.h" #include "RAS_IRasterizer.h" +#include "RAS_MeshObject.h" #include "SCA_IScene.h" #include "KX_Scene.h" #include "KX_Camera.h" @@ -163,15 +166,17 @@ bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo *client_info, KX_RayCast *r } else { - if (m_bFindMaterial) - { - if (client_info->m_auxilary_info) - { - bFound = (m_propertyname== ((char*)client_info->m_auxilary_info)); + if (m_bFindMaterial) { + for (unsigned int i = 0; i < hitKXObj->GetMeshCount(); ++i) { + RAS_MeshObject *meshObj = hitKXObj->GetMesh(i); + for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) { + bFound = strcmp(m_propertyname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0; + if (bFound) + break; + } } } - else - { + else { bFound = hitKXObj->GetProperty(m_propertyname) != NULL; } } @@ -195,6 +200,8 @@ bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo *client_info, KX_RayCast *r */ bool KX_MouseFocusSensor::NeedRayCast(KX_ClientObjectInfo* client) { + KX_GameObject *hitKXObj = client->m_gameobject; + if (client->m_type > KX_ClientObjectInfo::ACTOR) { // Unknown type of object, skip it. @@ -206,14 +213,21 @@ bool KX_MouseFocusSensor::NeedRayCast(KX_ClientObjectInfo* client) { if (m_bFindMaterial) { - // not quite correct: an object may have multiple material - // should check all the material and not only the first one - if (!client->m_auxilary_info || (m_propertyname != ((char*)client->m_auxilary_info))) + bool found = false; + for (unsigned int i = 0; i < hitKXObj->GetMeshCount(); ++i) { + RAS_MeshObject *meshObj = hitKXObj->GetMesh(i); + for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) { + found = strcmp(m_propertyname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0; + if (found) + break; + } + } + if (!found) return false; } else { - if (client->m_gameobject->GetProperty(m_propertyname) == NULL) + if (hitKXObj->GetProperty(m_propertyname) == NULL) return false; } } @@ -269,8 +283,8 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam) m_kxengine->GetSceneViewport(m_kxscene, cam, area, viewport); /* Check if the mouse is in the viewport */ - if (( m_x < viewport.m_x2 && // less then right - m_x > viewport.m_x1 && // more then then left + if (( m_x < viewport.m_x2 && // less than right + m_x > viewport.m_x1 && // more than then left m_y_inv < viewport.m_y2 && // below top m_y_inv > viewport.m_y1) == 0) // above bottom { |