MCPcopy Create free account
hub / github.com/defold/defold / CompModelGetProperty

Function CompModelGetProperty

engine/gamesys/src/gamesys/components/comp_model.cpp:2925–2976  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2923 }
2924
2925 dmGameObject::PropertyResult CompModelGetProperty(const dmGameObject::ComponentGetPropertyParams& params, dmGameObject::PropertyDesc& out_value)
2926 {
2927 ModelWorld* world = (ModelWorld*)params.m_World;
2928 ModelComponent* component = world->m_Components.Get(*params.m_UserData);
2929 if (params.m_PropertyId == PROP_SKIN)
2930 {
2931 out_value.m_Variant = dmGameObject::PropertyVar(dmRig::GetModel(component->m_RigInstance));
2932 return dmGameObject::PROPERTY_RESULT_OK;
2933 }
2934 else if (params.m_PropertyId == PROP_ANIMATION)
2935 {
2936 out_value.m_Variant = dmGameObject::PropertyVar(dmRig::GetAnimation(component->m_RigInstance));
2937 return dmGameObject::PROPERTY_RESULT_OK;
2938 }
2939 else if (params.m_PropertyId == PROP_CURSOR)
2940 {
2941 out_value.m_Variant = dmGameObject::PropertyVar(dmRig::GetCursor(component->m_RigInstance, true));
2942 return dmGameObject::PROPERTY_RESULT_OK;
2943 }
2944 else if (params.m_PropertyId == PROP_PLAYBACK_RATE)
2945 {
2946 out_value.m_Variant = dmGameObject::PropertyVar(dmRig::GetPlaybackRate(component->m_RigInstance));
2947 return dmGameObject::PROPERTY_RESULT_OK;
2948 }
2949 else if (params.m_PropertyId == PROP_MATERIAL)
2950 {
2951 return GetResourceProperty(dmGameObject::GetFactory(params.m_Instance), GetMaterialResource(component, component->m_Resource, 0), out_value);
2952 }
2953 for (uint32_t i = 0; i < dmRender::RenderObject::MAX_TEXTURE_COUNT; ++i)
2954 {
2955 if (params.m_PropertyId == PROP_TEXTURE[i])
2956 {
2957 return GetResourceProperty(dmGameObject::GetFactory(params.m_Instance), GetTextureResource(component, 0, i), out_value);
2958 }
2959 }
2960
2961 int32_t value_index = 0;
2962 GetPropertyOptionsIndex(params.m_Options, 0, &value_index);
2963
2964 dmRender::HMaterial material = GetComponentMaterial(component, component->m_Resource, 0);
2965 if (GetMaterialConstant(material, params.m_PropertyId, value_index, out_value, false, CompModelGetConstantCallback, component) == dmGameObject::PROPERTY_RESULT_OK)
2966 {
2967 return dmGameObject::PROPERTY_RESULT_OK;
2968 }
2969
2970 // TODO: This will use the dynamic vertex attribute index for the first render item only.
2971 // We need a way to address sub-components to support custom attributes for sub-models
2972 MeshRenderItem* render_item = GetMeshRenderItem(component, 0);
2973 uint16_t dynamic_attribute_index = render_item ? render_item->m_DynamicVertexAttributeIndex : INVALID_DYNAMIC_ATTRIBUTE_INDEX;
2974
2975 return GetMaterialAttribute(world->m_DynamicVertexAttributePool, dynamic_attribute_index, material, params.m_PropertyId, out_value, CompModelGetMaterialAttributeCallback, component);
2976 }
2977
2978 dmGameObject::PropertyResult CompModelSetProperty(const dmGameObject::ComponentSetPropertyParams& params)
2979 {

Callers

nothing calls this directly

Calls 15

GetPropertyOptionsIndexFunction · 0.85
GetMaterialConstantFunction · 0.85
GetMeshRenderItemFunction · 0.85
GetMaterialAttributeFunction · 0.85
GetCursorFunction · 0.70
GetPlaybackRateFunction · 0.70
GetResourcePropertyFunction · 0.70
GetFactoryFunction · 0.70
GetMaterialResourceFunction · 0.70
GetTextureResourceFunction · 0.70
GetComponentMaterialFunction · 0.70
PropertyVarClass · 0.50

Tested by

no test coverage detected