Skip to content

Commit

Permalink
Bug fixes in vec3_is_null
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi688 committed Jan 28, 2022
1 parent 7b6a4d3 commit 9016081
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/hpml/vec3/template_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ vec3_t(T) vec3_null(T)()\
#define instantiate_implementation_vec3_is_null(T)\
bool vec3_is_null(T)(vec3_t(T) v)\
{\
return (v.x == 0) || (v.y == 0) || (v.z == 0);\
return (v.x == 0) && (v.y == 0) && (v.z == 0);\
}

/* vec3_add: Adds two vector3 vectors component wise, i.e. v1 + v2
Expand Down
9 changes: 9 additions & 0 deletions include/hpml/vec4/template_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <hpml/defines.h>

#include <stdarg.h>
#include <stdbool.h>

/*DATA*/
/*vec4_t(T) struct*/
Expand Down Expand Up @@ -354,6 +355,14 @@ EXCEPTION_BLOCK\
return v;\
}

/*MISC*/
#define vec4_is_null(T) template(vec4_is_null, T)
#define instantiate_declaration_vec4_is_null(T) bool vec4_is_null(T)(vec4_t(T) v)
#define instantiate_implementation_vec4_is_null(T) bool vec4_is_null(T)(vec4_t(T) v)\
{\
return (v.x == 0) && (v.y == 0) && (v.z == 0) && (v.w == 0);\
}

/*DEBUGGING*/

/*vec4_print*/
Expand Down
7 changes: 5 additions & 2 deletions include/hpml/vec4/template_instantiations.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ instantiate_declaration_vec4_left(int);
instantiate_declaration_vec4_right(int);
instantiate_declaration_vec4_forward(int);
instantiate_declaration_vec4_back(int);
instantiate_declaration_vec4_is_null(int);

instantiate_declaration_vec4_print(int);
instantiate_declaration_vec4_normalize(int);
Expand All @@ -40,7 +41,7 @@ instantiate_declaration_vec4_axis_rotate(int);
instantiate_declaration_vec4_box(int);
instantiate_declaration_vec4_project(int);
instantiate_declaration_vec4_unit_project(int);

instantiate_declaration_vec4_is_null(int);

instantiate_vec4_struct(float);
instantiate_declaration_vec4(float);
Expand All @@ -59,6 +60,7 @@ instantiate_declaration_vec4_left(float);
instantiate_declaration_vec4_right(float);
instantiate_declaration_vec4_forward(float);
instantiate_declaration_vec4_back(float);
instantiate_declaration_vec4_is_null(float);

instantiate_declaration_vec4_print(float);
instantiate_declaration_vec4_normalize(float);
Expand Down Expand Up @@ -92,6 +94,7 @@ instantiate_implementation_vec4_left(int);
instantiate_implementation_vec4_right(int);
instantiate_implementation_vec4_forward(int);
instantiate_implementation_vec4_back(int);
instantiate_implementation_vec4_is_null(int);

void vec4_print(int)(vec4_t(int) v) { printf("vec4_t(int): { %d, %d, %d, %d }\n", v.x, v.y, v.z, v.w); }
instantiate_implementation_vec4_normalize(int);
Expand All @@ -108,7 +111,6 @@ instantiate_implementation_vec4_box(int);
instantiate_implementation_vec4_project(int);
instantiate_implementation_vec4_unit_project(int);


instantiate_implementation_vec4(float);
instantiate_implementation_vec4_zero(float);
instantiate_implementation_vec4_add(float);
Expand All @@ -125,6 +127,7 @@ instantiate_implementation_vec4_left(float);
instantiate_implementation_vec4_right(float);
instantiate_implementation_vec4_forward(float);
instantiate_implementation_vec4_back(float);
instantiate_implementation_vec4_is_null(float);

void vec4_print(float)(vec4_t(float) v) { printf("vec4_t(float): { %f, %f, %f, %f }\n", v.x, v.y, v.z, v.w); }
instantiate_implementation_vec4_normalize(float);
Expand Down

0 comments on commit 9016081

Please sign in to comment.