Closed as not planned
Description
Simple and elegant. Just like C itself.
typedef struct vec3 {
float x, y, z;
} vec3;
[[clang::operator(*)]]
inline vec3 v3v3_mul(vec3 lhs, vec3 rhs) {
return (vec3) { lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z };
}
[[clang::operator(*)]]
inline vec3 v3v1_mul(vec3 lhs, float rhs) {
return (vec3) { lhs.x * rhs, lhs.y * rhs, lhs.z * rhs };
}
// lhs/self expected to be a pointer for assignment operators
[[clang::operator(*=)]]
inline vec3 v3v3_smul(vec3* self, vec3 rhs) {
self->x *= rhs.x;
self->y *= rhs.y;
self->z *= rhs.z;
return *self;
}
[[clang::operator(*=)]]
inline vec3 v3v1_smul(vec3* self, float rhs) {
self->x *= rhs;
self->y *= rhs;
self->z *= rhs;
return *self;
}