Ape
December 16, 2024, 11:30am
1
In my GUI I often use invisible boxes to group nodes. What is the recommended way of doing it? Is there any difference in performance?
Visible = DISABLED
Alpha = 0
britzl
December 16, 2024, 5:17pm
2
It seems like these two options are treated the same:
static void CollectNodes(HScene scene, dmArray<InternalClippingNode>& clippers, dmArray<RenderEntry>& render_entries)
{
CollectClippers(scene, scene->m_RenderHead, 0, 0, clippers, INVALID_INDEX);
CollectRenderEntries(scene, scene->m_RenderHead, 0, clippers, render_entries);
}
static inline bool IsVisible(InternalNode* n, float opacity)
{
bool use_clipping = n->m_ClipperIndex != INVALID_INDEX;
return n->m_Node.m_IsVisible && (opacity != 0.0f || use_clipping);
}
void RenderScene(HScene scene, const RenderSceneParams& params, void* context)
{
Context* c = scene->m_Context;
c->m_RenderNodes.SetSize(0);
c->m_RenderTransforms.SetSize(0);
c->m_RenderOpacities.SetSize(0);
c->m_StencilClippingNodes.SetSize(0);
// Ideally, we'd like to be able to do this in an Update step,
// but since the gui script is updated _after_ the gui component, we need to accomodate
// for any late scripting changes
// Note: We need this update step for bones as well, since they update their transform
CalculateNodeSize(n);
CalculateNodeTransformAndAlphaCached(scene, n, CalculateNodeTransformFlags(CALCULATE_NODE_INCLUDE_SIZE | CALCULATE_NODE_RESET_PIVOT), transform, opacity);
// Ideally, we'd like to have this update step in the Update function (I'm not even sure why it isn't tbh)
// But for now, let's prune the list here
if (!IsVisible(n, opacity) || n->m_Node.m_IsBone)
{
entry.m_Node = INVALID_HANDLE;
entry.m_RenderKey = INVALID_RENDER_KEY;
++num_pruned;
continue;
}
c->m_RenderTransforms.Push(transform);
c->m_RenderOpacities.Push(opacity);
if (n->m_ClipperIndex != INVALID_INDEX) {
1 Like
AGulev
December 16, 2024, 7:55pm
3
A node can be enabled but invisible. This is useful if you use the node as a click-zone or as a “folder”—a container for other nodes.
In such cases, you usually don’t want the nodes to be rendered (visible) even if they are enabled (i.e., is_enabled
returns true and they can be animated).
4 Likes
11123
December 24, 2024, 3:11am
4
I use the Druid plugin to design the GUI. If I use is_enabled
to disable a node, it causes some APIs to throw errors, as the node becomes unreadable. Therefore, to make it invisible, I move it to a position where it cannot be seen using animations and gui.set_position
. If I set is_visible
, the callback functions will still be triggered.