]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
wrap the bone funcs
authorMartin Taibr <taibr.martin@gmail.com>
Tue, 13 Nov 2018 11:34:09 +0000 (12:34 +0100)
committerMartin Taibr <taibr.martin@gmail.com>
Tue, 13 Nov 2018 11:34:09 +0000 (12:34 +0100)
qcsrc/dpdefs/csprogsdefs.qh
qcsrc/dpdefs/dpextensions.qh
qcsrc/dpdefs/progsdefs.qh
qcsrc/lib/deglobalization.qh

index 0909ede7aa9498cf83f52cb81454e6769fc7a84e..7259b905d7f3a50c8c98613b4dce24e6cf08845e 100644 (file)
 .void(entity this, entity actor, entity trigger) use;
 #define touch move_touch
 
+// deglobalization:
+
+void(vector ang) _makevectors_hidden = #1;
+//#define makevectors DO_NOT_USE_GLOBALS_PREFER_MAKE_VECTORS_MACRO_INSTEAD
+
 void(vector dir) _vectorvectors_hidden = #432;
+
 #define vectorvectors DO_NOT_USE_GLOBALS_PREFER_VECTOR_VECTORS_MACRO_INSTEAD
+
+#define skel_get_bonerel DO_NOT_USE_GLOBALS // not used anywhere so not wrapped
+
+vector(float skel, float bonenum) _skel_get_boneabs_hidden = #270;
+//#define skel_get_boneabs DO_NOT_USE_GLOBALS_PREFER_SKEL_GET_BONE_ABS_MACRO_INSTEAD
+
+void(float skel, float bonenum, vector org) _skel_set_bone_hidden = #271;
+//#define skel_set_bone DO_NOT_USE_GLOBALS_PREFER_SKEL_SET_BONE_MACRO_INSTEAD
+
+#define skel_mul_bone DO_NOT_USE_GLOBALS // not used anywhere so not wrapped
+
+#define skel_mul_bones DO_NOT_USE_GLOBALS // not used anywhere so not wrapped
index 2ed0f9063889af40f2270740e069f47d29f62789..1976c3327af33675ef746cd4a9af9e8c77685d76 100644 (file)
@@ -63,3 +63,17 @@ int() _buf_create = #460;
 #define buf_create _buf_create
 
 #pragma noref 0
+
+// deglobalization:
+
+#define skel_get_bonerel DO_NOT_USE_GLOBALS // not used anywhere so not wrapped
+
+vector(float skel, float bonenum) _skel_get_boneabs_hidden = #270;
+//#define skel_get_boneabs DO_NOT_USE_GLOBALS_PREFER_SKEL_GET_BONE_ABS_MACRO_INSTEAD
+
+void(float skel, float bonenum, vector org) _skel_set_bone_hidden = #271;
+//#define skel_set_bone DO_NOT_USE_GLOBALS_PREFER_SKEL_SET_BONE_MACRO_INSTEAD
+
+#define skel_mul_bone DO_NOT_USE_GLOBALS // not used anywhere so not wrapped
+
+#define skel_mul_bones DO_NOT_USE_GLOBALS // not used anywhere so not wrapped
index ccdf9bc0c4293353a7e8392b059831e313474958..51f687a6a0d7564fdd0c64a701834f3ea7037ad3 100644 (file)
@@ -29,3 +29,10 @@ MACRO_END
 
 #define use use1
 .void(entity this, entity actor, entity trigger) use;
+
+// deglobalization:
+
+void(vector ang) _makevectors_hidden = #1;
+//#define makevectors DO_NOT_USE_GLOBALS_PREFER_MAKE_VECTORS_MACRO_INSTEAD
+
+#define aim DO_NOT_USE_GLOBALS // not used anywhere so not wrapped
index d9417b4895ae45b3b483cbdbad0d83ffe6c13415..c4969f5fc1343ede5cae8ecfb8aa44273f15f9e6 100644 (file)
@@ -6,22 +6,22 @@
 // Functions for which all usages are replaced with these macros can be hidden inside our `*defs.qh` files
 // to prevent anyone from using them accidentally.
 
-// TODO stuff in the engine that uses the v_forward/v_right/v_up globals and is not wrapped:
+// TODO stuff in the engine that uses the v_forward/v_right/v_up globals and is not wrapped yet:
 //  - RF_USEAXIS, addentities, predraw,
-//    CL_GetEntityMatrix (in engine but is called from other functions so transitively any of them can use the globals - e.g. V_CalcRefdef, maybe others)
+//    - CL_GetEntityMatrix (in engine but is called from other functions so transitively any of them can use the globals - e.g. V_CalcRefdef, maybe others)
+//    - however RF_USEAXIS is only used if MF_ROTATE is used which is only set in one place
 //  - e.camera_transform / CL_VM_TransformView (in engine)
 //  - adddynamiclight
 //  - makestatic
 //  - gettaginfo
 //  - getentity
-//  - skel_get_bonerel, skel_get_boneabs, skel_set_bone, skel_mul_bone, skel_mul_bones
-//  - aim
 
 #ifdef GAMEQC
 STATIC_INIT(globals) {
        // set to NaN to more easily detect uninitialized use
        // TODO when all functions are wrapped and the raw functions are not used anymore,
-       // assert that the global vectors are NaN before calling the raw functions
+       // uncomment the defines in *progs.qh files that hide the raw functions
+       // and assert that the global vectors are NaN before calling the raw functions here
        // to make sure nobody (even builtins) is accidentally using them - NaN is the most likely value to expose remaining usages
 
        // TODO make sure `isnan` actually works - potential compiler bug:
@@ -40,7 +40,7 @@ STATIC_INIT(globals) {
 /// Same as the `makevectors` builtin but uses the provided locals instead of the `v_*` globals.
 /// Always use this instead of raw `makevectors` to make the data flow clear.
 #define MAKE_VECTORS(angles, forward, right, up) MACRO_BEGIN { \
-       makevectors(angles); \
+       _makevectors_hidden(angles); \
        forward = v_forward; \
        right = v_right; \
        up = v_up; \
@@ -71,3 +71,24 @@ STATIC_INIT(globals) {
        vector right = '0 0 0'; \
        vector up = '0 0 0'; \
        VECTOR_VECTORS(forward_in, forward, right, up);
+
+/// Returns all 4 vectors by assigning to them (instead of returning a value) for consistency (and sanity)
+#define SKEL_GET_BONE_ABS(skel, bonenum, forward, right, up, origin) MACRO_BEGIN { \
+       origin = _skel_get_boneabs_hidden(skel, bonenum) \
+       forward = v_forward; \
+       right = v_right; \
+       up = v_up; \
+       v_forward = VEC_NAN; \
+       v_right = VEC_NAN; \
+       v_up = VEC_NAN; \
+} MACRO_END
+
+#define SKEL_SET_BONE(skel, bonenum, org, forward, right, up) MACRO_BEGIN { \
+       v_forward = forward; \
+       v_right = right; \
+       v_up = up; \
+       _skel_set_bone_hidden(skel, bonenum, org); \
+       v_forward = VEC_NAN; \
+       v_right = VEC_NAN; \
+       v_up = VEC_NAN; \
+} MACRO_END