Quat Quat::Normalized() const { #ifdef MATH_AUTOMATIC_SSE return Quat(vec4_normalize(q)); #else Quat copy = *this; float success = copy.Normalize(); assume(success > 0 && "Quat::Normalized failed!"); MARK_UNUSED(success); return copy; #endif }
/* this function is needed for a serious hack that I really * hate doing. R.I.P. clean code R.I.P. */ ray_t* ray_tinypush(ray_t *rayout, const ray_t *ray) { vector4_t v; vec4_set(&v, (float *)&ray->direction); /* make sure direction was normalized */ vec4_normalize(&v); /* create a tiny displacement vector along direction */ vec4_scale(&v, &v, 0.001f); /* copy the ray */ ray_copy(rayout, ray); /* display the new rays origin */ vec4_add(&rayout->origin, &rayout->origin, &v); return rayout; }
static int _llfunc_vec4_normalize(lua_State *L) { vec4 *v = (vec4*)userdata_get_or_die(L, 1); vec4_normalize(v); return 0; }