在PrimitiveComponent/MeshComponent实现GetBoundingBox函数
This commit is contained in:
2
CMCore
2
CMCore
Submodule CMCore updated: 8e733a2415...6b97ffdf79
Submodule CMSceneGraph updated: 1e7e4a025c...584ac02106
@@ -231,7 +231,7 @@ private:
|
|||||||
CreateComponentInfo cci(GetSceneRoot());
|
CreateComponentInfo cci(GetSceneRoot());
|
||||||
|
|
||||||
{
|
{
|
||||||
cci.mat=scale(10,10,1);
|
cci.mat=ScaleMatrix(10,10,1);
|
||||||
|
|
||||||
rm_plane->component=CreateComponent<MeshComponent>(&cci,rm_plane->cdp);
|
rm_plane->component=CreateComponent<MeshComponent>(&cci,rm_plane->cdp);
|
||||||
}
|
}
|
||||||
@@ -250,7 +250,7 @@ private:
|
|||||||
{
|
{
|
||||||
CreateComponentInfo cci(GetSceneRoot());
|
CreateComponentInfo cci(GetSceneRoot());
|
||||||
|
|
||||||
cci.mat=rm_torus->component->GetLocalMatrix();
|
//cci.mat=rm_torus->component->GetLocalMatrix()*rm_torus->component->GetMesh()->GetBoundingBox();
|
||||||
|
|
||||||
CreateComponent<MeshComponent>(&cci,rm_box->cdp);
|
CreateComponent<MeshComponent>(&cci,rm_box->cdp);
|
||||||
|
|
||||||
|
@@ -101,6 +101,17 @@ public:
|
|||||||
return mcd->mesh;
|
return mcd->mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool GetBoundingBox(AABB &box) const override
|
||||||
|
{
|
||||||
|
Mesh *mesh=GetMesh();
|
||||||
|
|
||||||
|
if (!mesh)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
box=mesh->GetBoundingBox();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Pipeline *GetPipeline() const
|
Pipeline *GetPipeline() const
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include<hgl/component/SceneComponent.h>
|
#include<hgl/component/SceneComponent.h>
|
||||||
|
#include<hgl/graph/AABB.h>
|
||||||
|
#include<hgl/graph/OBB.h>
|
||||||
|
|
||||||
COMPONENT_NAMESPACE_BEGIN
|
COMPONENT_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@@ -15,6 +17,20 @@ public:
|
|||||||
using SceneComponent::SceneComponent;
|
using SceneComponent::SceneComponent;
|
||||||
|
|
||||||
virtual ~PrimitiveComponent()=default;
|
virtual ~PrimitiveComponent()=default;
|
||||||
|
|
||||||
|
virtual const bool GetBoundingBox(AABB &box) const =0;
|
||||||
|
|
||||||
|
const bool GetBoundingBox(OBB &box)
|
||||||
|
{
|
||||||
|
AABB aabb;
|
||||||
|
|
||||||
|
if(!GetBoundingBox(aabb))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
box.Set(GetLocalToWorldMatrix(),aabb);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};//class PrimitiveComponent
|
};//class PrimitiveComponent
|
||||||
|
|
||||||
COMPONENT_NAMESPACE_END
|
COMPONENT_NAMESPACE_END
|
||||||
|
Reference in New Issue
Block a user