]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
set-material-flag! refactor
authorJavier Sancho <jsf@jsancho.org>
Wed, 8 Apr 2020 07:16:55 +0000 (09:16 +0200)
committerJavier Sancho <jsf@jsancho.org>
Wed, 8 Apr 2020 07:16:55 +0000 (09:16 +0200)
src/animated-mesh-scene-node.cpp
src/animated-mesh-scene-node.h
src/guile-irrlicht.cpp
src/guile-irrlicht.h
src/material-flags.cpp
src/material-flags.h
src/scene-node.cpp
src/scene-node.h

index ceb5ec201cbe4000d39728ed9ecfaabe582067fa..dc46e8010a2483abcd6d32d0557bf15eeead2dbe 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
+
 #include "animated-mesh-md2.h"
 #include "animated-mesh-scene-node.h"
 #include "wrapped.h"
@@ -40,11 +41,11 @@ extern "C" {
                        wrap_animated_mesh_scene_node, unwrap_animated_mesh_scene_node);
 
   SCM
-  irr_scene_setMD2Animation (SCM wrappedAnimatedMeshSceneNode,
+  irr_scene_setMD2Animation (SCM wrapped_animated_mesh_scene_node,
                              SCM anim)
   {
     irr::scene::IAnimatedMeshSceneNode* node =
-      unwrap_animated_mesh_scene_node (wrappedAnimatedMeshSceneNode);
+      unwrap_animated_mesh_scene_node (wrapped_animated_mesh_scene_node);
     bool result = node->setMD2Animation (scm_to_md2_animation_type (anim));
     return scm_from_bool (result);
   }
index c84aab9b67513e5720414aeeee153e24d119d0e9..04c484bdbed2cc929ca065bd19c1583c318e9450 100644 (file)
@@ -36,7 +36,7 @@ extern "C" {
                         wrap_animated_mesh_scene_node, unwrap_animated_mesh_scene_node);
 
   SCM
-  irr_scene_setMD2Animation (SCM wrappedAnimatedMeshSceneNode,
+  irr_scene_setMD2Animation (SCM wrapped_animated_mesh_scene_node,
                              SCM anim);
 
 }
index f81cff7c73730aeba74dc477fd5c8496da62b8f9..a1e84116ed28d4b07e88e873ae740eaaf5e7384c 100644 (file)
@@ -36,7 +36,6 @@
 #include "guile-irrlicht.h"
 #include "keymap.h"
 #include "material.h"
-#include "material-flags.h"
 #include "mesh.h"
 #include "mesh-scene-node.h"
 #include "reference-counted.h"
@@ -68,7 +67,6 @@ extern "C" {
     init_gui_static_text ();
     init_keymap ();
     init_material ();
-    init_material_flag ();
     init_mesh ();
     init_mesh_scene_node ();
     init_reference_counted ();
@@ -83,10 +81,11 @@ extern "C" {
     scm_c_define_gsubr ("draw-all", 1, 0, 0, (scm_t_subr)irr_drawAll);
     scm_c_define_gsubr ("get-name", 1, 0, 0, (scm_t_subr)irr_getName);
     scm_c_define_gsubr ("set-material!", 2, 0, 0, (scm_t_subr)irr_setMaterial);
+    scm_c_define_gsubr ("set-material-flag!", 3, 0, 0, (scm_t_subr)irr_setMaterialFlag);
     scm_c_define_gsubr ("set-position!", 2, 0, 0, (scm_t_subr)irr_setPosition);
     scm_c_define_gsubr ("set-visible!", 2, 0, 0, (scm_t_subr)irr_setVisible);
-    scm_c_export ("draw-all", "get-name", "set-material!", "set-position!",
-                  "set-visible!", NULL);
+    scm_c_export ("draw-all", "get-name", "set-material!", "set-material-flag!",
+                  "set-position!", "set-visible!", NULL);
   }
 
   SCM
@@ -137,6 +136,22 @@ extern "C" {
       }
   }
 
+  SCM
+  irr_setMaterialFlag (SCM wrapped_obj,
+                       SCM flag,
+                       SCM newvalue)
+  {
+    if (mesh_scene_node_p (wrapped_obj) || scene_node_p (wrapped_obj))
+      {
+        return irr_scene_ISceneNode_setMaterialFlag (wrapped_obj, flag, newvalue);
+      }
+    else
+      {
+        scm_error (scm_arg_type_key, NULL, "Cannot set material flag to object: ~S",
+                   scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
+      }
+  }
+
   SCM
   irr_setPosition (SCM wrapped_obj,
                    SCM position)
@@ -151,7 +166,7 @@ extern "C" {
       }
     else
       {
-        scm_error (scm_arg_type_key, NULL, "Cannot set position for object: ~S",
+        scm_error (scm_arg_type_key, NULL, "Cannot set position to object: ~S",
                    scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
       }
   }
@@ -174,7 +189,7 @@ extern "C" {
       }
     else
       {
-        scm_error (scm_arg_type_key, NULL, "Cannot set visibility for object: ~S",
+        scm_error (scm_arg_type_key, NULL, "Cannot set visibility to object: ~S",
                    scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
       }
     return SCM_UNSPECIFIED;
index 52026d722ebf76790895f2e463608aa96e48f30d..5f42bac5c671832b770f98b01617b76ce886e828 100644 (file)
@@ -40,6 +40,11 @@ extern "C" {
   irr_setMaterial (SCM wrapped_obj,
                    SCM material);
 
+  SCM
+  irr_setMaterialFlag (SCM wrapped_obj,
+                       SCM flag,
+                       SCM newvalue);
+
   SCM
   irr_setPosition (SCM wrapped_obj,
                    SCM position);
index 90aa64e9d335fa58c5ae26178eafa77dd9e282a0..0957af61433ee4fe9c62127f1ed8b579ec3fcfbc 100644 (file)
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-#include "animated-mesh-scene-node.h"
-#include "material-flags.h"
-#include "scene-node.h"
 
 extern "C" {
 
-  void
-  init_material_flag (void)
-  {
-    scm_c_define_gsubr ("set-material-flag!", 3, 0, 0, (scm_t_subr)irr_scene_setMaterialFlag);
-    scm_c_export ("set-material-flag!", NULL);
-  }
-
-  SCM
-  irr_scene_setMaterialFlag (SCM wrapped_obj,
-                             SCM flag,
-                             SCM newvalue)
-  {
-    if (animated_mesh_scene_node_p (wrapped_obj))
-      {
-        unwrap_animated_mesh_scene_node (wrapped_obj)->setMaterialFlag (scm_to_material_flag (flag),
-                                                                        scm_to_bool (newvalue));
-      }
-    else if (scene_node_p (wrapped_obj))
-      {
-        unwrap_scene_node (wrapped_obj)->setMaterialFlag (scm_to_material_flag (flag),
-                                                          scm_to_bool (newvalue));
-      }
-    else
-      {
-        scm_error (scm_arg_type_key, NULL, "Cannot set material flag for object: ~S",
-                   scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
-      }
-    return SCM_UNSPECIFIED;
-  }
-
   irr::video::E_MATERIAL_FLAG
   scm_to_material_flag (SCM material_flag)
   {
index 77aa62b65b9ca81edebbbe93acfe546a2ac7ef53..1b1f0533767d1221d0e7f365047577d58938b962 100644 (file)
 
 extern "C" {
 
-  void
-  init_material_flag (void);
-
-  SCM
-  irr_scene_setMaterialFlag (SCM wrapped_obj,
-                             SCM flag,
-                             SCM newvalue);
-
   irr::video::E_MATERIAL_FLAG
   scm_to_material_flag (SCM material_flag);
 
index 684ad3fa4b57e9fd7a2ee2f74c175bcf1d3ff0b2..f587c05ec28f86662a435bd178b096550c53d605 100644 (file)
@@ -23,6 +23,7 @@
 #include <libguile.h>
 
 #include "animated-mesh-scene-node.h"
+#include "material-flags.h"
 #include "matrix4.h"
 #include "mesh-scene-node.h"
 #include "scene-node.h"
@@ -65,28 +66,63 @@ extern "C" {
     return scm_from_matrix4 (node->getAbsoluteTransformation ());
   }
 
+  SCM
+  irr_scene_ISceneNode_setMaterialFlag (SCM wrapped_scene_node,
+                                        SCM flag,
+                                        SCM newvalue)
+  {
+    irr::scene::ISceneNode* node;
+
+    if (animated_mesh_scene_node_p (wrapped_scene_node))
+      {
+        node = (irr::scene::ISceneNode*)unwrap_animated_mesh_scene_node (wrapped_scene_node);
+      }
+    else if (mesh_scene_node_p (wrapped_scene_node))
+      {
+        node = (irr::scene::ISceneNode*)unwrap_mesh_scene_node (wrapped_scene_node);
+      }
+    else if (scene_node_p (wrapped_scene_node))
+      {
+        node = unwrap_scene_node (wrapped_scene_node);
+      }
+    else
+      {
+        scm_error (scm_arg_type_key, NULL, "Cannot set material flag to object: ~S",
+                   scm_list_1 (wrapped_scene_node), scm_list_1 (wrapped_scene_node));
+      }
+
+    node->setMaterialFlag (scm_to_material_flag (flag),
+                           scm_to_bool (newvalue));
+    return SCM_UNSPECIFIED;
+  }
+
   SCM
   irr_scene_setMaterialTexture (SCM wrapped_scene_node,
                                 SCM texture_layer,
                                 SCM texture)
   {
+    irr::scene::ISceneNode* node;
+
     if (animated_mesh_scene_node_p (wrapped_scene_node))
       {
-        unwrap_animated_mesh_scene_node (wrapped_scene_node)->
-          setMaterialTexture (scm_to_uint32 (texture_layer),
-                              unwrap_texture (texture));
+        node = (irr::scene::ISceneNode*)unwrap_animated_mesh_scene_node (wrapped_scene_node);
+      }
+    else if (mesh_scene_node_p (wrapped_scene_node))
+      {
+        node = (irr::scene::ISceneNode*)unwrap_mesh_scene_node (wrapped_scene_node);
       }
     else if (scene_node_p (wrapped_scene_node))
       {
-        unwrap_scene_node (wrapped_scene_node)->
-          setMaterialTexture (scm_to_uint32 (texture_layer),
-                              unwrap_texture (texture));
+        node = unwrap_scene_node (wrapped_scene_node);
       }
     else
       {
         scm_error (scm_arg_type_key, NULL, "Cannot set material texture to object: ~S",
                    scm_list_1 (wrapped_scene_node), scm_list_1 (wrapped_scene_node));
       }
+
+    node->setMaterialTexture (scm_to_uint32 (texture_layer),
+                              unwrap_texture (texture));
     return SCM_UNSPECIFIED;
   }
 
index 660cc86438a1e7f9f88d33b4323b114d335af17f..3246b8b45d09a5e67bc606f0da34e1e70d40beea 100644 (file)
@@ -41,6 +41,11 @@ extern "C" {
   SCM
   irr_scene_getAbsoluteTransformation (SCM wrapped_scene_node);
 
+  SCM
+  irr_scene_ISceneNode_setMaterialFlag (SCM wrapped_scene_node,
+                                        SCM flag,
+                                        SCM newvalue);
+
   SCM
   irr_scene_setMaterialTexture (SCM wrapped_scene_node,
                                 SCM texture_layer,