ModelComponent.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. // Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <AnKi/Scene/Components/ModelComponent.h>
  6. #include <AnKi/Scene/SceneNode.h>
  7. #include <AnKi/Scene/SceneGraph.h>
  8. #include <AnKi/Scene/Components/MoveComponent.h>
  9. #include <AnKi/Scene/Components/SkinComponent.h>
  10. #include <AnKi/Resource/ModelResource.h>
  11. #include <AnKi/Resource/ResourceManager.h>
  12. namespace anki {
  13. ModelComponent::ModelComponent(SceneNode* node)
  14. : SceneComponent(node, getStaticClassId())
  15. , m_node(node)
  16. , m_spatial(this)
  17. {
  18. m_gpuSceneTransformsIndex = U32(SceneGraph::getSingleton().getAllGpuSceneContiguousArrays().allocate(
  19. GpuSceneContiguousArrayType::kTransformPairs));
  20. }
  21. ModelComponent::~ModelComponent()
  22. {
  23. GpuSceneMemoryPool::getSingleton().deferredFree(m_gpuSceneUniforms);
  24. for(const PatchInfo& patch : m_patchInfos)
  25. {
  26. if(patch.m_gpuSceneMeshLodsIndex != kMaxU32)
  27. {
  28. SceneGraph::getSingleton().getAllGpuSceneContiguousArrays().deferredFree(
  29. GpuSceneContiguousArrayType::kMeshLods, patch.m_gpuSceneMeshLodsIndex);
  30. }
  31. if(patch.m_gpuSceneRenderableIndex != kMaxU32)
  32. {
  33. SceneGraph::getSingleton().getAllGpuSceneContiguousArrays().deferredFree(
  34. GpuSceneContiguousArrayType::kRenderablesGBuffer, patch.m_gpuSceneRenderableIndex);
  35. }
  36. if(patch.m_gpuSceneRenderableBoundingVolumeIndex != kMaxU32)
  37. {
  38. SceneGraph::getSingleton().getAllGpuSceneContiguousArrays().deferredFree(
  39. GpuSceneContiguousArrayType::kRenderableBoundingVolumesGBuffer,
  40. patch.m_gpuSceneRenderableBoundingVolumeIndex);
  41. }
  42. }
  43. SceneGraph::getSingleton().getAllGpuSceneContiguousArrays().deferredFree(
  44. GpuSceneContiguousArrayType::kTransformPairs, m_gpuSceneTransformsIndex);
  45. m_spatial.removeFromOctree(SceneGraph::getSingleton().getOctree());
  46. }
  47. void ModelComponent::loadModelResource(CString filename)
  48. {
  49. ModelResourcePtr rsrc;
  50. const Error err = ResourceManager::getSingleton().loadResource(filename, rsrc);
  51. if(err)
  52. {
  53. ANKI_SCENE_LOGE("Failed to load model resource");
  54. return;
  55. }
  56. m_dirty = true;
  57. m_model = std::move(rsrc);
  58. const U32 modelPatchCount = m_model->getModelPatches().getSize();
  59. // GPU scene allocations
  60. for(const PatchInfo& patch : m_patchInfos)
  61. {
  62. if(patch.m_gpuSceneMeshLodsIndex != kMaxU32)
  63. {
  64. SceneGraph::getSingleton().getAllGpuSceneContiguousArrays().deferredFree(
  65. GpuSceneContiguousArrayType::kMeshLods, patch.m_gpuSceneMeshLodsIndex);
  66. }
  67. if(patch.m_gpuSceneRenderableIndex != kMaxU32)
  68. {
  69. SceneGraph::getSingleton().getAllGpuSceneContiguousArrays().deferredFree(
  70. GpuSceneContiguousArrayType::kRenderablesGBuffer, patch.m_gpuSceneRenderableIndex);
  71. }
  72. if(patch.m_gpuSceneRenderableBoundingVolumeIndex != kMaxU32)
  73. {
  74. SceneGraph::getSingleton().getAllGpuSceneContiguousArrays().deferredFree(
  75. GpuSceneContiguousArrayType::kRenderableBoundingVolumesGBuffer,
  76. patch.m_gpuSceneRenderableBoundingVolumeIndex);
  77. }
  78. }
  79. m_patchInfos.resize(modelPatchCount);
  80. for(U32 i = 0; i < modelPatchCount; ++i)
  81. {
  82. m_patchInfos[i].m_gpuSceneMeshLodsIndex = SceneGraph::getSingleton().getAllGpuSceneContiguousArrays().allocate(
  83. GpuSceneContiguousArrayType::kMeshLods);
  84. m_patchInfos[i].m_gpuSceneRenderableIndex =
  85. SceneGraph::getSingleton().getAllGpuSceneContiguousArrays().allocate(
  86. GpuSceneContiguousArrayType::kRenderablesGBuffer);
  87. m_patchInfos[i].m_gpuSceneRenderableBoundingVolumeIndex =
  88. SceneGraph::getSingleton().getAllGpuSceneContiguousArrays().allocate(
  89. GpuSceneContiguousArrayType::kRenderableBoundingVolumesGBuffer);
  90. }
  91. U32 uniformsSize = 0;
  92. for(U32 i = 0; i < modelPatchCount; ++i)
  93. {
  94. m_patchInfos[i].m_gpuSceneUniformsOffset = uniformsSize;
  95. const U32 size = U32(m_model->getModelPatches()[i].getMaterial()->getPrefilledLocalUniforms().getSizeInBytes());
  96. ANKI_ASSERT((size % 4) == 0);
  97. uniformsSize += size;
  98. }
  99. GpuSceneMemoryPool::getSingleton().deferredFree(m_gpuSceneUniforms);
  100. GpuSceneMemoryPool::getSingleton().allocate(uniformsSize, 4, m_gpuSceneUniforms);
  101. for(U32 i = 0; i < modelPatchCount; ++i)
  102. {
  103. m_patchInfos[i].m_gpuSceneUniformsOffset += U32(m_gpuSceneUniforms.m_offset);
  104. }
  105. // Some other per-patch init
  106. m_presentRenderingTechniques = RenderingTechniqueBit::kNone;
  107. m_castsShadow = false;
  108. for(U32 i = 0; i < modelPatchCount; ++i)
  109. {
  110. m_patchInfos[i].m_techniques = m_model->getModelPatches()[i].getMaterial()->getRenderingTechniques();
  111. m_castsShadow = m_castsShadow || m_model->getModelPatches()[i].getMaterial()->castsShadow();
  112. m_presentRenderingTechniques |= m_model->getModelPatches()[i].getMaterial()->getRenderingTechniques();
  113. }
  114. }
  115. Error ModelComponent::update(SceneComponentUpdateInfo& info, Bool& updated)
  116. {
  117. if(!isEnabled()) [[unlikely]]
  118. {
  119. updated = false;
  120. return Error::kNone;
  121. }
  122. const AllGpuSceneContiguousArrays& gpuArrays = SceneGraph::getSingleton().getAllGpuSceneContiguousArrays();
  123. const Bool resourceUpdated = m_dirty;
  124. m_dirty = false;
  125. const Bool moved = info.m_node->movedThisFrame() || m_firstTimeUpdate;
  126. const Bool movedLastFrame = m_movedLastFrame || m_firstTimeUpdate;
  127. m_firstTimeUpdate = false;
  128. m_movedLastFrame = moved;
  129. updated = resourceUpdated || moved || movedLastFrame;
  130. const Bool hasSkin = m_skinComponent != nullptr && m_skinComponent->isEnabled();
  131. // Upload mesh LODs and uniforms
  132. if(resourceUpdated) [[unlikely]]
  133. {
  134. // Upload the mesh views
  135. const U32 modelPatchCount = m_model->getModelPatches().getSize();
  136. for(U32 i = 0; i < modelPatchCount; ++i)
  137. {
  138. const ModelPatch& patch = m_model->getModelPatches()[i];
  139. const MeshResource& mesh = *patch.getMesh();
  140. Array<GpuSceneMeshLod, kMaxLodCount> meshLods;
  141. for(U32 l = 0; l < mesh.getLodCount(); ++l)
  142. {
  143. GpuSceneMeshLod& meshLod = meshLods[l];
  144. meshLod = {};
  145. meshLod.m_positionScale = mesh.getPositionsScale();
  146. meshLod.m_positionTranslation = mesh.getPositionsTranslation();
  147. for(VertexStreamId stream = VertexStreamId::kPosition; stream <= VertexStreamId::kBoneWeights; ++stream)
  148. {
  149. if(!mesh.isVertexStreamPresent(stream))
  150. {
  151. continue;
  152. }
  153. PtrSize offset;
  154. U32 vertCount;
  155. mesh.getVertexStreamInfo(l, stream, offset, vertCount);
  156. const PtrSize elementSize = getFormatInfo(kMeshRelatedVertexStreamFormats[stream]).m_texelSize;
  157. ANKI_ASSERT((offset % elementSize) == 0);
  158. meshLod.m_vertexOffsets[U32(stream)] = U32(offset / elementSize);
  159. }
  160. U32 firstIndex;
  161. U32 indexCount;
  162. Aabb aabb;
  163. mesh.getSubMeshInfo(l, i, firstIndex, indexCount, aabb);
  164. PtrSize offset;
  165. IndexType indexType;
  166. mesh.getIndexBufferInfo(l, offset, indexCount, indexType);
  167. meshLod.m_indexBufferOffset = U32(offset) / getIndexSize(indexType) + firstIndex;
  168. meshLod.m_indexCount = indexCount;
  169. }
  170. // Copy the last LOD to the rest just in case
  171. for(U32 l = mesh.getLodCount(); l < kMaxLodCount; ++l)
  172. {
  173. meshLods[l] = meshLods[l - 1];
  174. }
  175. PtrSize offset = m_patchInfos[i].m_gpuSceneMeshLodsIndex * sizeof(meshLods)
  176. + gpuArrays.getArrayBase(GpuSceneContiguousArrayType::kMeshLods);
  177. GpuSceneMicroPatcher::getSingleton().newCopy(*info.m_framePool, offset, meshLods.getSizeInBytes(),
  178. &meshLods[0]);
  179. // Upload the GpuSceneRenderable
  180. GpuSceneRenderable gpuRenderable;
  181. gpuRenderable.m_worldTransformsOffset =
  182. U32(m_gpuSceneTransformsIndex * sizeof(Mat3x4) * 2
  183. + gpuArrays.getArrayBase(GpuSceneContiguousArrayType::kTransformPairs));
  184. gpuRenderable.m_uniformsOffset = m_patchInfos[i].m_gpuSceneUniformsOffset;
  185. gpuRenderable.m_geometryOffset =
  186. U32(m_patchInfos[i].m_gpuSceneMeshLodsIndex * sizeof(GpuSceneMeshLod) * kMaxLodCount
  187. + gpuArrays.getArrayBase(GpuSceneContiguousArrayType::kMeshLods));
  188. gpuRenderable.m_boneTransformsOffset = (hasSkin) ? m_skinComponent->getBoneTransformsGpuSceneOffset() : 0;
  189. offset = m_patchInfos[i].m_gpuSceneRenderableIndex * sizeof(GpuSceneRenderable)
  190. + gpuArrays.getArrayBase(GpuSceneContiguousArrayType::kRenderablesGBuffer);
  191. GpuSceneMicroPatcher::getSingleton().newCopy(*info.m_framePool, offset, sizeof(gpuRenderable),
  192. &gpuRenderable);
  193. }
  194. // Upload the uniforms
  195. DynamicArray<U32, MemoryPoolPtrWrapper<StackMemoryPool>> allUniforms(info.m_framePool);
  196. allUniforms.resize(U32(m_gpuSceneUniforms.m_size / 4));
  197. U32 count = 0;
  198. for(U32 i = 0; i < modelPatchCount; ++i)
  199. {
  200. const ModelPatch& patch = m_model->getModelPatches()[i];
  201. const MaterialResource& mtl = *patch.getMaterial();
  202. memcpy(&allUniforms[count], mtl.getPrefilledLocalUniforms().getBegin(),
  203. mtl.getPrefilledLocalUniforms().getSizeInBytes());
  204. count += U32(mtl.getPrefilledLocalUniforms().getSizeInBytes() / 4);
  205. }
  206. ANKI_ASSERT(count * 4 == m_gpuSceneUniforms.m_size);
  207. GpuSceneMicroPatcher::getSingleton().newCopy(*info.m_framePool, m_gpuSceneUniforms.m_offset,
  208. m_gpuSceneUniforms.m_size, &allUniforms[0]);
  209. // Refresh the render state buckets
  210. for(U32 i = 0; i < modelPatchCount; ++i)
  211. {
  212. for(RenderingTechnique t : EnumIterable<RenderingTechnique>())
  213. {
  214. for(U32 velocity = 0; velocity < 1; ++velocity)
  215. {
  216. RenderStateBucketContainer& buckets = SceneGraph::getSingleton().getRenderStateBuckets();
  217. buckets.removeUser(t, m_patchInfos[i].m_renderStateBucketIndices[t][velocity]);
  218. }
  219. }
  220. }
  221. }
  222. // Upload transforms
  223. if(moved || movedLastFrame) [[unlikely]]
  224. {
  225. Array<Mat3x4, 2> trfs;
  226. trfs[0] = Mat3x4(info.m_node->getWorldTransform());
  227. trfs[1] = Mat3x4(info.m_node->getPreviousWorldTransform());
  228. const PtrSize offset = m_gpuSceneTransformsIndex * sizeof(trfs)
  229. + SceneGraph::getSingleton().getAllGpuSceneContiguousArrays().getArrayBase(
  230. GpuSceneContiguousArrayType::kTransformPairs);
  231. GpuSceneMicroPatcher::getSingleton().newCopy(*info.m_framePool, offset, sizeof(trfs), &trfs[0]);
  232. }
  233. // Spatial update
  234. if(moved || resourceUpdated || m_skinComponent) [[unlikely]]
  235. {
  236. Aabb aabbLocal;
  237. if(m_skinComponent == nullptr) [[likely]]
  238. {
  239. aabbLocal = m_model->getBoundingVolume();
  240. }
  241. else
  242. {
  243. aabbLocal =
  244. m_skinComponent->getBoneBoundingVolumeLocalSpace().getCompoundShape(m_model->getBoundingVolume());
  245. }
  246. const Aabb aabbWorld = aabbLocal.getTransformed(info.m_node->getWorldTransform());
  247. m_spatial.setBoundingShape(aabbWorld);
  248. // Upload the GpuSceneRenderableBoundingVolume to the GPU scene
  249. const U32 modelPatchCount = m_model->getModelPatches().getSize();
  250. for(U32 i = 0; i < modelPatchCount; ++i)
  251. {
  252. GpuSceneRenderableBoundingVolume gpuVolume;
  253. gpuVolume.m_aabbMin = aabbWorld.getMin().xyz();
  254. gpuVolume.m_aabbMax = aabbWorld.getMax().xyz();
  255. gpuVolume.m_renderableOffset = m_patchInfos[i].m_gpuSceneRenderableIndex * sizeof(GpuSceneRenderable)
  256. + gpuArrays.getArrayBase(GpuSceneContiguousArrayType::kRenderablesGBuffer);
  257. gpuVolume.m_renderStateBucket = 0; // TODO
  258. const PtrSize offset =
  259. U32(m_patchInfos[i].m_gpuSceneRenderableBoundingVolumeIndex * sizeof(GpuSceneRenderableBoundingVolume)
  260. + gpuArrays.getArrayBase(GpuSceneContiguousArrayType::kRenderableBoundingVolumesGBuffer));
  261. GpuSceneMicroPatcher::getSingleton().newCopy(*info.m_framePool, offset, sizeof(gpuVolume), &gpuVolume);
  262. }
  263. }
  264. const Bool spatialUpdated = m_spatial.update(SceneGraph::getSingleton().getOctree());
  265. updated = updated || spatialUpdated;
  266. return Error::kNone;
  267. }
  268. void ModelComponent::setupRenderableQueueElements(U32 lod, RenderingTechnique technique,
  269. WeakArray<RenderableQueueElement>& outRenderables) const
  270. {
  271. ANKI_ASSERT(isEnabled());
  272. outRenderables.setArray(nullptr, 0);
  273. const RenderingTechniqueBit requestedRenderingTechniqueMask = RenderingTechniqueBit(1 << technique);
  274. if(!(m_presentRenderingTechniques & requestedRenderingTechniqueMask))
  275. {
  276. return;
  277. }
  278. // Allocate renderables
  279. U32 renderableCount = 0;
  280. for(U32 i = 0; i < m_patchInfos.getSize(); ++i)
  281. {
  282. renderableCount += !!(m_patchInfos[i].m_techniques & requestedRenderingTechniqueMask);
  283. }
  284. if(renderableCount == 0)
  285. {
  286. return;
  287. }
  288. RenderableQueueElement* renderables =
  289. static_cast<RenderableQueueElement*>(SceneGraph::getSingleton().getFrameMemoryPool().allocate(
  290. sizeof(RenderableQueueElement) * renderableCount, alignof(RenderableQueueElement)));
  291. outRenderables.setArray(renderables, renderableCount);
  292. // Fill renderables
  293. const Bool moved = m_node->movedThisFrame() && technique == RenderingTechnique::kGBuffer;
  294. const Bool hasSkin = m_skinComponent != nullptr && m_skinComponent->isEnabled();
  295. RenderingKey key;
  296. key.setLod(lod);
  297. key.setRenderingTechnique(technique);
  298. key.setVelocity(moved);
  299. key.setSkinned(hasSkin);
  300. renderableCount = 0;
  301. for(U32 i = 0; i < m_patchInfos.getSize(); ++i)
  302. {
  303. if(!(m_patchInfos[i].m_techniques & requestedRenderingTechniqueMask))
  304. {
  305. continue;
  306. }
  307. RenderableQueueElement& queueElem = renderables[renderableCount];
  308. const ModelPatch& patch = m_model->getModelPatches()[i];
  309. ModelRenderingInfo modelInf;
  310. patch.getRenderingInfo(key, modelInf);
  311. AllGpuSceneContiguousArrays& gpuArrays = SceneGraph::getSingleton().getAllGpuSceneContiguousArrays();
  312. queueElem.m_program = modelInf.m_program.get();
  313. queueElem.m_worldTransformsOffset = U32(m_gpuSceneTransformsIndex * sizeof(Mat3x4) * 2
  314. + gpuArrays.getArrayBase(GpuSceneContiguousArrayType::kTransformPairs));
  315. queueElem.m_uniformsOffset = m_patchInfos[i].m_gpuSceneUniformsOffset;
  316. queueElem.m_geometryOffset =
  317. U32(m_patchInfos[i].m_gpuSceneMeshLodsIndex * sizeof(GpuSceneMeshLod) * kMaxLodCount
  318. + lod * sizeof(GpuSceneMeshLod));
  319. queueElem.m_geometryOffset += U32(gpuArrays.getArrayBase(GpuSceneContiguousArrayType::kMeshLods));
  320. queueElem.m_boneTransformsOffset = (hasSkin) ? m_skinComponent->getBoneTransformsGpuSceneOffset() : 0;
  321. queueElem.m_indexCount = modelInf.m_indexCount;
  322. queueElem.m_firstIndex = U32(modelInf.m_indexBufferOffset / 2 + modelInf.m_firstIndex);
  323. queueElem.m_indexed = true;
  324. queueElem.m_primitiveTopology = PrimitiveTopology::kTriangles;
  325. queueElem.m_aabbMin = m_spatial.getAabbWorldSpace().getMin().xyz();
  326. queueElem.m_aabbMax = m_spatial.getAabbWorldSpace().getMax().xyz();
  327. queueElem.computeMergeKey();
  328. ++renderableCount;
  329. }
  330. }
  331. void ModelComponent::setupRayTracingInstanceQueueElements(U32 lod, RenderingTechnique technique,
  332. WeakArray<RayTracingInstanceQueueElement>& outInstances) const
  333. {
  334. ANKI_ASSERT(isEnabled());
  335. outInstances.setArray(nullptr, 0);
  336. const RenderingTechniqueBit requestedRenderingTechniqueMask = RenderingTechniqueBit(1 << technique);
  337. if(!(m_presentRenderingTechniques & requestedRenderingTechniqueMask))
  338. {
  339. return;
  340. }
  341. // Allocate instances
  342. U32 instanceCount = 0;
  343. for(U32 i = 0; i < m_patchInfos.getSize(); ++i)
  344. {
  345. instanceCount += !!(m_patchInfos[i].m_techniques & requestedRenderingTechniqueMask);
  346. }
  347. if(instanceCount == 0)
  348. {
  349. return;
  350. }
  351. RayTracingInstanceQueueElement* instances =
  352. static_cast<RayTracingInstanceQueueElement*>(SceneGraph::getSingleton().getFrameMemoryPool().allocate(
  353. sizeof(RayTracingInstanceQueueElement) * instanceCount, alignof(RayTracingInstanceQueueElement)));
  354. outInstances.setArray(instances, instanceCount);
  355. RenderingKey key;
  356. key.setLod(lod);
  357. key.setRenderingTechnique(technique);
  358. instanceCount = 0;
  359. for(U32 i = 0; i < m_patchInfos.getSize(); ++i)
  360. {
  361. if(!(m_patchInfos[i].m_techniques & requestedRenderingTechniqueMask))
  362. {
  363. continue;
  364. }
  365. RayTracingInstanceQueueElement& queueElem = instances[instanceCount];
  366. const ModelPatch& patch = m_model->getModelPatches()[i];
  367. AllGpuSceneContiguousArrays& gpuArrays = SceneGraph::getSingleton().getAllGpuSceneContiguousArrays();
  368. ModelRayTracingInfo modelInf;
  369. patch.getRayTracingInfo(key, modelInf);
  370. queueElem.m_bottomLevelAccelerationStructure = modelInf.m_bottomLevelAccelerationStructure.get();
  371. queueElem.m_shaderGroupHandleIndex = modelInf.m_shaderGroupHandleIndex;
  372. queueElem.m_worldTransformsOffset = U32(m_gpuSceneTransformsIndex * sizeof(Mat3x4) * 2
  373. + gpuArrays.getArrayBase(GpuSceneContiguousArrayType::kTransformPairs));
  374. queueElem.m_uniformsOffset = m_patchInfos[i].m_gpuSceneUniformsOffset;
  375. queueElem.m_geometryOffset =
  376. U32(m_patchInfos[i].m_gpuSceneMeshLodsIndex * sizeof(GpuSceneMeshLod) * kMaxLodCount
  377. + lod * sizeof(GpuSceneMeshLod));
  378. queueElem.m_geometryOffset += U32(gpuArrays.getArrayBase(GpuSceneContiguousArrayType::kMeshLods));
  379. queueElem.m_indexBufferOffset = U32(modelInf.m_indexBufferOffset);
  380. const Transform positionTransform(patch.getMesh()->getPositionsTranslation().xyz0(), Mat3x4::getIdentity(),
  381. patch.getMesh()->getPositionsScale());
  382. queueElem.m_transform = Mat3x4(m_node->getWorldTransform()).combineTransformations(Mat3x4(positionTransform));
  383. ++instanceCount;
  384. }
  385. }
  386. void ModelComponent::onOtherComponentRemovedOrAdded(SceneComponent* other, Bool added)
  387. {
  388. ANKI_ASSERT(other);
  389. if(other->getClassId() != SkinComponent::getStaticClassId())
  390. {
  391. return;
  392. }
  393. const Bool alreadyHasSkinComponent = m_skinComponent != nullptr;
  394. if(added && !alreadyHasSkinComponent)
  395. {
  396. m_skinComponent = static_cast<SkinComponent*>(other);
  397. m_dirty = true;
  398. }
  399. else if(!added && other == m_skinComponent)
  400. {
  401. m_skinComponent = nullptr;
  402. m_dirty = true;
  403. }
  404. }
  405. } // end namespace anki