Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultDebugDrawer: transform bones and set axes size #2843

Merged
merged 2 commits into from
May 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion OgreMain/include/OgreDefaultDebugDrawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class _OgreExport DefaultDebugDrawer : public DebugDrawer
ManualObject mAxes;
int mDrawType;
bool mStatic;
float mBoneAxesSize;
void preFindVisibleObjects(SceneManager* source, SceneManager::IlluminationRenderStage irs, Viewport* v) override;
void postFindVisibleObjects(SceneManager* source, SceneManager::IlluminationRenderStage irs, Viewport* v) override;
void beginLines();
Expand All @@ -31,13 +32,15 @@ class _OgreExport DefaultDebugDrawer : public DebugDrawer
/// if static, the drawer contents are preserved across frames. They are cleared otherwise.
void setStatic(bool enable) { mStatic = enable; }

void drawBone(const Node* node) override;
void drawBone(const Node* node, const Affine3 & transform = Affine3::IDENTITY) override;
void drawSceneNode(const SceneNode* node) override;
void drawFrustum(const Frustum* frust) override;
/// Allows the rendering of a wireframe bounding box.
void drawWireBox(const AxisAlignedBox& aabb, const ColourValue& colour = ColourValue::White);
/// draw coordinate axes
void drawAxes(const Affine3& pose, float size = 1.0f);
/// Specifes the size of the axes drawn by drawBone()
void setBoneAxesSize(float size);
};

} /* namespace Ogre */
Expand Down
2 changes: 1 addition & 1 deletion OgreMain/include/OgreSceneManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -3306,7 +3306,7 @@ namespace Ogre {
public:
virtual ~DebugDrawer() {}
virtual void drawSceneNode(const SceneNode* node) = 0;
virtual void drawBone(const Node* node) = 0;
virtual void drawBone(const Node* node, const Affine3 & transform = Affine3::IDENTITY) = 0;
virtual void drawFrustum(const Frustum* frust) = 0;
};

Expand Down
10 changes: 7 additions & 3 deletions OgreMain/src/OgreDefaultDebugDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Ogre
{

DefaultDebugDrawer::DefaultDebugDrawer() : mLines(""), mAxes(""), mDrawType(0), mStatic(false) {}
DefaultDebugDrawer::DefaultDebugDrawer() : mLines(""), mAxes(""), mDrawType(0), mStatic(false), mBoneAxesSize(1.0f) {}

void DefaultDebugDrawer::preFindVisibleObjects(SceneManager* source,
SceneManager::IlluminationRenderStage irs, Viewport* v)
Expand Down Expand Up @@ -141,9 +141,13 @@ void DefaultDebugDrawer::drawAxes(const Affine3& pose, float size)
mAxes.triangle(base + 4, base + 5, base + 6);
}
}
void DefaultDebugDrawer::drawBone(const Node* node)
void DefaultDebugDrawer::setBoneAxesSize(float size)
{
drawAxes(node->_getFullTransform());
mBoneAxesSize = size;
}
void DefaultDebugDrawer::drawBone(const Node* node, const Affine3 & transform)
{
drawAxes(transform * node->_getFullTransform(), mBoneAxesSize);
}
void DefaultDebugDrawer::drawSceneNode(const SceneNode* node)
{
Expand Down
4 changes: 1 addition & 3 deletions OgreMain/src/OgreEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,11 @@ namespace Ogre {
}

// HACK to display bones
// This won't work if the entity is not centered at the origin
// TODO work out a way to allow bones to be rendered when Entity not centered
if (mDisplaySkeleton && hasSkeleton() && mManager && mManager->getDebugDrawer())
{
for (Bone* bone : mSkeletonInstance->getBones())
{
mManager->getDebugDrawer()->drawBone(bone);
mManager->getDebugDrawer()->drawBone(bone, mParentNode->_getFullTransform());
}
}
}
Expand Down