Skip to content

Commit

Permalink
Attempt to fix #1769 (#1778)
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 authored Dec 19, 2023
1 parent 3e8133c commit b7f5dd1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
5 changes: 4 additions & 1 deletion dart/dynamics/BodyNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ ConstSkeletonPtr SkeletonRefCountingBase::getSkeleton() const
/// SET_FLAGS : A version of SKEL_SET_FLAGS that assumes a SkeletonPtr named
/// 'skel' has already been locked
#define SET_FLAGS(X) \
skel->mTreeCache[mTreeIndex].mDirty.X = true; \
if (mTreeIndex != INVALID_INDEX) \
{ \
skel->mTreeCache[mTreeIndex].mDirty.X = true; \
} \
skel->mSkelCache.mDirty.X = true;

/// CHECK_FLAG : Check if the dirty flag X for the tree of this BodyNode is
Expand Down
7 changes: 7 additions & 0 deletions dart/dynamics/Skeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2357,6 +2357,13 @@ void Skeleton::registerNode(Node* _newNode)
//==============================================================================
void Skeleton::destructOldTree(std::size_t tree)
{
// Invalidate the tree indices of every BodyNode that is being removed
DataCache& treeToDestroy = mTreeCache[tree];
for (auto& bodyNode : treeToDestroy.mBodyNodes)
{
bodyNode->mTreeIndex = INVALID_INDEX;
}

mTreeCache.erase(mTreeCache.begin() + tree);
mTreeNodeMaps.erase(mTreeNodeMaps.begin() + tree);

Expand Down
13 changes: 13 additions & 0 deletions dart/gui/osg/Viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ namespace dart {
namespace gui {
namespace osg {

std::string toString(CameraMode mode)
{
switch (mode)
{
case CameraMode::RGBA:
return "RGBA";
case CameraMode::DEPTH:
return "DEPTH";
default:
return "UNKNOWN";
}
}

class SaveScreen : public ::osg::Camera::DrawCallback
{
public:
Expand Down
4 changes: 3 additions & 1 deletion dart/gui/osg/Viewer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ enum class CameraMode

/// To render the depth buffer
///
/// \warning The DEPTH mode currently not compatible with the ImGui wigets.
/// \warning The DEPTH mode currently not compatible with the ImGui widgets.
DEPTH,
};

[[nodiscard]] std::string toString(CameraMode mode);

DART_DECLARE_CLASS_WITH_VIRTUAL_BASE_BEGIN
class ViewerAttachment : public virtual ::osg::Group
{
Expand Down
3 changes: 1 addition & 2 deletions dart/gui/osg/detail/CameraModeCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ void CameraModeCallback::setCameraMode(CameraMode mode)
if (mode != CameraMode::RGBA && mode != CameraMode::DEPTH)
{
DART_WARN(
"Unsupported camera mode '{}'. Use RGBA or DEPTH.",
static_cast<int>(mode));
"Unsupported camera mode '{}'. Use RGBA or DEPTH.", toString(mode));
return;
}

Expand Down

0 comments on commit b7f5dd1

Please sign in to comment.