From 7604309014d7f8f89c41f95c525f74edd6f56410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 10 Jul 2019 13:37:54 +0200 Subject: [PATCH] DebugTools: make it clearer that ForceRenderer takes a reference. --- doc/snippets/MagnumDebugTools-gl.cpp | 5 +++-- src/Magnum/DebugTools/ForceRenderer.h | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/snippets/MagnumDebugTools-gl.cpp b/doc/snippets/MagnumDebugTools-gl.cpp index 3be3cd82c..9ca354bf6 100644 --- a/doc/snippets/MagnumDebugTools-gl.cpp +++ b/doc/snippets/MagnumDebugTools-gl.cpp @@ -73,8 +73,9 @@ DebugTools::ResourceManager::instance().set("my", .setSize(5.0f) .setColor(Color3::fromHsv({120.0_degf, 1.0f, 0.7f}))); -// Create debug renderer for given object, use "my" options for it -Vector3 force; +Vector3 force; // taken as a reference, has to be kept in scope + +// Create debug renderer for given force, use "my" options for it new DebugTools::ForceRenderer3D(*object, {0.3f, 1.5f, -0.7f}, force, "my", &debugDrawables); /* [ForceRenderer] */ diff --git a/src/Magnum/DebugTools/ForceRenderer.h b/src/Magnum/DebugTools/ForceRenderer.h index 0fd31cced..f290ce4a4 100644 --- a/src/Magnum/DebugTools/ForceRenderer.h +++ b/src/Magnum/DebugTools/ForceRenderer.h @@ -103,7 +103,11 @@ See @ref debug-tools-renderers for more information. @section DebugTools-ForceRenderer-usage Basic usage -Example code: +Example code --- note that the @p force is saved as a reference to the original +vector (so when you update it, the renderer updates itself as well), and thus +it must be available for the whole lifetime of the renderer. The renderer is +automatically added to object's features so you don't need to keep a reference +to it. @snippet MagnumDebugTools-gl.cpp ForceRenderer @@ -124,10 +128,6 @@ template class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer: p * @ref DebugTools-ForceRenderer-usage "class documentation" for * more information. * @param drawables Drawable group - * - * The renderer is automatically added to object's features, @p force - * is saved as reference to original vector and thus it must be - * available for the whole lifetime of the renderer. */ explicit ForceRenderer(SceneGraph::AbstractObject& object, const VectorTypeFor& forcePosition, const VectorTypeFor& force, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup* drawables = nullptr);