fix that update_transform flag was never cleared

Sun, 11 Aug 2024 16:28:54 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 11 Aug 2024 16:28:54 +0200
changeset 69
86d545f490e4
parent 68
823c03733e42
child 70
81a089a47eff

fix that update_transform flag was never cleared

added more flags regarding graphics and transform update

src/ascension/scene.h file | annotate | diff | comparison | revisions
src/scene.c file | annotate | diff | comparison | revisions
--- a/src/ascension/scene.h	Sun Aug 11 16:11:30 2024 +0200
+++ b/src/ascension/scene.h	Sun Aug 11 16:28:54 2024 +0200
@@ -69,10 +69,30 @@
     uint32_t flags;
 };
 
-#define ASC_SCENE_NODE_FLAGS_MASK       0xFF000000
-#define ASC_SCENE_NODE_UPDATE_GRAPHICS  0x01000000
-#define ASC_SCENE_NODE_UPDATE_TRANSFORM 0x02000000
-#define ASC_SCENE_NODE_HIDDEN           0x80000000
+/**
+ * The reserved bits for general flags.
+ */
+#define ASC_SCENE_NODE_FLAGS_MASK             0xFF000000
+/**
+ * Set when a graphics update is needed in this frame.
+ */
+#define ASC_SCENE_NODE_UPDATE_GRAPHICS        0x01000000
+/**
+ * Set when a graphics updated happened last frame.
+ */
+#define ASC_SCENE_NODE_GRAPHICS_UPDATED       0x10000000
+/**
+ * Set when a transform update is needed in this frame.
+ */
+#define ASC_SCENE_NODE_UPDATE_TRANSFORM       0x02000000
+/**
+ * Set when a transform update happened last frame.
+ */
+#define ASC_SCENE_NODE_TRANSFORM_UPDATED      0x20000000
+/**
+ * Set when the node is not supposed to be shown on screen.
+ */
+#define ASC_SCENE_NODE_HIDDEN                 0x80000000
 
 /**
  * Place this as first member of a structure that shall be used as a scene node.
--- a/src/scene.c	Sun Aug 11 16:11:30 2024 +0200
+++ b/src/scene.c	Sun Aug 11 16:28:54 2024 +0200
@@ -100,13 +100,18 @@
         // TODO: implement culling
 
         // check if geometry needs update
+        asc_clear_flag(node->flags,
+                       ASC_SCENE_NODE_GRAPHICS_UPDATED
+                       | ASC_SCENE_NODE_TRANSFORM_UPDATED);
         if (asc_test_flag(node->flags, ASC_SCENE_NODE_UPDATE_GRAPHICS)) {
+            asc_set_flag(node->flags, ASC_SCENE_NODE_GRAPHICS_UPDATED);
+            asc_clear_flag(node->flags, ASC_SCENE_NODE_UPDATE_GRAPHICS);
             assert(node->update_func != NULL);
-            asc_clear_flag(node->flags, ASC_SCENE_NODE_UPDATE_GRAPHICS);
             node->update_func(node);
         }
         if (asc_test_flag(node->flags, ASC_SCENE_NODE_UPDATE_TRANSFORM)) {
-            asc_test_flag(node->flags, ASC_SCENE_NODE_UPDATE_TRANSFORM);
+            asc_set_flag(node->flags, ASC_SCENE_NODE_TRANSFORM_UPDATED);
+            asc_clear_flag(node->flags, ASC_SCENE_NODE_UPDATE_TRANSFORM);
             asc_transform_from_parts(
                     node->transform,
                     node->position,

mercurial