Added SharedMaterial for Renderable #357

Merged
Pycorax merged 1 commits from SP3-6-c-scripting into main 2023-02-22 14:53:47 +08:00
2 changed files with 17 additions and 2 deletions

View File

@ -47,11 +47,16 @@ namespace SHADE
} }
} }
SHADE::Material Renderable::Material::get() SHADE::Material Renderable::Material::get()
{
auto mat = GetNativeComponent()->GetModifiableMaterial();
return mat ? SHADE::Material(mat) : SHADE::Material();
}
SHADE::Material Renderable::SharedMaterial::get()
{ {
auto mat = GetNativeComponent()->GetMaterial(); auto mat = GetNativeComponent()->GetMaterial();
return mat ? SHADE::Material(mat) : SHADE::Material(); return mat ? SHADE::Material(mat) : SHADE::Material();
} }
void Renderable::Material::set(SHADE::Material value) void Renderable::SharedMaterial::set(SHADE::Material value)
{ {
if (value) if (value)
{ {

View File

@ -55,9 +55,19 @@ namespace SHADE
void set(MeshAsset value); void set(MeshAsset value);
} }
/// <summary> /// <summary>
/// Material used to render this Renderable. /// Special instance of the shared Material for this Renderable. When accessing
/// this property, a new instance of the shared Material is created and assigned
/// to this Renderable. Hence, changes will only affect this Renderable.
/// </summary> /// </summary>
property SHADE::Material Material property SHADE::Material Material
{
SHADE::Material get();
}
/// <summary>
/// The shared Material used to render this Renderable and other Renderables
/// using the same base Material.
/// </summary>
property SHADE::Material SharedMaterial
{ {
SHADE::Material get(); SHADE::Material get();
void set(SHADE::Material value); void set(SHADE::Material value);