reepblue Posted May 26 Posted May 26 I brought this up in the discord and now I'm posting it here. It seems that models that have a collision mesh get additional padding on the 2D grid view. This can make it hard to scale certain models like pipes. No collision box After adding a box collision shape. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon!
Josh Posted July 18 Posted July 18 Strange. I tried it with the glTF fox and saw no problem, but this model does show the issue. models.zip Quote My job is to make tools you love, with the features you want, and performance you can't live without.
Josh Posted July 18 Posted July 18 It appears that NewtonCollisionCalculateAABB is calculating extra padding around box colliders. Probably around all of them, judging by this code. void dgCollisionInstance::CalcAABB (const dgMatrix& matrix, dgVector& p0, dgVector& p1) const { switch (m_scaleType) { case m_unit: { m_childShape->CalcAABB (matrix, p0, p1); p0 -= m_padding; p1 += m_padding; break; } case m_uniform: case m_nonUniform: { dgMatrix matrix1 (matrix); matrix1[0] = matrix1[0].Scale(m_scale.m_x); matrix1[1] = matrix1[1].Scale(m_scale.m_y); matrix1[2] = matrix1[2].Scale(m_scale.m_z); m_childShape->CalcAABB (matrix1, p0, p1); p0 -= m_padding; p1 += m_padding; break; } case m_global: default: { dgMatrix matrix1 (matrix); matrix1[0] = matrix1[0].Scale(m_scale.m_x); matrix1[1] = matrix1[1].Scale(m_scale.m_y); matrix1[2] = matrix1[2].Scale(m_scale.m_z); m_childShape->CalcAABB (m_aligmentMatrix * matrix1, p0, p1); p0 -= m_padding; p1 += m_padding; break; } } dgAssert (p0.m_w == dgFloat32 (0.0f)); dgAssert (p1.m_w == dgFloat32 (0.0f)); } Quote My job is to make tools you love, with the features you want, and performance you can't live without.
Josh Posted July 18 Posted July 18 Here is the value... #define DG_MAX_COLLISION_AABB_PADDING dgFloat32 (1.0f / 16.0f) Quote My job is to make tools you love, with the features you want, and performance you can't live without.
Solution Josh Posted July 18 Solution Posted July 18 I just reduced the resulting AABB by the value above, and it seems to work correctly. NewtonCollisionCalculateAABB(col, &identity.i.x, &bounds.min.x, &bounds.max.x); const float DG_MAX_COLLISION_AABB_PADDING = dgFloat32(1.0f / 16.0f); bounds.min += DG_MAX_COLLISION_AABB_PADDING; bounds.max -= DG_MAX_COLLISION_AABB_PADDING; bounds.Update(); Quote My job is to make tools you love, with the features you want, and performance you can't live without.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.