| 2976 | } |
| 2977 | |
| 2978 | dmGameObject::PropertyResult CompModelSetProperty(const dmGameObject::ComponentSetPropertyParams& params) |
| 2979 | { |
| 2980 | ModelWorld* world = (ModelWorld*)params.m_World; |
| 2981 | ModelComponent* component = world->m_Components.Get(*params.m_UserData); |
| 2982 | if (params.m_PropertyId == PROP_SKIN) |
| 2983 | { |
| 2984 | if (params.m_Value.m_Type != dmGameObject::PROPERTY_TYPE_HASH) |
| 2985 | return dmGameObject::PROPERTY_RESULT_TYPE_MISMATCH; |
| 2986 | |
| 2987 | dmRig::Result res = dmRig::SetModel(component->m_RigInstance, params.m_Value.m_Hash); |
| 2988 | if (res == dmRig::RESULT_ERROR) |
| 2989 | { |
| 2990 | dmLogError("Could not find skin '%s' on the model.", dmHashReverseSafe64(params.m_Value.m_Hash)); |
| 2991 | return dmGameObject::PROPERTY_RESULT_UNSUPPORTED_VALUE; |
| 2992 | } |
| 2993 | return dmGameObject::PROPERTY_RESULT_OK; |
| 2994 | } |
| 2995 | else if (params.m_PropertyId == PROP_CURSOR) |
| 2996 | { |
| 2997 | if (params.m_Value.m_Type != dmGameObject::PROPERTY_TYPE_NUMBER) |
| 2998 | return dmGameObject::PROPERTY_RESULT_TYPE_MISMATCH; |
| 2999 | |
| 3000 | dmRig::Result res = dmRig::SetCursor(component->m_RigInstance, params.m_Value.m_Number, true); |
| 3001 | if (res == dmRig::RESULT_ERROR) |
| 3002 | { |
| 3003 | dmLogError("Could not set cursor %f on the model.", params.m_Value.m_Number); |
| 3004 | return dmGameObject::PROPERTY_RESULT_UNSUPPORTED_VALUE; |
| 3005 | } |
| 3006 | return dmGameObject::PROPERTY_RESULT_OK; |
| 3007 | } |
| 3008 | else if (params.m_PropertyId == PROP_PLAYBACK_RATE) |
| 3009 | { |
| 3010 | if (params.m_Value.m_Type != dmGameObject::PROPERTY_TYPE_NUMBER) |
| 3011 | return dmGameObject::PROPERTY_RESULT_TYPE_MISMATCH; |
| 3012 | |
| 3013 | dmRig::Result res = dmRig::SetPlaybackRate(component->m_RigInstance, params.m_Value.m_Number); |
| 3014 | if (res == dmRig::RESULT_ERROR) |
| 3015 | { |
| 3016 | dmLogError("Could not set playback rate %f on the model.", params.m_Value.m_Number); |
| 3017 | return dmGameObject::PROPERTY_RESULT_UNSUPPORTED_VALUE; |
| 3018 | } |
| 3019 | return dmGameObject::PROPERTY_RESULT_OK; |
| 3020 | } |
| 3021 | else if (params.m_PropertyId == PROP_MATERIAL) |
| 3022 | { |
| 3023 | dmGameObject::PropertyResult res = SetResourceProperty(dmGameObject::GetFactory(params.m_Instance), params.m_Value, MATERIAL_EXT_HASH, (void**)&component->m_Material); |
| 3024 | component->m_ReHash |= res == dmGameObject::PROPERTY_RESULT_OK; |
| 3025 | return res; |
| 3026 | } |
| 3027 | for(uint32_t i = 0; i < dmRender::RenderObject::MAX_TEXTURE_COUNT; ++i) |
| 3028 | { |
| 3029 | if(params.m_PropertyId == PROP_TEXTURE[i]) |
| 3030 | { |
| 3031 | dmhash_t ext_hashes[] = { TEXTURE_EXT_HASH, RENDER_TARGET_EXT_HASH }; |
| 3032 | dmGameObject::PropertyResult res = SetResourceProperty(dmGameObject::GetFactory(params.m_Instance), params.m_Value, ext_hashes, DM_ARRAY_SIZE(ext_hashes), (void**)&component->m_Textures[i]); |
| 3033 | component->m_ReHash |= res == dmGameObject::PROPERTY_RESULT_OK; |
| 3034 | return res; |
| 3035 | } |
nothing calls this directly
no test coverage detected