}
}
-Property::Index Object::RegisterProperty( const std::string& name, const Property::Value& propertyValue)
+Property::Index Object::RegisterProperty( const std::string& name, const Property::Value& propertyValue )
{
- Property::Index index = RegisterSceneGraphProperty(name, PROPERTY_CUSTOM_START_INDEX + mCustomProperties.Count(), propertyValue);
-
- /// @todo: don't keep a table of mappings per handle.
- AddUniformMapping(index, name);
-
- return index;
+ return RegisterProperty( name, propertyValue, Property::ANIMATABLE );
}
-Property::Index Object::RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode)
+Property::Index Object::RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode )
{
- Property::Index index = Property::INVALID_INDEX;
-
- if(Property::ANIMATABLE == accessMode)
+ // If property with the required name already exists, then just set it.
+ Property::Index index = GetPropertyIndex( name );
+ if( index != Property::INVALID_INDEX )
{
- index = RegisterProperty(name, propertyValue);
+ SetProperty( index, propertyValue );
}
else
{
- // Add entry to the property lookup
- index = PROPERTY_CUSTOM_START_INDEX + mCustomProperties.Count();
- mCustomProperties.PushBack( new CustomPropertyMetadata( name, propertyValue, accessMode ) );
+ // Otherwise register the property
+
+ if(Property::ANIMATABLE == accessMode)
+ {
+ index = RegisterSceneGraphProperty( name, PROPERTY_CUSTOM_START_INDEX + mCustomProperties.Count(), propertyValue );
+ AddUniformMapping( index, name );
+ }
+ else
+ {
+ // Add entry to the property lookup
+ index = PROPERTY_CUSTOM_START_INDEX + mCustomProperties.Count();
+ mCustomProperties.PushBack( new CustomPropertyMetadata( name, propertyValue, accessMode ) );
+ }
}
return index;
}
}
-void Object::AddUniformMapping( Property::Index propertyIndex, const std::string& uniformName )
+void Object::AddUniformMapping( Property::Index propertyIndex, const std::string& uniformName ) const
{
// Get the address of the property if it's a scene property
const PropertyInputImpl* propertyPtr = GetSceneObjectInputProperty( propertyIndex );
}
}
- // @todo MESH_REWORK Store mappings for unstaged objects?
-
if( propertyPtr != NULL )
{
const SceneGraph::PropertyOwner* sceneObject = GetPropertyOwner();
{
SceneGraph::UniformPropertyMapping* map = new SceneGraph::UniformPropertyMapping( uniformName, propertyPtr );
// Message takes ownership of Uniform map (and will delete it after copy)
- AddUniformMapMessage( GetEventThreadServices(), *sceneObject, map);
+ AddUniformMapMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), *sceneObject, map);
}
else
{
- // @todo MESH_REWORK FIXME Need to store something that can be sent to the scene
- // object when staged.
DALI_ASSERT_ALWAYS(0 && "MESH_REWORK - Need to store property whilst off-stage" );
}
}
if(basePropertyIndex == Property::INVALID_INDEX)
{
// If the property is not a component of a base property, register the whole property itself.
- index = RegisterSceneGraphProperty(typeInfo->GetPropertyName(index), index, Property::Value(typeInfo->GetPropertyType(index)));
+ const std::string& propertyName = typeInfo->GetPropertyName(index);
+ RegisterSceneGraphProperty(propertyName, index, typeInfo->GetPropertyDefaultValue(index));
+ AddUniformMapping( index, propertyName );
}
else
{
if(!animatableProperty)
{
// If the base property is not registered yet, register the base property first.
- if(Property::INVALID_INDEX != RegisterSceneGraphProperty(typeInfo->GetPropertyName(basePropertyIndex), basePropertyIndex, Property::Value(typeInfo->GetPropertyType(basePropertyIndex))))
+ const std::string& basePropertyName = typeInfo->GetPropertyName(basePropertyIndex);
+ if(Property::INVALID_INDEX != RegisterSceneGraphProperty(basePropertyName, basePropertyIndex, Property::Value(typeInfo->GetPropertyType(basePropertyIndex))))
{
animatableProperty = static_cast<AnimatablePropertyMetadata*>(mAnimatableProperties[mAnimatableProperties.Size()-1]);
+ AddUniformMapping( basePropertyIndex, basePropertyName );
}
}