diff --git a/CMCore b/CMCore index 6b97ffdf..a9e37e62 160000 --- a/CMCore +++ b/CMCore @@ -1 +1 @@ -Subproject commit 6b97ffdf79ff978fff89ca5276a21c1a18c98669 +Subproject commit a9e37e6219e538592686e00f0447d3144677ff97 diff --git a/CMSceneGraph b/CMSceneGraph index 584ac021..048acfdf 160000 --- a/CMSceneGraph +++ b/CMSceneGraph @@ -1 +1 @@ -Subproject commit 584ac02106791566f6df9a45ccd0678f333efbc7 +Subproject commit 048acfdf45554155de4ca6e79e67480a9c9eebd1 diff --git a/example/Basic/RenderBoundBox.cpp b/example/Basic/RenderBoundBox.cpp index 53fced5d..6e50791e 100644 --- a/example/Basic/RenderBoundBox.cpp +++ b/example/Basic/RenderBoundBox.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -250,7 +250,13 @@ private: { CreateComponentInfo cci(GetSceneRoot()); - //cci.mat=rm_torus->component->GetLocalMatrix()*rm_torus->component->GetMesh()->GetBoundingBox(); + ParsePrimitiveType + OBB obb; + rm_torus->component->GetWorldOBB(obb); + + cci.mat=TranslateMatrix(obb.GetCenter()) * + obb.GetRotationMatrix() * + ScaleMatrix(obb.GetHalfExtend()*2.0f); //*2.0f并不是因为OBB尺寸不对,是因为CUBE的原始尺寸就是1 CreateComponent(&cci,rm_box->cdp); diff --git a/inc/hgl/component/MeshComponent.h b/inc/hgl/component/MeshComponent.h index d10d0469..179c9924 100644 --- a/inc/hgl/component/MeshComponent.h +++ b/inc/hgl/component/MeshComponent.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -101,7 +101,7 @@ public: return mcd->mesh; } - const bool GetBoundingBox(AABB &box) const override + const bool GetLocalAABB(AABB &box) const override { Mesh *mesh=GetMesh(); diff --git a/inc/hgl/component/PrimitiveComponent.h b/inc/hgl/component/PrimitiveComponent.h index 678f1750..e3f5d3e5 100644 --- a/inc/hgl/component/PrimitiveComponent.h +++ b/inc/hgl/component/PrimitiveComponent.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -18,13 +18,13 @@ public: virtual ~PrimitiveComponent()=default; - virtual const bool GetBoundingBox(AABB &box) const =0; + virtual const bool GetLocalAABB(AABB &box) const=0; - const bool GetBoundingBox(OBB &box) + const bool GetWorldOBB(OBB &box) { AABB aabb; - if(!GetBoundingBox(aabb)) + if(!GetLocalAABB(aabb)) return false; box.Set(GetLocalToWorldMatrix(),aabb);