forked from Mirrors/openclonk
Mesh rotation: Keep rendered mesh inside shape
parent
de1d00eb68
commit
3641509462
|
@ -145,6 +145,11 @@ struct StdMeshBox
|
|||
{
|
||||
float x1, y1, z1;
|
||||
float x2, y2, z2;
|
||||
|
||||
StdMeshVector GetCenter() const
|
||||
{
|
||||
return StdMeshVector{ (x2 + x1) / 2.0f, (y2 + y1) / 2.0f, (z2 + z1) / 2.0f };
|
||||
}
|
||||
};
|
||||
|
||||
class StdSubMesh
|
||||
|
|
|
@ -584,7 +584,10 @@ void C4Object::DrawFaceImpl(C4TargetFacet &cgo, bool action, float fx, float fy,
|
|||
|
||||
if (fix_r != Fix0)
|
||||
{
|
||||
const auto mesh_center = pMeshInstance->GetMesh().GetBoundingBox().GetCenter();
|
||||
matrix = StdMeshMatrix::Translate(-mesh_center.x, -mesh_center.y, -mesh_center.z) * matrix;
|
||||
matrix = StdMeshMatrix::Rotate(fixtof(fix_r) * (M_PI / 180.0f), 0.0f, 0.0f, 1.0f) * matrix;
|
||||
matrix = StdMeshMatrix::Translate(mesh_center.x, mesh_center.y, mesh_center.z) * matrix;
|
||||
}
|
||||
|
||||
if(twdt != fwdt || thgt != fhgt)
|
||||
|
|
Loading…
Reference in New Issue