在PrimitiveComponent/MeshComponent实现GetBoundingBox函数
This commit is contained in:
@@ -101,6 +101,17 @@ public:
|
||||
return mcd->mesh;
|
||||
}
|
||||
|
||||
const bool GetBoundingBox(AABB &box) const override
|
||||
{
|
||||
Mesh *mesh=GetMesh();
|
||||
|
||||
if (!mesh)
|
||||
return false;
|
||||
|
||||
box=mesh->GetBoundingBox();
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Pipeline *GetPipeline() const
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/component/SceneComponent.h>
|
||||
#include<hgl/graph/AABB.h>
|
||||
#include<hgl/graph/OBB.h>
|
||||
|
||||
COMPONENT_NAMESPACE_BEGIN
|
||||
|
||||
@@ -15,6 +17,20 @@ public:
|
||||
using SceneComponent::SceneComponent;
|
||||
|
||||
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
|
||||
|
||||
COMPONENT_NAMESPACE_END
|
||||
|
Reference in New Issue
Block a user