优化代码、排版、重命名

This commit is contained in:
2025-07-04 11:12:55 +08:00
parent e87838289a
commit 2b135b1d24
6 changed files with 39 additions and 48 deletions

2
CMCore

Submodule CMCore updated: 25060b07d0...a38866694c

View File

@@ -35,7 +35,7 @@ enum class GizmoShape:uint
bool InitGizmoResource(RenderFramework *);
void FreeGizmoResource();
ComponentDataPtr GetGizmoMeshComponentDataPtr(const GizmoShape &shape,const GizmoColor &color);
ComponentDataPtr GetGizmoMeshCDP(const GizmoShape &shape,const GizmoColor &color);
SceneNode *GetGizmoMoveNode();
//SceneNode *GetGizmoScaleMesh();

View File

@@ -58,124 +58,115 @@ namespace
SceneNode * Duplication() const override
{
GizmoMoveNode *new_gma=(GizmoMoveNode *)SceneNode::Duplication();
GizmoMoveNode *new_gmn=(GizmoMoveNode *)SceneNode::Duplication();
if(!new_gma)
if(!new_gmn)
return(nullptr);
new_gma->sphere=sphere;
for(int i=0;i<3;i++)
{
new_gma->axis[i].cylinder =axis[i].cylinder;
new_gma->axis[i].cone =axis[i].cone;
new_gma->axis[i].square =axis[i].square;
}
new_gmn->sphere=sphere;
hgl_cpy(new_gmn->axis,axis);
return new_gma;
return new_gmn;
}
bool Init(RenderFramework *render_framework)
{
ComponentDataPtr sphere=GetGizmoMeshComponentDataPtr(GizmoShape::Sphere,GizmoColor::White);
ComponentDataPtr sphere_ptr=GetGizmoMeshCDP(GizmoShape::Sphere,GizmoColor::White);
ComponentDataPtr cylinder[3]
{
GetGizmoMeshComponentDataPtr(GizmoShape::Cylinder,GizmoColor::Red),
GetGizmoMeshComponentDataPtr(GizmoShape::Cylinder,GizmoColor::Green),
GetGizmoMeshComponentDataPtr(GizmoShape::Cylinder,GizmoColor::Blue),
#define GET_GIZMO_MESH_CDP(shape) ComponentDataPtr shape##Ptr[3]{ \
GetGizmoMeshCDP(GizmoShape::shape,GizmoColor::Red), \
GetGizmoMeshCDP(GizmoShape::shape,GizmoColor::Green), \
GetGizmoMeshCDP(GizmoShape::shape,GizmoColor::Blue) \
};
ComponentDataPtr cone[3]
{
GetGizmoMeshComponentDataPtr(GizmoShape::Cone,GizmoColor::Red),
GetGizmoMeshComponentDataPtr(GizmoShape::Cone,GizmoColor::Green),
GetGizmoMeshComponentDataPtr(GizmoShape::Cone,GizmoColor::Blue),
};
GET_GIZMO_MESH_CDP(Cylinder)
GET_GIZMO_MESH_CDP(Cone)
GET_GIZMO_MESH_CDP(Square)
ComponentDataPtr square[3]=
{
GetGizmoMeshComponentDataPtr(GizmoShape::Square,GizmoColor::Red),
GetGizmoMeshComponentDataPtr(GizmoShape::Square,GizmoColor::Green),
GetGizmoMeshComponentDataPtr(GizmoShape::Square,GizmoColor::Blue)
};
if(!sphere)
if(!sphere_ptr)
return(false);
for(int i=0;i<3;i++)
{
if(!cylinder[i])
if(!CylinderPtr[i])
return(false);
if(!cone[i])
if(!ConePtr[i])
return(false);
if(!square[i])
if(!SquarePtr[i])
return(false);
}
CreateComponentInfo cci(this);
render_framework->CreateComponent<MeshComponent>(&cci,sphere);
sphere=render_framework->CreateComponent<MeshComponent>(&cci,sphere_ptr);
{
Transform tm;
GizmoMoveAxis *gma;
const Vector3f one_scale(1);
const Vector3f square_scale(2);
const Vector3f cylinder_scale(GIZMO_CYLINDER_RADIUS,GIZMO_CYLINDER_RADIUS,GIZMO_CYLINDER_HALF_LENGTH);
{
gma=axis+size_t(AXIS::Z);
tm.SetScale(cylinder_scale);
tm.SetTranslation(0,0,GIZMO_CYLINDER_OFFSET);
cci.mat=tm;
render_framework->CreateComponent<MeshComponent>(&cci,cylinder[2]); //Z 向上圆柱
gma->cylinder=render_framework->CreateComponent<MeshComponent>(&cci,CylinderPtr[2]); //Z 向上圆柱
tm.SetScale(one_scale);
tm.SetTranslation(0,0,GIZMO_CONE_OFFSET);
cci.mat=tm;
render_framework->CreateComponent<MeshComponent>(&cci,cone[2]); //Z 向上圆锥
gma->cone=render_framework->CreateComponent<MeshComponent>(&cci,ConePtr[2]); //Z 向上圆锥
tm.SetScale(square_scale);
tm.SetTranslation(GIZMO_TWO_AXIS_OFFSET,GIZMO_TWO_AXIS_OFFSET,0);
cci.mat=tm;
render_framework->CreateComponent<MeshComponent>(&cci,square[2]);
gma->square=render_framework->CreateComponent<MeshComponent>(&cci,SquarePtr[2]);
}
{
gma=axis+size_t(AXIS::X);
tm.SetScale(cylinder_scale);
tm.SetRotation(AxisVector::Y,90);
tm.SetTranslation(GIZMO_CYLINDER_OFFSET,0,0);
cci.mat=tm;
render_framework->CreateComponent<MeshComponent>(&cci,cylinder[0]); //X 向右圆柱
gma->cylinder=render_framework->CreateComponent<MeshComponent>(&cci,CylinderPtr[0]); //X 向右圆柱
tm.SetScale(one_scale);
tm.SetTranslation(GIZMO_CONE_OFFSET,0,0);
cci.mat=tm;
render_framework->CreateComponent<MeshComponent>(&cci,cone[0]); //X 向右圆锥
gma->cone=render_framework->CreateComponent<MeshComponent>(&cci,ConePtr[0]); //X 向右圆锥
tm.SetScale(square_scale);
tm.SetTranslation(0,GIZMO_TWO_AXIS_OFFSET,GIZMO_TWO_AXIS_OFFSET);
cci.mat=tm;
render_framework->CreateComponent<MeshComponent>(&cci,square[0]);
gma->square=render_framework->CreateComponent<MeshComponent>(&cci,SquarePtr[0]);
}
{
gma=axis+size_t(AXIS::Y);
tm.SetScale(cylinder_scale);
tm.SetRotation(AxisVector::X,-90);
tm.SetTranslation(0,GIZMO_CYLINDER_OFFSET,0);
cci.mat=tm;
render_framework->CreateComponent<MeshComponent>(&cci,cylinder[1]); //Y 向前圆柱
gma->cylinder=render_framework->CreateComponent<MeshComponent>(&cci,CylinderPtr[1]); //Y 向前圆柱
tm.SetScale(one_scale);
tm.SetTranslation(0,GIZMO_CONE_OFFSET,0);
cci.mat=tm;
render_framework->CreateComponent<MeshComponent>(&cci,cone[1]); //Y 向前圆锥
gma->cone=render_framework->CreateComponent<MeshComponent>(&cci,ConePtr[1]); //Y 向前圆锥
tm.SetScale(square_scale);
tm.SetTranslation(GIZMO_TWO_AXIS_OFFSET,0,GIZMO_TWO_AXIS_OFFSET);
cci.mat=tm;
render_framework->CreateComponent<MeshComponent>(&cci,square[1]);
gma->square=render_framework->CreateComponent<MeshComponent>(&cci,SquarePtr[1]);
}
}

View File

@@ -338,7 +338,7 @@ void FreeGizmoResource()
SAFE_CLEAR(gizmo_line.vdm);
}
ComponentDataPtr GetGizmoMeshComponentDataPtr(const GizmoShape &shape,const GizmoColor &color)
ComponentDataPtr GetGizmoMeshCDP(const GizmoShape &shape,const GizmoColor &color)
{
if(!gizmo_rr)
return(nullptr);

View File

@@ -23,7 +23,7 @@ public:
public:
RenderFramework * GetRenderFramework ()const{return render_framework;} ///<取得渲染框架
VulkanDevice * GetDevice ()const; ///<取得GPU设备
VulkanDevice * GetDevice ()const; ///<取得GPU设备
public: