Changeset View
Changeset View
Standalone View
Standalone View
source/gameengine/GameLogic/SCA_ObjectActuator.cpp
- This file was moved from source/gameengine/Ketsji/KX_ObjectActuator.cpp.
| Show All 22 Lines | |||||
| * | * | ||||
| * The Original Code is: all of this file. | * The Original Code is: all of this file. | ||||
| * | * | ||||
| * Contributor(s): none yet. | * Contributor(s): none yet. | ||||
| * | * | ||||
| * ***** END GPL LICENSE BLOCK ***** | * ***** END GPL LICENSE BLOCK ***** | ||||
| */ | */ | ||||
| /** \file gameengine/Ketsji/KX_ObjectActuator.cpp | /** \file gameengine/GameLogic/SCA_ObjectActuator.cpp | ||||
| * \ingroup ketsji | * \ingroup gamelogic | ||||
| */ | */ | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include "KX_ObjectActuator.h" | #include "SCA_ObjectActuator.h" | ||||
| #include "KX_GameObject.h" | #include "KX_GameObject.h" | ||||
| #include "KX_PyMath.h" // For PyVecTo - should this include be put in PyObjectPlus? | #include "KX_PyMath.h" // For PyVecTo - should this include be put in PyObjectPlus? | ||||
| #include "PHY_IPhysicsController.h" | #include "PHY_IPhysicsController.h" | ||||
| #include "PHY_ICharacter.h" | #include "PHY_ICharacter.h" | ||||
| #include "PHY_IPhysicsEnvironment.h" | #include "PHY_IPhysicsEnvironment.h" | ||||
| /* ------------------------------------------------------------------------- */ | /* ------------------------------------------------------------------------- */ | ||||
| /* Native functions */ | /* Native functions */ | ||||
| /* ------------------------------------------------------------------------- */ | /* ------------------------------------------------------------------------- */ | ||||
| KX_ObjectActuator:: | SCA_ObjectActuator:: SCA_ObjectActuator( | ||||
| KX_ObjectActuator( | |||||
| SCA_IObject* gameobj, | SCA_IObject* gameobj, | ||||
| KX_GameObject* refobj, | KX_GameObject* refobj, | ||||
| const MT_Vector3& force, | const MT_Vector3& force, | ||||
| const MT_Vector3& torque, | const MT_Vector3& torque, | ||||
| const MT_Vector3& dloc, | const MT_Vector3& dloc, | ||||
| const MT_Vector3& drot, | const MT_Vector3& drot, | ||||
| const MT_Vector3& linV, | const MT_Vector3& linV, | ||||
| const MT_Vector3& angV, | const MT_Vector3& angV, | ||||
| const short damping, | const short damping, | ||||
| const KX_LocalFlags& flag | const KX_LocalFlags& flag | ||||
| ) : | ) : | ||||
| SCA_IActuator(gameobj, KX_ACT_OBJECT), | SCA_IActuator(gameobj, SCA_ACT_OBJECT), | ||||
| m_force(force), | m_force(force), | ||||
| m_torque(torque), | m_torque(torque), | ||||
| m_dloc(dloc), | m_dloc(dloc), | ||||
| m_drot(drot), | m_drot(drot), | ||||
| m_linear_velocity(linV), | m_linear_velocity(linV), | ||||
| m_angular_velocity(angV), | m_angular_velocity(angV), | ||||
| m_linear_length2(0.0), | m_linear_length2(0.0), | ||||
| m_current_linear_factor(0.0), | m_current_linear_factor(0.0), | ||||
| Show All 25 Lines | if (!character) | ||||
| m_bitLocalFlag.CharacterMotion = false; | m_bitLocalFlag.CharacterMotion = false; | ||||
| } | } | ||||
| } | } | ||||
| if (m_reference) | if (m_reference) | ||||
| m_reference->RegisterActuator(this); | m_reference->RegisterActuator(this); | ||||
| UpdateFuzzyFlags(); | UpdateFuzzyFlags(); | ||||
| } | } | ||||
| KX_ObjectActuator::~KX_ObjectActuator() | SCA_ObjectActuator::~SCA_ObjectActuator() | ||||
| { | { | ||||
| if (m_reference) | if (m_reference) | ||||
| m_reference->UnregisterActuator(this); | m_reference->UnregisterActuator(this); | ||||
| } | } | ||||
| bool KX_ObjectActuator::Update() | bool SCA_ObjectActuator::Update() | ||||
| { | { | ||||
| bool bNegativeEvent = IsNegativeEvent(); | bool bNegativeEvent = IsNegativeEvent(); | ||||
| RemoveAllEvents(); | RemoveAllEvents(); | ||||
| KX_GameObject *parent = static_cast<KX_GameObject *>(GetParent()); | KX_GameObject *parent = static_cast<KX_GameObject *>(GetParent()); | ||||
| PHY_ICharacter *character = parent->GetScene()->GetPhysicsEnvironment()->GetCharacterController(parent); | PHY_ICharacter *character = parent->GetScene()->GetPhysicsEnvironment()->GetCharacterController(parent); | ||||
| ▲ Show 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | if (bNegativeEvent) { | ||||
| } | } | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| CValue* KX_ObjectActuator::GetReplica() | CValue* SCA_ObjectActuator::GetReplica() | ||||
| { | { | ||||
| KX_ObjectActuator* replica = new KX_ObjectActuator(*this);//m_float,GetName()); | SCA_ObjectActuator* replica = new SCA_ObjectActuator(*this);//m_float,GetName()); | ||||
| replica->ProcessReplica(); | replica->ProcessReplica(); | ||||
| return replica; | return replica; | ||||
| } | } | ||||
| void KX_ObjectActuator::ProcessReplica() | void SCA_ObjectActuator::ProcessReplica() | ||||
| { | { | ||||
| SCA_IActuator::ProcessReplica(); | SCA_IActuator::ProcessReplica(); | ||||
| if (m_reference) | if (m_reference) | ||||
| m_reference->RegisterActuator(this); | m_reference->RegisterActuator(this); | ||||
| } | } | ||||
| bool KX_ObjectActuator::UnlinkObject(SCA_IObject* clientobj) | bool SCA_ObjectActuator::UnlinkObject(SCA_IObject* clientobj) | ||||
| { | { | ||||
| if (clientobj == (SCA_IObject*)m_reference) | if (clientobj == (SCA_IObject*)m_reference) | ||||
| { | { | ||||
| // this object is being deleted, we cannot continue to use it as reference. | // this object is being deleted, we cannot continue to use it as reference. | ||||
| m_reference = NULL; | m_reference = NULL; | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| void KX_ObjectActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map) | void SCA_ObjectActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map) | ||||
| { | { | ||||
| void **h_obj = (*obj_map)[m_reference]; | void **h_obj = (*obj_map)[m_reference]; | ||||
| if (h_obj) { | if (h_obj) { | ||||
| if (m_reference) | if (m_reference) | ||||
| m_reference->UnregisterActuator(this); | m_reference->UnregisterActuator(this); | ||||
| m_reference = (KX_GameObject*)(*h_obj); | m_reference = (KX_GameObject*)(*h_obj); | ||||
| m_reference->RegisterActuator(this); | m_reference->RegisterActuator(this); | ||||
| } | } | ||||
| } | } | ||||
| /* some 'standard' utilities... */ | /* some 'standard' utilities... */ | ||||
| bool KX_ObjectActuator::isValid(KX_ObjectActuator::KX_OBJECT_ACT_VEC_TYPE type) | bool SCA_ObjectActuator::isValid(SCA_ObjectActuator::KX_OBJECT_ACT_VEC_TYPE type) | ||||
| { | { | ||||
| bool res = false; | bool res = false; | ||||
| res = (type > KX_OBJECT_ACT_NODEF) && (type < KX_OBJECT_ACT_MAX); | res = (type > KX_OBJECT_ACT_NODEF) && (type < KX_OBJECT_ACT_MAX); | ||||
| return res; | return res; | ||||
| } | } | ||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| /* ------------------------------------------------------------------------- */ | /* ------------------------------------------------------------------------- */ | ||||
| /* Python functions */ | /* Python functions */ | ||||
| /* ------------------------------------------------------------------------- */ | /* ------------------------------------------------------------------------- */ | ||||
| /* Integration hooks ------------------------------------------------------- */ | /* Integration hooks ------------------------------------------------------- */ | ||||
| PyTypeObject KX_ObjectActuator::Type = { | PyTypeObject SCA_ObjectActuator::Type = { | ||||
| PyVarObject_HEAD_INIT(NULL, 0) | PyVarObject_HEAD_INIT(NULL, 0) | ||||
| "KX_ObjectActuator", | "SCA_ObjectActuator", | ||||
| sizeof(PyObjectPlus_Proxy), | sizeof(PyObjectPlus_Proxy), | ||||
| 0, | 0, | ||||
| py_base_dealloc, | py_base_dealloc, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| py_base_repr, | py_base_repr, | ||||
| 0,0,0,0,0,0,0,0,0, | 0,0,0,0,0,0,0,0,0, | ||||
| Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, | ||||
| 0,0,0,0,0,0,0, | 0,0,0,0,0,0,0, | ||||
| Methods, | Methods, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| &SCA_IActuator::Type, | &SCA_IActuator::Type, | ||||
| 0,0,0,0,0,0, | 0,0,0,0,0,0, | ||||
| py_base_new | py_base_new | ||||
| }; | }; | ||||
| PyMethodDef KX_ObjectActuator::Methods[] = { | PyMethodDef SCA_ObjectActuator::Methods[] = { | ||||
| {NULL,NULL} //Sentinel | {NULL,NULL} //Sentinel | ||||
| }; | }; | ||||
| PyAttributeDef KX_ObjectActuator::Attributes[] = { | PyAttributeDef SCA_ObjectActuator::Attributes[] = { | ||||
| KX_PYATTRIBUTE_VECTOR_RW_CHECK("force", -1000, 1000, false, KX_ObjectActuator, m_force, PyUpdateFuzzyFlags), | KX_PYATTRIBUTE_VECTOR_RW_CHECK("force", -1000, 1000, false, SCA_ObjectActuator, m_force, PyUpdateFuzzyFlags), | ||||
| KX_PYATTRIBUTE_BOOL_RW("useLocalForce", KX_ObjectActuator, m_bitLocalFlag.Force), | KX_PYATTRIBUTE_BOOL_RW("useLocalForce", SCA_ObjectActuator, m_bitLocalFlag.Force), | ||||
| KX_PYATTRIBUTE_VECTOR_RW_CHECK("torque", -1000, 1000, false, KX_ObjectActuator, m_torque, PyUpdateFuzzyFlags), | KX_PYATTRIBUTE_VECTOR_RW_CHECK("torque", -1000, 1000, false, SCA_ObjectActuator, m_torque, PyUpdateFuzzyFlags), | ||||
| KX_PYATTRIBUTE_BOOL_RW("useLocalTorque", KX_ObjectActuator, m_bitLocalFlag.Torque), | KX_PYATTRIBUTE_BOOL_RW("useLocalTorque", SCA_ObjectActuator, m_bitLocalFlag.Torque), | ||||
| KX_PYATTRIBUTE_VECTOR_RW_CHECK("dLoc", -1000, 1000, false, KX_ObjectActuator, m_dloc, PyUpdateFuzzyFlags), | KX_PYATTRIBUTE_VECTOR_RW_CHECK("dLoc", -1000, 1000, false, SCA_ObjectActuator, m_dloc, PyUpdateFuzzyFlags), | ||||
| KX_PYATTRIBUTE_BOOL_RW("useLocalDLoc", KX_ObjectActuator, m_bitLocalFlag.DLoc), | KX_PYATTRIBUTE_BOOL_RW("useLocalDLoc", SCA_ObjectActuator, m_bitLocalFlag.DLoc), | ||||
| KX_PYATTRIBUTE_VECTOR_RW_CHECK("dRot", -1000, 1000, false, KX_ObjectActuator, m_drot, PyUpdateFuzzyFlags), | KX_PYATTRIBUTE_VECTOR_RW_CHECK("dRot", -1000, 1000, false, SCA_ObjectActuator, m_drot, PyUpdateFuzzyFlags), | ||||
| KX_PYATTRIBUTE_BOOL_RW("useLocalDRot", KX_ObjectActuator, m_bitLocalFlag.DRot), | KX_PYATTRIBUTE_BOOL_RW("useLocalDRot", SCA_ObjectActuator, m_bitLocalFlag.DRot), | ||||
| #ifdef USE_MATHUTILS | #ifdef USE_MATHUTILS | ||||
| KX_PYATTRIBUTE_RW_FUNCTION("linV", KX_ObjectActuator, pyattr_get_linV, pyattr_set_linV), | KX_PYATTRIBUTE_RW_FUNCTION("linV", SCA_ObjectActuator, pyattr_get_linV, pyattr_set_linV), | ||||
| KX_PYATTRIBUTE_RW_FUNCTION("angV", KX_ObjectActuator, pyattr_get_angV, pyattr_set_angV), | KX_PYATTRIBUTE_RW_FUNCTION("angV", SCA_ObjectActuator, pyattr_get_angV, pyattr_set_angV), | ||||
| #else | #else | ||||
| KX_PYATTRIBUTE_VECTOR_RW_CHECK("linV", -1000, 1000, false, KX_ObjectActuator, m_linear_velocity, PyUpdateFuzzyFlags), | KX_PYATTRIBUTE_VECTOR_RW_CHECK("linV", -1000, 1000, false, SCA_ObjectActuator, m_linear_velocity, PyUpdateFuzzyFlags), | ||||
| KX_PYATTRIBUTE_VECTOR_RW_CHECK("angV", -1000, 1000, false, KX_ObjectActuator, m_angular_velocity, PyUpdateFuzzyFlags), | KX_PYATTRIBUTE_VECTOR_RW_CHECK("angV", -1000, 1000, false, SCA_ObjectActuator, m_angular_velocity, PyUpdateFuzzyFlags), | ||||
| #endif | #endif | ||||
| KX_PYATTRIBUTE_BOOL_RW("useLocalLinV", KX_ObjectActuator, m_bitLocalFlag.LinearVelocity), | KX_PYATTRIBUTE_BOOL_RW("useLocalLinV", SCA_ObjectActuator, m_bitLocalFlag.LinearVelocity), | ||||
| KX_PYATTRIBUTE_BOOL_RW("useLocalAngV", KX_ObjectActuator, m_bitLocalFlag.AngularVelocity), | KX_PYATTRIBUTE_BOOL_RW("useLocalAngV", SCA_ObjectActuator, m_bitLocalFlag.AngularVelocity), | ||||
| KX_PYATTRIBUTE_SHORT_RW("damping", 0, 1000, false, KX_ObjectActuator, m_damping), | KX_PYATTRIBUTE_SHORT_RW("damping", 0, 1000, false, SCA_ObjectActuator, m_damping), | ||||
| KX_PYATTRIBUTE_RW_FUNCTION("forceLimitX", KX_ObjectActuator, pyattr_get_forceLimitX, pyattr_set_forceLimitX), | KX_PYATTRIBUTE_RW_FUNCTION("forceLimitX", SCA_ObjectActuator, pyattr_get_forceLimitX, pyattr_set_forceLimitX), | ||||
| KX_PYATTRIBUTE_RW_FUNCTION("forceLimitY", KX_ObjectActuator, pyattr_get_forceLimitY, pyattr_set_forceLimitY), | KX_PYATTRIBUTE_RW_FUNCTION("forceLimitY", SCA_ObjectActuator, pyattr_get_forceLimitY, pyattr_set_forceLimitY), | ||||
| KX_PYATTRIBUTE_RW_FUNCTION("forceLimitZ", KX_ObjectActuator, pyattr_get_forceLimitZ, pyattr_set_forceLimitZ), | KX_PYATTRIBUTE_RW_FUNCTION("forceLimitZ", SCA_ObjectActuator, pyattr_get_forceLimitZ, pyattr_set_forceLimitZ), | ||||
| KX_PYATTRIBUTE_VECTOR_RW_CHECK("pid", -100, 200, true, KX_ObjectActuator, m_pid, PyCheckPid), | KX_PYATTRIBUTE_VECTOR_RW_CHECK("pid", -100, 200, true, SCA_ObjectActuator, m_pid, PyCheckPid), | ||||
| KX_PYATTRIBUTE_RW_FUNCTION("reference", KX_ObjectActuator,pyattr_get_reference,pyattr_set_reference), | KX_PYATTRIBUTE_RW_FUNCTION("reference", SCA_ObjectActuator,pyattr_get_reference,pyattr_set_reference), | ||||
| { NULL } //Sentinel | { NULL } //Sentinel | ||||
| }; | }; | ||||
| /* Attribute get/set functions */ | /* Attribute get/set functions */ | ||||
| #ifdef USE_MATHUTILS | #ifdef USE_MATHUTILS | ||||
| /* These require an SGNode */ | /* These require an SGNode */ | ||||
| #define MATHUTILS_VEC_CB_LINV 1 | #define MATHUTILS_VEC_CB_LINV 1 | ||||
| #define MATHUTILS_VEC_CB_ANGV 2 | #define MATHUTILS_VEC_CB_ANGV 2 | ||||
| static unsigned char mathutils_kxobactu_vector_cb_index = -1; /* index for our callbacks */ | static unsigned char mathutils_scaobactu_vector_cb_index = -1; /* index for our callbacks */ | ||||
| static int mathutils_obactu_generic_check(BaseMathObject *bmo) | static int mathutils_obactu_generic_check(BaseMathObject *bmo) | ||||
| { | { | ||||
| KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user); | SCA_ObjectActuator* self = static_cast<SCA_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user); | ||||
| if (self == NULL) | if (self == NULL) | ||||
| return -1; | return -1; | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static int mathutils_obactu_vector_get(BaseMathObject *bmo, int subtype) | static int mathutils_obactu_vector_get(BaseMathObject *bmo, int subtype) | ||||
| { | { | ||||
| KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user); | SCA_ObjectActuator* self = static_cast<SCA_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user); | ||||
| if (self == NULL) | if (self == NULL) | ||||
| return -1; | return -1; | ||||
| switch (subtype) { | switch (subtype) { | ||||
| case MATHUTILS_VEC_CB_LINV: | case MATHUTILS_VEC_CB_LINV: | ||||
| self->m_linear_velocity.getValue(bmo->data); | self->m_linear_velocity.getValue(bmo->data); | ||||
| break; | break; | ||||
| case MATHUTILS_VEC_CB_ANGV: | case MATHUTILS_VEC_CB_ANGV: | ||||
| self->m_angular_velocity.getValue(bmo->data); | self->m_angular_velocity.getValue(bmo->data); | ||||
| break; | break; | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static int mathutils_obactu_vector_set(BaseMathObject *bmo, int subtype) | static int mathutils_obactu_vector_set(BaseMathObject *bmo, int subtype) | ||||
| { | { | ||||
| KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user); | SCA_ObjectActuator* self = static_cast<SCA_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user); | ||||
| if (self == NULL) | if (self == NULL) | ||||
| return -1; | return -1; | ||||
| switch (subtype) { | switch (subtype) { | ||||
| case MATHUTILS_VEC_CB_LINV: | case MATHUTILS_VEC_CB_LINV: | ||||
| self->m_linear_velocity.setValue(bmo->data); | self->m_linear_velocity.setValue(bmo->data); | ||||
| break; | break; | ||||
| case MATHUTILS_VEC_CB_ANGV: | case MATHUTILS_VEC_CB_ANGV: | ||||
| Show All 27 Lines | |||||
| static Mathutils_Callback mathutils_obactu_vector_cb = { | static Mathutils_Callback mathutils_obactu_vector_cb = { | ||||
| mathutils_obactu_generic_check, | mathutils_obactu_generic_check, | ||||
| mathutils_obactu_vector_get, | mathutils_obactu_vector_get, | ||||
| mathutils_obactu_vector_set, | mathutils_obactu_vector_set, | ||||
| mathutils_obactu_vector_get_index, | mathutils_obactu_vector_get_index, | ||||
| mathutils_obactu_vector_set_index | mathutils_obactu_vector_set_index | ||||
| }; | }; | ||||
| PyObject *KX_ObjectActuator::pyattr_get_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | PyObject *SCA_ObjectActuator::pyattr_get_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | ||||
| { | { | ||||
| return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_LINV); | return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_scaobactu_vector_cb_index, MATHUTILS_VEC_CB_LINV); | ||||
| } | } | ||||
| int KX_ObjectActuator::pyattr_set_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) | int SCA_ObjectActuator::pyattr_set_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) | ||||
| { | { | ||||
| KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>(self_v); | SCA_ObjectActuator* self = static_cast<SCA_ObjectActuator*>(self_v); | ||||
| if (!PyVecTo(value, self->m_linear_velocity)) | if (!PyVecTo(value, self->m_linear_velocity)) | ||||
| return PY_SET_ATTR_FAIL; | return PY_SET_ATTR_FAIL; | ||||
| self->UpdateFuzzyFlags(); | self->UpdateFuzzyFlags(); | ||||
| return PY_SET_ATTR_SUCCESS; | return PY_SET_ATTR_SUCCESS; | ||||
| } | } | ||||
| PyObject *KX_ObjectActuator::pyattr_get_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | PyObject *SCA_ObjectActuator::pyattr_get_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | ||||
| { | { | ||||
| return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_ANGV); | return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_scaobactu_vector_cb_index, MATHUTILS_VEC_CB_ANGV); | ||||
| } | } | ||||
| int KX_ObjectActuator::pyattr_set_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) | int SCA_ObjectActuator::pyattr_set_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) | ||||
| { | { | ||||
| KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>(self_v); | SCA_ObjectActuator* self = static_cast<SCA_ObjectActuator*>(self_v); | ||||
| if (!PyVecTo(value, self->m_angular_velocity)) | if (!PyVecTo(value, self->m_angular_velocity)) | ||||
| return PY_SET_ATTR_FAIL; | return PY_SET_ATTR_FAIL; | ||||
| self->UpdateFuzzyFlags(); | self->UpdateFuzzyFlags(); | ||||
| return PY_SET_ATTR_SUCCESS; | return PY_SET_ATTR_SUCCESS; | ||||
| } | } | ||||
| void KX_ObjectActuator_Mathutils_Callback_Init(void) | void SCA_ObjectActuator_Mathutils_Callback_Init(void) | ||||
| { | { | ||||
| // register mathutils callbacks, ok to run more than once. | // register mathutils callbacks, ok to run more than once. | ||||
| mathutils_kxobactu_vector_cb_index = Mathutils_RegisterCallback(&mathutils_obactu_vector_cb); | mathutils_scaobactu_vector_cb_index = Mathutils_RegisterCallback(&mathutils_obactu_vector_cb); | ||||
| } | } | ||||
| #endif // USE_MATHUTILS | #endif // USE_MATHUTILS | ||||
| PyObject *KX_ObjectActuator::pyattr_get_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | PyObject *SCA_ObjectActuator::pyattr_get_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | ||||
| { | { | ||||
| KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); | SCA_ObjectActuator* self = reinterpret_cast<SCA_ObjectActuator*>(self_v); | ||||
| PyObject *retVal = PyList_New(3); | PyObject *retVal = PyList_New(3); | ||||
| PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[0])); | PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[0])); | ||||
| PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[0])); | PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[0])); | ||||
| PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.Torque)); | PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.Torque)); | ||||
| return retVal; | return retVal; | ||||
| } | } | ||||
| int KX_ObjectActuator::pyattr_set_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) | int SCA_ObjectActuator::pyattr_set_forceLimitX(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) | ||||
| { | { | ||||
| KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); | SCA_ObjectActuator* self = reinterpret_cast<SCA_ObjectActuator*>(self_v); | ||||
| PyObject *seq = PySequence_Fast(value, ""); | PyObject *seq = PySequence_Fast(value, ""); | ||||
| if (seq && PySequence_Fast_GET_SIZE(seq) == 3) | if (seq && PySequence_Fast_GET_SIZE(seq) == 3) | ||||
| { | { | ||||
| self->m_drot[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)); | self->m_drot[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)); | ||||
| self->m_dloc[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1)); | self->m_dloc[0] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1)); | ||||
| self->m_bitLocalFlag.Torque = (PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0); | self->m_bitLocalFlag.Torque = (PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0); | ||||
| if (!PyErr_Occurred()) | if (!PyErr_Occurred()) | ||||
| { | { | ||||
| Py_DECREF(seq); | Py_DECREF(seq); | ||||
| return PY_SET_ATTR_SUCCESS; | return PY_SET_ATTR_SUCCESS; | ||||
| } | } | ||||
| } | } | ||||
| Py_XDECREF(seq); | Py_XDECREF(seq); | ||||
| PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool"); | PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool"); | ||||
| return PY_SET_ATTR_FAIL; | return PY_SET_ATTR_FAIL; | ||||
| } | } | ||||
| PyObject *KX_ObjectActuator::pyattr_get_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | PyObject *SCA_ObjectActuator::pyattr_get_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | ||||
| { | { | ||||
| KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); | SCA_ObjectActuator* self = reinterpret_cast<SCA_ObjectActuator*>(self_v); | ||||
| PyObject *retVal = PyList_New(3); | PyObject *retVal = PyList_New(3); | ||||
| PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[1])); | PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[1])); | ||||
| PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[1])); | PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[1])); | ||||
| PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.DLoc)); | PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.DLoc)); | ||||
| return retVal; | return retVal; | ||||
| } | } | ||||
| int KX_ObjectActuator::pyattr_set_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) | int SCA_ObjectActuator::pyattr_set_forceLimitY(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) | ||||
| { | { | ||||
| KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); | SCA_ObjectActuator* self = reinterpret_cast<SCA_ObjectActuator*>(self_v); | ||||
| PyObject *seq = PySequence_Fast(value, ""); | PyObject *seq = PySequence_Fast(value, ""); | ||||
| if (seq && PySequence_Fast_GET_SIZE(seq) == 3) | if (seq && PySequence_Fast_GET_SIZE(seq) == 3) | ||||
| { | { | ||||
| self->m_drot[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)); | self->m_drot[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)); | ||||
| self->m_dloc[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1)); | self->m_dloc[1] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1)); | ||||
| self->m_bitLocalFlag.DLoc = (PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0); | self->m_bitLocalFlag.DLoc = (PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0); | ||||
| if (!PyErr_Occurred()) | if (!PyErr_Occurred()) | ||||
| { | { | ||||
| Py_DECREF(seq); | Py_DECREF(seq); | ||||
| return PY_SET_ATTR_SUCCESS; | return PY_SET_ATTR_SUCCESS; | ||||
| } | } | ||||
| } | } | ||||
| Py_XDECREF(seq); | Py_XDECREF(seq); | ||||
| PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool"); | PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool"); | ||||
| return PY_SET_ATTR_FAIL; | return PY_SET_ATTR_FAIL; | ||||
| } | } | ||||
| PyObject *KX_ObjectActuator::pyattr_get_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | PyObject *SCA_ObjectActuator::pyattr_get_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) | ||||
| { | { | ||||
| KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); | SCA_ObjectActuator* self = reinterpret_cast<SCA_ObjectActuator*>(self_v); | ||||
| PyObject *retVal = PyList_New(3); | PyObject *retVal = PyList_New(3); | ||||
| PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[2])); | PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(self->m_drot[2])); | ||||
| PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[2])); | PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(self->m_dloc[2])); | ||||
| PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.DRot)); | PyList_SET_ITEM(retVal, 2, PyBool_FromLong(self->m_bitLocalFlag.DRot)); | ||||
| return retVal; | return retVal; | ||||
| } | } | ||||
| int KX_ObjectActuator::pyattr_set_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) | int SCA_ObjectActuator::pyattr_set_forceLimitZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) | ||||
| { | { | ||||
| KX_ObjectActuator* self = reinterpret_cast<KX_ObjectActuator*>(self_v); | SCA_ObjectActuator* self = reinterpret_cast<SCA_ObjectActuator*>(self_v); | ||||
| PyObject *seq = PySequence_Fast(value, ""); | PyObject *seq = PySequence_Fast(value, ""); | ||||
| if (seq && PySequence_Fast_GET_SIZE(seq) == 3) | if (seq && PySequence_Fast_GET_SIZE(seq) == 3) | ||||
| { | { | ||||
| self->m_drot[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)); | self->m_drot[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)); | ||||
| self->m_dloc[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1)); | self->m_dloc[2] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1)); | ||||
| self->m_bitLocalFlag.DRot = (PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0); | self->m_bitLocalFlag.DRot = (PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 2)) != 0); | ||||
| if (!PyErr_Occurred()) | if (!PyErr_Occurred()) | ||||
| { | { | ||||
| Py_DECREF(seq); | Py_DECREF(seq); | ||||
| return PY_SET_ATTR_SUCCESS; | return PY_SET_ATTR_SUCCESS; | ||||
| } | } | ||||
| } | } | ||||
| Py_XDECREF(seq); | Py_XDECREF(seq); | ||||
| PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool"); | PyErr_SetString(PyExc_ValueError, "expected a sequence of 2 floats and a bool"); | ||||
| return PY_SET_ATTR_FAIL; | return PY_SET_ATTR_FAIL; | ||||
| } | } | ||||
| PyObject *KX_ObjectActuator::pyattr_get_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) | PyObject *SCA_ObjectActuator::pyattr_get_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) | ||||
| { | { | ||||
| KX_ObjectActuator* actuator = static_cast<KX_ObjectActuator*>(self); | SCA_ObjectActuator* actuator = static_cast<SCA_ObjectActuator*>(self); | ||||
| if (!actuator->m_reference) | if (!actuator->m_reference) | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| return actuator->m_reference->GetProxy(); | return actuator->m_reference->GetProxy(); | ||||
| } | } | ||||
| int KX_ObjectActuator::pyattr_set_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) | int SCA_ObjectActuator::pyattr_set_reference(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) | ||||
| { | { | ||||
| KX_ObjectActuator* actuator = static_cast<KX_ObjectActuator*>(self); | SCA_ObjectActuator* actuator = static_cast<SCA_ObjectActuator*>(self); | ||||
| KX_GameObject *refOb; | KX_GameObject *refOb; | ||||
| if (!ConvertPythonToGameObject(value, &refOb, true, "actu.reference = value: KX_ObjectActuator")) | if (!ConvertPythonToGameObject(value, &refOb, true, "actu.reference = value: SCA_ObjectActuator")) | ||||
| return PY_SET_ATTR_FAIL; | return PY_SET_ATTR_FAIL; | ||||
| if (actuator->m_reference) | if (actuator->m_reference) | ||||
| actuator->m_reference->UnregisterActuator(actuator); | actuator->m_reference->UnregisterActuator(actuator); | ||||
| if (refOb==NULL) { | if (refOb==NULL) { | ||||
| actuator->m_reference= NULL; | actuator->m_reference= NULL; | ||||
| } | } | ||||
| Show All 11 Lines | |||||