OLD | NEW |
1 /* | 1 /* |
2 * ***** BEGIN GPL LICENSE BLOCK ***** | 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or | 4 * This program is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU General Public License | 5 * modify it under the terms of the GNU General Public License |
6 * as published by the Free Software Foundation; either version 2 | 6 * as published by the Free Software Foundation; either version 2 |
7 * of the License, or (at your option) any later version. | 7 * of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #include "KX_PythonInit.h" | 65 #include "KX_PythonInit.h" |
66 #include "KX_PyMath.h" | 66 #include "KX_PyMath.h" |
67 #include "KX_PythonSeq.h" | 67 #include "KX_PythonSeq.h" |
68 #include "KX_ConvertPhysicsObject.h" | 68 #include "KX_ConvertPhysicsObject.h" |
69 #include "SCA_IActuator.h" | 69 #include "SCA_IActuator.h" |
70 #include "SCA_ISensor.h" | 70 #include "SCA_ISensor.h" |
71 #include "SCA_IController.h" | 71 #include "SCA_IController.h" |
72 #include "NG_NetworkScene.h" //Needed for sendMessage() | 72 #include "NG_NetworkScene.h" //Needed for sendMessage() |
73 #include "KX_ObstacleSimulation.h" | 73 #include "KX_ObstacleSimulation.h" |
74 | 74 |
| 75 #include "BKE_object.h" |
| 76 |
75 #include "BL_ActionManager.h" | 77 #include "BL_ActionManager.h" |
76 | 78 |
77 #include "PyObjectPlus.h" /* python stuff */ | 79 #include "PyObjectPlus.h" /* python stuff */ |
78 | 80 |
79 // This file defines relationships between parents and children | 81 // This file defines relationships between parents and children |
80 // in the game engine. | 82 // in the game engine. |
81 | 83 |
82 #include "KX_SG_NodeRelationships.h" | 84 #include "KX_SG_NodeRelationships.h" |
83 | 85 |
84 #include "BLI_math.h" | 86 #include "BLI_math.h" |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 void KX_GameObject::RemoveMeshes() | 711 void KX_GameObject::RemoveMeshes() |
710 { | 712 { |
711 for (size_t i=0;i<m_meshes.size();i++) | 713 for (size_t i=0;i<m_meshes.size();i++) |
712 m_meshes[i]->RemoveFromBuckets(this); | 714 m_meshes[i]->RemoveFromBuckets(this); |
713 | 715 |
714 //note: meshes can be shared, and are deleted by KX_BlenderSceneConverte
r | 716 //note: meshes can be shared, and are deleted by KX_BlenderSceneConverte
r |
715 | 717 |
716 m_meshes.clear(); | 718 m_meshes.clear(); |
717 } | 719 } |
718 | 720 |
| 721 void KX_GameObject::UpdateLod(MT_Vector3 &cam_pos) |
| 722 { |
| 723 // Handle dupligroups |
| 724 if (this->m_pInstanceObjects) { |
| 725 KX_GameObject * instob; |
| 726 int count = this->m_pInstanceObjects->GetCount(); |
| 727 for (int i = 0; i < count; i++) { |
| 728 instob = (KX_GameObject*)this->m_pInstanceObjects->GetVa
lue(i); |
| 729 instob->UpdateLod(cam_pos); |
| 730 } |
| 731 } |
| 732 |
| 733 if (this->m_lodmeshes.empty()) return; |
| 734 |
| 735 MT_Vector3 delta = this->NodeGetWorldPosition() - cam_pos; |
| 736 float distance2 = delta.length2(); |
| 737 |
| 738 int level = 0; |
| 739 Object *bob = this->GetBlenderObject(); |
| 740 LodLevel *lod = (LodLevel*) bob->lodlevels.first; |
| 741 for (; lod; lod = lod->next, level++) { |
| 742 if (!lod->source) level--; |
| 743 if (!lod->next || lod->next->distance * lod->next->distance > di
stance2) break; |
| 744 } |
| 745 |
| 746 RAS_MeshObject *mesh = this->m_lodmeshes[level]; |
| 747 |
| 748 if (mesh != this->m_meshes[0]) { |
| 749 this->GetScene()->ReplaceMesh(this, mesh, true, false); |
| 750 } |
| 751 } |
| 752 |
719 void KX_GameObject::UpdateTransform() | 753 void KX_GameObject::UpdateTransform() |
720 { | 754 { |
721 // HACK: saves function call for dynamic object, they are handled differ
ently | 755 // HACK: saves function call for dynamic object, they are handled differ
ently |
722 if (m_pPhysicsController1 && !m_pPhysicsController1->IsDyna()) | 756 if (m_pPhysicsController1 && !m_pPhysicsController1->IsDyna()) |
723 // Note that for Bullet, this does not even update the transform
of static object | 757 // Note that for Bullet, this does not even update the transform
of static object |
724 // but merely sets there collision flag to "kinematic" because t
he synchronization is· | 758 // but merely sets there collision flag to "kinematic" because t
he synchronization is· |
725 // done during physics simulation | 759 // done during physics simulation |
726 m_pPhysicsController1->SetSumoTransform(true); | 760 m_pPhysicsController1->SetSumoTransform(true); |
727 if (m_pGraphicController) | 761 if (m_pGraphicController) |
728 // update the culling tree | 762 // update the culling tree |
(...skipping 2754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3483 ········ | 3517 ········ |
3484 if (py_none_ok) { | 3518 if (py_none_ok) { |
3485 PyErr_Format(PyExc_TypeError, "%s, expect a KX_GameObject, a str
ing or None", error_prefix); | 3519 PyErr_Format(PyExc_TypeError, "%s, expect a KX_GameObject, a str
ing or None", error_prefix); |
3486 } else { | 3520 } else { |
3487 PyErr_Format(PyExc_TypeError, "%s, expect a KX_GameObject or a s
tring", error_prefix); | 3521 PyErr_Format(PyExc_TypeError, "%s, expect a KX_GameObject or a s
tring", error_prefix); |
3488 } | 3522 } |
3489 ········ | 3523 ········ |
3490 return false; | 3524 return false; |
3491 } | 3525 } |
3492 #endif // WITH_PYTHON | 3526 #endif // WITH_PYTHON |
OLD | NEW |