进一步规范PrimitiveComponent/MeshComponent中获取绑定盒的函数名称,并正确渲染OBB。不过没处理旋转。

This commit is contained in:
2025-07-08 13:46:35 +08:00
parent 2ab8528e86
commit 35f5be16c3
5 changed files with 16 additions and 10 deletions

2
CMCore

Submodule CMCore updated: 6b97ffdf79...a9e37e6219

View File

@@ -1,4 +1,4 @@
#include<hgl/WorkManager.h>
#include<hgl/WorkManager.h>
#include<hgl/filesystem/FileSystem.h>
#include<hgl/graph/VertexDataManager.h>
#include<hgl/graph/InlineGeometry.h>
@@ -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<MeshComponent>(&cci,rm_box->cdp);

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include<hgl/component/RenderComponent.h>
#include<hgl/graph/Mesh.h>
@@ -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();

View File

@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include<hgl/component/SceneComponent.h>
#include<hgl/graph/AABB.h>
@@ -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);