X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-scene3d%2Finternal%2Fmodel-components%2Fmodel-node-impl.cpp;h=d566163e22894a2760d0df51794b80528ec3e7c7;hb=0ab2af8053436971758161fbf1c4ad73058ac5ce;hp=9d8d4b67c2e023266683ce29bceb2604997bbbc6;hpb=777641114ac10ea7695eb1fe37290fdfa0100ef7;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-scene3d/internal/model-components/model-node-impl.cpp b/dali-scene3d/internal/model-components/model-node-impl.cpp index 9d8d4b6..d566163 100644 --- a/dali-scene3d/internal/model-components/model-node-impl.cpp +++ b/dali-scene3d/internal/model-components/model-node-impl.cpp @@ -24,6 +24,7 @@ #include // INTERNAL INCLUDES +#include #include #include @@ -173,7 +174,7 @@ uint32_t ModelNode::GetModelPrimitiveCount() const return static_cast(mModelPrimitiveContainer.size()); } -void ModelNode::AddModelPrimitive(Dali::Scene3D::ModelPrimitive modelPrimitive) +void ModelNode::AddModelPrimitive(Dali::Scene3D::ModelPrimitive modelPrimitive, Loader::ShaderOption::HashType hash) { for(auto&& primitive : mModelPrimitiveContainer) { @@ -187,12 +188,17 @@ void ModelNode::AddModelPrimitive(Dali::Scene3D::ModelPrimitive modelPrimitive) Actor self = Self(); GetImplementation(modelPrimitive).AddPrimitiveObserver(this); + if(mShadowMapTexture) + { + GetImplementation(modelPrimitive).SetShadowMapTexture(mShadowMapTexture); + } + if(mDiffuseTexture && mSpecularTexture) { GetImplementation(modelPrimitive).SetImageBasedLightTexture(mDiffuseTexture, mSpecularTexture, mIblScaleFactor, mSpecularMipmapLevels); } - GetImplementation(modelPrimitive).UpdateShader(mShaderManager); + GetImplementation(modelPrimitive).UpdateShader(mShaderManager, hash); Dali::Renderer renderer = GetImplementation(modelPrimitive).GetRenderer(); if(renderer) @@ -236,7 +242,7 @@ void ModelNode::RemoveModelPrimitive(uint32_t index) return; } - GetImplementation(mModelPrimitiveContainer[index]).UpdateShader(nullptr); + GetImplementation(mModelPrimitiveContainer[index]).UpdateShader(nullptr, 0u); Actor self = Self(); GetImplementation(mModelPrimitiveContainer[index]).RemovePrimitiveObserver(this); @@ -284,6 +290,15 @@ Loader::BlendShapes::Index ModelNode::GetBlendShapeIndexByName(std::string_view return Loader::BlendShapes::INVALID_INDEX; } +void ModelNode::SetShadowMapTexture(Dali::Texture shadowMapTexture) +{ + mShadowMapTexture = shadowMapTexture; + for(auto&& primitive : mModelPrimitiveContainer) + { + GetImplementation(primitive).SetShadowMapTexture(mShadowMapTexture); + } +} + void ModelNode::SetImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float iblScaleFactor, uint32_t specularMipmapLevels) { mDiffuseTexture = diffuseTexture; @@ -312,7 +327,7 @@ void ModelNode::UpdateShader(Scene3D::Loader::ShaderManagerPtr shaderManager) mShaderManager = shaderManager; for(auto&& primitive : mModelPrimitiveContainer) { - GetImplementation(primitive).UpdateShader(mShaderManager); + GetImplementation(primitive).UpdateShader(mShaderManager, 0u); } } } @@ -391,6 +406,52 @@ void ModelNode::UpdateBoneMatrix(Scene3D::ModelPrimitive primitive) } } +void ModelNode::SetColliderMesh(ColliderMeshUniquePtr&& colliderMesh) +{ + if(!colliderMesh && !mColliderMesh) + { + return; + } + + if(!mParentModel) // find parent model if not set + { + auto parent = Self().GetParent(); + while(parent) + { + auto modelHandle = Scene3D::Model::DownCast(parent); + if(modelHandle) + { + mParentModel = &GetImpl(modelHandle); + break; + } + parent = parent.GetParent(); + } + } + + // Resetting collider mesh if argument is nullptr + auto handle = Scene3D::ModelNode::DownCast(Self()); + if(mParentModel) + { + if(mColliderMesh || colliderMesh == nullptr) + { + mParentModel->RemoveColliderMesh(handle); + } + mParentModel->RegisterColliderMesh(handle, *colliderMesh); + } + + mColliderMesh = std::move(colliderMesh); +} + +bool ModelNode::HasColliderMesh() const +{ + return mColliderMesh != nullptr; +} + +const Scene3D::Algorithm::ColliderMesh& ModelNode::GetColliderMesh() const +{ + return *mColliderMesh; +} + } // namespace Internal } // namespace Scene3D