More body flag fixes (#9)

better name handling
This commit is contained in:
Erin Catto 2026-05-29 21:35:38 -07:00 • committed by GitHub
commit 48d9f1dd5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 223 additions and 88 deletions

View file

@ -108,7 +108,7 @@ Matrix4 Camera::GetWorldMatrix() const
return m;
}
static Matrix4 InvertOrtho( const Matrix4& m)
static Matrix4 InvertOrthonormal( const Matrix4& m)
{
// [ R | t ]
// M = [ --+-- ]
@ -123,7 +123,9 @@ static Matrix4 InvertOrtho( const Matrix4& m)
r.cx = {m.cx.x, m.cx.y, m.cx.z };
r.cy = {m.cy.x, m.cy.y, m.cy.z };
r.cz = {m.cz.x, m.cz.y, m.cz.z };
b3Matrix3 invR = b3InvertMatrix(r);
// todo just transpose in place into out matrix
b3Matrix3 invR = b3Transpose(r);
b3Vec3 t{m.cw.x, m.cw.y, m.cw.z };
b3Vec3 invRXT = invR * t;
@ -140,7 +142,7 @@ static Matrix4 InvertOrtho( const Matrix4& m)
Matrix4 Camera::GetViewMatrix() const
{
Matrix4 v = GetWorldMatrix();
v = InvertOrtho(v);
v = InvertOrthonormal(v);
return v;
}

View file

@ -733,44 +733,6 @@ void DrawHull( Scene* scene, const b3Transform& transform, const b3Hull* hull, b
}
}
void DrawEllipsoid( Scene* scene, const b3Transform& transform, b3Vec3 radius, b3HexColor color )
{
b3Vec3 ex = { 1.0f, 0.0, 0.0f };
b3Vec3 ey = { 0.0f, 1.0, 0.0f };
b3Vec3 ez = { 0.0f, 0.0, 1.0f };
for ( float angle = 0.0f; angle < 360.0f; angle += 5.0f )
{
float alpha1 = B3_DEG_TO_RAD * ( angle + 0.0f );
float alpha2 = B3_DEG_TO_RAD * ( angle + 5.0f );
// XY - Plane
{
b3Vec3 vertex1 = radius * ( b3Cos( alpha1 ) * ex + b3Sin( alpha1 ) * ey );
b3Vec3 vertex2 = radius * ( b3Cos( alpha2 ) * ex + b3Sin( alpha2 ) * ey );
vertex1 = b3TransformPoint( transform, vertex1 );
vertex2 = b3TransformPoint( transform, vertex2 );
DrawLine( scene, vertex1, vertex2, color );
}
// XZ - Plane
{
b3Vec3 vertex1 = radius * ( b3Cos( alpha1 ) * ex + b3Sin( alpha1 ) * ez );
b3Vec3 vertex2 = radius * ( b3Cos( alpha2 ) * ex + b3Sin( alpha2 ) * ez );
vertex1 = b3TransformPoint( transform, vertex1 );
vertex2 = b3TransformPoint( transform, vertex2 );
DrawLine( scene, vertex1, vertex2, color );
}
// YZ - Plane
{
b3Vec3 vertex1 = radius * ( b3Cos( alpha1 ) * ex + b3Sin( alpha1 ) * ez );
b3Vec3 vertex2 = radius * ( b3Cos( alpha2 ) * ey + b3Sin( alpha2 ) * ez );
vertex1 = b3TransformPoint( transform, vertex1 );
vertex2 = b3TransformPoint( transform, vertex2 );
DrawLine( scene, vertex1, vertex2, color );
}
}
}
void DrawTransform( Scene* scene, const b3Transform& transform, float length )
{
b3Vec3 p = transform.p;

View file

@ -28,7 +28,6 @@ void DrawCross( Scene* scene, b3Vec3 center, float radius, b3HexColor color );
void DrawSphere( Scene* scene, const b3Transform& transform, const b3Sphere& sphere, b3HexColor color );
void DrawCapsule( Scene* scene, const b3Transform& transform, const b3Capsule& capsule, b3HexColor color );
void DrawHull( Scene* scene, const b3Transform& transform, const b3Hull* hull, b3HexColor color, bool drawNormals );
void DrawEllipsoid( Scene* scene, const b3Transform& transform, b3Vec3 radius, b3HexColor color );
void DrawTransform( Scene* scene, const b3Transform& transform, float length );
// Debug points