diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-11-16 16:59:33 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-01-20 11:30:08 +0300 |
commit | 674c98bd06a8d3752d750fb659b98ff5b9a238d8 (patch) | |
tree | 03509daa8e1537fa95c125b86a5fcf44d5197652 /source/blender/blenkernel/BKE_effect.h | |
parent | 52384179f4c5153a62d711d326a7f6a877508dbb (diff) |
Nicer hashing functionality for sim debugging using a variadic macro
to support multiple hash identifiers.
Using explicit hashing functions for every sim debug call defeats the
purpose of having a quick feedback system. Now this can be done simply
by passing an arbitrary number of hash inputs (integers) at the end of
the function calls, which are then combined by a system of variadic
macros (based on the ELEM feature). Up to 8 identifiers are supported
currently, but more could be added easily if needed.
Conflicts:
source/blender/blenkernel/intern/particle_system.c
source/blender/physics/intern/BPH_mass_spring.cpp
Diffstat (limited to 'source/blender/blenkernel/BKE_effect.h')
-rw-r--r-- | source/blender/blenkernel/BKE_effect.h | 64 |
1 files changed, 57 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h index 6688cd33e84..c85145470b1 100644 --- a/source/blender/blenkernel/BKE_effect.h +++ b/source/blender/blenkernel/BKE_effect.h @@ -32,8 +32,11 @@ * \since March 2001 * \author nzc */ + #include "DNA_modifier_types.h" +#include "BLI_utildefines.h" + struct Object; struct Scene; struct Effect; @@ -138,9 +141,35 @@ int get_effector_data(struct EffectorCache *eff, struct EffectorData *efd, struc /* ======== Simulation Debugging ======== */ +#define SIM_DEBUG_HASH_BASE 5381 + +unsigned int BKE_sim_debug_data_hash(int i); +unsigned int BKE_sim_debug_data_hash_combine(unsigned int kx, unsigned int ky); + +/* _VA_SIM_DEBUG_HASH#(i, ...): combined hash value of multiple integers */ +/* internal helpers*/ +#define _VA_SIM_DEBUG_HASH1(a) \ + (BKE_sim_debug_data_hash(a)) +#define _VA_SIM_DEBUG_HASH2(a, b) \ + (BKE_sim_debug_data_hash_combine(BKE_sim_debug_data_hash(a), _VA_SIM_DEBUG_HASH1(b))) +#define _VA_SIM_DEBUG_HASH3(a, b, c) \ + (BKE_sim_debug_data_hash_combine(BKE_sim_debug_data_hash(a), _VA_SIM_DEBUG_HASH2(b, c))) +#define _VA_SIM_DEBUG_HASH4(a, b, c, d) \ + (BKE_sim_debug_data_hash_combine(BKE_sim_debug_data_hash(a), _VA_SIM_DEBUG_HASH3(b, c, d))) +#define _VA_SIM_DEBUG_HASH5(a, b, c, d, e) \ + (BKE_sim_debug_data_hash_combine(BKE_sim_debug_data_hash(a), _VA_SIM_DEBUG_HASH4(b, c, d, e))) +#define _VA_SIM_DEBUG_HASH6(a, b, c, d, e, f) \ + (BKE_sim_debug_data_hash_combine(BKE_sim_debug_data_hash(a), _VA_SIM_DEBUG_HASH5(b, c, d, e, f))) +#define _VA_SIM_DEBUG_HASH7(a, b, c, d, e, f, g) \ + (BKE_sim_debug_data_hash_combine(BKE_sim_debug_data_hash(a), _VA_SIM_DEBUG_HASH6(b, c, d, e, f, g))) +#define _VA_SIM_DEBUG_HASH8(a, b, c, d, e, f, g, h) \ + (BKE_sim_debug_data_hash_combine(BKE_sim_debug_data_hash(a), _VA_SIM_DEBUG_HASH7(b, c, d, e, f, g, h))) + +#define SIM_DEBUG_HASH(...) VA_NARGS_CALL_OVERLOAD(_VA_SIM_DEBUG_HASH, __VA_ARGS__) + typedef struct SimDebugElement { - int category_hash; - int hash; + unsigned int category_hash; + unsigned int hash; int type; float color[3]; @@ -160,11 +189,32 @@ typedef struct SimDebugData { } SimDebugData; struct SimDebugData *BKE_sim_debug_data_new(void); -void BKE_sim_debug_data_add_dot(struct SimDebugData *debug_data, const float p[3], float r, float g, float b, const char *category, int hash); -void BKE_sim_debug_data_add_circle(struct SimDebugData *debug_data, const float p[3], const float radius, float r, float g, float b, const char *category, int hash); -void BKE_sim_debug_data_add_line(struct SimDebugData *debug_data, const float p1[3], const float p2[3], float r, float g, float b, const char *category, int hash); -void BKE_sim_debug_data_add_vector(struct SimDebugData *debug_data, const float p[3], const float d[3], float r, float g, float b, const char *category, int hash); -void BKE_sim_debug_data_remove(struct SimDebugData *debug_data, int hash); + +void BKE_sim_debug_data_add_element(struct SimDebugData *debug_data, int type, const float v1[3], const float v2[3], + float r, float g, float b, const char *category, unsigned int hash); +void BKE_sim_debug_data_remove_element(struct SimDebugData *debug_data, unsigned int hash); + +#define BKE_sim_debug_data_add_dot(debug_data, p, r, g, b, category, ...) { \ + const float v2[3] = { 0.0f, 0.0f, 0.0f }; \ + BKE_sim_debug_data_add_element(debug_data, SIM_DEBUG_ELEM_DOT, p, v2, r, g, b, category, SIM_DEBUG_HASH(__VA_ARGS__)); \ +} + +#define BKE_sim_debug_data_add_circle(debug_data, p, radius, r, g, b, category, ...) { \ + const float v2[3] = { radius, 0.0f, 0.0f }; \ + BKE_sim_debug_data_add_element(debug_data, SIM_DEBUG_ELEM_CIRCLE, p, v2, r, g, b, category, SIM_DEBUG_HASH(__VA_ARGS__)); \ +} + +#define BKE_sim_debug_data_add_line(debug_data, p1, p2, r, g, b, category, ...) { \ + BKE_sim_debug_data_add_element(debug_data, SIM_DEBUG_ELEM_LINE, p1, p2, r, g, b, category, SIM_DEBUG_HASH(__VA_ARGS__)); \ +} + +#define BKE_sim_debug_data_add_vector(debug_data, p, d, r, g, b, category, ...) { \ + BKE_sim_debug_data_add_element(debug_data, SIM_DEBUG_ELEM_VECTOR, p, d, r, g, b, category, SIM_DEBUG_HASH(__VA_ARGS__)); \ +} + +#define BKE_sim_debug_data_remove(debug_data, ...) \ + BKE_sim_debug_data_remove_element(debug_data, SIM_DEBUG_HASH(__VA_ARGS__)) + void BKE_sim_debug_data_clear(struct SimDebugData *debug_data); void BKE_sim_debug_data_clear_category(struct SimDebugData *debug_data, const char *category); void BKE_sim_debug_data_free(struct SimDebugData *debug_data); |