diff --git a/src/CRE/Glitter/effect_inst.cpp b/src/CRE/Glitter/effect_inst.cpp index 392e9cee..c596773c 100644 --- a/src/CRE/Glitter/effect_inst.cpp +++ b/src/CRE/Glitter/effect_inst.cpp @@ -192,14 +192,14 @@ namespace Glitter { mat4 mat; if (GetExtAnimMat(&mat)) - mat4_translate_mult(&mat, &translation, &mat); + mat4_mul_translate(&mat, &translation, &mat); else mat4_translate(&translation, &mat); vec3 rot = rotation; vec3 scale = this->scale * scale_all; - mat4_rotate_zyx_mult(&mat, &rot, &mat); + mat4_mul_rotate_zyx(&mat, &rot, &mat); mat4_scale_rot(&mat, &scale, &this->mat); for (F2EmitterInst*& i : emitters) @@ -299,7 +299,7 @@ namespace Glitter { vec3 rot = rotation; vec3 scale = this->scale * scale_all; - mat4_rotate_zyx_mult(&mat, &rot, &mat); + mat4_mul_rotate_zyx(&mat, &rot, &mat); mat4_scale_rot(&mat, &scale, &this->mat); for (F2EmitterInst*& i : emitters) @@ -337,7 +337,7 @@ namespace Glitter { mat4 mat; mat4_translate(&trans, &mat); - mat4_rotate_zyx_mult(&mat, &rot, &mat); + mat4_mul_rotate_zyx(&mat, &rot, &mat); mat4_scale_rot(&mat, &scale, &mat); this->mat = mat; @@ -384,7 +384,7 @@ namespace Glitter { if (!bone_mat) return; - mat4_mult(bone_mat, &mat, &mat); + mat4_mul(bone_mat, &mat, &mat); } if (flags & EFFECT_INST_EXT_ANIM_TRANS_ONLY) { @@ -439,7 +439,7 @@ namespace Glitter { obj_mesh* mesh = object_storage_get_obj_mesh_by_index( ext_anim->object, ext_anim->mesh_index); if (mesh) { - mat4_mult(obj_mat, &mat, &mat); + mat4_mul(obj_mat, &mat, &mat); ext_anim->mat = mat; ext_anim->translation = mesh->bounding_sphere.center; goto SetFlags; @@ -447,7 +447,7 @@ namespace Glitter { } } else { - mat4_mult(obj_mat, &mat, &mat); + mat4_mul(obj_mat, &mat, &mat); if (flags & EFFECT_INST_EXT_ANIM_TRANS_ONLY) { ext_anim->mat = mat4_identity; mat4_get_translation(&mat, &ext_anim->translation); @@ -488,7 +488,7 @@ namespace Glitter { if (!(flags & EFFECT_INST_HAS_EXT_ANIM_TRANS) || !ext_anim) return false; - mat4_translate_mult(&ext_anim->mat, &ext_anim->translation, mat); + mat4_mul_translate(&ext_anim->mat, &ext_anim->translation, mat); return true; } @@ -720,9 +720,9 @@ namespace Glitter { mat4_clear_trans(&mat_rot, &mat_rot); mat_rot_eff_rot = mat_rot; - mat4_rotate_zyx_mult(&mat_rot, &rot, &mat_rot); + mat4_mul_rotate_zyx(&mat_rot, &rot, &mat_rot); - mat4_translate_mult(&mat, &translation, &mat); + mat4_mul_translate(&mat, &translation, &mat); } else { mat_rot = mat4_identity; @@ -734,7 +734,7 @@ namespace Glitter { vec3 scale = this->scale * scale_all; - mat4_rotate_zyx_mult(&mat, &rot, &mat); + mat4_mul_rotate_zyx(&mat, &rot, &mat); mat4_scale_rot(&mat, &scale, &this->mat); for (XEmitterInst*& i : emitters) @@ -846,7 +846,7 @@ namespace Glitter { mat4 mat; mat4_translate(&trans, &mat); - mat4_rotate_zyx_mult(&mat, &rot, &mat); + mat4_mul_rotate_zyx(&mat, &rot, &mat); mat4_scale_rot(&mat, &scale, &this->mat); for (XEmitterInst*& i : emitters) @@ -884,7 +884,7 @@ namespace Glitter { mat4 mat; mat4_translate(&trans, &mat); - mat4_rotate_zyx_mult(&mat, &rot, &mat); + mat4_mul_rotate_zyx(&mat, &rot, &mat); mat4_scale_rot(&mat, &scale, &mat); this->mat = mat; @@ -1024,7 +1024,7 @@ namespace Glitter { if (!(flags & EFFECT_INST_HAS_EXT_ANIM_TRANS) || !ext_anim) return false; - mat4_translate_mult(&ext_anim->mat, &ext_anim->translation, mat); + mat4_mul_translate(&ext_anim->mat, &ext_anim->translation, mat); return true; } @@ -1131,7 +1131,7 @@ namespace Glitter { if (a2) { mat4 mat = *a2; if (a3) - mat4_mult(a3, &mat, &mat); + mat4_mul(a3, &mat, &mat); if (flags & EFFECT_INST_EXT_ANIM_TRANS_ONLY) { ext_anim->mat = mat4_identity; diff --git a/src/CRE/Glitter/emitter_inst.cpp b/src/CRE/Glitter/emitter_inst.cpp index df00b3e4..cf1c63c2 100644 --- a/src/CRE/Glitter/emitter_inst.cpp +++ b/src/CRE/Glitter/emitter_inst.cpp @@ -139,7 +139,7 @@ namespace Glitter { switch (data.direction) { case DIRECTION_BILLBOARD: mat4_from_mat3(&GPM_VAL->cam.inv_view_mat3, &dir_mat); - mat4_mult(&eff_inst->mat, &dir_mat, &dir_mat); + mat4_mul(&eff_inst->mat, &dir_mat, &dir_mat); mat4_clear_trans(&dir_mat, &dir_mat); break; case DIRECTION_Y_AXIS: @@ -160,11 +160,11 @@ namespace Glitter { } mat4 mat; - mat4_translate_mult(&eff_inst->mat, &trans, &mat); + mat4_mul_translate(&eff_inst->mat, &trans, &mat); mat4_normalize_rotation(&mat, &mat); if (mult) - mat4_mult(&dir_mat, &mat, &mat); - mat4_rotate_zyx_mult(&mat, &rot, &mat); + mat4_mul(&dir_mat, &mat, &mat); + mat4_mul_rotate_zyx(&mat, &rot, &mat); mat4_clear_trans(&mat, &mat_rot); mat4_scale_rot(&mat, &scale, &mat); this->mat = mat; @@ -485,7 +485,7 @@ namespace Glitter { vec3 scale = this->scale * scale_all; mat4 mat = eff_inst->mat; - mat4_translate_mult(&mat, &trans, &mat); + mat4_mul_translate(&mat, &trans, &mat); mat4 mat_rot; if (data.direction == DIRECTION_EFFECT_ROTATION) { mat4_normalize_rotation(&mat, &mat); @@ -501,14 +501,14 @@ namespace Glitter { if (eff_inst->data.flags & EFFECT_LOCAL) { dir_mat = GPM_VAL->cam.view; mat4_clear_trans(&dir_mat, &dir_mat); - mat4_mult(&dir_mat, &mat, &dir_mat); + mat4_mul(&dir_mat, &mat, &dir_mat); } else dir_mat = mat; mat4 inv_view_mat; mat4_from_mat3(&GPM_VAL->cam.inv_view_mat3, &inv_view_mat); - mat4_mult(&dir_mat, &inv_view_mat, &dir_mat); + mat4_mul(&dir_mat, &inv_view_mat, &dir_mat); mat4_clear_trans(&dir_mat, &dir_mat); } break; case DIRECTION_Y_AXIS: @@ -526,12 +526,12 @@ namespace Glitter { } if (mult) { - mat4_mult(&dir_mat, &mat, &mat); - mat4_mult(&dir_mat, &mat_rot, &mat_rot); + mat4_mul(&dir_mat, &mat, &mat); + mat4_mul(&dir_mat, &mat_rot, &mat_rot); } - mat4_rotate_zyx_mult(&mat, &rot, &mat); - mat4_rotate_zyx_mult(&mat_rot, &rot, &mat_rot); + mat4_mul_rotate_zyx(&mat, &rot, &mat); + mat4_mul_rotate_zyx(&mat_rot, &rot, &mat_rot); mat4_scale_rot(&mat, &scale, &mat); this->mat = mat; this->mat_rot = mat_rot; @@ -593,9 +593,9 @@ namespace Glitter { vec3 trans = translation; vec3 rot = rotation; mat = eff_inst->mat; - mat4_translate_mult(&mat, &trans, &mat); - mat4_rotate_zyx_mult(&mat, &rot, &mat); - mat4_rotate_zyx_mult(&mat_rot, &rot, &mat_rot); + mat4_mul_translate(&mat, &trans, &mat); + mat4_mul_rotate_zyx(&mat, &rot, &mat); + mat4_mul_rotate_zyx(&mat_rot, &rot, &mat_rot); this->mat = mat; this->mat_rot = mat_rot; @@ -611,7 +611,7 @@ namespace Glitter { vec3 scale = this->scale * scale_all; mat4 mat = eff_inst->mat; - mat4_translate_mult(&mat, &trans, &mat); + mat4_mul_translate(&mat, &trans, &mat); mat4 mat_rot; if (data.direction == DIRECTION_EFFECT_ROTATION) { mat4_normalize_rotation(&mat, &mat); @@ -625,7 +625,7 @@ namespace Glitter { switch (data.direction) { case DIRECTION_BILLBOARD: { mat4_from_mat3(&GPM_VAL->cam.inv_view_mat3, &dir_mat); - mat4_mult(&dir_mat, &mat, &dir_mat); + mat4_mul(&dir_mat, &mat, &dir_mat); mat4_clear_trans(&dir_mat, &dir_mat); } break; case DIRECTION_Y_AXIS: @@ -643,12 +643,12 @@ namespace Glitter { } if (mult) { - mat4_mult(&dir_mat, &mat, &mat); - mat4_mult(&dir_mat, &mat_rot, &mat_rot); + mat4_mul(&dir_mat, &mat, &mat); + mat4_mul(&dir_mat, &mat_rot, &mat_rot); } - mat4_rotate_zyx_mult(&mat, &rot, &mat); - mat4_rotate_zyx_mult(&mat_rot, &rot, &mat_rot); + mat4_mul_rotate_zyx(&mat, &rot, &mat); + mat4_mul_rotate_zyx(&mat_rot, &rot, &mat_rot); mat4_scale_rot(&mat, &scale, &mat); this->mat = mat; this->mat_rot = mat_rot; diff --git a/src/CRE/Glitter/locus_history.cpp b/src/CRE/Glitter/locus_history.cpp index 9acd363f..3caac59a 100644 --- a/src/CRE/Glitter/locus_history.cpp +++ b/src/CRE/Glitter/locus_history.cpp @@ -63,7 +63,7 @@ namespace Glitter { mat4_get_translation(&ptcl_inst->data.emitter->mat, &emit_trans); temp += emit_trans; if (ptcl_inst->data.data.flags & PARTICLE_ROTATE_LOCUS) - mat4_mult_vec3(&ptcl_inst->data.emitter->mat_rot, &temp, &temp); + mat4_transform_vector(&ptcl_inst->data.emitter->mat_rot, &temp, &temp); } LocusHistory::Data locus_history; diff --git a/src/CRE/Glitter/particle_inst.cpp b/src/CRE/Glitter/particle_inst.cpp index 7098e1bf..b267920c 100644 --- a/src/CRE/Glitter/particle_inst.cpp +++ b/src/CRE/Glitter/particle_inst.cpp @@ -403,7 +403,7 @@ namespace Glitter { if (data.data.flags & PARTICLE_ROTATE_BY_EMITTER || has_translation) { translation += rend_elem->base_translation; if (data.data.flags & PARTICLE_ROTATE_BY_EMITTER) - mat4_mult_vec3_trans(&rend_elem->mat, &translation, &translation); + mat4_transform_point(&rend_elem->mat, &translation, &translation); rend_elem->translation = translation; } return true; @@ -909,7 +909,7 @@ namespace Glitter { if (data.data.flags & PARTICLE_ROTATE_BY_EMITTER || has_translation) { translation += rend_elem->base_translation; if (data.data.flags & PARTICLE_ROTATE_BY_EMITTER) - mat4_mult_vec3_trans(&rend_elem->mat, &translation, &translation); + mat4_transform_point(&rend_elem->mat, &translation, &translation); rend_elem->translation = translation; } return true; diff --git a/src/CRE/Glitter/render_element.cpp b/src/CRE/Glitter/render_element.cpp index 4222351e..17c47fd9 100644 --- a/src/CRE/Glitter/render_element.cpp +++ b/src/CRE/Glitter/render_element.cpp @@ -54,7 +54,7 @@ namespace Glitter { emit_inst->InitMesh(GLT_VAL, index, scale, position, direction, random); if (!(ptcl_inst_data->data.flags & PARTICLE_EMITTER_LOCAL)) - mat4_mult_vec3(&emit_inst->mat_rot, &position, &position); + mat4_transform_vector(&emit_inst->mat_rot, &position, &position); base_translation += position; translation = base_translation; @@ -64,7 +64,7 @@ namespace Glitter { + random->F2GetVec3(GLT_VAL, ptcl_inst_data->data.direction_random)); if (!(ptcl_inst_data->data.flags & PARTICLE_EMITTER_LOCAL)) - mat4_mult_vec3(&emit_inst->mat_rot, &direction, &direction); + mat4_transform_vector(&emit_inst->mat_rot, &direction, &direction); base_direction = direction; this->direction = direction; @@ -97,7 +97,7 @@ namespace Glitter { emit_inst->InitMesh(index, scale, position, direction, random); if (!(ptcl_inst_data->data.flags & PARTICLE_EMITTER_LOCAL)) - mat4_mult_vec3(&emit_inst->mat_rot, &position, &position); + mat4_transform_vector(&emit_inst->mat_rot, &position, &position); base_translation += position; translation = base_translation; @@ -107,7 +107,7 @@ namespace Glitter { + random->XGetVec3(ptcl_inst_data->data.direction_random)); if (!(ptcl_inst_data->data.flags & PARTICLE_EMITTER_LOCAL)) - mat4_mult_vec3(&emit_inst->mat_rot, &direction, &direction); + mat4_transform_vector(&emit_inst->mat_rot, &direction, &direction); base_direction = direction; this->direction = direction; diff --git a/src/CRE/Glitter/render_scene.cpp b/src/CRE/Glitter/render_scene.cpp index 9c227bd6..7d633e28 100644 --- a/src/CRE/Glitter/render_scene.cpp +++ b/src/CRE/Glitter/render_scene.cpp @@ -274,9 +274,9 @@ namespace Glitter { vec3 x_vec = { 1.0f, 0.0f, 0.0f }; if (rend_group->flags & PARTICLE_LOCAL) { mat4 mat; - mat4_mult(&GPM_VAL->cam.inv_view, &rend_group->mat, &mat); - mat4_mult(&GPM_VAL->cam.view, &mat, &mat); - mat4_mult(&mat, &GPM_VAL->cam.inv_view, &rend_group->mat_draw); + mat4_mul(&GPM_VAL->cam.inv_view, &rend_group->mat, &mat); + mat4_mul(&GPM_VAL->cam.view, &mat, &mat); + mat4_mul(&mat, &GPM_VAL->cam.inv_view, &rend_group->mat_draw); } else rend_group->mat_draw = mat4_identity; @@ -295,7 +295,7 @@ namespace Glitter { scale.y = 0.0f; if (!(has_scale |= fabsf(scale.z) > 0.000001f ? true : false)) scale.z = 0.0f; - mat4_mult_vec3(&rend_group->mat_rot, &scale, &scale); + mat4_transform_vector(&rend_group->mat_rot, &scale, &scale); mat3_from_mat4(&rend_group->mat, &model_mat); mat3_normalize_rotation(&model_mat, &model_mat); @@ -303,7 +303,7 @@ namespace Glitter { else model_mat = mat3_identity; - mat3_mult_vec(&GPM_VAL->cam.inv_view_mat3, &x_vec, &x_vec); + mat3_transform_vector(&GPM_VAL->cam.inv_view_mat3, &x_vec, &x_vec); Buffer* buf; if (GLAD_GL_VERSION_4_5) @@ -345,7 +345,7 @@ namespace Glitter { for (LocusHistory::Data& hist_data : hist->data) { vec3 pos = hist_data.translation; vec3 pos_diff = (pos - elem->base_translation) * scale; - mat3_mult_vec(&model_mat, &pos_diff, &pos_diff); + mat3_transform_vector(&model_mat, &pos_diff, &pos_diff); pos += pos_diff; float_t v00; @@ -419,7 +419,7 @@ namespace Glitter { if (rend_group->flags & PARTICLE_EMITTER_LOCAL) { model_mat = rend_group->mat; mat4_normalize_rotation(&model_mat, &view_mat); - mat4_mult(&view_mat, &GPM_VAL->cam.view, &view_mat); + mat4_mul(&view_mat, &GPM_VAL->cam.view, &view_mat); mat4_inverse(&view_mat, &inv_view_mat); } else { @@ -429,18 +429,18 @@ namespace Glitter { } if (rend_group->flags & PARTICLE_LOCAL) { - mat4_mult(&inv_view_mat, &rend_group->mat, &inv_view_mat); - mat4_mult(&view_mat, &inv_view_mat, &view_mat); + mat4_mul(&inv_view_mat, &rend_group->mat, &inv_view_mat); + mat4_mul(&view_mat, &inv_view_mat, &view_mat); mat4_inverse(&view_mat, &inv_view_mat); } - mat4_mult(&view_mat, &GPM_VAL->cam.inv_view, &rend_group->mat_draw); + mat4_mul(&view_mat, &GPM_VAL->cam.inv_view, &rend_group->mat_draw); mat4 dir_mat; switch (rend_group->draw_type) { case DIRECTION_BILLBOARD: mat4_clear_trans(&model_mat, &dir_mat); - mat4_mult(&dir_mat, &inv_view_mat, &dir_mat); + mat4_mul(&dir_mat, &inv_view_mat, &dir_mat); mat4_clear_trans(&dir_mat, &dir_mat); break; case DIRECTION_EMITTER_DIRECTION: @@ -492,8 +492,8 @@ namespace Glitter { vec3 x_vec_base = { 1.0f, 0.0f, 0.0f }; vec3 y_vec_base = { 0.0f, 1.0f, 0.0f }; - mat4_mult_vec3(&inv_model_mat, &x_vec_base, &x_vec_base); - mat4_mult_vec3(&inv_model_mat, &y_vec_base, &y_vec_base); + mat4_transform_vector(&inv_model_mat, &x_vec_base, &x_vec_base); + mat4_transform_vector(&inv_model_mat, &y_vec_base, &y_vec_base); vec3 up_vec; mat4(*rotate_func)(F2RenderGroup*, RenderElement*, vec3*); @@ -575,13 +575,13 @@ namespace Glitter { mat4 mat = rotate_func(rend_group, elem, &up_vec); mat4_clear_trans(&mat, &mat); - mat4_mult(dir_mat, &mat, &mat); + mat4_mul(dir_mat, &mat, &mat); mat4_clear_trans(&mat, &mat); vec3 x_vec; - mat4_mult_vec3(&mat, &x_vec_base, &x_vec); + mat4_transform_vector(&mat, &x_vec_base, &x_vec); vec3 y_vec; - mat4_mult_vec3(&mat, &y_vec_base, &y_vec); + mat4_transform_vector(&mat, &y_vec_base, &y_vec); if (use_scale) { x_vec *= scale; @@ -648,7 +648,7 @@ namespace Glitter { scale.y = 0.0f; if (!(has_scale |= fabsf(scale.z) > 0.000001f ? true : false)) scale.z = 0.0f; - mat4_mult_vec3(&rend_group->mat_rot, &scale, &scale); + mat4_transform_vector(&rend_group->mat_rot, &scale, &scale); emitter_local = true; } @@ -664,14 +664,14 @@ namespace Glitter { } if (rend_group->draw_type != DIRECTION_BILLBOARD) { - mat4_mult_vec3(dir_mat, &x_vec, &x_vec); - mat4_mult_vec3(dir_mat, &y_vec, &y_vec); + mat4_transform_vector(dir_mat, &x_vec, &x_vec); + mat4_transform_vector(dir_mat, &y_vec, &y_vec); } else - mat4_mult(&inv_model_mat, dir_mat, &inv_model_mat); + mat4_mul(&inv_model_mat, dir_mat, &inv_model_mat); - mat4_mult_vec3(&inv_model_mat, &x_vec, &x_vec); - mat4_mult_vec3(&inv_model_mat, &y_vec, &y_vec); + mat4_transform_vector(&inv_model_mat, &x_vec, &x_vec); + mat4_transform_vector(&inv_model_mat, &y_vec, &y_vec); Buffer* buf; if (GLAD_GL_VERSION_4_5) @@ -710,7 +710,7 @@ namespace Glitter { vec3 pos = elem->translation; if (has_scale) { vec3 pos_diff = (pos - elem->base_translation) * scale; - mat4_mult_vec3(&inv_model_mat, &pos_diff, &pos_diff); + mat4_transform_vector(&inv_model_mat, &pos_diff, &pos_diff); pos += pos_diff; } @@ -746,7 +746,7 @@ namespace Glitter { if (use_z_offset) { vec3 z_offset_dir = vec3::normalize(dist_to_cam - pos); if (emitter_local) - mat4_mult_vec3(&z_offset_inv_mat, &z_offset_dir, &z_offset_dir); + mat4_transform_vector(&z_offset_inv_mat, &z_offset_dir, &z_offset_dir); pos += z_offset_dir * z_offset; } @@ -757,7 +757,7 @@ namespace Glitter { xy_vec_rot.x = x_vec.x * pos_add[k].x; xy_vec_rot.y = y_vec.y * pos_add[k].y; xy_vec_rot.z = 0.0f; - mat3_mult_vec(&ptc_rot, &xy_vec_rot, &xy_vec_rot); + mat3_transform_vector(&ptc_rot, &xy_vec_rot, &xy_vec_rot); buf->position = pos + xy_vec_rot; buf->uv[0] = uv + uv_add[k]; buf->uv[1] = buf->uv[0]; @@ -784,7 +784,7 @@ namespace Glitter { vec3 pos = elem->translation; if (has_scale) { vec3 pos_diff = (pos - elem->base_translation) * scale; - mat4_mult_vec3(&inv_model_mat, &pos_diff, &pos_diff); + mat4_transform_vector(&inv_model_mat, &pos_diff, &pos_diff); pos += pos_diff; } @@ -820,7 +820,7 @@ namespace Glitter { if (use_z_offset) { vec3 z_offset_dir = vec3::normalize(dist_to_cam - pos); if (emitter_local) - mat4_mult_vec3(&z_offset_inv_mat, &z_offset_dir, &z_offset_dir); + mat4_transform_vector(&z_offset_inv_mat, &z_offset_dir, &z_offset_dir); pos += z_offset_dir * z_offset; } @@ -951,8 +951,8 @@ namespace Glitter { return; mat4 mat; - mat4_mult(&rend_group->mat_draw, &GPM_VAL->cam.view, &mat); - mat4_mult(&mat, &GPM_VAL->cam.projection, &mat); + mat4_mul(&rend_group->mat_draw, &GPM_VAL->cam.view, &mat); + mat4_mul(&mat, &GPM_VAL->cam.projection, &mat); float_t emission = 1.0f; if (rend_group->flags & PARTICLE_EMISSION || rend_group->blend_mode == PARTICLE_BLEND_TYPICAL) @@ -1284,9 +1284,9 @@ namespace Glitter { vec3 x_vec = { 1.0f, 0.0f, 0.0f }; if (rend_group->flags & PARTICLE_LOCAL) { mat4 mat; - mat4_mult(&GPM_VAL->cam.inv_view, &rend_group->mat, &mat); - mat4_mult(&GPM_VAL->cam.view, &mat, &mat); - mat4_mult(&mat, &GPM_VAL->cam.inv_view, &rend_group->mat_draw); + mat4_mul(&GPM_VAL->cam.inv_view, &rend_group->mat, &mat); + mat4_mul(&GPM_VAL->cam.view, &mat, &mat); + mat4_mul(&mat, &GPM_VAL->cam.inv_view, &rend_group->mat_draw); } else rend_group->mat_draw = mat4_identity; @@ -1312,7 +1312,7 @@ namespace Glitter { else model_mat = mat3_identity; - mat3_mult_vec(&GPM_VAL->cam.inv_view_mat3, &x_vec, &x_vec); + mat3_transform_vector(&GPM_VAL->cam.inv_view_mat3, &x_vec, &x_vec); Buffer* buf; if (GLAD_GL_VERSION_4_5) @@ -1354,7 +1354,7 @@ namespace Glitter { for (LocusHistory::Data& hist_data : hist->data) { vec3 pos = hist_data.translation; vec3 pos_diff = (pos - elem->base_translation) * scale; - mat3_mult_vec(&model_mat, &pos_diff, &pos_diff); + mat3_transform_vector(&model_mat, &pos_diff, &pos_diff); pos += pos_diff; float_t v00; @@ -1432,7 +1432,7 @@ namespace Glitter { if (rend_group->flags & PARTICLE_EMITTER_LOCAL) { model_mat = rend_group->mat; mat4_normalize_rotation(&model_mat, &view_mat); - mat4_mult(&view_mat, &GPM_VAL->cam.view, &view_mat); + mat4_mul(&view_mat, &GPM_VAL->cam.view, &view_mat); mat4_inverse(&view_mat, &inv_view_mat); emitter_local = true; @@ -1449,12 +1449,12 @@ namespace Glitter { bool local = false; if (rend_group->flags & PARTICLE_LOCAL) { - mat4_mult(&inv_view_mat, &rend_group->mat, &inv_view_mat); - mat4_mult(&view_mat, &inv_view_mat, &view_mat); + mat4_mul(&inv_view_mat, &rend_group->mat, &inv_view_mat); + mat4_mul(&view_mat, &inv_view_mat, &view_mat); mat4_inverse(&view_mat, &inv_view_mat); local = true; } - mat4_mult(&view_mat, &GPM_VAL->cam.inv_view, &rend_group->mat_draw); + mat4_mul(&view_mat, &GPM_VAL->cam.inv_view, &rend_group->mat_draw); mat4 dir_mat = mat4_identity; vec3 up_vec = { 0.0f, 0.0f, 1.0f }; @@ -1464,7 +1464,7 @@ namespace Glitter { switch (rend_group->draw_type) { case DIRECTION_BILLBOARD: mat4_clear_trans(&model_mat, &dir_mat); - mat4_mult(&dir_mat, &inv_view_mat, &dir_mat); + mat4_mul(&dir_mat, &inv_view_mat, &dir_mat); mat4_clear_trans(&dir_mat, &dir_mat); billboard = true; break; @@ -1558,7 +1558,7 @@ namespace Glitter { scale *= emit_scale; if (emitter_local) - mat4_mult_vec3_trans(&model_mat, &trans, &trans); + mat4_transform_point(&model_mat, &trans, &trans); mat4 mat; if (billboard) { @@ -1576,7 +1576,7 @@ namespace Glitter { mat = dir_mat; mat4_set_translation(&mat, &trans); - mat4_rotate_zyx_mult(&mat, &rot, &mat); + mat4_mul_rotate_zyx(&mat, &rot, &mat); mat4_scale_rot(&mat, &scale, &mat); vec3 uv_scroll; @@ -1594,7 +1594,7 @@ namespace Glitter { disp_manager.set_texture_transform(tex_trans_count, tex_trans); if (local) - mat4_mult(&mat, &GPM_VAL->cam.inv_view, &mat); + mat4_mul(&mat, &GPM_VAL->cam.inv_view, &mat); if (disp_manager.entry_obj_by_object_info( &mat, object_info, &elem->color, 0, local)) @@ -1624,7 +1624,7 @@ namespace Glitter { mat4_clear_rot(&rend_group->mat, &view_mat); else mat4_normalize_rotation(&rend_group->mat, &view_mat); - mat4_mult(&view_mat, &GPM_VAL->cam.view, &view_mat); + mat4_mul(&view_mat, &GPM_VAL->cam.view, &view_mat); mat4_inverse(&view_mat, &inv_view_mat); } else { @@ -1635,16 +1635,16 @@ namespace Glitter { if (rend_group->flags & PARTICLE_LOCAL) { if (rend_group->flags & PARTICLE_EMITTER_LOCAL) - mat4_mult(&inv_view_mat, &rend_group->mat, &inv_view_mat); - mat4_mult(&view_mat, &inv_view_mat, &view_mat); + mat4_mul(&inv_view_mat, &rend_group->mat, &inv_view_mat); + mat4_mul(&view_mat, &inv_view_mat, &view_mat); mat4_inverse(&view_mat, &inv_view_mat); } - mat4_mult(&view_mat, &GPM_VAL->cam.inv_view, &rend_group->mat_draw); + mat4_mul(&view_mat, &GPM_VAL->cam.inv_view, &rend_group->mat_draw); switch (rend_group->draw_type) { case DIRECTION_BILLBOARD: mat4_clear_trans(&model_mat, &dir_mat); - mat4_mult(&dir_mat, &inv_view_mat, &dir_mat); + mat4_mul(&dir_mat, &inv_view_mat, &dir_mat); mat4_clear_trans(&dir_mat, &dir_mat); break; case DIRECTION_EMITTER_DIRECTION: @@ -1686,8 +1686,8 @@ namespace Glitter { vec3 x_vec_base = { 1.0f, 0.0f, 0.0f }; vec3 y_vec_base = { 0.0f, 1.0f, 0.0f }; - mat4_mult_vec3(&inv_model_mat, &x_vec_base, &x_vec_base); - mat4_mult_vec3(&inv_model_mat, &y_vec_base, &y_vec_base); + mat4_transform_vector(&inv_model_mat, &x_vec_base, &x_vec_base); + mat4_transform_vector(&inv_model_mat, &y_vec_base, &y_vec_base); vec3 up_vec; mat4(*rotate_func)(XRenderGroup*, RenderElement*, vec3*); @@ -1773,9 +1773,9 @@ namespace Glitter { mat4 mat = rotate_func(rend_group, elem, &up_vec); vec3 x_vec; - mat4_mult_vec3(&mat, &x_vec_base, &x_vec); + mat4_transform_vector(&mat, &x_vec_base, &x_vec); vec3 y_vec; - mat4_mult_vec3(&mat, &y_vec_base, &y_vec); + mat4_transform_vector(&mat, &y_vec_base, &y_vec); if (use_scale) { x_vec *= scale; @@ -1855,14 +1855,14 @@ namespace Glitter { } if (rend_group->draw_type != DIRECTION_BILLBOARD) { - mat4_mult_vec3(dir_mat, &x_vec, &x_vec); - mat4_mult_vec3(dir_mat, &y_vec, &y_vec); + mat4_transform_vector(dir_mat, &x_vec, &x_vec); + mat4_transform_vector(dir_mat, &y_vec, &y_vec); } else - mat4_mult(&inv_model_mat, dir_mat, &inv_model_mat); + mat4_mul(&inv_model_mat, dir_mat, &inv_model_mat); - mat4_mult_vec3(&inv_model_mat, &x_vec, &x_vec); - mat4_mult_vec3(&inv_model_mat, &y_vec, &y_vec); + mat4_transform_vector(&inv_model_mat, &x_vec, &x_vec); + mat4_transform_vector(&inv_model_mat, &y_vec, &y_vec); Buffer* buf; if (GLAD_GL_VERSION_4_5) @@ -1934,7 +1934,7 @@ namespace Glitter { if (use_z_offset) { vec3 z_offset_dir = vec3::normalize(dist_to_cam - pos); if (emitter_local) - mat4_mult_vec3(&z_offset_inv_mat, &z_offset_dir, &z_offset_dir); + mat4_transform_vector(&z_offset_inv_mat, &z_offset_dir, &z_offset_dir); pos += z_offset_dir * z_offset; } @@ -1945,7 +1945,7 @@ namespace Glitter { xy_vec_rot.x = x_vec.x * pos_add[k].x; xy_vec_rot.y = y_vec.y * pos_add[k].y; xy_vec_rot.z = 0.0f; - mat3_mult_vec(&ptc_rot, &xy_vec_rot, &xy_vec_rot); + mat3_transform_vector(&ptc_rot, &xy_vec_rot, &xy_vec_rot); buf->position = pos + xy_vec_rot; buf->uv[0] = uv + uv_add[k]; buf->uv[1] = buf->uv[0]; @@ -2005,7 +2005,7 @@ namespace Glitter { if (use_z_offset) { vec3 z_offset_dir = vec3::normalize(dist_to_cam - pos); if (emitter_local) - mat4_mult_vec3(&z_offset_inv_mat, &z_offset_dir, &z_offset_dir); + mat4_transform_vector(&z_offset_inv_mat, &z_offset_dir, &z_offset_dir); pos += z_offset_dir * z_offset; } @@ -2144,8 +2144,8 @@ namespace Glitter { return; mat4 mat; - mat4_mult(&rend_group->mat_draw, &GPM_VAL->cam.view, &mat); - mat4_mult(&mat, &GPM_VAL->cam.projection, &mat); + mat4_mul(&rend_group->mat_draw, &GPM_VAL->cam.view, &mat); + mat4_mul(&mat, &GPM_VAL->cam.projection, &mat); float_t emission = 1.0f; if (rend_group->flags & PARTICLE_EMISSION || rend_group->blend_mode == PARTICLE_BLEND_TYPICAL) diff --git a/src/CRE/auth_2d.cpp b/src/CRE/auth_2d.cpp index f288b1a1..c6e0e4c3 100644 --- a/src/CRE/auth_2d.cpp +++ b/src/CRE/auth_2d.cpp @@ -706,16 +706,16 @@ void AetObj::Disp() { mat4 mat; mat4_translate(&pos, &mat); - mat4_rotate_xyz_mult(&mat, rot.x, rot.y, rot.z * scale_size.x * scale_size.y, &mat); + mat4_mul_rotate_xyz(&mat, rot.x, rot.y, rot.z * scale_size.x * scale_size.y, &mat); mat4_scale_rot(&mat, scale.x * scale_size.x, scale.y * scale_size.y, scale.z, &mat); - mat4_translate_mult(&mat, -anchor.x, -anchor.y, -anchor.z, &mat); + mat4_mul_translate(&mat, -anchor.x, -anchor.y, -anchor.z, &mat); const aet_camera* camera = scene->camera; if (camera) { float_t eye_x = camera->eye_x.interpolate(frame) - (float_t)scene->width * 0.5f; float_t eye_y = camera->eye_y.interpolate(frame) - (float_t)scene->height * 0.5f; float_t eye_z = camera->eye_z.interpolate(frame); - mat4_translate_mult(&mat, -eye_x, -eye_y, -eye_z, &mat); + mat4_mul_translate(&mat, -eye_x, -eye_y, -eye_z, &mat); } if (layer) @@ -1163,21 +1163,21 @@ void AetObj::CalcMat(mat4& mat, const aet_layer* layer, float_t frame) { } } - mat4_translate_mult(&mat, pos_x, pos_y, -pos_z, &mat); + mat4_mul_translate(&mat, pos_x, pos_y, -pos_z, &mat); if (fabsf(dir_x) > 0.000001f) - mat4_rotate_x_mult(&mat, -dir_x, &mat); + mat4_mul_rotate_x(&mat, -dir_x, &mat); if (fabsf(dir_y) > 0.000001f) - mat4_rotate_y_mult(&mat, -dir_y, &mat); + mat4_mul_rotate_y(&mat, -dir_y, &mat); if (fabsf(dir_z) > 0.000001f) - mat4_rotate_z_mult(&mat, dir_z * scale_size.x * scale_size.y, &mat); + mat4_mul_rotate_z(&mat, dir_z * scale_size.x * scale_size.y, &mat); if (fabsf(rot_x) > 0.000001f) - mat4_rotate_x_mult(&mat, -rot_x, &mat); + mat4_mul_rotate_x(&mat, -rot_x, &mat); if (fabsf(rot_y) > 0.000001f) - mat4_rotate_y_mult(&mat, -rot_y, &mat); + mat4_mul_rotate_y(&mat, -rot_y, &mat); if (fabsf(rot_z) > 0.000001f) - mat4_rotate_z_mult(&mat, rot_z * scale_size.x * scale_size.y, &mat); + mat4_mul_rotate_z(&mat, rot_z * scale_size.x * scale_size.y, &mat); mat4_scale_rot(&mat, scale_x, scale_y, scale_z, &mat); - mat4_translate_mult(&mat, -anchor_x, -anchor_y, -anchor_z, &mat); + mat4_mul_translate(&mat, -anchor_x, -anchor_y, -anchor_z, &mat); } AetLyo::AetLyo(AetComp* comp) { @@ -1216,7 +1216,7 @@ void AetLyo::DispLayer(const mat4& mat, const aet_layer* layer, if (layer_video_3d) data.anchor.z = layer_video_3d->anchor_z.interpolate(frame); data.mat = m; - mat4_mult_vec3_trans(&m, &data.anchor, &data.position); + mat4_transform_point(&m, &data.anchor, &data.position); const aet_video* video = layer->item.video; data.width = (float_t)video->width; diff --git a/src/CRE/auth_3d.cpp b/src/CRE/auth_3d.cpp index 9bfdef1c..c8315b00 100644 --- a/src/CRE/auth_3d.cpp +++ b/src/CRE/auth_3d.cpp @@ -418,8 +418,8 @@ void auth_3d::ctrl(render_context* rctx) { cam.roll = -cam.roll; } - mat4_mult_vec3_trans(&mat, &cam.interest, &cam.interest); - mat4_mult_vec3_trans(&mat, &cam.view_point, &cam.view_point); + mat4_transform_point(&mat, &cam.interest, &cam.interest); + mat4_transform_point(&mat, &cam.view_point, &cam.view_point); cam.set(rctx->camera); break; @@ -1076,7 +1076,7 @@ namespace auth_3d_detail { if (auth->left_right_reverse) trans.x = -trans.x; - mat4_mult_vec3_trans(&auth->mat, &trans, &trans); + mat4_transform_point(&auth->mat, &trans, &trans); particle_event_data event; event.type = 1.0f; event.count = point.model_transform.scale_value.x * 100.0f; @@ -1471,8 +1471,8 @@ void auth_3d_model_transform::reset() { void auth_3d_model_transform::set_mat(const mat4* parent_mat) { mat4 mat; - mat4_translate_mult(parent_mat, &translation_value, &mat); - mat4_rotate_zyx_mult(&mat, &rotation_value, &mat); + mat4_mul_translate(parent_mat, &translation_value, &mat); + mat4_mul_rotate_zyx(&mat, &rotation_value, &mat); mat4_scale_rot(&mat, &scale_value, &this->mat); } @@ -1552,10 +1552,10 @@ void auth_3d_camera_root::interpolate(float_t frame) { mat4& cr_mat = model_transform.mat; vec3 _view_point = view_point.model_transform.translation.interpolate(frame); - mat4_mult_vec3_trans(&cr_mat, &_view_point, &view_point_value); + mat4_transform_point(&cr_mat, &_view_point, &view_point_value); vec3 _interest = interest.translation.interpolate(frame); - mat4_mult_vec3_trans(&cr_mat, &_interest, &interest_value); + mat4_transform_point(&cr_mat, &_interest, &interest_value); float_t fov; if (view_point.flags & AUTH_3D_CAMERA_ROOT_VIEW_POINT_FOV) { @@ -2092,7 +2092,7 @@ void auth_3d_object_model_transform::interpolate(float_t frame) { mat4 mat; mat4_translate(&translation_value, &mat); - mat4_mult(&mat_rot, &mat, &mat); + mat4_mul(&mat_rot, &mat, &mat); if (has_scale) mat4_scale_rot(&mat, &scale_value, &mat); mat_inner = mat; @@ -2100,7 +2100,7 @@ void auth_3d_object_model_transform::interpolate(float_t frame) { } void auth_3d_object_model_transform::mat_mult(const mat4* mat) { - mat4_mult(&this->mat_inner, mat, &this->mat); + mat4_mul(&this->mat_inner, mat, &this->mat); } void auth_3d_object_model_transform::reset() { @@ -2244,13 +2244,13 @@ void auth_3d_object_texture_transform::interpolate(float_t frame) { mat4_translate(&translate_frame, &mat); mat4_scale_rot(&mat, &scale, &mat); - mat4_translate_mult(&mat, 1.0f, 1.0f, 0.0f, &mat); + mat4_mul_translate(&mat, 1.0f, 1.0f, 0.0f, &mat); mat4_scale_rot(&mat, &repeat, &mat); - mat4_translate_mult(&mat, -1.0f, -1.0f, 0.0f, &mat); + mat4_mul_translate(&mat, -1.0f, -1.0f, 0.0f, &mat); - mat4_translate_mult(&mat, 0.5f, 0.5f, 0.0f, &mat); - mat4_rotate_z_mult(&mat, rotate.z, &mat); - mat4_translate_mult(&mat, -0.5f, -0.5f, 0.0f, &mat); + mat4_mul_translate(&mat, 0.5f, 0.5f, 0.0f, &mat); + mat4_mul_rotate_z(&mat, rotate.z, &mat); + mat4_mul_translate(&mat, -0.5f, -0.5f, 0.0f, &mat); this->mat = mat; } @@ -4483,7 +4483,7 @@ static void auth_3d_m_object_hrc_disp(auth_3d_m_object_hrc* moh, auth_3d* auth, mat4 mat = i.model_transform.mat; mat4 t = *m; - mat4_mult(&mat, &t, &mat); + mat4_mul(&mat, &t, &mat); vec3 pos = *(vec3*)&mat.row3; pos.y -= 0.2f; @@ -6090,11 +6090,11 @@ static void auth_3d_object_disp(auth_3d_object* o, auth_3d* auth, render_context if (rob_chara_pv_data_array_check_chara_id(auth->chara_id)) { rob_chara* rob_chr = rob_chara_array_get(auth->chara_id); mat4 m; - mat4_mult(&rob_chr->data.miku_rot.field_6C, + mat4_mul(&rob_chr->data.miku_rot.field_6C, auth->chara_item ? &rob_chr->data.adjust_data.item_mat : &rob_chr->data.adjust_data.mat, &m); - mat4_mult(&m, &mat, &mat); + mat4_mul(&m, &mat, &mat); disp_manager.set_shadow_type(auth->chara_id ? SHADOW_STAGE : SHADOW_CHARA); } @@ -6312,7 +6312,7 @@ static void auth_3d_object_hrc_disp(auth_3d_object_hrc* oh, auth_3d* auth, rende if (auth->chara_id >= 0 && auth->chara_id < ROB_CHARA_COUNT) { if (rob_chara_pv_data_array_check_chara_id(auth->chara_id)) { rob_chara* rob_chr = rob_chara_array_get(auth->chara_id); - mat4_mult(&rob_chr->data.miku_rot.field_6C, + mat4_mul(&rob_chr->data.miku_rot.field_6C, auth->chara_item ? &rob_chr->data.adjust_data.item_mat : &rob_chr->data.adjust_data.mat, &mat); @@ -6439,7 +6439,7 @@ static void auth_3d_object_hrc_nodes_mat_mult(auth_3d_object_hrc* oh, const mat4 else m = *mat; - mat4_mult(&i.joint_orient_mat, &m, &m); + mat4_mul(&i.joint_orient_mat, &m, &m); i.model_transform.mat_mult(&m); if (i.mat) diff --git a/src/CRE/camera.cpp b/src/CRE/camera.cpp index 9bfb04cb..ab10fb15 100644 --- a/src/CRE/camera.cpp +++ b/src/CRE/camera.cpp @@ -294,10 +294,10 @@ void camera::set(const vec3& view_point, const vec3& interest, mat4 cam; mat4_translate(&trans, &cam); - mat4_rotate_zyx_mult(&cam, &rot, &cam); + mat4_mul_rotate_zyx(&cam, &rot, &cam); mat4_scale_rot(&cam, &scale, &cam); - mat4_mult_vec3_trans(&cam, &_vp, &_vp); - mat4_mult_vec3_trans(&cam, &_int, &_int); + mat4_transform_point(&cam, &_vp, &_vp); + mat4_transform_point(&cam, &_int, &_int); set_view_point(_vp); set_interest(_int); @@ -339,7 +339,7 @@ void camera::update_data() { camera_calculate_view(this); if (changed_proj || changed_view) { - mat4_mult(&view, &projection, &view_projection); + mat4_mul(&view, &projection, &view_projection); mat4_inverse(&view_projection, &inv_view_projection); } @@ -413,7 +413,7 @@ static void camera_calculate_projection_aet(camera* c) { mat4 spr_2d_view; mat4_look_at(&spr_2d_viewpoint, &spr_2d_interest, &spr_2d_up, &spr_2d_view); - mat4_mult(&spr_2d_view, &spr_2d_proj, &c->view_projection_aet_2d); + mat4_mul(&spr_2d_view, &spr_2d_proj, &c->view_projection_aet_2d); float_t v13c = render_half_height / tanf((float_t)c->fov_rad * 0.5f); @@ -430,7 +430,7 @@ static void camera_calculate_projection_aet(camera* c) { mat4 spr_3d_view; mat4_look_at(&spr_3d_viewpoint, &spr_3d_interest, &spr_3d_up, &spr_3d_view); - mat4_mult(&spr_3d_view, &spr_3d_proj, &c->view_projection_aet_3d); + mat4_mul(&spr_3d_view, &spr_3d_proj, &c->view_projection_aet_3d); } static void camera_calculate_view(camera* c) { @@ -460,7 +460,7 @@ static void camera_calculate_view(camera* c) { vec3 view_point = -c->view_point; mat4_rotate_zxy(&rotation, &c->view); - mat4_translate_mult(&c->view, &view_point, &c->view); + mat4_mul_translate(&c->view, &view_point, &c->view); mat4_inverse(&c->view, &c->inv_view); } diff --git a/src/CRE/draw_object.cpp b/src/CRE/draw_object.cpp index 4afe4851..166d0a4c 100644 --- a/src/CRE/draw_object.cpp +++ b/src/CRE/draw_object.cpp @@ -275,7 +275,7 @@ namespace mdl { const mat4* instances_mat = args->instances_mat; mat4 _mat; for (int32_t i = args->instances_count; i >= 0; i--, instances_mat++) { - mat4_mult(instances_mat, mat, &_mat); + mat4_mul(instances_mat, mat, &_mat); draw_object_model_mat_load(rctx, _mat); draw(rctx, sub_mesh->primitive_type, @@ -540,7 +540,7 @@ inline void model_mat_face_camera_view(const mat4* view, const mat4* src, mat4* mat3_from_mat4(view, &mat); mat3_inverse(&mat, &mat); mat4_from_mat3(&mat, dst); - mat4_mult(dst, src, dst); + mat4_mul(dst, src, dst); } static bool draw_object_blend_set(render_context* rctx, diff --git a/src/CRE/light_param/wind.cpp b/src/CRE/light_param/wind.cpp index 6eaddf46..57dbb2d8 100644 --- a/src/CRE/light_param/wind.cpp +++ b/src/CRE/light_param/wind.cpp @@ -90,11 +90,11 @@ static float_t wind_apply_spc(wind* w, float_t frame) { static void wind_ctrl(wind* w) { float_t value = wind_apply_spc(w, w->cycle * w->frame) * w->scale; mat4 mat = mat4_identity; - mat4_rotate_y_mult(&mat, w->rot_y * DEG_TO_RAD_FLOAT, &mat); - mat4_rotate_z_mult(&mat, w->rot_z * DEG_TO_RAD_FLOAT, &mat); + mat4_mul_rotate_y(&mat, w->rot_y * DEG_TO_RAD_FLOAT, &mat); + mat4_mul_rotate_z(&mat, w->rot_z * DEG_TO_RAD_FLOAT, &mat); vec3 wind_direction = 0.0f; wind_direction.x = value; - mat4_mult_vec3(&mat, &wind_direction, &wind_direction); + mat4_transform_vector(&mat, &wind_direction, &wind_direction); w->wind_direction = wind_direction * w->strength; if (w->strength >= 1.0f) w->strength = 1.0f; diff --git a/src/CRE/object.cpp b/src/CRE/object.cpp index cad538a9..a68fbe0f 100644 --- a/src/CRE/object.cpp +++ b/src/CRE/object.cpp @@ -583,12 +583,12 @@ void obj_skin_set_matrix_buffer(obj_skin* s, mat4* matrices, mat4 temp; int32_t bone_id = s->bone_array[i].id; if (bone_id & 0x8000) - mat4_mult(mat, &ex_data_matrices[bone_id & 0x7FFF], &temp); + mat4_mul(mat, &ex_data_matrices[bone_id & 0x7FFF], &temp); else - mat4_mult(mat, &matrices[bone_id], &temp); + mat4_mul(mat, &matrices[bone_id], &temp); - mat4_mult(&temp, global_mat, &temp); - mat4_mult(&s->bone_array[i].inv_bind_pose_mat, &temp, &matrix_buffer[i]); + mat4_mul(&temp, global_mat, &temp); + mat4_mul(&s->bone_array[i].inv_bind_pose_mat, &temp, &matrix_buffer[i]); } else for (uint32_t i = 0; i < s->num_bone; i++) { @@ -599,8 +599,8 @@ void obj_skin_set_matrix_buffer(obj_skin* s, mat4* matrices, else temp = matrices[bone_id]; - mat4_mult(&temp, global_mat, &temp); - mat4_mult(&s->bone_array[i].inv_bind_pose_mat, &temp, &matrix_buffer[i]); + mat4_mul(&temp, global_mat, &temp); + mat4_mul(&s->bone_array[i].inv_bind_pose_mat, &temp, &matrix_buffer[i]); } } diff --git a/src/CRE/post_process.cpp b/src/CRE/post_process.cpp index 51874858..fc40063d 100644 --- a/src/CRE/post_process.cpp +++ b/src/CRE/post_process.cpp @@ -320,7 +320,7 @@ void post_process::draw_lens_flare(camera* cam) { *(vec3*)&v44 = position; v44.w = 1.0f; - mat4_mult_vec(&cam->view_projection, &v44, &v44); + mat4_transform_vector(&cam->view_projection, &v44, &v44); float_t v13 = 1.0f / v44.w; float_t v14 = v44.x * v13; @@ -331,7 +331,7 @@ void post_process::draw_lens_flare(camera* cam) { v44.x = v14 * v44.w; v44.y = v15 * v44.w; - mat4_mult_vec(&cam->inv_view_projection, &v44, &v44); + mat4_transform_vector(&cam->inv_view_projection, &v44, &v44); ((pos_scale*)&lens_flare_pos)->get_screen_pos_scale(cam->view_projection, position, false); float_t v17 = lens_flare_pos.x - (float_t)render_width * 0.5f; @@ -367,10 +367,10 @@ void post_process::draw_lens_flare(camera* cam) { gl_state_disable_cull_face(); mat4 mat; - mat4_translate_mult(&cam->view, &position, &mat); + mat4_mul_translate(&cam->view, &position, &mat); mat4_clear_rot(&mat, &mat); mat4_scale_rot(&mat, v24 * 0.2f, &mat); - mat4_mult(&mat, &cam->projection, &mat); + mat4_mul(&mat, &cam->projection, &mat); mat4_transpose(&mat, &mat); shader_data.g_transform[0] = mat.row0; @@ -383,10 +383,10 @@ void post_process::draw_lens_flare(camera* cam) { glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glEndQuery(GL_SAMPLES_PASSED); - mat4_translate_mult(&cam->view, (vec3*)&v44, &mat); + mat4_mul_translate(&cam->view, (vec3*)&v44, &mat); mat4_clear_rot(&mat, &mat); mat4_scale_rot(&mat, v24 * 2.0f, &mat); - mat4_mult(&mat, &cam->projection, &mat); + mat4_mul(&mat, &cam->projection, &mat); mat4_transpose(&mat, &mat); shader_data.g_transform[0] = mat.row0; @@ -422,10 +422,10 @@ void post_process::draw_lens_flare(camera* cam) { gl_state_set_blend_func(GL_ONE, GL_ONE); gl_state_set_depth_mask(GL_FALSE); - mat4_translate_mult(&cam->view, &position, &mat); + mat4_mul_translate(&cam->view, &position, &mat); mat4_clear_rot(&mat, &mat); mat4_scale_rot(&mat, v24 * 1.1f, &mat); - mat4_mult(&mat, &cam->projection, &mat); + mat4_mul(&mat, &cam->projection, &mat); mat4_transpose(&mat, &mat); shader_data.g_transform[0] = mat.row0; @@ -496,10 +496,10 @@ static void make_ghost_quad(uint8_t flags, float_t opacity, mat4* mat, float_t*& vec4 p1 = { 0.5f, -0.5f, x1, y0 }; vec4 p2 = { -0.5f, 0.5f, x0, y1 }; vec4 p3 = { 0.5f, 0.5f, x1, y1 }; - mat4_mult_vec2_trans(mat, (vec2*)&p0, (vec2*)&p0); - mat4_mult_vec2_trans(mat, (vec2*)&p1, (vec2*)&p1); - mat4_mult_vec2_trans(mat, (vec2*)&p2, (vec2*)&p2); - mat4_mult_vec2_trans(mat, (vec2*)&p3, (vec2*)&p3); + mat4_transform_point(mat, (vec2*)&p0, (vec2*)&p0); + mat4_transform_point(mat, (vec2*)&p1, (vec2*)&p1); + mat4_transform_point(mat, (vec2*)&p2, (vec2*)&p2); + mat4_transform_point(mat, (vec2*)&p3, (vec2*)&p3); *(vec4*)&data[0] = p0; data[4] = opacity; @@ -586,7 +586,7 @@ void post_process::draw_lens_ghost(RenderTexture* rt) { mat4 mat; mat4_translate(v13[i] * v7 + 0.5f, v13[i] * v8 + 0.5f, 0.0f, &mat); mat4_scale_rot(&mat, scale, scale * aspect, 1.0f, &mat); - mat4_rotate_z_mult_sin_cos(&mat, angle_sin, angle_cos, &mat); + mat4_mul_rotate_z(&mat, angle_sin, angle_cos, &mat); make_ghost_quad((uint8_t)(i & 0x03), opacity, &mat, data); } diff --git a/src/CRE/post_process/exposure.cpp b/src/CRE/post_process/exposure.cpp index 2a8a9d3f..989f1ad6 100644 --- a/src/CRE/post_process/exposure.cpp +++ b/src/CRE/post_process/exposure.cpp @@ -66,13 +66,13 @@ void post_process_exposure::get_exposure(camera* cam, int32_t render_width, mat4 v42 = cam->view; mat4 v43 = cam->projection; - mat4_mult(&v44, &v42, &v42); - mat4_mult(&v42, &v43, &v43); + mat4_mul(&v44, &v42, &v42); + mat4_mul(&v42, &v43, &v43); vec4 v41; vec4 v40; - mat4_mult_vec(&v42, &v34, &v41); - mat4_mult_vec(&v43, &v34, &v40); + mat4_transform_vector(&v42, &v34, &v41); + mat4_transform_vector(&v43, &v34, &v40); float_t v12 = 1.0f / v40.w; float_t v13 = v40.x * v12; @@ -93,7 +93,7 @@ void post_process_exposure::get_exposure(camera* cam, int32_t render_width, v16 = 1.0f; vec4 v39; - mat4_mult_vec(&v42, &v33, &v39); + mat4_transform_vector(&v42, &v33, &v39); float_t v17 = (v39.z + 1.0f) * 0.5f; if (v17 > 0.8f) @@ -215,11 +215,11 @@ void post_process_exposure::get_exposure_chara_data(void* pp_data, camera* cam) mat4 mat = mat4_identity; sub_1405163C0(rob_chr, 4, &mat); - mat4_mult(&mat, &cam->view, &mat); - mat4_translate_mult(&mat, max_face_depth + 0.1f, 0.0f, -0.06f, &mat); + mat4_mul(&mat, &cam->view, &mat); + mat4_mul_translate(&mat, max_face_depth + 0.1f, 0.0f, -0.06f, &mat); mat4_clear_rot(&mat, &mat); mat4_scale_rot(&mat, 0.0035f, &mat); - mat4_mult(&mat, &cam->projection, &mat); + mat4_mul(&mat, &cam->projection, &mat); sun_quad_shader_data shader_data = {}; mat4_transpose(&mat, &mat); diff --git a/src/CRE/post_process/tone_map.cpp b/src/CRE/post_process/tone_map.cpp index 4d74eb0f..391c02ff 100644 --- a/src/CRE/post_process/tone_map.cpp +++ b/src/CRE/post_process/tone_map.cpp @@ -108,9 +108,9 @@ void post_process_tone_map::apply(RenderTexture* in_tex, texture* light_proj_tex mat4 mat; mat4_translate(0.5f, 0.5f, 0.0f, &mat); mat4_scale_rot(&mat, 0.75f, 0.75f, 1.0f, &mat); - mat4_rotate_z_mult(&mat, (pp->lens_flare_pos.x / (float_t)pp->render_width) + mat4_mul_rotate_z(&mat, (pp->lens_flare_pos.x / (float_t)pp->render_width) * 25.0f * DEG_TO_RAD_FLOAT, &mat); - mat4_translate_mult(&mat, -((1.0f / (float_t)pp->render_width) * pp->lens_flare_pos.x), + mat4_mul_translate(&mat, -((1.0f / (float_t)pp->render_width) * pp->lens_flare_pos.x), (pp->lens_flare_pos.y - (float_t)pp->render_height) * (1.0f / (float_t)pp->render_width), 0.0f, &mat); mat4_scale_rot(&mat, 1.0f, aspect, 1.0f, &mat); @@ -126,9 +126,9 @@ void post_process_tone_map::apply(RenderTexture* in_tex, texture* light_proj_tex glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); mat4_translate(0.5f, 0.5f, 0.0f, &mat); mat4_scale_rot(&mat, pp->lens_shaft_scale, pp->lens_shaft_scale, 1.0f, &mat); - mat4_rotate_z_mult(&mat, (pp->lens_flare_pos.x / (float_t)pp->render_width) + mat4_mul_rotate_z(&mat, (pp->lens_flare_pos.x / (float_t)pp->render_width) * 60.0f * DEG_TO_RAD_FLOAT, &mat); - mat4_translate_mult(&mat, -((1.0f / (float_t)pp->render_width) * pp->lens_flare_pos.x), + mat4_mul_translate(&mat, -((1.0f / (float_t)pp->render_width) * pp->lens_flare_pos.x), (pp->lens_flare_pos.y - (float_t)pp->render_height) * (1.0f / (float_t)pp->render_width), 0.0f, &mat); mat4_scale_rot(&mat, 1.0f, aspect, 1.0f, &mat); diff --git a/src/CRE/render_context.cpp b/src/CRE/render_context.cpp index 31684bff..d00e8478 100644 --- a/src/CRE/render_context.cpp +++ b/src/CRE/render_context.cpp @@ -414,14 +414,14 @@ bool light_proj::set_mat(render_context* rctx, bool set_mat) { mat4 proj; mat4_persp(fov, 4.0f, 0.1f, 10.0f, &proj); - mat4_mult(&proj, &temp, &proj); + mat4_mul(&proj, &temp, &proj); mat4 view; vec3 up = { 0.0f, 1.0f, 0.0f }; mat4_look_at(&position, &interest, &up, &view); mat4 mat; - mat4_mult(&view, &proj, &mat); + mat4_mul(&view, &proj, &mat); rctx->obj_scene.set_g_light_projection(mat); } else { @@ -1489,7 +1489,7 @@ namespace mdl { EtcObjCapsule& capsule = etc->data.capsule; vec3 origin = (capsule.pos[0] + capsule.pos[1]) * 0.5f; - mat4_translate_add(&mat, &origin, &mat); + mat4_add_translate(&mat, &origin, &mat); vec3 dir = vec3::normalize(capsule.pos[1] - capsule.pos[0]); vec3 up = { 0.0f, 1.0f, 0.0f }; @@ -1498,7 +1498,7 @@ namespace mdl { Glitter::axis_angle_from_vectors(&axis, &angle, &up, &dir); mat4 m; mat4_mult_axis_angle(&mat4_identity, &axis, angle, &m); - mat4_mult(&m, &mat, &mat); + mat4_mul(&m, &mat, &mat); indexed = true; wire = capsule.wire; @@ -1508,7 +1508,7 @@ namespace mdl { EtcObjEllipse& ellipse = etc->data.ellipse; vec3 origin = (ellipse.pos[0] + ellipse.pos[1]) * 0.5f; - mat4_translate_add(&mat, &origin, &mat); + mat4_add_translate(&mat, &origin, &mat); vec3 dir = vec3::normalize(ellipse.pos[1] - ellipse.pos[0]); vec3 up = { 0.0f, 1.0f, 0.0f }; @@ -1517,7 +1517,7 @@ namespace mdl { Glitter::axis_angle_from_vectors(&axis, &angle, &up, &dir); mat4 m; mat4_mult_axis_angle(&mat4_identity, &axis, angle, &m); - mat4_mult(&m, &mat, &mat); + mat4_mul(&m, &mat, &mat); indexed = true; wire = ellipse.wire; @@ -2123,9 +2123,9 @@ namespace mdl { points[7] = aabb->center + (aabb->size ^ vec3(-0.0f, -0.0f, 0.0f)); mat4 view_mat; - mat4_mult(mat, &cam->view, &view_mat); + mat4_mul(mat, &cam->view, &view_mat); for (int32_t i = 0; i < 8; i++) - mat4_mult_vec3_trans(&view_mat, &points[i], &points[i]); + mat4_transform_point(&view_mat, &points[i], &points[i]); vec4 v2[6]; *(vec3*)&v2[0] = { 0.0f, 0.0f, -1.0f }; @@ -2159,8 +2159,8 @@ namespace mdl { return culling->func(sphere, &cam->view); vec3 center; - mat4_mult_vec3_trans(mat, &sphere->center, ¢er); - mat4_mult_vec3_trans(&cam->view, ¢er, ¢er); + mat4_transform_point(mat, &sphere->center, ¢er); + mat4_transform_point(&cam->view, ¢er, ¢er); float_t radius = mat4_get_max_scale(mat) * sphere->radius; double_t min_depth = (double_t)center.z - (double_t)radius; @@ -2927,12 +2927,12 @@ namespace mdl { const obj_sub_mesh* sub_mesh = i->args.sub_mesh.sub_mesh; if (i->args.sub_mesh.mat_count < 1 || !sub_mesh->num_bone_index) - mat4_mult_vec3_trans(&mat, &sub_mesh->bounding_sphere.center, ¢er); + mat4_transform_point(&mat, &sub_mesh->bounding_sphere.center, ¢er); else { vec3 center_sum = 0.0f; for (uint32_t j = 0; j < sub_mesh->num_bone_index; j++) { center = sub_mesh->bounding_sphere.center; - mat4_mult_vec3_trans(&i->args.sub_mesh.mats[j], ¢er, ¢er); + mat4_transform_point(&i->args.sub_mesh.mats[j], ¢er, ¢er); center_sum += center; } center_sum *= 1.0f / (float_t)sub_mesh->num_bone_index; @@ -2940,7 +2940,7 @@ namespace mdl { i->radius = i->args.sub_mesh.mesh->bounding_sphere.radius; } - mat4_mult_vec3_trans(view, ¢er, ¢er); + mat4_transform_point(view, ¢er, ¢er); i->view_z = center.z; } @@ -3345,7 +3345,7 @@ void obj_scene_shader_data::set_projection_view(const mat4& view, const mat4& pr g_view_inverse[1] = temp.row1; g_view_inverse[2] = temp.row2; - mat4_mult(&view, &proj, &temp); + mat4_mul(&view, &proj, &temp); mat4_transpose(&temp, &temp); g_projection_view[0] = temp.row0; g_projection_view[1] = temp.row1; @@ -3389,7 +3389,7 @@ void obj_batch_shader_data::set_transforms(const mat4& model, const mat4& view, g_worlds_invtrans[2] = temp.row2; mat4 mv; - mat4_mult(&model, &view, &mv); + mat4_mul(&model, &view, &mv); mat4_transpose(&mv, &temp); g_worldview[0] = temp.row0; @@ -3402,7 +3402,7 @@ void obj_batch_shader_data::set_transforms(const mat4& model, const mat4& view, g_worldview_inverse[1] = temp.row1; g_worldview_inverse[2] = temp.row2; - mat4_mult(&mv, &proj, &temp); + mat4_mul(&mv, &proj, &temp); mat4_transpose(&temp, &temp); g_transforms[0] = temp.row0; g_transforms[1] = temp.row1; diff --git a/src/CRE/render_manager.cpp b/src/CRE/render_manager.cpp index 1b3ceb24..ad99ccc4 100644 --- a/src/CRE/render_manager.cpp +++ b/src/CRE/render_manager.cpp @@ -973,7 +973,7 @@ static void draw_pass_shadow_begin_make_shadowmap(render_context* rctx, mat4 proj; mat4_ortho(-range, range, -range, range, shad->z_near, shad->z_far, &proj); - mat4_mult(&proj, &temp, &rctx->proj_mat); + mat4_mul(&proj, &temp, &rctx->proj_mat); mat4_look_at(view_point, interest, &rctx->view_mat); rctx->draw_state.shader_index = SHADER_FT_SIL; @@ -1413,15 +1413,15 @@ static void draw_pass_3d_shadow_set(Shadow* shad, render_context* rctx) { mat4 temp; mat4_translate(0.5f, 0.5f, 0.5f, &temp); mat4_scale_rot(&temp, 0.5f, 0.5f, 0.5f, &temp); - mat4_translate_mult(&temp, v6, 0.0f, 0.0f, &temp); + mat4_mul_translate(&temp, v6, 0.0f, 0.0f, &temp); mat4 proj; mat4_ortho(-range, range, -range, range, shad->z_near, shad->z_far, &proj); - mat4_mult(&proj, &temp, &proj); + mat4_mul(&proj, &temp, &proj); mat4 view; mat4_look_at(view_point, interest, &view); - mat4_mult(&view, &proj, &view); + mat4_mul(&view, &proj, &view); rctx->obj_scene.set_g_self_shadow_receivers(i, view); } diff --git a/src/CRE/rob/ex_block.cpp b/src/CRE/rob/ex_block.cpp index 840638f7..a080e1a3 100644 --- a/src/CRE/rob/ex_block.cpp +++ b/src/CRE/rob/ex_block.cpp @@ -295,7 +295,7 @@ void RobOsageNodeDataNormalRef::GetMat() { mat.row3.y = -vec3::dot(n_trans, v21); mat.row3.z = -vec3::dot(n_trans, v22); mat.row3.w = 1.0f; - mat4_mult(&n->mat, &mat, &mat); + mat4_mul(&n->mat, &mat, &mat); } } @@ -443,17 +443,17 @@ void OsageCollision::Work::update_cls_work(OsageCollision::Work* cls, for (; cls_param->type; cls++, cls_param++) { cls->type = cls_param->type; cls->radius = cls_param->radius; - mat4_mult_vec3_trans(&transform[cls_param->node_idx[0]], + mat4_transform_point(&transform[cls_param->node_idx[0]], &cls_param->pos[0], &cls->pos[0]); switch (cls->type) { case SkinParam::CollisionTypePlane: - mat4_mult_vec3(&transform[cls_param->node_idx[0]], + mat4_transform_vector(&transform[cls_param->node_idx[0]], &cls_param->pos[1], &cls->pos[1]); break; case SkinParam::CollisionTypeCapsule: case SkinParam::CollisionTypeEllipse: - mat4_mult_vec3_trans(&transform[cls_param->node_idx[1]], + mat4_transform_point(&transform[cls_param->node_idx[1]], &cls_param->pos[1], &cls->pos[1]); cls->vec_center = cls->pos[1] - cls->pos[0]; cls->vec_center_length_squared = vec3::length_squared(cls->vec_center); @@ -959,8 +959,8 @@ void RobCloth::ApplyResetData() { for (size_t i = 0; i < root_count; i++, root++) { CLOTHNode* node = &nodes.data()[i + root_count]; for (size_t j = 1; j < nodes_count; j++, node += root_count) { - mat4_mult_vec3_trans(&root->field_D8, &node->reset_data.trans, &node->trans); - mat4_mult_vec3(&root->field_D8, &node->reset_data.trans_diff, &node->trans_diff); + mat4_transform_point(&root->field_D8, &node->reset_data.trans, &node->trans); + mat4_transform_vector(&root->field_D8, &node->reset_data.trans_diff, &node->trans_diff); } } } @@ -1220,12 +1220,12 @@ void RobCloth::SetOsagePlayData(std::vector& opd_blend_data) { CLOTHNode& root_node = nodes.data()[j]; vec3 v26 = root_node.trans; mat4 mat = root.data()[j].field_98; - mat4_translate_mult(&mat, &root_node.trans_orig, &mat); + mat4_mul_translate(&mat, &root_node.trans_orig, &mat); CLOTHNode* v29 = &nodes.data()[j + root_count]; vec3 v78; - mat4_mult_vec3(&mat, &v29->field_64, &v78); + mat4_transform_vector(&mat, &v29->field_64, &v78); int32_t yz_order = 0; sub_140482FF0(mat, v78, 0, 0, yz_order); @@ -1247,19 +1247,19 @@ void RobCloth::SetOsagePlayData(std::vector& opd_blend_data) { v62.y = opd_y[next_key]; v62.z = opd_z[next_key]; - mat4_mult_vec3_trans(&v32, &v61, &v61); - mat4_mult_vec3_trans(&v32, &v62, &v62); + mat4_transform_point(&v32, &v61, &v61); + mat4_transform_point(&v32, &v62, &v62); vec3 v57 = v61 * inv_blend + v62 * blend; vec3 v85; - mat4_mult_vec3_inv_trans(&mat, &v57, &v85); + mat4_inverse_transform_point(&mat, &v57, &v85); vec3 rotation = 0.0f; int32_t yz_order = 0; sub_140482FF0(mat, v85, 0, &rotation, yz_order); - mat4_translate_mult(&mat, vec3::distance(v57, v26), 0.0f, 0.0f, &mat); + mat4_mul_translate(&mat, vec3::distance(v57, v26), 0.0f, 0.0f, &mat); v29->opd_node_data.set_data(i, { v29->dist_top, rotation }); @@ -1271,19 +1271,19 @@ void RobCloth::SetOsagePlayData(std::vector& opd_blend_data) { for (size_t i = 0; i < root_count; i++) { CLOTHNode& root_node = nodes.data()[i]; mat4 mat = root.data()[0].field_98; - mat4_translate_mult(&mat, &root_node.trans_orig, &mat); + mat4_mul_translate(&mat, &root_node.trans_orig, &mat); CLOTHNode* v50 = &nodes.data()[i + root_count]; vec3 v78; - mat4_mult_vec3(&mat, &v50->field_64, &v78); + mat4_transform_vector(&mat, &v50->field_64, &v78); int32_t yz_order = 0; sub_140482FF0(mat, v78, 0, 0, yz_order); for (size_t j = 1; j < nodes_count; j++, v50 += root_count) { - mat4_rotate_z_mult(&mat, v50->opd_node_data.curr.rotation.z, &mat); - mat4_rotate_y_mult(&mat, v50->opd_node_data.curr.rotation.y, &mat); - mat4_translate_mult(&mat, v50->opd_node_data.curr.length, 0.0f, 0.0f, &mat); + mat4_mul_rotate_z(&mat, v50->opd_node_data.curr.rotation.z, &mat); + mat4_mul_rotate_y(&mat, v50->opd_node_data.curr.rotation.y, &mat); + mat4_mul_translate(&mat, v50->opd_node_data.curr.length, 0.0f, 0.0f, &mat); mat4_get_translation(&mat, &v50->trans); } } @@ -1637,8 +1637,8 @@ void RobOsage::ApplyResetData(const mat4* mat) { RobOsageNode* i_begin = nodes.data() + 1; RobOsageNode* i_end = nodes.data() + nodes.size(); for (RobOsageNode* i = i_begin; i != i_end; i++) { - mat4_mult_vec3(mat, &i->reset_data.trans_diff, &i->trans_diff); - mat4_mult_vec3_trans(mat, &i->reset_data.trans, &i->trans); + mat4_transform_vector(mat, &i->reset_data.trans_diff, &i->trans_diff); + mat4_transform_point(mat, &i->reset_data.trans, &i->trans); } root_matrix = *root_matrix_ptr; } @@ -1711,7 +1711,7 @@ void RobOsage::InitData(obj_skin_block_osage* osg_data, obj_skin_osage_node* osg mat3_rotate_zyx(&node_array[i].rotation, &mat); vec3 v49 = { v26[i].length, 0.0f, 0.0f }; - mat3_mult_vec(&mat, &v49, &v26[i].field_94); + mat3_transform_vector(&mat, &v49, &v26[i].field_94); } else for (size_t i = 0; i < osg_data->count; i++) @@ -1737,7 +1737,7 @@ void RobOsage::InitData(obj_skin_block_osage* osg_data, obj_skin_osage_node* osg RobOsageNode* v38 = &nodes.back(); if (memcmp(&v38->mat, &mat4_null, sizeof(mat4))) - mat4_translate_mult(&v38->mat, node.length, 0.0f, 0.0f, &node.mat); + mat4_mul_translate(&v38->mat, node.length, 0.0f, 0.0f, &node.mat); } const float_t* RobOsage::LoadOpdData(size_t node_index, const float_t* opd_data, size_t opd_count) { @@ -1905,7 +1905,7 @@ void RobOsage::SetOsagePlayData(const mat4* root_matrix, vec3 v63 = exp_data.position * parent_scale; mat4 v85 = *root_matrix; - mat4_mult_vec3_trans(&v85, &v63, &nodes.data()[0].trans); + mat4_transform_point(&v85, &v63, &nodes.data()[0].trans); sub_14047F110(this, &v85, &parent_scale, false); *nodes.data()[0].bone_node_mat = v85; @@ -1953,13 +1953,13 @@ void RobOsage::SetOsagePlayData(const mat4* root_matrix, v77.y = opd_y[next_key]; v77.z = opd_z[next_key]; - mat4_mult_vec3_trans(root_matrix, &v62, &v62); - mat4_mult_vec3_trans(root_matrix, &v77, &v77); + mat4_transform_point(root_matrix, &v62, &v62); + mat4_transform_point(root_matrix, &v77, &v77); vec3 v82 = v62 * inv_blend + v77 * blend; vec3 v86; - mat4_mult_vec3_inv_trans(&v87, &v82, &v86); + mat4_inverse_transform_point(&v87, &v82, &v86); vec3 rotation = 0.0f; sub_140482FF0(v87, v86, 0, &rotation, yz_order); @@ -1980,22 +1980,22 @@ void RobOsage::SetOsagePlayData(const mat4* root_matrix, float_t rot_z = j->opd_node_data.curr.rotation.z; rot_y = clamp_def(rot_y, (float_t)-M_PI, (float_t)M_PI); rot_z = clamp_def(rot_z, (float_t)-M_PI, (float_t)M_PI); - mat4_rotate_z_mult(&v85, rot_z, &v85); - mat4_rotate_y_mult(&v85, rot_y, &v85); + mat4_mul_rotate_z(&v85, rot_z, &v85); + mat4_mul_rotate_y(&v85, rot_y, &v85); j->bone_node_ptr->exp_data.parent_scale = parent_scale; *j->bone_node_ptr->ex_data_mat = v85; if (j->bone_node_mat) mat4_scale_rot(&v85, &parent_scale, j->bone_node_mat); - mat4_translate_mult(&v85, j->opd_node_data.curr.length, 0.0f, 0.0f, &v85); + mat4_mul_translate(&v85, j->opd_node_data.curr.length, 0.0f, 0.0f, &v85); j->trans_orig = j->trans; mat4_get_translation(&v85, &j->trans); } if (nodes.size() && node.bone_node_mat) { mat4 v87 = *nodes.back().bone_node_ptr->ex_data_mat; - mat4_translate_mult(&v87, node.length * parent_scale.x, 0.0f, 0.0f, &v87); + mat4_mul_translate(&v87, node.length * parent_scale.x, 0.0f, 0.0f, &v87); *node.bone_node_ptr->ex_data_mat = v87; mat4_scale_rot(&v87, &parent_scale, &v87); @@ -2355,7 +2355,7 @@ void ExConstraintBlock::Calc() { vec3 pos = parent_bone_node->exp_data.parent_scale * node->exp_data.position; mat4 mat; - mat4_translate_mult(parent_bone_node->ex_data_mat, &pos, &mat); + mat4_mul_translate(parent_bone_node->ex_data_mat, &pos, &mat); switch (constraint_type) { case OBJ_SKIN_BLOCK_CONSTRAINT_ORIENTATION: { @@ -2367,7 +2367,7 @@ void ExConstraintBlock::Calc() { mat3 rot; mat3_from_mat4(source_node_bone_node->mat, &rot); mat3_normalize_rotation(&rot, &rot); - mat3_rotate_zyx_mult(&rot, &orientation->offset, &rot); + mat3_mul_rotate_zyx(&rot, &orientation->offset, &rot); mat4_from_mat3(&rot, node->mat); mat4_set_translation(node->mat, &trans); } break; @@ -2376,8 +2376,8 @@ void ExConstraintBlock::Calc() { vec3 align_axis = direction->align_axis; vec3 target_offset = direction->target_offset; - mat4_mult_vec3_trans(source_node_bone_node->mat, &target_offset, &target_offset); - mat4_mult_vec3_inv_trans(&mat, &target_offset, &target_offset); + mat4_transform_point(source_node_bone_node->mat, &target_offset, &target_offset); + mat4_inverse_transform_point(&mat, &target_offset, &target_offset); float_t target_offset_length = vec3::length_squared(target_offset); if (target_offset_length <= 0.000001f) break; @@ -2387,8 +2387,8 @@ void ExConstraintBlock::Calc() { if (direction_up_vector_bone_node) { vec3 affected_axis = direction->up_vector.affected_axis; mat4 v56; - mat4_mult(&v59, &mat, &v56); - mat4_mult_vec3(&v56, &affected_axis, &affected_axis); + mat4_mul(&v59, &mat, &v56); + mat4_transform_vector(&v56, &affected_axis, &affected_axis); mat4* v20 = direction_up_vector_bone_node->mat; vec3 v23; @@ -2398,7 +2398,7 @@ void ExConstraintBlock::Calc() { v23 = v23 - v24; vec3 v50; - mat4_mult_vec3(&mat, &target_offset, &v50); + mat4_transform_vector(&mat, &target_offset, &v50); vec3 v25 = vec3::normalize(vec3::cross(v50, affected_axis)); vec3 v29 = vec3::normalize(vec3::cross(v50, v23)); @@ -2413,9 +2413,9 @@ void ExConstraintBlock::Calc() { v40 = -v40; sub_1405F10D0(&v56, &target_offset, v39, v40); - mat4_mult(&v59, &v56, &v59); + mat4_mul(&v59, &v56, &v59); } - mat4_mult(&v59, &mat, node->mat); + mat4_mul(&v59, &mat, node->mat); } break; case OBJ_SKIN_BLOCK_CONSTRAINT_POSITION: { obj_skin_block_constraint_position* position = cns_data->position; @@ -2423,7 +2423,7 @@ void ExConstraintBlock::Calc() { vec3 constraining_offset = position->constraining_object.offset; vec3 constrained_offset = position->constrained_object.offset; if (position->constraining_object.affected_by_orientation) - mat4_mult_vec3(source_node_bone_node->mat, &constraining_offset, &constraining_offset); + mat4_transform_vector(source_node_bone_node->mat, &constraining_offset, &constraining_offset); vec3 source_node_trans; mat4_get_translation(source_node_bone_node->mat, &source_node_trans); @@ -2432,18 +2432,18 @@ void ExConstraintBlock::Calc() { if (direction_up_vector_bone_node) { vec3 up_vector_trans; mat4_get_translation(direction_up_vector_bone_node->mat, &up_vector_trans); - mat4_mult_vec3_inv_trans(&mat, &up_vector_trans, &up_vector_trans); + mat4_inverse_transform_point(&mat, &up_vector_trans, &up_vector_trans); mat4 v26; sub_1401EB410(&v26, &position->up_vector.affected_axis, &up_vector_trans); - mat4_mult(&v26, &mat, &mat); + mat4_mul(&v26, &mat, &mat); } if (position->constrained_object.affected_by_orientation) - mat4_mult_vec3(&mat, &constrained_offset, &constrained_offset); + mat4_transform_vector(&mat, &constrained_offset, &constrained_offset); mat4 constrained_offset_mat; mat4_translate(&constrained_offset, &constrained_offset_mat); - mat4_mult(&mat, &constrained_offset_mat, node->mat); + mat4_mul(&mat, &constrained_offset_mat, node->mat); } break; case OBJ_SKIN_BLOCK_CONSTRAINT_DISTANCE: default: @@ -2461,7 +2461,7 @@ void ExConstraintBlock::DataSet() { mat4 mat; mat4_inverse_normalized(parent_bone_node->ex_data_mat, &mat); - mat4_mult(bone_node_ptr->mat, &mat, &mat); + mat4_mul(bone_node_ptr->mat, &mat, &mat); mat4_get_rotation(&mat, &exp_data->rotation); mat4_get_translation(&mat, &exp_data->position); if (fabsf(parent_scale.x) > 0.000001f) @@ -3026,7 +3026,7 @@ static void sub_140218560(RobCloth* rob_cls, float_t step, bool a3) { CLOTHNode* node = &rob_cls->nodes.data()[i + root_count]; for (size_t j = 1; j < nodes_count; j++, node += root_count) { vec3 v19; - mat4_mult_vec3_trans(&mat, &node->reset_data.trans, &v19); + mat4_transform_point(&mat, &node->reset_data.trans, &v19); node->trans += (v19 - node->trans) * move_cancel; } } @@ -3066,7 +3066,7 @@ static void sub_1402187D0(RobCloth* rob_cls, bool a2) { mat4 mat = root->field_98; vec3 v37; - mat4_mult_vec3(&mat, &node->field_64, &v37); + mat4_transform_vector(&mat, &node->field_64, &v37); float_t v25; if (!a2) @@ -3100,21 +3100,21 @@ static void sub_140219940(RobCloth* rob_cls) { continue; mat4 mat; - mat4_mult(root.mat[j], root.node_mat[j], &mat); + mat4_mul(root.mat[j], root.node_mat[j], &mat); float_t weight = root.weight[j]; - mat4_scale_mult(&mat, weight, weight, weight, weight, &mat); + mat4_mul_scale(&mat, weight, weight, weight, weight, &mat); mat4_add(&m, &mat, &m); } root.field_98 = m; - mat4_mult_vec3_trans(&m, &root_node.trans_orig, &root_node.trans); - mat4_mult_vec3(&m, &root.normal, &root_node.normal); - mat4_mult_vec3(&m, (vec3*)&root.tangent, &root_node.tangent); + mat4_transform_point(&m, &root_node.trans_orig, &root_node.trans); + mat4_transform_vector(&m, &root.normal, &root_node.normal); + mat4_transform_vector(&m, (vec3*)&root.tangent, &root_node.tangent); root_node.tangent_sign = root.tangent.w; root_node.field_1C = root_node.trans; - mat4_translate_mult(&m, &root_node.trans_orig, &m); + mat4_mul_translate(&m, &root_node.trans_orig, &m); root.field_D8 = m; mat4_inverse(&m, &m); root.field_118 = m; @@ -3309,11 +3309,11 @@ void sub_14021AA60(RobCloth* rob_cls, float_t step, bool a3) { sub_140482FF0(mat, node->field_64, 0, 0, yz_order); vec3 v74; - mat4_mult_vec3_inv_trans(&mat, &node->trans, &v74); + mat4_inverse_transform_point(&mat, &node->trans, &v74); sub_140482FF0(mat, v74, &rob_cls->skin_param_ptr->hinge, &node->reset_data.rotation, yz_order); - mat4_translate_mult(&mat, node->dist_top, 0.0f, 0.0f, &mat); + mat4_mul_translate(&mat, node->dist_top, 0.0f, 0.0f, &mat); mat4_get_translation(&mat, &node->trans); if (v39) @@ -3323,8 +3323,8 @@ void sub_14021AA60(RobCloth* rob_cls, float_t step, bool a3) { if (!a3) { mat4& v49 = rob_cls->root.data()[j].field_118; - mat4_mult_vec3_trans(&v49, &node->trans, &node->reset_data.trans); - mat4_mult_vec3(&v49, &node->trans_diff, &node->reset_data.trans_diff); + mat4_transform_point(&v49, &node->trans, &node->reset_data.trans); + mat4_transform_vector(&v49, &node->trans_diff, &node->reset_data.trans_diff); } } } @@ -3357,7 +3357,7 @@ static void sub_14021D480(RobCloth* rob_cls) { mat4 mat = root->field_98; vec3 v38; - mat4_mult_vec3(&mat, &node->field_64, &v38); + mat4_transform_vector(&mat, &node->field_64, &v38); v38.y -= osage_gravity_const; node[0].trans = node[-root_count].trans + vec3::normalize(v38) * node->dist_top; @@ -3412,7 +3412,7 @@ static void sub_14047C800(RobOsage* rob_osg, const mat4* root_matrix, vec3 v113 = rob_osg->exp_data.position * *parent_scale; mat4 v130 = *root_matrix; - mat4_mult_vec3_trans(&v130, &v113, &v17->trans); + mat4_transform_point(&v130, &v113, &v17->trans); v17->trans_diff = v17->trans - v17->trans_orig; sub_14047F110(rob_osg, &v130, parent_scale, false); @@ -3421,7 +3421,7 @@ static void sub_14047C800(RobOsage* rob_osg, const mat4* root_matrix, v113 = { 1.0f, 0.0f, 0.0f }; vec3 v128; - mat4_mult_vec3(&v130, &v113, &v128); + mat4_transform_vector(&v130, &v113, &v128); float_t v25 = parent_scale->x; if (!rob_osg->osage_reset && step <= 0.0f) @@ -3470,7 +3470,7 @@ static void sub_14047C800(RobOsage* rob_osg, const mat4* root_matrix, RobOsageNode* v55_begin = rob_osg->nodes.data() + 1; RobOsageNode* v55_end = rob_osg->nodes.data() + rob_osg->nodes.size(); for (RobOsageNode* v55 = v55_begin; v55 != v55_end; v55++) { - mat4_mult_vec3_trans(&v131, &v55->field_94, &v128); + mat4_transform_point(&v131, &v55->field_94, &v128); vec3 v126 = v55->trans + v55->trans_diff + v55->field_28; sub_140482F30(&v126, &v111, v25 * v55->length); @@ -3483,11 +3483,11 @@ static void sub_14047C800(RobOsage* rob_osg, const mat4* root_matrix, v126 = v55->trans + v55->trans_diff + v55->field_28; vec3 v129; - mat4_mult_vec3_inv_trans(&v131, &v126, &v129); + mat4_inverse_transform_point(&v131, &v126, &v129); sub_140482FF0(v131, v129, 0, 0, rob_osg->yz_order); - mat4_translate_mult(&v131, vec3::distance(v111, v126), 0.0f, 0.0f, &v131); + mat4_mul_translate(&v131, vec3::distance(v111, v126), 0.0f, 0.0f, &v131); v111 = v126; } @@ -3535,7 +3535,7 @@ static void sub_14047C800(RobOsage* rob_osg, const mat4* root_matrix, RobOsageNode* v99_end = rob_osg->nodes.data() + rob_osg->nodes.size(); for (RobOsageNode* v99 = v99_begin; v99 != v99_end; v99++, v100++) { vec3 v129; - mat4_mult_vec3_inv_trans(&v130, &v99->trans, &v129); + mat4_inverse_transform_point(&v130, &v99->trans, &v129); bool v102 = sub_140482FF0(v130, v129, &v99->data_ptr->skp_osg_node.hinge, &v99->reset_data.rotation, rob_osg->yz_order); @@ -3552,14 +3552,14 @@ static void sub_14047C800(RobOsage* rob_osg, const mat4* root_matrix, else v106 = true; - mat4_translate_mult(&v130, v105, 0.0f, 0.0f, &v130); + mat4_mul_translate(&v130, v105, 0.0f, 0.0f, &v130); if (v102 || v106) mat4_get_translation(&v130, &v99->trans); } if (rob_osg->nodes.size() && rob_osg->node.bone_node_mat) { mat4 v131 = *rob_osg->nodes.back().bone_node_ptr->ex_data_mat; - mat4_translate_mult(&v131, v25 * rob_osg->node.length, 0.0f, 0.0f, &v131); + mat4_mul_translate(&v131, v25 * rob_osg->node.length, 0.0f, 0.0f, &v131); *rob_osg->node.bone_node_ptr->ex_data_mat = v131; } } @@ -3578,21 +3578,21 @@ static void sub_14047E1C0(RobOsage* rob_osg, vec3* scale) { static void sub_14047F110(RobOsage* rob_osg, mat4* mat, const vec3* parent_scale, bool init_rot) { vec3 position = rob_osg->exp_data.position * *parent_scale; - mat4_translate_mult(mat, &position, mat); - mat4_rotate_zyx_mult(mat, &rob_osg->exp_data.rotation, mat); + mat4_mul_translate(mat, &position, mat); + mat4_mul_rotate_zyx(mat, &rob_osg->exp_data.rotation, mat); skin_param* skin_param = rob_osg->skin_param_ptr; vec3 rot = skin_param->rot; if (init_rot) rot = skin_param->init_rot + rot; - mat4_rotate_zyx_mult(mat, &rot, mat); + mat4_mul_rotate_zyx(mat, &rot, mat); } static void sub_1404803B0(RobOsage* rob_osg, const mat4* root_matrix, const vec3* parent_scale, bool has_children_node) { mat4 v47 = *root_matrix; vec3 v45 = rob_osg->exp_data.position * *parent_scale; - mat4_mult_vec3_trans(&v47, &v45, &rob_osg->nodes.data()[0].trans); + mat4_transform_point(&v47, &v45, &rob_osg->nodes.data()[0].trans); if (rob_osg->osage_reset && !rob_osg->prev_osage_reset) { rob_osg->prev_osage_reset = true; @@ -3611,8 +3611,8 @@ static void sub_1404803B0(RobOsage* rob_osg, const mat4* root_matrix, RobOsageNode* i_end = rob_osg->nodes.data() + rob_osg->nodes.size(); for (RobOsageNode* i = i_begin; i != i_end; i++) { vec3 v44; - mat4_mult_vec3_inv_trans(&rob_osg->root_matrix, &i->trans, &v44); - mat4_mult_vec3_trans(rob_osg->root_matrix_ptr, &v44, &v44); + mat4_inverse_transform_point(&rob_osg->root_matrix, &i->trans, &v44); + mat4_transform_point(rob_osg->root_matrix_ptr, &v44, &v44); i->trans += (v44 - i->trans) * move_cancel; } } @@ -3629,7 +3629,7 @@ static void sub_1404803B0(RobOsage* rob_osg, const mat4* root_matrix, RobOsageNode* v30_end = rob_osg->nodes.data() + rob_osg->nodes.size(); for (RobOsageNode* v30 = v30_begin; v30 != v30_end; v29++, v30++) { vec3 v45; - mat4_mult_vec3_inv_trans(&v47, &v30->trans, &v45); + mat4_inverse_transform_point(&v47, &v30->trans, &v45); bool v32 = sub_140482FF0(v47, v45, &v30->data_ptr->skp_osg_node.hinge, &v30->reset_data.rotation, rob_osg->yz_order); *v30->bone_node_ptr->ex_data_mat = v47; @@ -3645,14 +3645,14 @@ static void sub_1404803B0(RobOsage* rob_osg, const mat4* root_matrix, else v36 = true; - mat4_translate_mult(&v47, v35, 0.0f, 0.0f, &v47); + mat4_mul_translate(&v47, v35, 0.0f, 0.0f, &v47); if (v32 || v36) mat4_get_translation(&v47, &v30->trans); } if (rob_osg->nodes.size() && rob_osg->node.bone_node_mat) { mat4 v48 = *rob_osg->nodes.back().bone_node_ptr->ex_data_mat; - mat4_translate_mult(&v48, parent_scale->x * rob_osg->node.length, 0.0f, 0.0f, &v48); + mat4_mul_translate(&v48, parent_scale->x * rob_osg->node.length, 0.0f, 0.0f, &v48); *rob_osg->node.bone_node_ptr->ex_data_mat = v48; } } @@ -3723,7 +3723,7 @@ static void sub_14047D8C0(RobOsage* rob_osg, const mat4* root_matrix, v64 = *root_matrix; vec3 trans = rob_osg->exp_data.position * *parent_scale; - mat4_mult_vec3_trans(&v64, &trans, &rob_osg->nodes.data()[0].trans); + mat4_transform_point(&v64, &trans, &rob_osg->nodes.data()[0].trans); sub_14047F110(rob_osg, &v64, parent_scale, false); } @@ -3782,7 +3782,7 @@ static void sub_14047D8C0(RobOsage* rob_osg, const mat4* root_matrix, sub_140482F30(&v35[0].trans, &v35[-1].trans, v35[0].length * parent_scale->x); vec3 v63; - mat4_mult_vec3_inv_trans(&v64, &v35->trans, &v63); + mat4_inverse_transform_point(&v64, &v35->trans, &v63); bool v40 = sub_140482FF0(v64, v63, &skp_osg_node->hinge, &v35->reset_data.rotation, rob_osg->yz_order); v35->bone_node_ptr->exp_data.parent_scale = *parent_scale; @@ -3802,7 +3802,7 @@ static void sub_14047D8C0(RobOsage* rob_osg, const mat4* root_matrix, else v45 = true; - mat4_translate_mult(&v64, v42, 0.0f, 0.0f, &v64); + mat4_mul_translate(&v64, v42, 0.0f, 0.0f, &v64); v35->reset_data.length = v42; if (v40 || v45) mat4_get_translation(&v64, &v35->trans); @@ -3819,13 +3819,13 @@ static void sub_14047D8C0(RobOsage* rob_osg, const mat4* root_matrix, if (v55 > v23 * v23) v35->trans_diff *= v23 / sqrtf(v55); - mat4_mult_vec3_inv_trans(root_matrix, &v35->trans, &v35->reset_data.trans); - mat4_mult_vec3_inv(root_matrix, &v35->trans_diff, &v35->reset_data.trans_diff); + mat4_inverse_transform_point(root_matrix, &v35->trans, &v35->reset_data.trans); + mat4_inverse_transform_vector(root_matrix, &v35->trans_diff, &v35->reset_data.trans_diff); } if (rob_osg->nodes.size() && rob_osg->node.bone_node_mat) { mat4 v65 = *rob_osg->nodes.back().bone_node_ptr->ex_data_mat; - mat4_translate_mult(&v65, rob_osg->node.length * parent_scale->x, 0.0f, 0.0f, &v65); + mat4_mul_translate(&v65, rob_osg->node.length * parent_scale->x, 0.0f, 0.0f, &v65); *rob_osg->node.bone_node_ptr->ex_data_mat = v65; mat4_scale_rot(&v65, parent_scale, &v65); *rob_osg->node.bone_node_mat = v65; @@ -3914,7 +3914,7 @@ static void sub_14047F990(RobOsage* rob_osg, const mat4* root_matrix, return; vec3 v76 = rob_osg->exp_data.position * *parent_scale; - mat4_mult_vec3_trans(root_matrix, &v76, &v76); + mat4_transform_point(root_matrix, &v76, &v76); RobOsageNode* v12 = &rob_osg->nodes.data()[0]; v12->trans = v76; v12->trans_orig = v76; @@ -3934,7 +3934,7 @@ static void sub_14047F990(RobOsage* rob_osg, const mat4* root_matrix, mat4 v78 = *root_matrix; sub_14047F110(rob_osg, &v78, parent_scale, true); vec3 v60 = { 1.0f, 0.0f, 0.0f }; - mat4_mult_vec3(&v78, &v60, &v60); + mat4_transform_vector(&v78, &v60, &v60); OsageCollision::Work* coli_ring = rob_osg->coli_ring; OsageCollision::Work* coli = rob_osg->coli; @@ -3960,7 +3960,7 @@ static void sub_14047F990(RobOsage* rob_osg, const mat4* root_matrix, j->trans = v74; j->trans_diff = 0.0f; vec3 v77; - mat4_mult_vec3_inv_trans(&v78, &j->trans, &v77); + mat4_inverse_transform_point(&v78, &j->trans, &v77); sub_140482FF0(v78, v77, &j->data_ptr->skp_osg_node.hinge, &j->reset_data.rotation, rob_osg->yz_order); j->bone_node_ptr->exp_data.parent_scale = *parent_scale; @@ -3973,14 +3973,14 @@ static void sub_14047F990(RobOsage* rob_osg, const mat4* root_matrix, float_t v56 = v16 * j->length; if (v55 >= fabsf(v56)) v56 = v55; - mat4_translate_mult(&v78, v56, 0.0f, 0.0f, &v78); + mat4_mul_translate(&v78, v56, 0.0f, 0.0f, &v78); mat4_get_translation(&v78, &j->trans); v60 = j->trans - i->trans; } if (rob_osg->nodes.size() && rob_osg->node.bone_node_mat) { mat4 v79 = *rob_osg->nodes.back().bone_node_ptr->ex_data_mat; - mat4_translate_mult(&v79, v16 * rob_osg->node.length, 0.0f, 0.0f, &v79); + mat4_mul_translate(&v79, v16 * rob_osg->node.length, 0.0f, 0.0f, &v79); *rob_osg->node.bone_node_ptr->ex_data_mat = v79; mat4_scale_rot(&v79, parent_scale, &v79); *rob_osg->node.bone_node_mat = v79; @@ -4040,8 +4040,8 @@ static bool sub_140482FF0(mat4& mat, vec3& trans, skin_param_hinge* hinge, vec3* clipped = true; } } - mat4_rotate_y_mult(&mat, y_rot, &mat); - mat4_rotate_z_mult(&mat, z_rot, &mat); + mat4_mul_rotate_y(&mat, y_rot, &mat); + mat4_mul_rotate_z(&mat, z_rot, &mat); } else { z_rot = atan2f(trans.y, trans.x); @@ -4067,8 +4067,8 @@ static bool sub_140482FF0(mat4& mat, vec3& trans, skin_param_hinge* hinge, vec3* clipped = true; } } - mat4_rotate_z_mult(&mat, z_rot, &mat); - mat4_rotate_y_mult(&mat, y_rot, &mat); + mat4_mul_rotate_z(&mat, z_rot, &mat); + mat4_mul_rotate_y(&mat, y_rot, &mat); } if (rot) { @@ -4108,7 +4108,7 @@ static void sub_14053CE30(RobOsageNodeDataNormalRef* normal_ref, mat4* a2) { v34.row3.w = 1.0f; mat4 v33 = normal_ref->mat; - mat4_mult(&v33, &v34, a2); + mat4_mul(&v33, &v34, a2); } } diff --git a/src/CRE/rob/rob.cpp b/src/CRE/rob/rob.cpp index 619f3bec..3c3d78e4 100644 --- a/src/CRE/rob/rob.cpp +++ b/src/CRE/rob/rob.cpp @@ -2482,30 +2482,30 @@ static void rob_chara_data_adjust_ctrl(rob_chara* rob_chr, if (adjust->type == 1) { mat4 mat = mat4_identity; - mat4_rotate_y_mult(&mat, (float_t)((double_t)rob_chr->data.miku_rot.rot_y_int16 + mat4_mul_rotate_y(&mat, (float_t)((double_t)rob_chr->data.miku_rot.rot_y_int16 * M_PI * (1.0 / 32768.0)), &mat); - mat4_mult_vec3(&mat, &adjust->curr_external_force, &adjust->curr_external_force); + mat4_transform_vector(&mat, &adjust->curr_external_force, &adjust->curr_external_force); } else if (adjust->type == 2) { mat4* mat = rob_chara_bone_data_get_node(rob_chr->bone_data, MOT_BONE_KL_MUNE_B_WJ)->ex_data_mat; if (mat) - mat4_mult_vec3(mat, &adjust->curr_external_force, &adjust->curr_external_force); + mat4_transform_vector(mat, &adjust->curr_external_force, &adjust->curr_external_force); } else if (adjust->type == 3) { mat4* mat = rob_chara_bone_data_get_node(rob_chr->bone_data, MOT_BONE_KL_KUBI)->ex_data_mat; if (mat) - mat4_mult_vec3(mat, &adjust->curr_external_force, &adjust->curr_external_force); + mat4_transform_vector(mat, &adjust->curr_external_force, &adjust->curr_external_force); } else if (adjust->type == 4) { mat4* mat = rob_chara_bone_data_get_node(rob_chr->bone_data, MOT_BONE_FACE_ROOT)->ex_data_mat; if (mat) - mat4_mult_vec3(mat, &adjust->curr_external_force, &adjust->curr_external_force); + mat4_transform_vector(mat, &adjust->curr_external_force, &adjust->curr_external_force); } else if (adjust->type == 5) { mat4* mat = rob_chara_bone_data_get_node(rob_chr->bone_data, MOT_BONE_KL_KOSI_ETC_WJ)->ex_data_mat; if (mat) { adjust->curr_external_force.z = -adjust->curr_external_force.z; - mat4_mult_vec3(mat, &adjust->curr_external_force, &adjust->curr_external_force); + mat4_transform_vector(mat, &adjust->curr_external_force, &adjust->curr_external_force); } } @@ -3333,7 +3333,7 @@ static void rob_chara_bone_data_set_left_hand_scale(rob_chara_bone_data* rob_bon for (int32_t i = ROB_BONE_KL_TE_L_WJ; i <= ROB_BONE_NL_OYA_C_L_WJ; i++) { mat4* m = rob_chara_bone_data_get_mats_mat(rob_bone_data, i); if (m) - mat4_mult(m, &mat, m); + mat4_mul(m, &mat, m); } for (int32_t i = MOT_BONE_KL_TE_L_WJ; i <= MOT_BONE_NL_OYA_C_L_WJ; i++) { @@ -3359,7 +3359,7 @@ static void rob_chara_bone_data_set_right_hand_scale(rob_chara_bone_data* rob_bo for (int32_t i = ROB_BONE_KL_TE_R_WJ; i <= ROB_BONE_NL_OYA_C_R_WJ; i++) { mat4* m = rob_chara_bone_data_get_mats_mat(rob_bone_data, i); if (m) - mat4_mult(m, &mat, m); + mat4_mul(m, &mat, m); } for (int32_t i = MOT_BONE_KL_TE_R_WJ; i <= MOT_BONE_NL_OYA_C_R_WJ; i++) { @@ -4786,11 +4786,11 @@ void rob_chara::sub_140509D30() { mat4 mat; for (int32_t i = 0; i < 27; i++) { m = rob_chara_bone_data_get_mats_mat(bone_data, v3->bone_index); - mat4_translate_mult(m, &v3->bone_offset, &mat); + mat4_mul_translate(m, &v3->bone_offset, &mat); *v42 = mat; m = rob_chara_bone_data_get_mats_mat(bone_data, v6->bone_index); - mat4_translate_mult(m, &v3->bone_offset, &mat); + mat4_mul_translate(m, &v3->bone_offset, &mat); *v43 = mat; float_t chara_scale = data.adjust_data.scale; @@ -4916,12 +4916,12 @@ static void bone_data_mult_0(bone_data* a1, int32_t skeleton_select) { mat = mat4_identity; if (a1->type == BONE_DATABASE_BONE_POSITION) { - mat4_translate_mult(&mat, &a1->trans, &mat); + mat4_mul_translate(&mat, &a1->trans, &mat); a1->rot_mat[0] = mat4_identity; } else if (a1->type == BONE_DATABASE_BONE_TYPE_1) { - mat4_mult_vec3_inv_trans(&mat, &a1->trans, &a1->trans); - mat4_translate_mult(&mat, &a1->trans, &mat); + mat4_inverse_transform_point(&mat, &a1->trans, &a1->trans); + mat4_mul_translate(&mat, &a1->trans, &mat); a1->rot_mat[0] = mat4_identity; } else { @@ -4935,14 +4935,14 @@ static void bone_data_mult_0(bone_data* a1, int32_t skeleton_select) { mat4 rot_mat; if (a1->type == BONE_DATABASE_BONE_POSITION_ROTATION) - mat4_rotate_zyx_mult(&a1->rot_mat[0], &a1->rotation, &rot_mat); + mat4_mul_rotate_zyx(&a1->rot_mat[0], &a1->rotation, &rot_mat); else { a1->trans = a1->base_translation[skeleton_select]; mat4_rotate_zyx(&a1->rotation, &rot_mat); } - mat4_translate_mult(&mat, &a1->trans, &mat); - mat4_mult(&rot_mat, &mat, &mat); + mat4_mul_translate(&mat, &a1->trans, &mat); + mat4_mul(&rot_mat, &mat, &mat); a1->rot_mat[0] = rot_mat; } @@ -4962,7 +4962,7 @@ static void bone_data_mult_1(bone_data* a1, mat4* parent_mat, bone_data* a3, boo if (a1->type != BONE_DATABASE_BONE_POSITION_ROTATION) a1->trans = a1->base_translation[1]; - mat4_translate_mult(&mat, &a1->trans, &mat); + mat4_mul_translate(&mat, &a1->trans, &mat); if (solve_ik) { a1->node[0].exp_data.rotation = 0.0f; if (!a1->check_flags_not_null()) @@ -4975,7 +4975,7 @@ static void bone_data_mult_1(bone_data* a1, mat4* parent_mat, bone_data* a3, boo if (bone_data_mult_1_ik(a1, a3)) { mat4 rot_mat; mat4_invrot_normalized(&mat, &rot_mat); - mat4_mult(a1->node[0].mat, &rot_mat, &rot_mat); + mat4_mul(a1->node[0].mat, &rot_mat, &rot_mat); mat4_clear_trans(&rot_mat, &rot_mat); mat4_get_rotation(&rot_mat, &a1->node[0].exp_data.rotation); a1->rot_mat[0] = rot_mat; @@ -4985,10 +4985,10 @@ static void bone_data_mult_1(bone_data* a1, mat4* parent_mat, bone_data* a3, boo } } - mat4_mult(&a1->rot_mat[0], &mat, &mat); + mat4_mul(&a1->rot_mat[0], &mat, &mat); } else { - mat4_translate_mult(&mat, &a1->trans, &mat); + mat4_mul_translate(&mat, &a1->trans, &mat); if (solve_ik) a1->node[0].exp_data.rotation = 0.0f; } @@ -5002,11 +5002,11 @@ static void bone_data_mult_1(bone_data* a1, mat4* parent_mat, bone_data* a3, boo if (a1->type < BONE_DATABASE_BONE_HEAD_IK_ROTATION) return; - mat4_mult(&a1->rot_mat[1], &mat, &mat); + mat4_mul(&a1->rot_mat[1], &mat, &mat); *a1->node[1].mat = mat; if (a1->type == BONE_DATABASE_BONE_HEAD_IK_ROTATION) { - mat4_translate_mult(&mat, a1->ik_segment_length[1], 0.0f, 0.0f, &mat); + mat4_mul_translate(&mat, a1->ik_segment_length[1], 0.0f, 0.0f, &mat); *a1->node[2].mat = mat; if (!solve_ik) return; @@ -5018,11 +5018,11 @@ static void bone_data_mult_1(bone_data* a1, mat4* parent_mat, bone_data* a3, boo a1->ik_segment_length[1], 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); } else { - mat4_translate_mult(&mat, a1->ik_segment_length[1], 0.0f, 0.0f, &mat); - mat4_mult(&a1->rot_mat[2], &mat, &mat); + mat4_mul_translate(&mat, a1->ik_segment_length[1], 0.0f, 0.0f, &mat); + mat4_mul(&a1->rot_mat[2], &mat, &mat); *a1->node[2].mat = mat; - mat4_translate_mult(&mat, a1->ik_2nd_segment_length[1], 0.0f, 0.0f, &mat); + mat4_mul_translate(&mat, a1->ik_2nd_segment_length[1], 0.0f, 0.0f, &mat); *a1->node[3].mat = mat; if (!solve_ik) return; @@ -5068,19 +5068,19 @@ static bool bone_data_mult_1_ik(bone_data* a1, bone_data* a2) { break; case MOTION_BONE_N_MOMO_A_L_WJ_CD_EX: mat4_get_translation(a2[MOTION_BONE_CL_MOMO_L].node[2].mat, &trans); - mat4_mult_vec3_inv_trans(a1->node[0].mat, &trans, &trans); + mat4_inverse_transform_point(a1->node[0].mat, &trans, &trans); trans = -trans; bone_data_mult_1_ik_legs(a1, &trans); break; case MOTION_BONE_N_MOMO_A_R_WJ_CD_EX: mat4_get_translation(a2[MOTION_BONE_CL_MOMO_R].node[2].mat, &trans); - mat4_mult_vec3_inv_trans(a1->node[0].mat, &trans, &trans); + mat4_inverse_transform_point(a1->node[0].mat, &trans, &trans); trans = -trans; bone_data_mult_1_ik_legs(a1, &trans); break; case MOTION_BONE_N_HARA_CD_EX: mat4_get_translation(a2[MOTION_BONE_KL_MUNE_B_WJ].node[0].mat, &trans); - mat4_mult_vec3_inv_trans(a1->node[0].mat, &trans, &trans); + mat4_inverse_transform_point(a1->node[0].mat, &trans, &trans); bone_data_mult_1_ik_legs(a1, &trans); break; default: @@ -5091,7 +5091,7 @@ static bool bone_data_mult_1_ik(bone_data* a1, bone_data* a2) { static void bone_data_mult_1_ik_hands(bone_data* a1, vec3* a2) { vec3 v15; - mat4_mult_vec3_inv_trans(a1->node[0].mat, a2, &v15); + mat4_inverse_transform_point(a1->node[0].mat, a2, &v15); float_t len; len = vec3::length_squared(v15); @@ -5121,12 +5121,12 @@ static void bone_data_mult_1_ik_hands(bone_data* a1, vec3* a2) { *(vec3*)&rot_mat.row1 = v16; *(vec3*)&rot_mat.row2 = v17; - mat4_mult(&rot_mat, a1->node[0].mat, a1->node[0].mat); + mat4_mul(&rot_mat, a1->node[0].mat, a1->node[0].mat); } static void bone_data_mult_1_ik_hands_2(bone_data* a1, vec3* a2, float_t a3) { vec3 v8; - mat4_mult_vec3_inv_trans(a1->node[0].mat, a2, &v8); + mat4_inverse_transform_point(a1->node[0].mat, a2, &v8); v8.x = 0.0f; float_t len = vec3::length(v8); @@ -5135,7 +5135,7 @@ static void bone_data_mult_1_ik_hands_2(bone_data* a1, vec3* a2, float_t a3) { v8 *= 1.0f / len; float_t angle = atan2f(v8.z, v8.y); - mat4_rotate_x_mult(a1->node[0].mat, angle * a3, a1->node[0].mat); + mat4_mul_rotate_x(a1->node[0].mat, angle * a3, a1->node[0].mat); } static void bone_data_mult_1_ik_legs(bone_data* a1, vec3* a2) { @@ -5170,7 +5170,7 @@ static void bone_data_mult_1_ik_legs(bone_data* a1, vec3* a2) { *(vec3*)&rot_mat.row1 = v9; *(vec3*)&rot_mat.row2 = v8; - mat4_mult(&rot_mat, a1->node[0].mat, a1->node[0].mat); + mat4_mul(&rot_mat, a1->node[0].mat, a1->node[0].mat); } static bool bone_data_mult_1_exp_data(bone_data* a1, bone_node_expression_data* exp_data, bone_data* a3) { @@ -5193,7 +5193,7 @@ static bool bone_data_mult_1_exp_data(bone_data* a1, bone_node_expression_data* case MOTION_BONE_N_KUBI_WJ_EX: dst = a3[MOTION_BONE_CL_KAO].rot_mat[0]; mat = a3[MOTION_BONE_CL_KAO].rot_mat[1]; - mat4_mult(&mat, &dst, &dst); + mat4_mul(&mat, &dst, &dst); mat4_get_rotation(&dst, &v15); v10 = v15.z; if (v10 < (float_t)-M_PI_2) @@ -5295,16 +5295,16 @@ static void bone_data_mult_ik(bone_data* a1, int32_t skeleton_select) { mat4 mat = *a1->node[0].mat; vec3 v30; - mat4_mult_vec3_inv_trans(&mat, &a1->ik_target, &v30); + mat4_inverse_transform_point(&mat, &a1->ik_target, &v30); float_t v6 = vec2::length_squared(*(vec2*)&v30); float_t v8 = vec3::length_squared(v30); float_t v9 = sqrtf(v6); float_t v10 = sqrtf(v8); mat4 rot_mat; if (v9 > 0.000001f && v8 > 0.000001f) { - mat4_rotate_z_sin_cos(v30.y / v9, v30.x / v9, &rot_mat); - mat4_rotate_y_mult_sin_cos(&rot_mat, -v30.z / v10, v9 / v10, &rot_mat); - mat4_mult(&rot_mat, &mat, &mat); + mat4_rotate_z(v30.y / v9, v30.x / v9, &rot_mat); + mat4_mul_rotate_y(&rot_mat, -v30.z / v10, v9 / v10, &rot_mat); + mat4_mul(&rot_mat, &mat, &mat); } else rot_mat = mat4_identity; @@ -5312,21 +5312,21 @@ static void bone_data_mult_ik(bone_data* a1, int32_t skeleton_select) { if (a1->pole_target_mat) { vec3 pole_target; mat4_get_translation(a1->pole_target_mat, &pole_target); - mat4_mult_vec3_inv_trans(&mat, &pole_target, &pole_target); + mat4_inverse_transform_point(&mat, &pole_target, &pole_target); float_t pole_target_length = vec2::length(*(vec2*)&pole_target.y); if (pole_target_length > 0.000001f) { pole_target *= 1.0f / pole_target_length; float_t rot_cos = pole_target.y; float_t rot_sin = pole_target.z; - mat4_rotate_x_mult_sin_cos(&mat, rot_sin, rot_cos, &mat); - mat4_rotate_x_mult_sin_cos(&rot_mat, rot_sin, rot_cos, &rot_mat); + mat4_mul_rotate_x(&mat, rot_sin, rot_cos, &mat); + mat4_mul_rotate_x(&rot_mat, rot_sin, rot_cos, &rot_mat); } } if (a1->type == BONE_DATABASE_BONE_HEAD_IK_ROTATION) { a1->rot_mat[1] = rot_mat; *a1->node[1].mat = mat; - mat4_translate_mult(&mat, a1->ik_segment_length[skeleton_select], 0.0f, 0.0f, &mat); + mat4_mul_translate(&mat, a1->ik_segment_length[skeleton_select], 0.0f, 0.0f, &mat); *a1->node[2].mat = mat; return; } @@ -5367,16 +5367,16 @@ static void bone_data_mult_ik(bone_data* a1, int32_t skeleton_select) { rot_2nd_cos = -1.0f; } - mat4_rotate_z_mult_sin_cos(&mat, rot_sin, rot_cos, &mat); + mat4_mul_rotate_z(&mat, rot_sin, rot_cos, &mat); *a1->node[1].mat = mat; - mat4_rotate_z_mult_sin_cos(&rot_mat, rot_sin, rot_cos, &rot_mat); + mat4_mul_rotate_z(&rot_mat, rot_sin, rot_cos, &rot_mat); a1->rot_mat[1] = rot_mat; - mat4_translate_mult(&mat, ik_segment_length, 0.0f, 0.0f, &mat); - mat4_rotate_z_mult_sin_cos(&mat, rot_2nd_sin, rot_2nd_cos, &mat); + mat4_mul_translate(&mat, ik_segment_length, 0.0f, 0.0f, &mat); + mat4_mul_rotate_z(&mat, rot_2nd_sin, rot_2nd_cos, &mat); *a1->node[2].mat = mat; - mat4_rotate_z_sin_cos(rot_2nd_sin, rot_2nd_cos, &rot_mat); + mat4_rotate_z(rot_2nd_sin, rot_2nd_cos, &rot_mat); a1->rot_mat[2] = rot_mat; - mat4_translate_mult(&mat, ik_2nd_segment_length, 0.0f, 0.0f, &mat); + mat4_mul_translate(&mat, ik_2nd_segment_length, 0.0f, 0.0f, &mat); *a1->node[3].mat = mat; } @@ -7112,23 +7112,23 @@ static void motion_blend_mot_interpolate(motion_blend_mot* a1) { float_t rot_y = a1->bone_data.rot_y; mat4 mat; mat4_rotate_y(rot_y, &mat); - mat4_translate_mult(&mat, &global_trans, &mat); - mat4_rotate_zyx_mult(&mat, &global_rotation, &mat); + mat4_mul_translate(&mat, &global_trans, &mat); + mat4_mul_rotate_zyx(&mat, &global_rotation, &mat); for (bone_data& i : a1->bone_data.bones) switch (i.type) { case BONE_DATABASE_BONE_TYPE_1: - mat4_mult_vec3_trans(&mat, &i.trans, &i.trans); + mat4_transform_point(&mat, &i.trans, &i.trans); break; case BONE_DATABASE_BONE_POSITION_ROTATION: { mat4 rot_mat; mat4_clear_trans(&mat, &rot_mat); i.rot_mat[0] = rot_mat; - mat4_mult_vec3_trans(&mat, &i.trans, &i.trans); + mat4_transform_point(&mat, &i.trans, &i.trans); } break; case BONE_DATABASE_BONE_HEAD_IK_ROTATION: case BONE_DATABASE_BONE_ARM_IK_ROTATION: case BONE_DATABASE_BONE_LEGS_IK_ROTATION: - mat4_mult_vec3_trans(&mat, &i.ik_target, &i.ik_target); + mat4_transform_point(&mat, &i.ik_target, &i.ik_target); break; } } @@ -7500,7 +7500,7 @@ static mat4* sub_140504E80(rob_chara* rob_chr) { static void sub_14041DA50(rob_chara_bone_data* rob_bone_data, mat4* mat) { for (bone_node& i : rob_bone_data->nodes) - mat4_mult(i.mat, mat, i.mat); + mat4_mul(i.mat, mat, i.mat); sub_140414900(&rob_bone_data->motion_loaded.front()->field_4F8, mat); } @@ -7516,7 +7516,7 @@ static void sub_140507F60(rob_chara* rob_chr) { mat4* v8 = rob_chara_bone_data_get_mats_mat(rob_chr->bone_data, ROB_BONE_N_HARA_CP); vec3 v10 = { 0.0f, 0.0f, 1.0f }; - mat4_mult_vec3(v8, &v10, &v10); + mat4_transform_vector(v8, &v10, &v10); rob_chr->data.miku_rot.field_6 = (int32_t)((float_t)(atan2f(v10.x, v10.z) * 32768.0f) * (1.0 / M_PI)); } @@ -8053,7 +8053,7 @@ static void sub_140504F00(rob_chara* rob_chr) { mat4 mat; mat4_rotate_y((float_t)((double_t)rob_chr->data.miku_rot.rot_y_int16 * M_PI * (1.0 / 32768.0)), &mat); - mat4_mult_vec3(&mat, &v9, &v9); + mat4_transform_vector(&mat, &v9, &v9); if (!(rob_chr->data.field_1588.field_0.field_20.field_0 & 0x08)) { rob_chr->data.field_1588.field_0.field_20.field_0 |= 0x08; @@ -8363,7 +8363,7 @@ static void sub_140409B70(rob_chara_look_anim* look_anim, mat4_inverse(adjust_mat, &mat); vec3 v24; - mat4_mult_vec3_trans(&mat, target_view_point, &v24); + mat4_transform_point(&mat, target_view_point, &v24); look_anim->field_184 = vec3::clamp(look_anim->field_184, v24 - 0.05f, v24 + 0.05f); @@ -8431,12 +8431,12 @@ static void sub_140407280(rob_chara_look_anim* look_anim, std::vector v18 = v25 - v15; vec3 v67; - mat4_mult_vec3_inv_trans(n_kao_mat, &look_anim->field_184, &v67); + mat4_inverse_transform_point(n_kao_mat, &look_anim->field_184, &v67); if (fabsf(vec3::length(v67)) <= 0.000001f) return; vec3 v68; - mat4_mult_vec3_inv_trans(n_kao_mat, &v69, &v68); + mat4_inverse_transform_point(n_kao_mat, &v69, &v68); float_t v28 = vec3::length(v68); if (fabsf(v28) <= 0.000001f) return; @@ -8575,7 +8575,7 @@ static void sub_140407280(rob_chara_look_anim* look_anim, std::vector head_rot_axis.y = (n_kao_mat->row2.y + 1.0f) * 0.5f; head_rot_axis.z = n_kao_mat->row2.z * 0.5f; mat4_mult_axis_angle(&cl_kao_mat, &head_rot_axis, head_rot_angle, &cl_kao_mat); - mat4_mult_vec3_inv_trans(&cl_kao_mat, &look_anim->field_184, &v67); + mat4_inverse_transform_point(&cl_kao_mat, &look_anim->field_184, &v67); float_t v52; if (v36) @@ -8614,7 +8614,7 @@ static void sub_140407280(rob_chara_look_anim* look_anim, std::vector v58 = look_anim->field_1AC.field_4; } - mat4_rotate_y_mult(&cl_kao_mat, v58 * look_anim->head_rot_blend, &cl_kao_mat); + mat4_mul_rotate_y(&cl_kao_mat, v58 * look_anim->head_rot_blend, &cl_kao_mat); mat4 cl_kao_mat_backup = bones[MOTION_BONE_CL_KAO].rot_mat[1]; @@ -8622,7 +8622,7 @@ static void sub_140407280(rob_chara_look_anim* look_anim, std::vector mat4_inverse(bones[MOTION_BONE_CL_KAO].node->mat, &v74); mat4_clear_trans(&v74, &v74); mat4_clear_trans(&cl_kao_mat, &cl_kao_mat); - mat4_mult(&cl_kao_mat, &v74, &bones[MOTION_BONE_CL_KAO].rot_mat[1]); + mat4_mul(&cl_kao_mat, &v74, &bones[MOTION_BONE_CL_KAO].rot_mat[1]); for (int32_t i = MOTION_BONE_CL_KAO; i <= MOTION_BONE_N_KUBI_WJ_EX; i++) bone_data_mult_1(&bones[i], mat, &bones[MOTION_BONE_N_HARA_CP], true); @@ -8674,7 +8674,7 @@ static void sub_140406FC0(rob_chara_look_anim* look_anim, bone_data* bone, mat4* mat4 mat; mat4_rotate_y(rot_y, &mat); - mat4_rotate_x_mult(&mat, rot_x, &mat); + mat4_mul_rotate_x(&mat, rot_x, &mat); mat4_lerp_rotation(&mat4_identity, &mat, &mat, look_anim->eyes_rot_strength); if (eyes_rot_anim) mat4_lerp_rotation(&bone->rot_mat[0], &mat, &mat, eyes_rot_blend); @@ -8719,7 +8719,7 @@ static void sub_140409170(rob_chara_look_anim* look_anim, mat4* adjust_mat, look_anim->view_point = look_anim->target_view_point; mat4 v61; mat4_inverse(adjust_mat, &v61); - mat4_mult_vec3_trans(&v61, &look_anim->view_point, &look_anim->view_point); + mat4_transform_point(&v61, &look_anim->view_point, &look_anim->view_point); mat4* kl_eye_l_parent_mat = bones[MOTION_BONE_KL_EYE_L].parent_mat; mat4* kl_eye_r_parent_mat = bones[MOTION_BONE_KL_EYE_R].parent_mat; @@ -8746,7 +8746,7 @@ static void sub_140409170(rob_chara_look_anim* look_anim, mat4* adjust_mat, *(vec3*)&v61.row3 = *(vec3*)&kl_eye_l_parent_mat->row3 + *(vec3*)&kl_eye_r_parent_mat->row3; vec3 v54; - mat4_mult_vec3_inv_trans(&v61, &look_anim->view_point, &v54); + mat4_inverse_transform_point(&v61, &look_anim->view_point, &v54); float_t v38 = vec3::length(v54); if (fabsf(v38) <= 0.000001f || v54.x * v54.x + v54.z * v54.z <= 0.01f) { @@ -8756,17 +8756,17 @@ static void sub_140409170(rob_chara_look_anim* look_anim, mat4* adjust_mat, else if (v38 < look_anim->field_B0) { vec3 v53 = v54 * (look_anim->field_B0 / v38); vec3 v60; - mat4_mult_vec3_trans(&v61, &v53, &v60); + mat4_transform_point(&v61, &v53, &v60); vec3 v56; - mat4_mult_vec3_inv_trans(kl_eye_l_parent_mat, &v60, &v56); + mat4_inverse_transform_point(kl_eye_l_parent_mat, &v60, &v56); float_t v41 = atan2f(v56.x - look_anim->param.pos.x, v56.z); if (yrot_neg_left < v41) yrot_neg_left = min_def(yrot_pos_left, v41); vec3 v55; - mat4_mult_vec3_inv_trans(kl_eye_r_parent_mat, &v60, &v55); + mat4_inverse_transform_point(kl_eye_r_parent_mat, &v60, &v55); float_t v42 = atan2f(v55.x + look_anim->param.pos.x, v55.z); if (yrot_pos_right > v42) @@ -8790,7 +8790,7 @@ static void sub_140409170(rob_chara_look_anim* look_anim, mat4* adjust_mat, vec3 rot_neg_left = vec3(xrot_neg, yrot_neg_left, 0.0f); vec3 rot_pos_left = vec3(xrot_pos, yrot_pos_left, 0.0f); vec3 pos_left; - mat4_mult_vec3_inv_trans(kl_eye_l_parent_mat, &look_anim->view_point, &pos_left); + mat4_inverse_transform_point(kl_eye_l_parent_mat, &look_anim->view_point, &pos_left); sub_140406FC0(look_anim, &bones[MOTION_BONE_KL_EYE_L], &look_anim->left_eye_mat, pos_left - look_anim->param.pos, rot_neg_left, rot_pos_left, eyes_rot_anim, eyes_rot_blend, eyes_rot_step); @@ -8799,7 +8799,7 @@ static void sub_140409170(rob_chara_look_anim* look_anim, mat4* adjust_mat, vec3 rot_neg_right = vec3(xrot_neg, yrot_neg_right, 0.0f); vec3 rot_pos_right = vec3(xrot_pos, yrot_pos_right, 0.0f); vec3 pos_right; - mat4_mult_vec3_inv_trans(kl_eye_r_parent_mat, &look_anim->view_point, &pos_right); + mat4_inverse_transform_point(kl_eye_r_parent_mat, &look_anim->view_point, &pos_right); sub_140406FC0(look_anim, &bones[MOTION_BONE_KL_EYE_R], &look_anim->right_eye_mat, pos_right - (look_anim->param.pos ^ _xor), rot_neg_right, rot_pos_right, eyes_rot_anim, eyes_rot_blend, eyes_rot_step); @@ -8934,15 +8934,15 @@ static void rob_chara_set_hands_adjust(rob_chara* rob_chr) { static void sub_14040AE10(mat4* mat, const vec3 a2) { vec3 v8; - mat4_mult_vec3_inv_trans(mat, &a2, &v8); + mat4_inverse_transform_point(mat, &a2, &v8); float_t v5 = vec2::length(*(vec2*)&v8); float_t v6 = vec3::length(v8); if (fabsf(v5) > 0.000001f && fabsf(v6) > 0.000001f) { float_t v7 = v5; v5 = 1.0f / v5; v6 = 1.0f / v6; - mat4_rotate_z_mult_sin_cos(mat, v5 * v8.y, v5 * v8.x, mat); - mat4_rotate_y_mult_sin_cos(mat, -v6 * v8.z, v6 * v7, mat); + mat4_mul_rotate_z(mat, v5 * v8.y, v5 * v8.x, mat); + mat4_mul_rotate_y(mat, -v6 * v8.z, v6 * v7, mat); } } @@ -8956,13 +8956,13 @@ static void sub_140406A70(vec3* a1, std::vector& bones, mat4* a3, vec mat4 v38 = *v14->node->mat; sub_14040AE10(&v38, v14->ik_target); - mat4_mult_vec3_inv_trans(&v38, &v36, &v36); + mat4_inverse_transform_point(&v38, &v36, &v36); v38 = *v14->node->mat; sub_14040AE10(&v38, *a4); vec3 v37; - mat4_mult_vec3_trans(&v38, &v36, &v37); + mat4_transform_point(&v38, &v36, &v37); mat4_set_translation(v14->pole_target_mat, &v37); } @@ -8980,7 +8980,7 @@ static void sub_140406A70(vec3* a1, std::vector& bones, mat4* a3, vec mat4_clear_trans(v25->parent_mat, &v38); mat4_clear_trans(v25->node->mat, &v39); mat4_transpose(&v38, &v38); - mat4_mult(&v39, &v38, &v38); + mat4_mul(&v39, &v38, &v38); if (rotation_blend < 1.0f) mat4_lerp_rotation(&v25->rot_mat[0], &v38, &v38, rotation_blend); v25->rot_mat[0] = v38; @@ -9030,12 +9030,12 @@ static bool sub_14053ACA0(rob_chara* rob_chr, int32_t hand) { mat4* v40 = rob_chara_bone_data_get_mats_mat(rob_chr->bone_data, rob_kl_te_bones[hand]); mat4 v42; - mat4_mult(v40, &adjust_data.mat, &v42); + mat4_mul(v40, &adjust_data.mat, &v42); vec3 v37 = rob_chr->data.motion.hand_adjust[hand].offset * (1.0f - chara_scale / adjust_scale); vec3 v38; - mat4_mult_vec3_trans(&v42, &v37, &v38); + mat4_transform_point(&v42, &v37, &v38); vec3 v27 = 0.0f; if (rob_chr->data.motion.hand_adjust[hand].disable_x) @@ -9049,7 +9049,7 @@ static bool sub_14053ACA0(rob_chara* rob_chr, int32_t hand) { vec3 v18 = 0.0f; if (v15 > 0) { - mat4_mult_vec3_trans(&v42, &rob_chr->data.motion.hand_adjust[hand].offset, &v38); + mat4_transform_point(&v42, &rob_chr->data.motion.hand_adjust[hand].offset, &v38); v18 = v38 + v27; } @@ -9061,7 +9061,7 @@ static bool sub_14053ACA0(rob_chara* rob_chr, int32_t hand) { mat4_set_translation(v40, &v18); vec3 v37 = -rob_chr->data.motion.hand_adjust[hand].offset; - mat4_mult_vec3_trans(v40, &v37, &v39); + mat4_transform_point(v40, &v37, &v39); if (!--v15) { rotation_blend = 1.0f; solve_ik = true; @@ -9172,7 +9172,7 @@ static bool sub_14053B580(rob_chara* rob_chr, int32_t a2) { (rob_chara_bone_data*)((size_t)rob_chr->field_20 + 0x28), dword_140A2DDD0[v0.field_C]); mat4 v49; - mat4_translate_mult(v23, &v0.field_10, &v49); + mat4_mul_translate(v23, &v0.field_10, &v49); mat4_get_translation(&v49, &v45); } break; @@ -9248,10 +9248,10 @@ static bool sub_14053B580(rob_chara* rob_chr, int32_t a2) { static void sub_1403F9A40(vec3* a1, vec3* a2, mat4* a3, float_t a4, float_t a5) { vec3 v10; - mat4_mult_vec3_inv_trans(a3, a2, &v10); + mat4_inverse_transform_point(a3, a2, &v10); v10.y += a4; v10.z += a5; - mat4_mult_vec3_trans(a3, &v10, a1); + mat4_transform_point(a3, &v10, a1); } static bool sub_14040AC40(vec3* a1, vec3* a2, float_t a3, vec3* a4) { @@ -9276,7 +9276,7 @@ static void sub_1403FA040(vec3* a1, float_t a2, mat4* a3, float_t ymin, vec3 v51; vec3 v52; vec3 v53; - mat4_mult_vec3_inv(a3, a1, &v50); + mat4_inverse_transform_vector(a3, a1, &v50); v50.x = 0.0f; @@ -9407,7 +9407,7 @@ LABEL_55: goto LABEL_66; LABEL_66: - mat4_mult_vec3(a3, &v50, a1); + mat4_transform_vector(a3, &v50, a1); *a8 = v50; } @@ -9444,7 +9444,7 @@ static void sub_1403FA770(rob_chara_sleeve_adjust* a1) { } else { a1->field_5C *= v25 / v21; - mat4_mult_vec3(v4, &a1->field_5C, &v45); + mat4_transform_vector(v4, &a1->field_5C, &v45); v17 = true; } } @@ -9461,7 +9461,7 @@ static void sub_1403FA770(rob_chara_sleeve_adjust* a1) { } else { a1->field_68 *= v31 / v22; - mat4_mult_vec3(v5, &a1->field_68, &v44); + mat4_transform_vector(v5, &a1->field_68, &v44); v18 = true; } } @@ -9541,7 +9541,7 @@ static void sub_1403F9B20(rob_chara_sleeve_adjust* a1, motion_bone_index motion_ vec3 v40; mat4* v23 = v15[MOTION_BONE_KL_MUNE_B_WJ].node->mat; - mat4_mult_vec3_trans(v23, &sleeve_mune_ofs, &v40); + mat4_transform_point(v23, &sleeve_mune_ofs, &v40); vec3 v41 = v37 - v40; @@ -9556,7 +9556,7 @@ static void sub_1403F9B20(rob_chara_sleeve_adjust* a1, motion_bone_index motion_ return; } *v6 *= v32 / v31; - mat4_mult_vec3(v19, v6, &v41); + mat4_transform_vector(v19, v6, &v41); } mat4* v42 = v15[motion_bone_index].node[2].mat; @@ -9593,14 +9593,14 @@ static bool rob_chara_hands_adjust(rob_chara* rob_chr) { static float_t sub_140406E90(bone_data* a1, bone_data* a2, float_t a3, vec3* a4) { vec3 v18 = 0.0f; - mat4_mult_vec3_trans(a1->node[3].mat, &v18, &v18); + mat4_transform_point(a1->node[3].mat, &v18, &v18); *a4 = v18; vec3 v17; v17.x = 0.01f; v17.y = -0.05f; v17.z = 0.0f; - mat4_mult_vec3_trans(a2->node[0].mat, &v18, &v17); + mat4_transform_point(a2->node[0].mat, &v18, &v17); if (v18.y - a3 <= v17.y) return v18.y - a3; @@ -10604,11 +10604,11 @@ static void sub_14040FBF0(motion_blend_mot* a1, float_t a2) { mat4 rot_mat = b_n_hara_cp->rot_mat[0]; mat4 mat = b_kg_hara_y->rot_mat[0]; - mat4_mult(&mat, &rot_mat, &rot_mat); + mat4_mul(&mat, &rot_mat, &rot_mat); mat = b_kl_hara_xz->rot_mat[0]; - mat4_mult(&mat, &rot_mat, &rot_mat); + mat4_mul(&mat, &rot_mat, &rot_mat); mat = b_kl_hara_etc->rot_mat[0]; - mat4_mult(&mat, &rot_mat, &rot_mat); + mat4_mul(&mat, &rot_mat, &rot_mat); b_n_hara_cp->rot_mat[0] = rot_mat; b_kg_hara_y->rot_mat[0] = mat4_identity; b_kl_hara_xz->rot_mat[0] = mat4_identity; @@ -11067,7 +11067,7 @@ static void rob_chara_age_age_ctrl(rob_chara* rob_chr, int32_t part_id, const ch if (vec3::length(rob_chr->data.adjust_data.pos_adjust) > 0.000001f) { mat4 temp; mat4_translate(&rob_chr->data.adjust_data.pos_adjust, &temp); - mat4_mult(&mat, &temp, &mat); + mat4_mul(&mat, &temp, &mat); } rob_chara_age_age_array_ctrl(rob_chr->chara_id, part_id, mat); } @@ -11496,8 +11496,8 @@ bone_node_expression_data::bone_node_expression_data() { void bone_node_expression_data::mat_set(vec3& parent_scale, mat4& ex_data_mat, mat4& mat) { vec3 position = this->position * parent_scale; - mat4_translate_mult(&ex_data_mat, &position, &ex_data_mat); - mat4_rotate_zyx_mult(&ex_data_mat, &rotation, &ex_data_mat); + mat4_mul_translate(&ex_data_mat, &position, &ex_data_mat); + mat4_mul_rotate_zyx(&ex_data_mat, &rotation, &ex_data_mat); this->parent_scale = scale * parent_scale; mat = ex_data_mat; mat4_scale_rot(&mat, &this->parent_scale, &mat); @@ -11860,12 +11860,12 @@ void MotionBlendCross::Field_20(std::vector* bones_curr, std::vector< bone_data& n_hara_curr = (*bones_curr)[MOTION_BONE_N_HARA]; bone_data& n_hara_cp_prev = (*bones_prev)[MOTION_BONE_N_HARA_CP]; bone_data& n_hara_prev = (*bones_prev)[MOTION_BONE_N_HARA]; - mat4_mult(&n_hara_curr.rot_mat[0], &n_hara_cp_curr.rot_mat[0], &field_64); - mat4_mult(&n_hara_cp_prev.rot_mat[0], &rot_y_mat, &field_A4); + mat4_mul(&n_hara_curr.rot_mat[0], &n_hara_cp_curr.rot_mat[0], &field_64); + mat4_mul(&n_hara_cp_prev.rot_mat[0], &rot_y_mat, &field_A4); mat4_blend_rotation(&field_A4, &n_hara_cp_curr.rot_mat[0], &n_hara_cp_curr.rot_mat[0], blend); - mat4_mult(&n_hara_prev.rot_mat[0], &field_A4, &field_A4); + mat4_mul(&n_hara_prev.rot_mat[0], &field_A4, &field_A4); mat4_blend_rotation(&n_hara_prev.rot_mat[0], &n_hara_curr.rot_mat[0], &n_hara_curr.rot_mat[0], blend); - mat4_mult(&n_hara_curr.rot_mat[0], &n_hara_cp_curr.rot_mat[0], &field_E4); + mat4_mul(&n_hara_curr.rot_mat[0], &n_hara_cp_curr.rot_mat[0], &field_E4); mat4_transpose(&field_E4, &field_E4); } @@ -11881,10 +11881,10 @@ void MotionBlendCross::Blend(bone_data* curr, bone_data* prev) { case BONE_DATABASE_BONE_ROTATION: default: if (curr->motion_bone_index == MOTION_BONE_KL_KOSI_Y) { - mat4_mult(&prev->rot_mat[0], &field_A4, &prev_mat); - mat4_mult(&curr->rot_mat[0], &field_64, &mat); + mat4_mul(&prev->rot_mat[0], &field_A4, &prev_mat); + mat4_mul(&curr->rot_mat[0], &field_64, &mat); mat4_blend_rotation(&prev_mat, &mat, &mat, blend); - mat4_mult(&mat, &field_E4, &curr->rot_mat[0]); + mat4_mul(&mat, &field_E4, &curr->rot_mat[0]); } else if (curr->motion_bone_index < 0 || curr->motion_bone_index > MOTION_BONE_N_HARA) mat4_blend_rotation(&prev->rot_mat[0], &curr->rot_mat[0], &curr->rot_mat[0], blend); @@ -11903,29 +11903,29 @@ void MotionBlendCross::Blend(bone_data* curr, bone_data* prev) { break; case BONE_DATABASE_BONE_HEAD_IK_ROTATION: if (curr->motion_bone_index == MOTION_BONE_CL_MUNE) { - mat4_mult(&prev->rot_mat[0], &field_A4, &prev_mat); - mat4_mult(&prev->rot_mat[1], &prev_mat, &prev_mat); - mat4_mult(&curr->rot_mat[0], &field_64, &mat); - mat4_mult(&curr->rot_mat[1], &mat, &mat); + mat4_mul(&prev->rot_mat[0], &field_A4, &prev_mat); + mat4_mul(&prev->rot_mat[1], &prev_mat, &prev_mat); + mat4_mul(&curr->rot_mat[0], &field_64, &mat); + mat4_mul(&curr->rot_mat[1], &mat, &mat); mat4_blend_rotation(&prev_mat, &mat, &mat, blend); - mat4_mult(&mat, &field_E4, &mat); + mat4_mul(&mat, &field_E4, &mat); } else { - mat4_mult(&prev->rot_mat[1], &prev->rot_mat[0], &prev_mat); - mat4_mult(&curr->rot_mat[1], &curr->rot_mat[0], &mat); + mat4_mul(&prev->rot_mat[1], &prev->rot_mat[0], &prev_mat); + mat4_mul(&curr->rot_mat[1], &curr->rot_mat[0], &mat); mat4_blend_rotation(&prev_mat, &mat, &mat, blend); } mat4_transpose(&curr->rot_mat[0], &ik_mat); - mat4_mult(&mat, &ik_mat, &curr->rot_mat[1]); + mat4_mul(&mat, &ik_mat, &curr->rot_mat[1]); break; case BONE_DATABASE_BONE_ARM_IK_ROTATION: case BONE_DATABASE_BONE_LEGS_IK_ROTATION: mat4_blend_rotation(&prev->rot_mat[2], &curr->rot_mat[2], &curr->rot_mat[2], blend); - mat4_mult(&prev->rot_mat[1], &prev->rot_mat[0], &prev_mat); - mat4_mult(&curr->rot_mat[1], &curr->rot_mat[0], &mat); + mat4_mul(&prev->rot_mat[1], &prev->rot_mat[0], &prev_mat); + mat4_mul(&curr->rot_mat[1], &curr->rot_mat[0], &mat); mat4_blend_rotation(&prev_mat, &mat, &mat, blend); mat4_transpose(&curr->rot_mat[0], &ik_mat); - mat4_mult(&mat, &ik_mat, &curr->rot_mat[1]); + mat4_mul(&mat, &ik_mat, &curr->rot_mat[1]); break; } } @@ -12037,12 +12037,12 @@ void MotionBlendFreeze::Field_20(std::vector* bones_curr, std::vector bone_data& n_hara_cp = (*bones_curr)[MOTION_BONE_N_HARA_CP]; bone_data& n_hara = (*bones_curr)[MOTION_BONE_N_HARA]; - mat4_mult(&n_hara.rot_mat[0], &n_hara_cp.rot_mat[0], &field_74); - mat4_mult(&n_hara_cp.rot_mat_prev[0][field_24], &rot_y_mat, &field_B4); + mat4_mul(&n_hara.rot_mat[0], &n_hara_cp.rot_mat[0], &field_74); + mat4_mul(&n_hara_cp.rot_mat_prev[0][field_24], &rot_y_mat, &field_B4); mat4_blend_rotation(&field_B4, &n_hara_cp.rot_mat[0], &n_hara_cp.rot_mat[0], blend); - mat4_mult(&n_hara.rot_mat_prev[0][field_24], &field_B4, &field_B4); + mat4_mul(&n_hara.rot_mat_prev[0][field_24], &field_B4, &field_B4); mat4_blend_rotation(&n_hara.rot_mat_prev[0][field_24], &n_hara.rot_mat[0], &n_hara.rot_mat[0], blend); - mat4_mult(&n_hara.rot_mat[0], &n_hara_cp.rot_mat[0], &field_F4); + mat4_mul(&n_hara.rot_mat[0], &n_hara_cp.rot_mat[0], &field_F4); mat4_transpose(&field_F4, &field_F4); } @@ -12058,10 +12058,10 @@ void MotionBlendFreeze::Blend(bone_data* curr, bone_data* prev) { case BONE_DATABASE_BONE_ROTATION: default: if (curr->motion_bone_index == MOTION_BONE_KL_KOSI_Y) { - mat4_mult(&curr->rot_mat_prev[0][field_24], &field_B4, &prev_mat); - mat4_mult(&curr->rot_mat[0], &field_74, &mat); + mat4_mul(&curr->rot_mat_prev[0][field_24], &field_B4, &prev_mat); + mat4_mul(&curr->rot_mat[0], &field_74, &mat); mat4_blend_rotation(&prev_mat, &mat, &mat, blend); - mat4_mult(&mat, &field_F4, &curr->rot_mat[0]); + mat4_mul(&mat, &field_F4, &curr->rot_mat[0]); } else if (curr->motion_bone_index < 0 || curr->motion_bone_index > MOTION_BONE_N_HARA) mat4_blend_rotation(&curr->rot_mat_prev[0][field_24], &curr->rot_mat[0], &curr->rot_mat[0], blend); @@ -12080,29 +12080,29 @@ void MotionBlendFreeze::Blend(bone_data* curr, bone_data* prev) { break; case BONE_DATABASE_BONE_HEAD_IK_ROTATION: if (curr->motion_bone_index == MOTION_BONE_CL_MUNE) { - mat4_mult(&curr->rot_mat_prev[0][field_24], &field_B4, &prev_mat); - mat4_mult(&curr->rot_mat_prev[1][field_24], &prev_mat, &prev_mat); - mat4_mult(&curr->rot_mat[0], &field_74, &mat); - mat4_mult(&curr->rot_mat[1], &mat, &mat); + mat4_mul(&curr->rot_mat_prev[0][field_24], &field_B4, &prev_mat); + mat4_mul(&curr->rot_mat_prev[1][field_24], &prev_mat, &prev_mat); + mat4_mul(&curr->rot_mat[0], &field_74, &mat); + mat4_mul(&curr->rot_mat[1], &mat, &mat); mat4_blend_rotation(&prev_mat, &mat, &mat, blend); - mat4_mult(&mat, &field_F4, &mat); + mat4_mul(&mat, &field_F4, &mat); } else { - mat4_mult(&curr->rot_mat_prev[1][field_24], &curr->rot_mat_prev[0][field_24], &prev_mat); - mat4_mult( &curr->rot_mat[1], &curr->rot_mat[0], &mat); + mat4_mul(&curr->rot_mat_prev[1][field_24], &curr->rot_mat_prev[0][field_24], &prev_mat); + mat4_mul( &curr->rot_mat[1], &curr->rot_mat[0], &mat); mat4_blend_rotation(&prev_mat, &mat, &mat, blend); } mat4_transpose(&curr->rot_mat[0], &ik_mat); - mat4_mult(&mat, &ik_mat, &curr->rot_mat[1]); + mat4_mul(&mat, &ik_mat, &curr->rot_mat[1]); break; case BONE_DATABASE_BONE_ARM_IK_ROTATION: case BONE_DATABASE_BONE_LEGS_IK_ROTATION: mat4_blend_rotation(&curr->rot_mat_prev[2][field_24], &curr->rot_mat[2], &curr->rot_mat[2], blend); - mat4_mult(&curr->rot_mat_prev[1][field_24], &curr->rot_mat_prev[0][field_24], &prev_mat); - mat4_mult(&curr->rot_mat[1], &curr->rot_mat[0], &mat); + mat4_mul(&curr->rot_mat_prev[1][field_24], &curr->rot_mat_prev[0][field_24], &prev_mat); + mat4_mul(&curr->rot_mat[1], &curr->rot_mat[0], &mat); mat4_blend_rotation(&prev_mat, &mat, &mat, blend); mat4_transpose(&curr->rot_mat[0], &ik_mat); - mat4_mult(&mat, &ik_mat, &curr->rot_mat[1]); + mat4_mul(&mat, &ik_mat, &curr->rot_mat[1]); break; } } @@ -12164,11 +12164,11 @@ void PartialMotionBlendFreeze::Blend(bone_data* curr, bone_data* prev) { case BONE_DATABASE_BONE_LEGS_IK_ROTATION: mat4_lerp_rotation(&curr->rot_mat_prev[2][0], &curr->rot_mat[2], &curr->rot_mat[2], blend); case BONE_DATABASE_BONE_HEAD_IK_ROTATION: { - mat4_mult(&curr->rot_mat_prev[1][0], &curr->rot_mat_prev[0][0], &prev_mat); - mat4_mult(&curr->rot_mat[1], &curr->rot_mat[0], &mat); + mat4_mul(&curr->rot_mat_prev[1][0], &curr->rot_mat_prev[0][0], &prev_mat); + mat4_mul(&curr->rot_mat[1], &curr->rot_mat[0], &mat); mat4_lerp_rotation(&prev_mat, &mat, &mat, blend); mat4_transpose(&curr->rot_mat[0], &ik_mat); - mat4_mult(&mat, &ik_mat, &curr->rot_mat[1]); + mat4_mul(&mat, &ik_mat, &curr->rot_mat[1]); } break; } } @@ -13472,12 +13472,12 @@ static void sub_140512C20(rob_chara_item_equip* rob_itm_equip, render_context* r if (rob_itm_equip->field_DC == 1) { name = "kl_te_r_wj"; mat4_translate(0.0f, 0.0f, 0.082f, &mat); - mat4_rotate_zyx_mult(&mat, (float_t)(-90.9 * DEG_TO_RAD), 0.0f, (float_t)(-179.5 * DEG_TO_RAD), &mat); + mat4_mul_rotate_zyx(&mat, (float_t)(-90.9 * DEG_TO_RAD), 0.0f, (float_t)(-179.5 * DEG_TO_RAD), &mat); } if (rob_itm_equip->field_DC == 2) { name = "kl_te_l_wj"; mat4_translate(0.0f, 0.0015f, -0.0812f, &mat); - mat4_rotate_zyx_mult(&mat, (float_t)(-34.5 * DEG_TO_RAD), 0.0f, (float_t)(-179.5 * DEG_TO_RAD), &mat); + mat4_mul_rotate_zyx(&mat, (float_t)(-34.5 * DEG_TO_RAD), 0.0f, (float_t)(-179.5 * DEG_TO_RAD), &mat); } else name = "j_1_hyoutan_000wj"; @@ -13489,7 +13489,7 @@ static void sub_140512C20(rob_chara_item_equip* rob_itm_equip, render_context* r if (!node || !node->mat) return; - mat4_mult(&mat, node->mat, &mat); + mat4_mul(&mat, node->mat, &mat); int32_t tex_pat_count = (int32_t)rob_itm_equip->texture_pattern.size(); if (tex_pat_count) rctx->disp_manager.set_texture_pattern(tex_pat_count, rob_itm_equip->texture_pattern.data()); @@ -15263,7 +15263,7 @@ void pos_scale::get_screen_pos_scale(mat4& mat, vec3& trans, bool apply_offset) vec4 v15; *(vec3*)&v15 = trans; v15.w = 1.0f; - mat4_mult_vec(&mat, &v15, &v15); + mat4_transform_vector(&mat, &v15, &v15); if (fabsf(v15.w) >= 1.0e-10f) { post_process* pp = &rctx_ptr->post_process; @@ -17306,9 +17306,9 @@ void rob_chara_age_age_object::calc_vertex(rob_chara_age_age_object_vertex*& vtx obj_vertex_data* obj_vtx = vertex_array; rob_chara_age_age_object_vertex* vtx = vtx_data; for (uint32_t i = num_vertex; i; i--, obj_vtx++, vtx++) { - mat4_mult_vec3_trans(&mat, &obj_vtx->position, &vtx->position); - mat4_mult_vec3(&mat, &obj_vtx->normal, &vtx->normal); - mat4_mult_vec3(&mat, (vec3*)&obj_vtx->tangent, (vec3*)&vtx->tangent); + mat4_transform_point(&mat, &obj_vtx->position, &vtx->position); + mat4_transform_vector(&mat, &obj_vtx->normal, &vtx->normal); + mat4_transform_vector(&mat, (vec3*)&obj_vtx->tangent, (vec3*)&vtx->tangent); vtx->tangent.w = obj_vtx->tangent.w; vtx->texcoord.x = obj_vtx->texcoord0.x + alpha_1; vtx->texcoord.y = obj_vtx->texcoord0.y; @@ -17715,9 +17715,9 @@ void rob_chara_age_age::ctrl_data(rob_chara_age_age_data* data, mat4& mat) { data->rot_z = data->part_id == 1 ? -0.1f : 0.1f; data->field_1C = 0; data->rot_speed = init_data->rot_speed; - mat4_translate_mult(&data->mat, &init_data->trans, &data->mat); - mat4_rotate_x_mult(&data->mat, init_data->rot_x, &data->mat); - mat4_translate_mult(&data->mat, 0.0f, 0.0f, init_data->offset, &data->mat); + mat4_mul_translate(&data->mat, &init_data->trans, &data->mat); + mat4_mul_rotate_x(&data->mat, init_data->rot_x, &data->mat); + mat4_mul_translate(&data->mat, 0.0f, 0.0f, init_data->offset, &data->mat); data->scale = init_data->scale; mat4_scale_rot(&data->mat, data->scale, &data->mat_scale); data->alive = true; @@ -17735,12 +17735,12 @@ void rob_chara_age_age::ctrl_data(rob_chara_age_age_data* data, mat4& mat) { data->trans.z -= (90.0f - data->remaining) * 0.000011f * step * rot_speed; mat4 m; - mat4_translate_mult(&mat, &init_data->trans, &m); - mat4_rotate_x_mult(&m, init_data->rot_x, &m); - mat4_translate_mult(&m, 0.0f, 0.0f, init_data->offset, &m); - mat4_rotate_y_mult(&m, init_data->rot_y, &m); - mat4_translate_mult(&m, &data->trans, &m); - mat4_rotate_z_mult(&m, data->rot_z, &m); + mat4_mul_translate(&mat, &init_data->trans, &m); + mat4_mul_rotate_x(&m, init_data->rot_x, &m); + mat4_mul_translate(&m, 0.0f, 0.0f, init_data->offset, &m); + mat4_mul_rotate_y(&m, init_data->rot_y, &m); + mat4_mul_translate(&m, &data->trans, &m); + mat4_mul_rotate_z(&m, data->rot_z, &m); mat4_scale_rot(&m, data->scale, &m); vec3 v43; diff --git a/src/CRE/sprite.cpp b/src/CRE/sprite.cpp index 82dff27e..e6cec044 100644 --- a/src/CRE/sprite.cpp +++ b/src/CRE/sprite.cpp @@ -308,7 +308,7 @@ namespace spr { vec2 proj_sprite_3d_line(vec3 vec, bool offset) { camera* cam = rctx_ptr->camera; - mat4_mult_vec3_trans(&cam->view, &vec, &vec); + mat4_transform_point(&cam->view, &vec, &vec); if (fabsf(vec.z) < 1.0e-10f) return 0.0f; @@ -331,20 +331,20 @@ namespace spr { void put_cross(const mat4& mat, color4u8 color_x, color4u8 color_y, color4u8 color_z) { vec3 v5 = { 0.0f, 0.0f, 0.0f }; vec3 v6; - mat4_mult_vec3_trans(&mat, &v5, &v6); + mat4_transform_point(&mat, &v5, &v6); vec3 v7 = v6; v5 = { 1.0f, 0.0f, 0.0f }; - mat4_mult_vec3_trans(&mat, &v5, &v6); + mat4_transform_point(&mat, &v5, &v6); put_sprite_3d_line(v7, v6, color_x); v5 = { 0.0f, 1.0f, 0.0f }; - mat4_mult_vec3_trans(&mat, &v5, &v6); + mat4_transform_point(&mat, &v5, &v6); put_sprite_3d_line(v7, v6, color_y); v5 = { 0.0f, 0.0f, 1.0f }; - mat4_mult_vec3_trans(&mat, &v5, &v6); + mat4_transform_point(&mat, &v5, &v6); put_sprite_3d_line(v7, v6, color_z); } @@ -855,7 +855,7 @@ namespace spr { mat4 view; mat4_look_at(&eye, &target, &up, &view); - mat4_mult(&view, &proj, &view_projection); + mat4_mul(&view, &proj, &view_projection); vec2 min; vec2 max; @@ -1238,26 +1238,26 @@ namespace spr { mat4_translate(&args->trans, &m); if (fabsf(args->rot.x) > 0.000001f) - mat4_rotate_x_mult(&m, args->rot.x, &m); + mat4_mul_rotate_x(&m, args->rot.x, &m); if (fabsf(args->rot.y) > 0.000001f) - mat4_rotate_y_mult(&m, args->rot.y, &m); + mat4_mul_rotate_y(&m, args->rot.y, &m); if (fabsf(args->rot.z) > 0.000001f) - mat4_rotate_z_mult(&m, args->rot.z, &m); + mat4_mul_rotate_z(&m, args->rot.z, &m); mat4_scale_rot(&m, &args->scale, &m); const vec3 center = -args->center; - mat4_translate_mult(&m, ¢er, &m); + mat4_mul_translate(&m, ¢er, &m); } else { mat4_translate(&args->trans, &m); mat4_scale_rot(&m, &args->scale, &m); } - mat4_mult(&args->mat, &m, &m); + mat4_mul(&args->mat, &m, &m); - mat4_mult_vec3_trans(&m, &vtx[0], &vtx[0]); - mat4_mult_vec3_trans(&m, &vtx[1], &vtx[1]); - mat4_mult_vec3_trans(&m, &vtx[2], &vtx[2]); - mat4_mult_vec3_trans(&m, &vtx[3], &vtx[3]); + mat4_transform_point(&m, &vtx[0], &vtx[0]); + mat4_transform_point(&m, &vtx[1], &vtx[1]); + mat4_transform_point(&m, &vtx[2], &vtx[2]); + mat4_transform_point(&m, &vtx[3], &vtx[3]); if (mat) *mat = m; @@ -1285,10 +1285,10 @@ namespace spr { mat4 mat; calc_sprite_vertex(args, v42, &mat, font); mat4_inverse(&mat, &mat); - mat4_mult_vec3_trans(&mat, &vtx[0], &v42[0]); - mat4_mult_vec3_trans(&mat, &vtx[1], &v42[1]); - mat4_mult_vec3_trans(&mat, &vtx[2], &v42[2]); - mat4_mult_vec3_trans(&mat, &vtx[3], &v42[3]); + mat4_transform_point(&mat, &vtx[0], &v42[0]); + mat4_transform_point(&mat, &vtx[1], &v42[1]); + mat4_transform_point(&mat, &vtx[2], &v42[2]); + mat4_transform_point(&mat, &vtx[3], &v42[3]); uv00 = *(vec2*)&v42[0].x; uv01 = *(vec2*)&v42[1].x; uv10 = *(vec2*)&v42[2].x; diff --git a/src/CRE/stage.cpp b/src/CRE/stage.cpp index a2a0cf11..fa173274 100644 --- a/src/CRE/stage.cpp +++ b/src/CRE/stage.cpp @@ -430,8 +430,8 @@ static void stage_detail::TaskStage_Unload(stage_detail::TaskStage* a1) { static bool object_bounding_sphere_check_visibility_shadow(obj_bounding_sphere* sphere, mat4* view, mat4* mat) { vec3 center; - mat4_mult_vec3_trans(mat, &sphere->center, ¢er); - mat4_mult_vec3_trans(view, ¢er, ¢er); + mat4_transform_point(mat, &sphere->center, ¢er); + mat4_transform_point(view, ¢er, ¢er); float_t radius = sphere->radius; Shadow* shad = rctx_ptr->render_manager.shadow_ptr; @@ -501,7 +501,7 @@ static void stage_disp(stage* s) { if (s->stage_data->object_sky.not_null() && s->sky) { mat4 t = s->mat; - mat4_mult(&t, &mat, &t); + mat4_mul(&t, &mat, &t); disp_manager.entry_obj_by_object_info(&t, s->stage_data->object_sky); } diff --git a/src/CRE/stage_modern.cpp b/src/CRE/stage_modern.cpp index 22a9515d..650e1bd8 100644 --- a/src/CRE/stage_modern.cpp +++ b/src/CRE/stage_modern.cpp @@ -446,8 +446,8 @@ static void stage_detail::TaskStageModern_Unload(stage_detail::TaskStageModern* static bool object_bounding_sphere_check_visibility_shadow(obj_bounding_sphere* sphere, mat4* view, mat4* mat) { vec3 center; - mat4_mult_vec3_trans(mat, &sphere->center, ¢er); - mat4_mult_vec3_trans(view, ¢er, ¢er); + mat4_transform_point(mat, &sphere->center, ¢er); + mat4_transform_point(view, ¢er, ¢er); float_t radius = sphere->radius; Shadow* shad = rctx_ptr->render_manager.shadow_ptr; @@ -514,7 +514,7 @@ static void stage_modern_disp(stage_modern* s) { if (s->stage_data->object_sky.not_null_modern() && s->sky) { mat4 t = s->mat; - mat4_mult(&t, &mat, &t); + mat4_mul(&t, &mat, &t); disp_manager.entry_obj_by_object_info(&t, s->stage_data->object_sky); } } diff --git a/src/CRE/task_effect.cpp b/src/CRE/task_effect.cpp index 069b2133..87dfbb3b 100644 --- a/src/CRE/task_effect.cpp +++ b/src/CRE/task_effect.cpp @@ -626,9 +626,9 @@ bool TaskEffectAuth3D::Ctrl() { mat4 mat; mat4_translate(0.0f, -0.2f, 0.0f, &mat); - mat4_rotate_x_mult(&mat, sinf((float_t)((double_t)((float_t)(frame_int % 512) + mat4_mul_rotate_x(&mat, sinf((float_t)((double_t)((float_t)(frame_int % 512) * (float_t)(2.0 / 512.0)) * M_PI)) * 0.015f, &mat); - mat4_rotate_z_mult(&mat, sinf((float_t)((double_t)((float_t)(frame_int % 360) + mat4_mul_rotate_z(&mat, sinf((float_t)((double_t)((float_t)(frame_int % 360) * (float_t)(2.0 / 360.0)) * M_PI)) * 0.015f, &mat); task_stage_set_mat(mat); } @@ -3483,7 +3483,7 @@ void star_catalog_milky_way::draw(const mat4& vp, const mat4& mat, texture* tex, mat4_rotate_y(longitude * DEG_TO_RAD_FLOAT, &longitude_mat); mat4 model; - mat4_mult(&latitude_mat, &longitude_mat, &model); + mat4_mul(&latitude_mat, &longitude_mat, &model); const float_t pitch_forward = -0.50503153f; const float_t yaw_forward = 4.6496463f; @@ -3504,12 +3504,12 @@ void star_catalog_milky_way::draw(const mat4& vp, const mat4& mat, texture* tex, *(vec3*)&view.row1 = up; *(vec3*)&view.row2 = forward; - mat4_mult(&model, &view, &model); - mat4_mult(&model, &mat, &model); + mat4_mul(&model, &view, &model); + mat4_mul(&model, &mat, &model); star_catalog_scene_shader_data scene_shader_data = {}; mat4 temp; - mat4_mult(&model, &vp, &temp); + mat4_mul(&model, &vp, &temp); mat4_transpose(&temp, &temp); scene_shader_data.g_transform[0] = temp.row0; scene_shader_data.g_transform[1] = temp.row1; @@ -3599,7 +3599,7 @@ void star_catalog::draw() { proj.row3.z = proj.row3.w; mat4 vp; - mat4_mult(&rctx_ptr->view_mat, &proj, &vp); + mat4_mul(&rctx_ptr->view_mat, &proj, &vp); texture* milky_way_tex = texture_storage_get_texture(milky_way_tex_id); if (milky_way_tex) @@ -3610,7 +3610,7 @@ void star_catalog::draw() { star_catalog_scene_shader_data scene_shader_data = {}; mat4 temp; - mat4_mult(&model, &vp, &temp); + mat4_mul(&model, &vp, &temp); mat4_transpose(&temp, &temp); scene_shader_data.g_transform[0] = temp.row0; scene_shader_data.g_transform[1] = temp.row1; @@ -4342,19 +4342,19 @@ static int32_t leaf_particle_disp() { vec3 t1; vec3 t2; vec3 t3; - mat3_mult_vec(&mat, &position[0], &t0); - mat3_mult_vec(&mat, &position[1], &t1); - mat3_mult_vec(&mat, &position[2], &t2); - mat3_mult_vec(&mat, &position[3], &t3); + mat3_transform_vector(&mat, &position[0], &t0); + mat3_transform_vector(&mat, &position[1], &t1); + mat3_transform_vector(&mat, &position[2], &t2); + mat3_transform_vector(&mat, &position[3], &t3); vtx_data[0].position = pos + t0; vtx_data[1].position = pos + t1; vtx_data[2].position = pos + t2; vtx_data[3].position = pos + t3; - mat3_mult_vec(&mat, &normal[0], &t0); - mat3_mult_vec(&mat, &normal[1], &t1); - mat3_mult_vec(&mat, &normal[2], &t2); - mat3_mult_vec(&mat, &normal[3], &t3); + mat3_transform_vector(&mat, &normal[0], &t0); + mat3_transform_vector(&mat, &normal[1], &t1); + mat3_transform_vector(&mat, &normal[2], &t2); + mat3_transform_vector(&mat, &normal[3], &t3); vtx_data[0].normal = t0; vtx_data[1].normal = t1; vtx_data[2].normal = t2; @@ -4530,15 +4530,15 @@ static int32_t particle_disp(particle_vertex_data* vtx_data, particle_rot_data* vec3 t0 = vec3( 0.0125f, 0.007216875f, 0.0f) * size; vec3 t1 = vec3(-0.0125f, 0.007216875f, 0.0f) * size; vec3 t2 = vec3( 0.0f , -0.01443375f , 0.0f) * size; - mat3_mult_vec(&mat, &t0, &t0); - mat3_mult_vec(&mat, &t1, &t1); - mat3_mult_vec(&mat, &t2, &t2); + mat3_transform_vector(&mat, &t0, &t0); + mat3_transform_vector(&mat, &t1, &t1); + mat3_transform_vector(&mat, &t2, &t2); t0 += pos; t1 += pos; t2 += pos; vec3 normal = vec3(0.0f, 0.0f, 1.0f); - mat3_mult_vec(&mat, &normal, &normal); + mat3_transform_vector(&mat, &normal, &normal); data->normal = normal; vec4 color = data->color; diff --git a/src/DivaGL/bone_data.cpp b/src/DivaGL/bone_data.cpp index 8c393852..d84d1a17 100644 --- a/src/DivaGL/bone_data.cpp +++ b/src/DivaGL/bone_data.cpp @@ -218,8 +218,8 @@ static void rob_osage_apply_reset_data(rob_osage* rob_osg, mat4* mat) { mat4 temp; mat4_transpose(mat, &temp); for (rob_osage_node* v9 = rob_osg->nodes.begin + 1; v9 != rob_osg->nodes.end; v9++) { - mat4_mult_vec3(&temp, &v9->reset_data.trans_diff, &v9->trans_diff); - mat4_mult_vec3_trans(&temp, &v9->reset_data.trans, &v9->trans); + mat4_transform_vector(&temp, &v9->reset_data.trans_diff, &v9->trans_diff); + mat4_transform_point(&temp, &v9->reset_data.trans, &v9->trans); } rob_osg->parent_mat = *rob_osg->parent_mat_ptr; } @@ -227,14 +227,14 @@ static void rob_osage_apply_reset_data(rob_osage* rob_osg, mat4* mat) { static void sub_14047F110(rob_osage* rob_osg, mat4* mat, vec3* parent_scale, bool init_rot) { mat4_transpose(mat, mat); vec3 position = rob_osg->exp_data.position * *parent_scale; - mat4_translate_mult(mat, &position, mat); - mat4_rotate_zyx_mult(mat, &rob_osg->exp_data.rotation, mat); + mat4_mul_translate(mat, &position, mat); + mat4_mul_rotate_zyx(mat, &rob_osg->exp_data.rotation, mat); skin_param* skin_param = rob_osg->skin_param_ptr; vec3 rot = skin_param->rot; if (init_rot) rot = skin_param->init_rot + rot; - mat4_rotate_zyx_mult(mat, &rot, mat); + mat4_mul_rotate_zyx(mat, &rot, mat); mat4_transpose(mat, mat); } @@ -267,8 +267,8 @@ static bool sub_140482FF0(mat4* mat, vec3* trans, skin_param_hinge* hinge, vec3* clipped = true; } } - mat4_rotate_y_mult(mat, y_rot, mat); - mat4_rotate_z_mult(mat, z_rot, mat); + mat4_mul_rotate_y(mat, y_rot, mat); + mat4_mul_rotate_z(mat, z_rot, mat); } else { z_rot = atan2f(trans->y, trans->x); @@ -294,8 +294,8 @@ static bool sub_140482FF0(mat4* mat, vec3* trans, skin_param_hinge* hinge, vec3* clipped = true; } } - mat4_rotate_z_mult(mat, z_rot, mat); - mat4_rotate_y_mult(mat, y_rot, mat); + mat4_mul_rotate_z(mat, z_rot, mat); + mat4_mul_rotate_y(mat, y_rot, mat); } mat4_transpose(mat, mat); @@ -310,7 +310,7 @@ static void sub_1404803B0(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc mat4 v47 = *root_matrix; vec3 v45 = rob_osg->exp_data.position * *parent_scale; mat4_transpose(&v47, &v47); - mat4_mult_vec3_trans(&v47, &v45, &rob_osg->nodes.begin[0].trans); + mat4_transform_point(&v47, &v45, &rob_osg->nodes.begin[0].trans); if (rob_osg->osage_reset && !rob_osg->field_1F0E) { rob_osg->field_1F0E = true; @@ -331,9 +331,9 @@ static void sub_1404803B0(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc mat4 parent_mat; vec3 v44; mat4_transpose(&rob_osg->parent_mat, &parent_mat); - mat4_mult_vec3_inv_trans(&parent_mat, &v19->trans, &v44); + mat4_inverse_transform_point(&parent_mat, &v19->trans, &v44); mat4_transpose(rob_osg->parent_mat_ptr, &parent_mat); - mat4_mult_vec3_trans(&parent_mat, &v44, &v44); + mat4_transform_point(&parent_mat, &v44, &v44); v19->trans += (v44 - v19->trans) * move_cancel; } } @@ -349,7 +349,7 @@ static void sub_1404803B0(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc for (rob_osage_node* v29 = rob_osg->nodes.begin, *v30 = rob_osg->nodes.begin + 1; v30 != rob_osg->nodes.end; v29++, v30++) { vec3 v45; - mat4_mult_vec3_inv_trans(&v47, &v30->trans, &v45); + mat4_inverse_transform_point(&v47, &v30->trans, &v45); mat4_transpose(&v47, &v47); bool v32 = sub_140482FF0(&v47, &v45, &v30->data_ptr->skp_osg_node.hinge, &v30->reset_data.rotation, &rob_osg->yz_order); @@ -366,7 +366,7 @@ static void sub_1404803B0(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc else v36 = true; - mat4_translate_mult(&v47, v35, 0.0f, 0.0f, &v47); + mat4_mul_translate(&v47, v35, 0.0f, 0.0f, &v47); if (v32 || v36) mat4_get_translation(&v47, &v30->trans); } @@ -374,7 +374,7 @@ static void sub_1404803B0(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc if (vector_old_length(rob_osg->nodes) && rob_osg->node.bone_node_mat) { mat4 v48 = *rob_osg->nodes.end[-1].bone_node_ptr->ex_data_mat; mat4_transpose(&v48, &v48); - mat4_translate_mult(&v48, parent_scale->x * rob_osg->node.length, 0.0f, 0.0f, &v48); + mat4_mul_translate(&v48, parent_scale->x * rob_osg->node.length, 0.0f, 0.0f, &v48); mat4_transpose(&v48, &v48); *rob_osg->node.bone_node_ptr->ex_data_mat = v48; } @@ -455,7 +455,7 @@ static void sub_14047C800(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc mat4 v130 = *root_matrix; mat4_transpose(&v130, &v130); - mat4_mult_vec3_trans(&v130, &v113, &v17->trans); + mat4_transform_point(&v130, &v113, &v17->trans); v17->trans_diff = v17->trans - v17->trans_orig; mat4_transpose(&v130, &v130); @@ -466,7 +466,7 @@ static void sub_14047C800(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc v113 = { 1.0f, 0.0f, 0.0f }; vec3 v128; - mat4_mult_vec3(&v130, &v113, &v128); + mat4_transform_vector(&v130, &v113, &v128); float_t v25 = parent_scale->x; if (!rob_osg->osage_reset && step <= 0.0f) @@ -512,7 +512,7 @@ static void sub_14047C800(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc mat4_get_translation(&v131, &v111); for (rob_osage_node* v55 = rob_osg->nodes.begin + 1; v55 != v12; v55++) { - mat4_mult_vec3_trans(&v131, &v55->field_94, &v128); + mat4_transform_point(&v131, &v55->field_94, &v128); vec3 v126 = v55->trans + v55->trans_diff + v55->field_28; sub_140482F30(&v126, &v111, v25 * v55->length); @@ -525,13 +525,13 @@ static void sub_14047C800(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc v126 = v55->trans + v55->trans_diff + v55->field_28; vec3 v129; - mat4_mult_vec3_inv_trans(&v131, &v126, &v129); + mat4_inverse_transform_point(&v131, &v126, &v129); mat4_transpose(&v131, &v131); sub_140482FF0(&v131, &v129, 0, 0, &rob_osg->yz_order); mat4_transpose(&v131, &v131); - mat4_translate_mult(&v131, vec3::distance(v111, v126), 0.0f, 0.0f, &v131); + mat4_mul_translate(&v131, vec3::distance(v111, v126), 0.0f, 0.0f, &v131); v111 = v126; } @@ -569,7 +569,7 @@ static void sub_14047C800(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc for (rob_osage_node* v99 = rob_osg->nodes.begin + 1, *v100 = rob_osg->nodes.begin; v99 != v12; v99++, v100++) { vec3 v129; - mat4_mult_vec3_inv_trans(&v130, &v99->trans, &v129); + mat4_inverse_transform_point(&v130, &v99->trans, &v129); mat4_transpose(&v130, &v130); bool v102 = sub_140482FF0(&v130, &v129, &v99->data_ptr->skp_osg_node.hinge, @@ -588,7 +588,7 @@ static void sub_14047C800(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc else v106 = true; - mat4_translate_mult(&v130, v105, 0.0f, 0.0f, &v130); + mat4_mul_translate(&v130, v105, 0.0f, 0.0f, &v130); if (v102 || v106) mat4_get_translation(&v130, &v99->trans); } @@ -596,7 +596,7 @@ static void sub_14047C800(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc if (vector_old_length(rob_osg->nodes) && rob_osg->node.bone_node_mat) { mat4 v131 = *rob_osg->nodes.end[-1].bone_node_ptr->ex_data_mat; mat4_transpose(&v131, &v131); - mat4_translate_mult(&v131, v25 * rob_osg->node.length, 0.0f, 0.0f, &v131); + mat4_mul_translate(&v131, v25 * rob_osg->node.length, 0.0f, 0.0f, &v131); mat4_transpose(&v131, &v131); *rob_osg->node.bone_node_ptr->ex_data_mat = v131; } @@ -832,16 +832,16 @@ static void OsageCollision__Work__update_cls_work(OsageCollision__Work* cls, cls->radius = cls_param->radius; mat4 mat = transform[cls_param->node_idx[0]]; mat4_transpose(&mat, &mat); - mat4_mult_vec3_trans(&mat, &cls_param->pos[0], &cls->pos[0]); + mat4_transform_point(&mat, &cls_param->pos[0], &cls->pos[0]); switch (cls->type) { case SkinParam::CollisionTypePlane: - mat4_mult_vec3(&mat, &cls_param->pos[1], &cls->pos[1]); + mat4_transform_vector(&mat, &cls_param->pos[1], &cls->pos[1]); break; case SkinParam::CollisionTypeCapsule: case SkinParam::CollisionTypeEllipse: mat = transform[cls_param->node_idx[1]]; mat4_transpose(&mat, &mat); - mat4_mult_vec3_trans(&mat, &cls_param->pos[1], &cls->pos[1]); + mat4_transform_point(&mat, &cls_param->pos[1], &cls->pos[1]); cls->vec_center = cls->pos[1] - cls->pos[0]; cls->vec_center_length_squared = vec3::length_squared(cls->vec_center); cls->vec_center_length = sqrtf(cls->vec_center_length_squared); @@ -1078,7 +1078,7 @@ static void sub_14047D8C0(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc vec3 trans = rob_osg->exp_data.position * *parent_scale; mat4_transpose(&v64, &v64); - mat4_mult_vec3_trans(&v64, &trans, &rob_osg->nodes.begin[0].trans); + mat4_transform_point(&v64, &trans, &rob_osg->nodes.begin[0].trans); mat4_transpose(&v64, &v64); sub_14047F110(rob_osg, &v64, parent_scale, false); } @@ -1135,7 +1135,7 @@ static void sub_14047D8C0(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc sub_140482F30(&v35[0].trans, &v35[-1].trans, v35[0].length * parent_scale->x); vec3 v63; - mat4_mult_vec3_inv_trans(&v64, &v35->trans, &v63); + mat4_inverse_transform_point(&v64, &v35->trans, &v63); mat4_transpose(&v64, &v64); bool v40 = sub_140482FF0(&v64, &v63, &skp_osg_node->hinge, &v35->reset_data.rotation, &rob_osg->yz_order); @@ -1159,7 +1159,7 @@ static void sub_14047D8C0(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc else v45 = true; - mat4_translate_mult(&v64, v42, 0.0f, 0.0f, &v64); + mat4_mul_translate(&v64, v42, 0.0f, 0.0f, &v64); v35->reset_data.length = v42; if (v40 || v45) mat4_get_translation(&v64, &v35->trans); @@ -1178,14 +1178,14 @@ static void sub_14047D8C0(rob_osage* rob_osg, mat4* root_matrix, vec3* parent_sc mat4 v65; mat4_transpose(root_matrix, &v65); - mat4_mult_vec3_inv_trans(&v65, &v35->trans, &v35->reset_data.trans); - mat4_mult_vec3_inv(&v65, &v35->trans_diff, &v35->reset_data.trans_diff); + mat4_inverse_transform_point(&v65, &v35->trans, &v35->reset_data.trans); + mat4_inverse_transform_vector(&v65, &v35->trans_diff, &v35->reset_data.trans_diff); } if (vector_old_length(rob_osg->nodes) && rob_osg->node.bone_node_mat) { mat4 v65 = *rob_osg->nodes.end[-1].bone_node_ptr->ex_data_mat; mat4_transpose(&v65, &v65); - mat4_translate_mult(&v65, rob_osg->node.length * parent_scale->x, 0.0f, 0.0f, &v65); + mat4_mul_translate(&v65, rob_osg->node.length * parent_scale->x, 0.0f, 0.0f, &v65); mat4_transpose(&v65, &v65); *rob_osg->node.bone_node_ptr->ex_data_mat = v65; mat4_transpose(&v65, &v65); @@ -1361,7 +1361,7 @@ void rob_osage_set_osage_play_data(rob_osage* rob_osg, mat4* parent_mat, mat4 v85; mat4_transpose(parent_mat, &v85); - mat4_mult_vec3_trans(&v85, &v63, &rob_osg->nodes.begin[0].trans); + mat4_transform_point(&v85, &v63, &rob_osg->nodes.begin[0].trans); mat4_transpose(&v85, &v85); sub_14047F110(rob_osg, &v85, parent_scale, false); @@ -1407,13 +1407,13 @@ void rob_osage_set_osage_play_data(rob_osage* rob_osg, mat4* parent_mat, v77.y = opd_y[next_key]; v77.z = opd_z[next_key]; - mat4_mult_vec3_trans(parent_mat, &v62, &v62); - mat4_mult_vec3_trans(parent_mat, &v77, &v77); + mat4_transform_point(parent_mat, &v62, &v62); + mat4_transform_point(parent_mat, &v77, &v77); vec3 v82 = v62 * inv_blend + v77 * blend; vec3 v86; - mat4_mult_vec3_inv_trans(&v87, &v82, &v86); + mat4_inverse_transform_point(&v87, &v82, &v86); mat4_transpose(&v87, &v87); vec3 v64 = 0.0f; @@ -1437,8 +1437,8 @@ void rob_osage_set_osage_play_data(rob_osage* rob_osg, mat4* parent_mat, float_t v55 = i->field_1B0.field_0.angle.z; v54 = clamp_def(v54, (float_t)-M_PI, (float_t)M_PI); v55 = clamp_def(v55, (float_t)-M_PI, (float_t)M_PI); - mat4_rotate_z_mult(&v85, v55, &v85); - mat4_rotate_y_mult(&v85, v54, &v85); + mat4_mul_rotate_z(&v85, v55, &v85); + mat4_mul_rotate_y(&v85, v54, &v85); mat4_transpose(&v85, &v85); i->bone_node_ptr->exp_data.parent_scale = *parent_scale; *i->bone_node_ptr->ex_data_mat = v85; @@ -1448,7 +1448,7 @@ void rob_osage_set_osage_play_data(rob_osage* rob_osg, mat4* parent_mat, mat4_scale_rot(&mat, parent_scale, &mat); mat4_transpose(&mat, i->bone_node_mat); } - mat4_translate_mult(&v85, i->field_1B0.field_0.length, 0.0f, 0.0f, &v85); + mat4_mul_translate(&v85, i->field_1B0.field_0.length, 0.0f, 0.0f, &v85); i->trans_orig = i->trans; mat4_get_translation(&v85, &i->trans); } @@ -1456,7 +1456,7 @@ void rob_osage_set_osage_play_data(rob_osage* rob_osg, mat4* parent_mat, if (vector_old_length(rob_osg->nodes) && rob_osg->node.bone_node_mat) { mat4 v87 = *rob_osg->nodes.end[-1].bone_node_ptr->ex_data_mat; mat4_transpose(&v87, &v87); - mat4_translate_mult(&v87, rob_osg->node.length * parent_scale->x, 0.0f, 0.0f, &v87); + mat4_mul_translate(&v87, rob_osg->node.length * parent_scale->x, 0.0f, 0.0f, &v87); mat4_transpose(&v87, &v87); *rob_osg->node.bone_node_ptr->ex_data_mat = v87; @@ -1578,7 +1578,7 @@ static void sub_14053CE30(rob_osage_node_data_normal_ref* normal_ref, mat4* a2) mat4 v33 = normal_ref->mat; mat4_transpose(&v33, &v33); - mat4_mult(&v33, &v34, a2); + mat4_mul(&v33, &v34, a2); mat4_transpose(a2, a2); } } diff --git a/src/DivaGL/shader_table.cpp b/src/DivaGL/shader_table.cpp index c375da9d..3b31fc11 100644 --- a/src/DivaGL/shader_table.cpp +++ b/src/DivaGL/shader_table.cpp @@ -144,11 +144,11 @@ void FASTCALL shader_bind_membrane(shader* shad) { uint32_t(FASTCALL * sub_140192E00)() = (uint32_t(*)())0x0000000140192E00; uint32_t v1 = sub_140192E00(); mat4 mat = mat4_identity; - mat4_rotate_x_mult(&mat, (float_t)((v1 & 0x1FF) * (M_PI / 256.0)), &mat); - mat4_rotate_z_mult(&mat, (float_t)((v1 % 0x168) * (M_PI / 180.0)), &mat); + mat4_mul_rotate_x(&mat, (float_t)((v1 & 0x1FF) * (M_PI / 256.0)), &mat); + mat4_mul_rotate_z(&mat, (float_t)((v1 % 0x168) * (M_PI / 180.0)), &mat); vec4 vec = { 1.0f, 0.0f, 0.0f, 0.0f }; - mat4_mult_vec(&mat, &vec, &vec); + mat4_transform_vector(&mat, &vec, &vec); PFNGLPROGRAMLOCALPARAMETER4FARBPROC _glProgramLocalParameter4fARB = *(PFNGLPROGRAMLOCALPARAMETER4FARBPROC*)0x00000001411A4AA8; diff --git a/src/KKdLib/mat.cpp b/src/KKdLib/mat.cpp index 082dbff0..94c4e1d0 100644 --- a/src/KKdLib/mat.cpp +++ b/src/KKdLib/mat.cpp @@ -32,19 +32,37 @@ const mat4 mat4_null = { { 0.0f, 0.0f, 0.0f, 0.0f }, }; +inline void mat3_add(const mat3* x, float_t y, mat3* z) { + z->row0 = x->row0 + y; + z->row1 = x->row1 + y; + z->row2 = x->row2 + y; +} + inline void mat3_add(const mat3* x, const mat3* y, mat3* z) { z->row0 = x->row0 + y->row0; z->row1 = x->row1 + y->row1; z->row2 = x->row2 + y->row2; } +inline void mat3_sub(const mat3* x, float_t y, mat3* z) { + z->row0 = x->row0 - y; + z->row1 = x->row1 - y; + z->row2 = x->row2 - y; +} + inline void mat3_sub(const mat3* x, const mat3* y, mat3* z) { z->row0 = x->row0 - y->row0; z->row1 = x->row1 - y->row1; z->row2 = x->row2 - y->row2; } -inline void mat3_mult(const mat3* x, const mat3* y, mat3* z) { +inline void mat3_mul(const mat3* x, float_t y, mat3* z) { + z->row0 = x->row0 * y; + z->row1 = x->row1 * y; + z->row2 = x->row2 * y; +} + +inline void mat3_mul(const mat3* x, const mat3* y, mat3* z) { __m128 t0; __m128 t1; __m128 t2; @@ -76,7 +94,7 @@ inline void mat3_mult(const mat3* x, const mat3* y, mat3* z) { z->row2 = *(vec3*)&zt; } -inline void mat3_mult_vec2(const mat3* x, const vec2* y, vec2* z) { +inline void mat3_transform_vector(const mat3* x, const vec2* y, vec2* z) { __m128 xt; __m128 yt; __m128 zt; @@ -91,7 +109,7 @@ inline void mat3_mult_vec2(const mat3* x, const vec2* y, vec2* z) { *z = *(vec2*)&zt; } -inline void mat3_mult_vec(const mat3* x, const vec3* y, vec3* z) { +inline void mat3_transform_vector(const mat3* x, const vec3* y, vec3* z) { __m128 xt; __m128 yt; __m128 zt; @@ -109,20 +127,36 @@ inline void mat3_mult_vec(const mat3* x, const vec3* y, vec3* z) { *z = *(vec3*)&zt; } -inline void mat3_mult_scalar(const mat3* x, float_t y, mat3* z) { +inline void mat3_inverse_transform_vector(const mat3* x, const vec2* y, vec2* z) { __m128 xt; __m128 yt; __m128 zt; - yt = vec4::load_xmm(y); + yt = vec2::load_xmm(*y); *(vec3*)&xt = x->row0; - zt = _mm_mul_ps(xt, yt); - z->row0 = *(vec3*)&zt; + zt = _mm_mul_ps(yt, xt); + z->x = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); *(vec3*)&xt = x->row1; - zt = _mm_mul_ps(xt, yt); - z->row1 = *(vec3*)&zt; + zt = _mm_mul_ps(yt, xt); + z->y = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); +} + +inline void mat3_inverse_transform_vector(const mat3* x, const vec3* y, vec3* z) { + __m128 xt; + __m128 yt; + __m128 zt; + yt = vec3::load_xmm(*y); + *(vec3*)&xt = x->row0; + zt = _mm_mul_ps(yt, xt); + zt = _mm_hadd_ps(zt, zt); + z->x = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); + *(vec3*)&xt = x->row1; + zt = _mm_mul_ps(yt, xt); + zt = _mm_hadd_ps(zt, zt); + z->y = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); *(vec3*)&xt = x->row2; - zt = _mm_mul_ps(xt, yt); - z->row2 = *(vec3*)&zt; + zt = _mm_mul_ps(yt, xt); + zt = _mm_hadd_ps(zt, zt); + z->z = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); } inline void mat3_transpose(const mat3* x, mat3* z) { @@ -265,157 +299,202 @@ inline float_t mat3_determinant(const mat3* x) { return b00 + b01 + b02 - b03 - b04 - b05; } -inline void mat3_rotate_xyz(float_t x, float_t y, float_t z, mat3* d) { +inline void mat3_rotate_x(float_t rad, mat3* y) { + float_t s = sinf(rad); + float_t c = cosf(rad); + *y = mat3_identity; + y->row1.y = c; + y->row1.z = s; + y->row2.y = -s; + y->row2.z = c; +} + +inline void mat3_rotate_y(float_t rad, mat3* y) { + float_t s = sinf(rad); + float_t c = cosf(rad); + *y = mat3_identity; + y->row0.x = c; + y->row0.z = -s; + y->row2.x = s; + y->row2.z = c; +} + +inline void mat3_rotate_z(float_t rad, mat3* y) { + float_t s = sinf(rad); + float_t c = cosf(rad); + *y = mat3_identity; + y->row0.x = c; + y->row0.y = s; + y->row1.x = -s; + y->row1.y = c; +} + +inline void mat3_rotate_x(float_t s, float_t c, mat3* y) { + *y = mat3_identity; + y->row1.y = c; + y->row1.z = s; + y->row2.y = -s; + y->row2.z = c; +} + +inline void mat3_rotate_y(float_t s, float_t c, mat3* y) { + *y = mat3_identity; + y->row0.x = c; + y->row0.z = -s; + y->row2.x = s; + y->row2.z = c; +} + +inline void mat3_rotate_z(float_t s, float_t c, mat3* y) { + *y = mat3_identity; + y->row0.x = c; + y->row0.y = s; + y->row1.x = -s; + y->row1.y = c; +} + +inline void mat3_rotate_xyz(float_t rad_x, float_t rad_y, float_t rad_z, mat3* z) { mat3 dt; dt = mat3_identity; - if (x != 0.0f) - mat3_rotate_x(x, &dt); - - if (y != 0.0f) - if (x != 0.0f) - mat3_rotate_y_mult(&dt, y, &dt); - else - mat3_rotate_y(y, &dt); - - if (z != 0.0f) - if (y != 0.0f || x != 0.0f) - mat3_rotate_z_mult(&dt, z, &dt); - else - mat3_rotate_z(z, &dt); - *d = dt; + if (rad_x != 0.0f) + mat3_mul_rotate_x(&dt, rad_x, &dt); + if (rad_y != 0.0f) + mat3_mul_rotate_y(&dt, rad_y, &dt); + if (rad_z != 0.0f) + mat3_mul_rotate_z(&dt, rad_z, &dt); + *z = dt; } -inline void mat3_rotate_xzy(float_t x, float_t y, float_t z, mat3* d) { +inline void mat3_rotate_xzy(float_t rad_x, float_t rad_y, float_t rad_z, mat3* z) { mat3 dt; dt = mat3_identity; - if (x != 0.0f) - mat3_rotate_x(x, &dt); - - if (z != 0.0f) - if (x != 0.0f) - mat3_rotate_z_mult(&dt, z, &dt); - else - mat3_rotate_z(z, &dt); - - if (y != 0.0f) - if (z != 0.0f || x != 0.0f) - mat3_rotate_y_mult(&dt, y, &dt); - else - mat3_rotate_y(y, &dt); - *d = dt; + if (rad_x != 0.0f) + mat3_mul_rotate_x(&dt, rad_x, &dt); + if (rad_z != 0.0f) + mat3_mul_rotate_z(&dt, rad_z, &dt); + if (rad_y != 0.0f) + mat3_mul_rotate_y(&dt, rad_y, &dt); + *z = dt; } -inline void mat3_rotate_yxz(float_t x, float_t y, float_t z, mat3* d) { +inline void mat3_rotate_yxz(float_t rad_x, float_t rad_y, float_t rad_z, mat3* z) { mat3 dt; dt = mat3_identity; - if (y != 0.0f) - mat3_rotate_y(y, &dt); - - if (x != 0.0f) - if (y != 0.0f) - mat3_rotate_x_mult(&dt, x, &dt); - else - mat3_rotate_x(x, &dt); - - if (z != 0.0f) - if (x != 0.0f || y != 0.0f) - mat3_rotate_z_mult(&dt, z, &dt); - else - mat3_rotate_z(z, &dt); - *d = dt; + if (rad_y != 0.0f) + mat3_mul_rotate_y(&dt, rad_y, &dt); + if (rad_x != 0.0f) + mat3_mul_rotate_x(&dt, rad_x, &dt); + if (rad_z != 0.0f) + mat3_mul_rotate_z(&dt, rad_z, &dt); + *z = dt; } -inline void mat3_rotate_yzx(float_t x, float_t y, float_t z, mat3* d) { +inline void mat3_rotate_yzx(float_t rad_x, float_t rad_y, float_t rad_z, mat3* z) { mat3 dt; dt = mat3_identity; - if (y != 0.0f) - mat3_rotate_y(y, &dt); - - if (z != 0.0f) - if (y != 0.0f) - mat3_rotate_z_mult(&dt, z, &dt); - else - mat3_rotate_z(z, &dt); - - if (x != 0.0f) - if (z != 0.0f || y != 0.0f) - mat3_rotate_x_mult(&dt, x, &dt); - else - mat3_rotate_x(x, &dt); - *d = dt; + if (rad_y != 0.0f) + mat3_mul_rotate_y(&dt, rad_y, &dt); + if (rad_z != 0.0f) + mat3_mul_rotate_z(&dt, rad_z, &dt); + if (rad_x != 0.0f) + mat3_mul_rotate_x(&dt, rad_x, &dt); + *z = dt; } -inline void mat3_rotate_zxy(float_t x, float_t y, float_t z, mat3* d) { +inline void mat3_rotate_zxy(float_t rad_x, float_t rad_y, float_t rad_z, mat3* z) { mat3 dt; dt = mat3_identity; - if (z != 0.0f) - mat3_rotate_z(z, &dt); - - if (x != 0.0f) - if (z != 0.0f) - mat3_rotate_x_mult(&dt, x, &dt); - else - mat3_rotate_x(x, &dt); - - if (y != 0.0f) - if (x != 0.0f || z != 0.0f) - mat3_rotate_y_mult(&dt, y, &dt); - else - mat3_rotate_y(y, &dt); - *d = dt; + if (rad_z != 0.0f) + mat3_mul_rotate_z(&dt, rad_z, &dt); + if (rad_x != 0.0f) + mat3_mul_rotate_x(&dt, rad_x, &dt); + if (rad_y != 0.0f) + mat3_mul_rotate_y(&dt, rad_y, &dt); + *z = dt; } -inline void mat3_rotate_zyx(float_t x, float_t y, float_t z, mat3* d) { +inline void mat3_rotate_zyx(float_t rad_x, float_t rad_y, float_t rad_z, mat3* z) { mat3 dt; dt = mat3_identity; - if (z != 0.0f) - mat3_rotate_z(z, &dt); - - if (y != 0.0f) - if (z != 0.0f) - mat3_rotate_y_mult(&dt, y, &dt); - else - mat3_rotate_y(y, &dt); - - if (x != 0.0f) - if (y != 0.0f || z != 0.0f) - mat3_rotate_x_mult(&dt, x, &dt); - else - mat3_rotate_x(x, &dt); - *d = dt; + if (rad_z != 0.0f) + mat3_mul_rotate_z(&dt, rad_z, &dt); + if (rad_y != 0.0f) + mat3_mul_rotate_y(&dt, rad_y, &dt); + if (rad_x != 0.0f) + mat3_mul_rotate_x(&dt, rad_x, &dt); + *z = dt; } -inline void mat3_rotate_x_sin_cos(float_t sin_val, float_t cos_val, mat3* y) { - mat3 yt; - yt = mat3_identity; - yt.row1.y = cos_val; - yt.row1.z = sin_val; - yt.row2.y = -sin_val; - yt.row2.z = cos_val; - *y = yt; +inline void mat3_mul_rotate_x(const mat3* x, float_t rad, mat3* z) { + __m128 t1; + __m128 t2; + __m128 y0; + __m128 y1; + __m128 y2; + __m128 zt; + float_t s = sinf(rad); + float_t c = cosf(rad); + *(vec3*)&y0 = x->row0; + *(vec3*)&y1 = x->row1; + *(vec3*)&y2 = x->row2; + z->row0 = *(vec3*)&y0; + t1 = _mm_mul_ps(y1, vec4::load_xmm(c)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(s)); + zt = _mm_add_ps(t1, t2); + z->row1 = *(vec3*)&zt; + t1 = _mm_mul_ps(y1, vec4::load_xmm(-s)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(c)); + zt = _mm_add_ps(t1, t2); + z->row2 = *(vec3*)&zt; } -inline void mat3_rotate_y_sin_cos(float_t sin_val, float_t cos_val, mat3* y) { - mat3 yt; - yt = mat3_identity; - yt.row0.x = cos_val; - yt.row0.z = -sin_val; - yt.row2.x = sin_val; - yt.row2.z = cos_val; - *y = yt; +inline void mat3_mul_rotate_y(const mat3* x, float_t rad, mat3* z) { + __m128 t0; + __m128 t2; + __m128 y0; + __m128 y1; + __m128 y2; + __m128 zt; + float_t s = sinf(rad); + float_t c = cosf(rad); + *(vec3*)&y0 = x->row0; + *(vec3*)&y1 = x->row1; + *(vec3*)&y2 = x->row2; + t0 = _mm_mul_ps(y0, vec4::load_xmm(c)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(-s)); + zt = _mm_add_ps(t0, t2); + z->row0 = *(vec3*)&zt; + z->row1 = *(vec3*)&y1; + t0 = _mm_mul_ps(y0, vec4::load_xmm(s)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(c)); + zt = _mm_add_ps(t0, t2); + z->row2 = *(vec3*)&zt; } -inline void mat3_rotate_z_sin_cos(float_t sin_val, float_t cos_val, mat3* y) { - mat3 yt; - yt = mat3_identity; - yt.row0.x = cos_val; - yt.row0.y = sin_val; - yt.row1.x = -sin_val; - yt.row1.y = cos_val; - *y = yt; +inline void mat3_mul_rotate_z(const mat3* x, float_t rad, mat3* z) { + __m128 t0; + __m128 t1; + __m128 y0; + __m128 y1; + __m128 y2; + __m128 zt; + float_t s = sinf(rad); + float_t c = cosf(rad); + *(vec3*)&y0 = x->row0; + *(vec3*)&y1 = x->row1; + *(vec3*)&y2 = x->row2; + t0 = _mm_mul_ps(y0, vec4::load_xmm(c)); + t1 = _mm_mul_ps(y1, vec4::load_xmm(s)); + zt = _mm_add_ps(t0, t1); + z->row0 = *(vec3*)&zt; + t0 = _mm_mul_ps(y0, vec4::load_xmm(-s)); + t1 = _mm_mul_ps(y1, vec4::load_xmm(c)); + zt = _mm_add_ps(t0, t1); + z->row1 = *(vec3*)&zt; + z->row2 = *(vec3*)&y2; } -inline void mat3_rotate_x_mult_sin_cos(const mat3* x, float_t sin_val, float_t cos_val, mat3* z) { +inline void mat3_mul_rotate_x(const mat3* x, float_t s, float_t c, mat3* z) { __m128 t1; __m128 t2; __m128 y0; @@ -426,17 +505,17 @@ inline void mat3_rotate_x_mult_sin_cos(const mat3* x, float_t sin_val, float_t c *(vec3*)&y1 = x->row1; *(vec3*)&y2 = x->row2; z->row0 = *(vec3*)&y0; - t1 = _mm_mul_ps(y1, vec4::load_xmm(cos_val)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(sin_val)); + t1 = _mm_mul_ps(y1, vec4::load_xmm(c)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(s)); zt = _mm_add_ps(t1, t2); z->row1 = *(vec3*)&zt; - t1 = _mm_mul_ps(y1, vec4::load_xmm(-sin_val)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(cos_val)); + t1 = _mm_mul_ps(y1, vec4::load_xmm(-s)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(c)); zt = _mm_add_ps(t1, t2); z->row2 = *(vec3*)&zt; } -inline void mat3_rotate_y_mult_sin_cos(const mat3* x, float_t sin_val, float_t cos_val, mat3* z) { +inline void mat3_mul_rotate_y(const mat3* x, float_t s, float_t c, mat3* z) { __m128 t0; __m128 t2; __m128 y0; @@ -446,18 +525,18 @@ inline void mat3_rotate_y_mult_sin_cos(const mat3* x, float_t sin_val, float_t c *(vec3*)&y0 = x->row0; *(vec3*)&y1 = x->row1; *(vec3*)&y2 = x->row2; - t0 = _mm_mul_ps(y0, vec4::load_xmm(cos_val)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(-sin_val)); + t0 = _mm_mul_ps(y0, vec4::load_xmm(c)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(-s)); zt = _mm_add_ps(t0, t2); z->row0 = *(vec3*)&zt; z->row1 = *(vec3*)&y1; - t0 = _mm_mul_ps(y0, vec4::load_xmm(sin_val)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(cos_val)); + t0 = _mm_mul_ps(y0, vec4::load_xmm(s)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(c)); zt = _mm_add_ps(t0, t2); z->row2 = *(vec3*)&zt; } -inline void mat3_rotate_z_mult_sin_cos(const mat3* x, float_t sin_val, float_t cos_val, mat3* z) { +inline void mat3_mul_rotate_z(const mat3* x, float_t s, float_t c, mat3* z) { __m128 t0; __m128 t1; __m128 y0; @@ -467,262 +546,144 @@ inline void mat3_rotate_z_mult_sin_cos(const mat3* x, float_t sin_val, float_t c *(vec3*)&y0 = x->row0; *(vec3*)&y1 = x->row1; *(vec3*)&y2 = x->row2; - t0 = _mm_mul_ps(y0, vec4::load_xmm(cos_val)); - t1 = _mm_mul_ps(y1, vec4::load_xmm(sin_val)); + t0 = _mm_mul_ps(y0, vec4::load_xmm(c)); + t1 = _mm_mul_ps(y1, vec4::load_xmm(s)); zt = _mm_add_ps(t0, t1); z->row0 = *(vec3*)&zt; - t0 = _mm_mul_ps(y0, vec4::load_xmm(-sin_val)); - t1 = _mm_mul_ps(y1, vec4::load_xmm(cos_val)); + t0 = _mm_mul_ps(y0, vec4::load_xmm(-s)); + t1 = _mm_mul_ps(y1, vec4::load_xmm(c)); zt = _mm_add_ps(t0, t1); z->row1 = *(vec3*)&zt; z->row2 = *(vec3*)&y2; } -inline void mat3_rotate_x(float_t x, mat3* y) { - mat3 yt; - float_t x_sin = sinf(x); - float_t x_cos = cosf(x); - yt = mat3_identity; - yt.row1.y = x_cos; - yt.row1.z = x_sin; - yt.row2.y = -x_sin; - yt.row2.z = x_cos; - *y = yt; -} - -inline void mat3_rotate_y(float_t x, mat3* y) { - mat3 yt; - float_t x_sin = sinf(x); - float_t x_cos = cosf(x); - yt = mat3_identity; - yt.row0.x = x_cos; - yt.row0.z = -x_sin; - yt.row2.x = x_sin; - yt.row2.z = x_cos; - *y = yt; -} - -inline void mat3_rotate_z(float_t x, mat3* y) { - mat3 yt; - float_t x_sin = sinf(x); - float_t x_cos = cosf(x); - yt = mat3_identity; - yt.row0.x = x_cos; - yt.row0.y = x_sin; - yt.row1.x = -x_sin; - yt.row1.y = x_cos; - *y = yt; -} - -inline void mat3_rotate_xyz_mult(const mat3* s, float_t x, float_t y, float_t z, mat3* d) { +inline void mat3_mul_rotate_xyz(const mat3* x, float_t rad_x, float_t rad_y, float_t rad_z, mat3* z) { mat3 dt; - dt = *s; - if (x != 0.0f) - mat3_rotate_x_mult(&dt, x, &dt); - if (y != 0.0f) - mat3_rotate_y_mult(&dt, y, &dt); - if (z != 0.0f) - mat3_rotate_z_mult(&dt, z, &dt); - *d = dt; + dt = *x; + if (rad_x != 0.0f) + mat3_mul_rotate_x(&dt, rad_x, &dt); + if (rad_y != 0.0f) + mat3_mul_rotate_y(&dt, rad_y, &dt); + if (rad_z != 0.0f) + mat3_mul_rotate_z(&dt, rad_z, &dt); + *z = dt; } -inline void mat3_rotate_xzy_mult(const mat3* s, float_t x, float_t y, float_t z, mat3* d) { +inline void mat3_mul_rotate_xzy(const mat3* x, float_t rad_x, float_t rad_y, float_t rad_z, mat3* z) { mat3 dt; - dt = *s; - if (x != 0.0f) - mat3_rotate_x_mult(&dt, x, &dt); - if (z != 0.0f) - mat3_rotate_z_mult(&dt, z, &dt); - if (y != 0.0f) - mat3_rotate_y_mult(&dt, y, &dt); - *d = dt; + dt = *x; + if (rad_x != 0.0f) + mat3_mul_rotate_x(&dt, rad_x, &dt); + if (rad_z != 0.0f) + mat3_mul_rotate_z(&dt, rad_z, &dt); + if (rad_y != 0.0f) + mat3_mul_rotate_y(&dt, rad_y, &dt); + *z = dt; } -inline void mat3_rotate_yxz_mult(const mat3* s, float_t x, float_t y, float_t z, mat3* d) { +inline void mat3_mul_rotate_yxz(const mat3* x, float_t rad_x, float_t rad_y, float_t rad_z, mat3* z) { mat3 dt; - dt = *s; - if (y != 0.0f) - mat3_rotate_y_mult(&dt, y, &dt); - if (x != 0.0f) - mat3_rotate_x_mult(&dt, x, &dt); - if (z != 0.0f) - mat3_rotate_z_mult(&dt, z, &dt); - *d = dt; + dt = *x; + if (rad_y != 0.0f) + mat3_mul_rotate_y(&dt, rad_y, &dt); + if (rad_x != 0.0f) + mat3_mul_rotate_x(&dt, rad_x, &dt); + if (rad_z != 0.0f) + mat3_mul_rotate_z(&dt, rad_z, &dt); + *z = dt; } -inline void mat3_rotate_yzx_mult(const mat3* s, float_t x, float_t y, float_t z, mat3* d) { +inline void mat3_mul_rotate_yzx(const mat3* x, float_t rad_x, float_t rad_y, float_t rad_z, mat3* z) { mat3 dt; - dt = *s; - if (y != 0.0f) - mat3_rotate_y_mult(&dt, y, &dt); - if (z != 0.0f) - mat3_rotate_z_mult(&dt, z, &dt); - if (x != 0.0f) - mat3_rotate_x_mult(&dt, x, &dt); - *d = dt; + dt = *x; + if (rad_y != 0.0f) + mat3_mul_rotate_y(&dt, rad_y, &dt); + if (rad_z != 0.0f) + mat3_mul_rotate_z(&dt, rad_z, &dt); + if (rad_x != 0.0f) + mat3_mul_rotate_x(&dt, rad_x, &dt); + *z = dt; } -inline void mat3_rotate_zxy_mult(const mat3* s, float_t x, float_t y, float_t z, mat3* d) { +inline void mat3_mul_rotate_zxy(const mat3* x, float_t rad_x, float_t rad_y, float_t rad_z, mat3* z) { mat3 dt; - dt = *s; - if (z != 0.0f) - mat3_rotate_z_mult(&dt, z, &dt); - if (x != 0.0f) - mat3_rotate_x_mult(&dt, x, &dt); - if (y != 0.0f) - mat3_rotate_y_mult(&dt, y, &dt); - *d = dt; + dt = *x; + if (rad_z != 0.0f) + mat3_mul_rotate_z(&dt, rad_z, &dt); + if (rad_x != 0.0f) + mat3_mul_rotate_x(&dt, rad_x, &dt); + if (rad_y != 0.0f) + mat3_mul_rotate_y(&dt, rad_y, &dt); + *z = dt; } -inline void mat3_rotate_zyx_mult(const mat3* s, float_t x, float_t y, float_t z, mat3* d) { +inline void mat3_mul_rotate_zyx(const mat3* x, float_t rad_x, float_t rad_y, float_t rad_z, mat3* z) { mat3 dt; - dt = *s; - if (z != 0.0f) - mat3_rotate_z_mult(&dt, z, &dt); - if (y != 0.0f) - mat3_rotate_y_mult(&dt, y, &dt); - if (x != 0.0f) - mat3_rotate_x_mult(&dt, x, &dt); - *d = dt; + dt = *x; + if (rad_z != 0.0f) + mat3_mul_rotate_z(&dt, rad_z, &dt); + if (rad_y != 0.0f) + mat3_mul_rotate_y(&dt, rad_y, &dt); + if (rad_x != 0.0f) + mat3_mul_rotate_x(&dt, rad_x, &dt); + *z = dt; } -inline void mat3_rotate_x_mult(const mat3* x, float_t y, mat3* z) { - __m128 t1; - __m128 t2; - __m128 y0; - __m128 y1; - __m128 y2; - __m128 zt; - float_t y_sin = sinf(y); - float_t y_cos = cosf(y); - *(vec3*)&y0 = x->row0; - *(vec3*)&y1 = x->row1; - *(vec3*)&y2 = x->row2; - z->row0 = *(vec3*)&y0; - t1 = _mm_mul_ps(y1, vec4::load_xmm(y_cos)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(y_sin)); - zt = _mm_add_ps(t1, t2); - z->row1 = *(vec3*)&zt; - t1 = _mm_mul_ps(y1, vec4::load_xmm(-y_sin)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(y_cos)); - zt = _mm_add_ps(t1, t2); - z->row2 = *(vec3*)&zt; +inline void mat3_scale(float_t sx, float_t sy, float_t sz, mat3* z) { + *z = mat3_identity; + z->row0.x = sx; + z->row1.y = sy; + z->row2.z = sz; } -inline void mat3_rotate_y_mult(const mat3* x, float_t y, mat3* z) { - __m128 t0; - __m128 t2; - __m128 y0; - __m128 y1; - __m128 y2; - __m128 zt; - float_t y_sin = sinf(y); - float_t y_cos = cosf(y); - *(vec3*)&y0 = x->row0; - *(vec3*)&y1 = x->row1; - *(vec3*)&y2 = x->row2; - t0 = _mm_mul_ps(y0, vec4::load_xmm(y_cos)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(-y_sin)); - zt = _mm_add_ps(t0, t2); - z->row0 = *(vec3*)&zt; - z->row1 = *(vec3*)&y1; - t0 = _mm_mul_ps(y0, vec4::load_xmm(y_sin)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(y_cos)); - zt = _mm_add_ps(t0, t2); - z->row2 = *(vec3*)&zt; +inline void mat3_scale_x(float_t s, mat3* y) { + *y = mat3_identity; + y->row0.x = s; } -inline void mat3_rotate_z_mult(const mat3* x, float_t y, mat3* z) { - __m128 t0; - __m128 t1; - __m128 y0; - __m128 y1; - __m128 y2; - __m128 zt; - float_t y_sin = sinf(y); - float_t y_cos = cosf(y); - *(vec3*)&y0 = x->row0; - *(vec3*)&y1 = x->row1; - *(vec3*)&y2 = x->row2; - t0 = _mm_mul_ps(y0, vec4::load_xmm(y_cos)); - t1 = _mm_mul_ps(y1, vec4::load_xmm(y_sin)); - zt = _mm_add_ps(t0, t1); - z->row0 = *(vec3*)&zt; - t0 = _mm_mul_ps(y0, vec4::load_xmm(-y_sin)); - t1 = _mm_mul_ps(y1, vec4::load_xmm(y_cos)); - zt = _mm_add_ps(t0, t1); - z->row1 = *(vec3*)&zt; - z->row2 = *(vec3*)&y2; +inline void mat3_scale_y(float_t s, mat3* y) { + *y = mat3_identity; + y->row1.y = s; } -inline void mat3_scale(float_t x, float_t y, float_t z, mat3* d) { - mat3 dt; - dt = mat3_identity; - if (x != 1.0f) - dt.row0.x = x; - if (y != 1.0f) - dt.row1.y = y; - if (z != 1.0f) - dt.row2.z = z; - *d = dt; +inline void mat3_scale_z(float_t s, mat3* y) { + *y = mat3_identity; + y->row2.z = s; } -inline void mat3_scale_x(float_t x, mat3* y) { - mat3 yt; - yt = mat3_identity; - yt.row0.x = x; - *y = yt; -} - -inline void mat3_scale_y(float_t x, mat3* y) { - mat3 yt; - yt = mat3_identity; - yt.row1.y = x; - *y = yt; -} - -inline void mat3_scale_z(float_t x, mat3* y) { - mat3 yt; - yt = mat3_identity; - yt.row2.z = x; - *y = yt; -} - -inline void mat3_scale_mult(const mat3* s, float_t x, float_t y, float_t z, mat3* d) { +inline void mat3_mul_scale(const mat3* x, float_t sx, float_t sy, float_t sz, mat3* z) { mat3 st; mat3 dt; - if (x != 1.0f || y != 1.0f || z != 1.0f) { - st = *s; + if (sx != 1.0f || sy != 1.0f || sz != 1.0f) { dt = mat3_identity; - dt.row0.x = x; - dt.row1.y = y; - dt.row2.z = z; - mat3_mult(&st, &dt, &dt); - *d = dt; + dt.row0.x = sx; + dt.row1.y = sy; + dt.row2.z = sz; + mat3_mul(x, &dt, z); } else - *d = *s; + *z = *x; } -inline void mat3_scale_x_mult(const mat3* x, float_t y, mat3* z) { +inline void mat3_mul_scale_x(const mat3* x, float_t s, mat3* z) { mat3 yt; yt = mat3_identity; - yt.row0.x = y; - mat3_mult(x, &yt, z); + yt.row0.x = s; + mat3_mul(x, &yt, z); } -inline void mat3_scale_y_mult(const mat3* x, float_t y, mat3* z) { +inline void mat3_mul_scale_y(const mat3* x, float_t s, mat3* z) { mat3 yt; yt = mat3_identity; - yt.row1.y = y; - mat3_mult(x, &yt, z); + yt.row1.y = s; + mat3_mul(x, &yt, z); } -inline void mat3_scale_z_mult(const mat3* x, float_t y, mat3* z) { +inline void mat3_mul_scale_z(const mat3* x, float_t s, mat3* z) { mat3 yt; yt = mat3_identity; - yt.row2.z = y; - mat3_mult(x, &yt, z); + yt.row2.z = s; + mat3_mul(x, &yt, z); } inline void mat3_from_quat(const quat* quat, mat3* mat) { @@ -768,57 +729,57 @@ inline void mat3_from_quat(const quat* quat, mat3* mat) { } inline void mat3_from_axis_angle(const vec3* axis, float_t angle, mat3* mat) { - float_t angle_sin; - float_t angle_cos; - float_t angle_cos_1; + float_t s; + float_t c; + float_t c_1; vec3 _axis; - vec3 _axis_sin; + vec3 _axis_s; vec3 temp; - angle_sin = sinf(angle); - angle_cos = cosf(angle); - angle_cos_1 = 1.0f - angle_cos; + s = sinf(angle); + c = cosf(angle); + c_1 = 1.0f - c; _axis = vec3::normalize(*axis); - _axis_sin = _axis * angle_sin; - temp = _axis * (_axis.x * angle_cos_1); - mat->row0.x = temp.x + angle_cos; - mat->row1.x = temp.y - _axis_sin.z; - mat->row2.x = temp.z + _axis_sin.y; - temp = _axis * (_axis.y * angle_cos_1); - mat->row0.y = temp.x + _axis_sin.z; - mat->row1.y = temp.y + angle_cos; - mat->row2.y = temp.z - _axis_sin.x; - temp = _axis * (_axis.z * angle_cos_1); - mat->row0.z = temp.x - _axis_sin.y; - mat->row1.z = temp.y + _axis_sin.x; - mat->row2.z = temp.z + angle_cos; + _axis_s = _axis * s; + temp = _axis * (_axis.x * c_1); + mat->row0.x = temp.x + c; + mat->row1.x = temp.y - _axis_s.z; + mat->row2.x = temp.z + _axis_s.y; + temp = _axis * (_axis.y * c_1); + mat->row0.y = temp.x + _axis_s.z; + mat->row1.y = temp.y + c; + mat->row2.y = temp.z - _axis_s.x; + temp = _axis * (_axis.z * c_1); + mat->row0.z = temp.x - _axis_s.y; + mat->row1.z = temp.y + _axis_s.x; + mat->row2.z = temp.z + c; } -inline void mat3_from_axis_angle_sin_cos(const vec3* axis, float_t sin_val, float_t cos_val, mat3* mat) { - float_t cos_val_1; +inline void mat3_from_axis_angle(const vec3* axis, float_t s, float_t c, mat3* mat) { + float_t c_1; vec3 _axis; - vec3 _axis_sin; + vec3 _axis_s; vec3 temp; - cos_val_1 = 1.0f - cos_val; + c_1 = 1.0f - c; _axis = vec3::normalize(*axis); - _axis_sin = _axis * sin_val; - temp = _axis * (_axis.x * cos_val_1); - mat->row0.x = temp.x + cos_val; - mat->row1.x = temp.y - _axis_sin.z; - mat->row2.x = temp.z + _axis_sin.y; - temp = _axis * (_axis.y * cos_val_1); - mat->row0.y = temp.x + _axis_sin.z; - mat->row1.y = temp.y + cos_val; - mat->row2.y = temp.z - _axis_sin.x; - temp = _axis * (_axis.z * cos_val_1); - mat->row0.z = temp.x - _axis_sin.y; - mat->row1.z = temp.y + _axis_sin.x; - mat->row2.z = temp.z + cos_val; + _axis_s = _axis * s; + temp = _axis * (_axis.x * c_1); + mat->row0.x = temp.x + c; + mat->row1.x = temp.y - _axis_s.z; + mat->row2.x = temp.z + _axis_s.y; + temp = _axis * (_axis.y * c_1); + mat->row0.y = temp.x + _axis_s.z; + mat->row1.y = temp.y + c; + mat->row2.y = temp.z - _axis_s.x; + temp = _axis * (_axis.z * c_1); + mat->row0.z = temp.x - _axis_s.y; + mat->row1.z = temp.y + _axis_s.x; + mat->row2.z = temp.z + c; } inline void mat3_from_mat4(const mat4* x, mat3* z) { @@ -890,6 +851,13 @@ inline void mat3_mult_axis_angle(const mat3* x, const vec3* axis, const float_t mat3_from_quat(&q3, z); } +inline void mat4_add(const mat4* x, float_t y, mat4* z) { + z->row0 = x->row0 + y; + z->row1 = x->row1 + y; + z->row2 = x->row2 + y; + z->row3 = x->row3 + y; +} + inline void mat4_add(const mat4* x, const mat4* y, mat4* z) { z->row0 = x->row0 + y->row0; z->row1 = x->row1 + y->row1; @@ -897,6 +865,13 @@ inline void mat4_add(const mat4* x, const mat4* y, mat4* z) { z->row3 = x->row3 + y->row3; } +inline void mat4_sub(const mat4* x, float_t y, mat4* z) { + z->row0 = x->row0 - y; + z->row1 = x->row1 - y; + z->row2 = x->row2 - y; + z->row3 = x->row3 - y; +} + inline void mat4_sub(const mat4* x, const mat4* y, mat4* z) { z->row0 = x->row0 - y->row0; z->row1 = x->row1 - y->row1; @@ -904,7 +879,14 @@ inline void mat4_sub(const mat4* x, const mat4* y, mat4* z) { z->row3 = x->row3 - y->row3; } -inline void mat4_mult(const mat4* x, const mat4* y, mat4* z) { +inline void mat4_mul(const mat4* x, float_t y, mat4* z) { + z->row0 = x->row0 * y; + z->row1 = x->row1 * y; + z->row2 = x->row2 * y; + z->row3 = x->row3 * y; +} + +inline void mat4_mul(const mat4* x, const mat4* y, mat4* z) { __m128 t0; __m128 t1; __m128 t2; @@ -944,7 +926,7 @@ inline void mat4_mult(const mat4* x, const mat4* y, mat4* z) { z->row3 = vec4::store_xmm(_mm_add_ps(_mm_add_ps(t0, t1), _mm_add_ps(t2, t3))); } -inline void mat4_mult_vec2(const mat4* x, const vec2* y, vec2* z) { +inline void mat4_transform_vector(const mat4* x, const vec2* y, vec2* z) { __m128 yt; __m128 zt; __m128 zt0; @@ -956,21 +938,7 @@ inline void mat4_mult_vec2(const mat4* x, const vec2* y, vec2* z) { *z = *(vec2*)&zt; } -inline void mat4_mult_vec2_trans(const mat4* x, const vec2* y, vec2* z) { - __m128 yt; - __m128 zt; - __m128 zt0; - __m128 zt1; - __m128 zt2; - *(vec2*)&yt = *y; - zt0 = _mm_mul_ps(vec4::load_xmm(x->row0), _mm_shuffle_ps(yt, yt, 0x00)); - zt1 = _mm_mul_ps(vec4::load_xmm(x->row1), _mm_shuffle_ps(yt, yt, 0x55)); - zt2 = vec4::load_xmm(x->row3); - zt = _mm_add_ps(_mm_add_ps(zt0, zt1), zt2); - *z = *(vec2*)&zt; -} - -inline void mat4_mult_vec3(const mat4* x, const vec3* y, vec3* z) { +inline void mat4_transform_vector(const mat4* x, const vec3* y, vec3* z) { __m128 yt; __m128 zt; __m128 zt0; @@ -984,22 +952,35 @@ inline void mat4_mult_vec3(const mat4* x, const vec3* y, vec3* z) { *z = *(vec3*)&zt; } -inline void mat4_mult_vec3_inv(const mat4* x, const vec3* y, vec3* z) { +inline void mat4_transform_vector(const mat4* x, const vec4* y, vec4* z) { __m128 yt; - __m128 zt; - yt = vec3::load_xmm(*y); - zt = _mm_mul_ps(yt, vec4::load_xmm(x->row0)); - zt = _mm_hadd_ps(zt, zt); - z->x = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); - zt = _mm_mul_ps(yt, vec4::load_xmm(x->row1)); - zt = _mm_hadd_ps(zt, zt); - z->y = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); - zt = _mm_mul_ps(yt, vec4::load_xmm(x->row2)); - zt = _mm_hadd_ps(zt, zt); - z->z = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); + __m128 zt0; + __m128 zt1; + __m128 zt2; + __m128 zt3; + yt = vec4::load_xmm(*y); + zt0 = _mm_mul_ps(vec4::load_xmm(x->row0), _mm_shuffle_ps(yt, yt, 0x00)); + zt1 = _mm_mul_ps(vec4::load_xmm(x->row1), _mm_shuffle_ps(yt, yt, 0x55)); + zt2 = _mm_mul_ps(vec4::load_xmm(x->row2), _mm_shuffle_ps(yt, yt, 0xAA)); + zt3 = _mm_mul_ps(vec4::load_xmm(x->row3), _mm_shuffle_ps(yt, yt, 0xFF)); + *z = vec4::store_xmm(_mm_add_ps(_mm_add_ps(zt0, zt1), _mm_add_ps(zt2, zt3))); } -inline void mat4_mult_vec3_trans(const mat4* x, const vec3* y, vec3* z) { +inline void mat4_transform_point(const mat4* x, const vec2* y, vec2* z) { + __m128 yt; + __m128 zt; + __m128 zt0; + __m128 zt1; + __m128 zt2; + *(vec2*)&yt = *y; + zt0 = _mm_mul_ps(vec4::load_xmm(x->row0), _mm_shuffle_ps(yt, yt, 0x00)); + zt1 = _mm_mul_ps(vec4::load_xmm(x->row1), _mm_shuffle_ps(yt, yt, 0x55)); + zt2 = vec4::load_xmm(x->row3); + zt = _mm_add_ps(_mm_add_ps(zt0, zt1), zt2); + *z = *(vec2*)&zt; +} + +inline void mat4_transform_point(const mat4* x, const vec3* y, vec3* z) { __m128 yt; __m128 zt; __m128 zt0; @@ -1015,7 +996,61 @@ inline void mat4_mult_vec3_trans(const mat4* x, const vec3* y, vec3* z) { *z = *(vec3*)&zt; } -inline void mat4_mult_vec3_inv_trans(const mat4* x, const vec3* y, vec3* z) { +inline void mat4_inverse_transform_vector(const mat4* x, const vec2* y, vec2* z) { + __m128 yt; + __m128 zt; + yt = vec2::load_xmm(*y); + zt = _mm_mul_ps(yt, vec4::load_xmm(x->row0)); + z->x = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); + zt = _mm_mul_ps(yt, vec4::load_xmm(x->row1)); + z->y = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); +} + +inline void mat4_inverse_transform_vector(const mat4* x, const vec3* y, vec3* z) { + __m128 yt; + __m128 zt; + yt = vec3::load_xmm(*y); + zt = _mm_mul_ps(yt, vec4::load_xmm(x->row0)); + zt = _mm_hadd_ps(zt, zt); + z->x = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); + zt = _mm_mul_ps(yt, vec4::load_xmm(x->row1)); + zt = _mm_hadd_ps(zt, zt); + z->y = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); + zt = _mm_mul_ps(yt, vec4::load_xmm(x->row2)); + zt = _mm_hadd_ps(zt, zt); + z->z = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); +} + +inline void mat4_inverse_transform_vector(const mat4* x, const vec4* y, vec4* z) { + __m128 yt; + __m128 zt; + yt = vec4::load_xmm(*y); + zt = _mm_mul_ps(yt, vec4::load_xmm(x->row0)); + zt = _mm_hadd_ps(zt, zt); + z->x = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); + zt = _mm_mul_ps(yt, vec4::load_xmm(x->row1)); + zt = _mm_hadd_ps(zt, zt); + z->y = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); + zt = _mm_mul_ps(yt, vec4::load_xmm(x->row2)); + zt = _mm_hadd_ps(zt, zt); + z->z = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); + zt = _mm_mul_ps(yt, vec4::load_xmm(x->row3)); + zt = _mm_hadd_ps(zt, zt); + z->w = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); +} + +inline void mat4_inverse_transform_point(const mat4* x, const vec2* y, vec2* z) { + __m128 yt; + __m128 zt; + yt = vec2::load_xmm(*y); + yt = _mm_sub_ps(yt, vec4::load_xmm(x->row3)); + zt = _mm_mul_ps(yt, vec4::load_xmm(x->row0)); + z->x = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); + zt = _mm_mul_ps(yt, vec4::load_xmm(x->row1)); + z->y = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); +} + +inline void mat4_inverse_transform_point(const mat4* x, const vec3* y, vec3* z) { __m128 yt; __m128 zt; yt = vec3::load_xmm(*y); @@ -1031,29 +1066,6 @@ inline void mat4_mult_vec3_inv_trans(const mat4* x, const vec3* y, vec3* z) { z->z = _mm_cvtss_f32(_mm_hadd_ps(zt, zt)); } -inline void mat4_mult_vec(const mat4* x, vec4* y, vec4* z) { - __m128 yt; - __m128 zt0; - __m128 zt1; - __m128 zt2; - __m128 zt3; - yt = vec4::load_xmm(*y); - zt0 = _mm_mul_ps(vec4::load_xmm(x->row0), _mm_shuffle_ps(yt, yt, 0x00)); - zt1 = _mm_mul_ps(vec4::load_xmm(x->row1), _mm_shuffle_ps(yt, yt, 0x55)); - zt2 = _mm_mul_ps(vec4::load_xmm(x->row2), _mm_shuffle_ps(yt, yt, 0xAA)); - zt3 = _mm_mul_ps(vec4::load_xmm(x->row3), _mm_shuffle_ps(yt, yt, 0xFF)); - *z = vec4::store_xmm(_mm_add_ps(_mm_add_ps(zt0, zt1), _mm_add_ps(zt2, zt3))); -} - -inline void mat4_mult_scalar(const mat4* x, float_t y, mat4* z) { - __m128 yt; - yt = vec4::load_xmm(y); - z->row0 = vec4::store_xmm(_mm_mul_ps(vec4::load_xmm(x->row0), yt)); - z->row1 = vec4::store_xmm(_mm_mul_ps(vec4::load_xmm(x->row1), yt)); - z->row2 = vec4::store_xmm(_mm_mul_ps(vec4::load_xmm(x->row2), yt)); - z->row3 = vec4::store_xmm(_mm_mul_ps(vec4::load_xmm(x->row3), yt)); -} - inline void mat4_transpose(const mat4* x, mat4* z) { __m128 xt0; __m128 xt1; @@ -1256,334 +1268,202 @@ inline float_t mat4_determinant(const mat4* x) { return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; } -inline void mat4_rotate_xyz(float_t x, float_t y, float_t z, mat4* d) { +inline void mat4_rotate_x(float_t rad, mat4* y) { + float_t s = sinf(rad); + float_t c = cosf(rad); + *y = mat4_identity; + y->row1.y = c; + y->row1.z = s; + y->row2.y = -s; + y->row2.z = c; +} + +inline void mat4_rotate_y(float_t rad, mat4* y) { + float_t s = sinf(rad); + float_t c = cosf(rad); + *y = mat4_identity; + y->row0.x = c; + y->row0.z = -s; + y->row2.x = s; + y->row2.z = c; +} + +inline void mat4_rotate_z(float_t rad, mat4* y) { + float_t s = sinf(rad); + float_t c = cosf(rad); + *y = mat4_identity; + y->row0.x = c; + y->row0.y = s; + y->row1.x = -s; + y->row1.y = c; +} + +inline void mat4_rotate_x(float_t s, float_t c, mat4* y) { + *y = mat4_identity; + y->row1.y = c; + y->row1.z = s; + y->row2.y = -s; + y->row2.z = c; +} + +inline void mat4_rotate_y(float_t s, float_t c, mat4* y) { + *y = mat4_identity; + y->row0.x = c; + y->row0.z = -s; + y->row2.x = s; + y->row2.z = c; +} + +inline void mat4_rotate_z(float_t s, float_t c, mat4* y) { + *y = mat4_identity; + y->row0.x = c; + y->row0.y = s; + y->row1.x = -s; + y->row1.y = c; +} + +inline void mat4_rotate_xyz(float_t rad_x, float_t rad_y, float_t rad_z, mat4* z) { mat4 dt; dt = mat4_identity; - if (x != 0.0f) - mat4_rotate_x(x, &dt); - - if (y != 0.0f) - if (x != 0.0f) - mat4_rotate_y_mult(&dt, y, &dt); - else - mat4_rotate_y(y, &dt); - - if (z != 0.0f) - if (y != 0.0f || x != 0.0f) - mat4_rotate_z_mult(&dt, z, &dt); - else - mat4_rotate_z(z, &dt); - *d = dt; + if (rad_x != 0.0f) + mat4_mul_rotate_x(&dt, rad_x, &dt); + if (rad_y != 0.0f) + mat4_mul_rotate_y(&dt, rad_y, &dt); + if (rad_z != 0.0f) + mat4_mul_rotate_z(&dt, rad_z, &dt); + *z = dt; } -inline void mat4_rotate_xzy(float_t x, float_t y, float_t z, mat4* d) { +inline void mat4_rotate_xzy(float_t rad_x, float_t rad_y, float_t rad_z, mat4* z) { mat4 dt; dt = mat4_identity; - if (x != 0.0f) - mat4_rotate_x(x, &dt); - - if (z != 0.0f) - if (x != 0.0f) - mat4_rotate_z_mult(&dt, z, &dt); - else - mat4_rotate_z(z, &dt); - - if (y != 0.0f) - if (z != 0.0f || x != 0.0f) - mat4_rotate_y_mult(&dt, y, &dt); - else - mat4_rotate_y(y, &dt); - *d = dt; + if (rad_x != 0.0f) + mat4_mul_rotate_x(&dt, rad_x, &dt); + if (rad_z != 0.0f) + mat4_mul_rotate_z(&dt, rad_z, &dt); + if (rad_y != 0.0f) + mat4_mul_rotate_y(&dt, rad_y, &dt); + *z = dt; } -inline void mat4_rotate_yxz(float_t x, float_t y, float_t z, mat4* d) { +inline void mat4_rotate_yxz(float_t rad_x, float_t rad_y, float_t rad_z, mat4* z) { mat4 dt; dt = mat4_identity; - if (y != 0.0f) - mat4_rotate_y(y, &dt); - - if (x != 0.0f) - if (y != 0.0f) - mat4_rotate_x_mult(&dt, x, &dt); - else - mat4_rotate_x(x, &dt); - - if (z != 0.0f) - if (x != 0.0f || y != 0.0f) - mat4_rotate_z_mult(&dt, z, &dt); - else - mat4_rotate_z(z, &dt); - *d = dt; + if (rad_y != 0.0f) + mat4_mul_rotate_y(&dt, rad_y, &dt); + if (rad_x != 0.0f) + mat4_mul_rotate_x(&dt, rad_x, &dt); + if (rad_z != 0.0f) + mat4_mul_rotate_z(&dt, rad_z, &dt); + *z = dt; } -inline void mat4_rotate_yzx(float_t x, float_t y, float_t z, mat4* d) { +inline void mat4_rotate_yzx(float_t rad_x, float_t rad_y, float_t rad_z, mat4* z) { mat4 dt; dt = mat4_identity; - if (y != 0.0f) - mat4_rotate_y(y, &dt); - - if (z != 0.0f) - if (y != 0.0f) - mat4_rotate_z_mult(&dt, z, &dt); - else - mat4_rotate_z(z, &dt); - - if (x != 0.0f) - if (z != 0.0f || y != 0.0f) - mat4_rotate_x_mult(&dt, x, &dt); - else - mat4_rotate_x(x, &dt); - *d = dt; + if (rad_y != 0.0f) + mat4_mul_rotate_y(&dt, rad_y, &dt); + if (rad_z != 0.0f) + mat4_mul_rotate_z(&dt, rad_z, &dt); + if (rad_x != 0.0f) + mat4_mul_rotate_x(&dt, rad_x, &dt); + *z = dt; } -inline void mat4_rotate_zxy(float_t x, float_t y, float_t z, mat4* d) { +inline void mat4_rotate_zxy(float_t rad_x, float_t rad_y, float_t rad_z, mat4* z) { mat4 dt; dt = mat4_identity; - if (z != 0.0f) - mat4_rotate_z(z, &dt); - - if (x != 0.0f) - if (z != 0.0f) - mat4_rotate_x_mult(&dt, x, &dt); - else - mat4_rotate_x(x, &dt); - - if (y != 0.0f) - if (x != 0.0f || z != 0.0f) - mat4_rotate_y_mult(&dt, y, &dt); - else - mat4_rotate_y(y, &dt); - *d = dt; + if (rad_z != 0.0f) + mat4_mul_rotate_z(&dt, rad_z, &dt); + if (rad_x != 0.0f) + mat4_mul_rotate_x(&dt, rad_x, &dt); + if (rad_y != 0.0f) + mat4_mul_rotate_y(&dt, rad_y, &dt); + *z = dt; } -inline void mat4_rotate_zyx(float_t x, float_t y, float_t z, mat4* d) { +inline void mat4_rotate_zyx(float_t rad_x, float_t rad_y, float_t rad_z, mat4* z) { mat4 dt; dt = mat4_identity; - if (z != 0.0f) - mat4_rotate_z(z, &dt); - - if (y != 0.0f) - if (z != 0.0f) - mat4_rotate_y_mult(&dt, y, &dt); - else - mat4_rotate_y(y, &dt); - - if (x != 0.0f) - if (y != 0.0f || z != 0.0f) - mat4_rotate_x_mult(&dt, x, &dt); - else - mat4_rotate_x(x, &dt); - *d = dt; + if (rad_z != 0.0f) + mat4_mul_rotate_z(&dt, rad_z, &dt); + if (rad_y != 0.0f) + mat4_mul_rotate_y(&dt, rad_y, &dt); + if (rad_x != 0.0f) + mat4_mul_rotate_x(&dt, rad_x, &dt); + *z = dt; } -inline void mat4_rotate_x(float_t x, mat4* y) { - mat4 yt; - float_t x_sin = sinf(x); - float_t x_cos = cosf(x); - yt = mat4_identity; - yt.row1.y = x_cos; - yt.row1.z = x_sin; - yt.row2.y = -x_sin; - yt.row2.z = x_cos; - *y = yt; -} - -inline void mat4_rotate_y(float_t x, mat4* y) { - mat4 yt; - float_t x_sin = sinf(x); - float_t x_cos = cosf(x); - yt = mat4_identity; - yt.row0.x = x_cos; - yt.row0.z = -x_sin; - yt.row2.x = x_sin; - yt.row2.z = x_cos; - *y = yt; -} - -inline void mat4_rotate_z(float_t x, mat4* y) { - mat4 yt; - float_t x_sin = sinf(x); - float_t x_cos = cosf(x); - yt = mat4_identity; - yt.row0.x = x_cos; - yt.row0.y = x_sin; - yt.row1.x = -x_sin; - yt.row1.y = x_cos; - *y = yt; -} - -inline void mat4_rotate_xyz_mult(const mat4* s, float_t x, float_t y, float_t z, mat4* d) { - mat4 dt; - dt = *s; - if (x != 0.0f) - mat4_rotate_x_mult(&dt, x, &dt); - if (y != 0.0f) - mat4_rotate_y_mult(&dt, y, &dt); - if (z != 0.0f) - mat4_rotate_z_mult(&dt, z, &dt); - *d = dt; -} - -inline void mat4_rotate_xzy_mult(const mat4* s, float_t x, float_t y, float_t z, mat4* d) { - mat4 dt; - dt = *s; - if (x != 0.0f) - mat4_rotate_x_mult(&dt, x, &dt); - if (z != 0.0f) - mat4_rotate_z_mult(&dt, z, &dt); - if (y != 0.0f) - mat4_rotate_y_mult(&dt, y, &dt); - *d = dt; -} - -inline void mat4_rotate_yxz_mult(const mat4* s, float_t x, float_t y, float_t z, mat4* d) { - mat4 dt; - dt = *s; - if (y != 0.0f) - mat4_rotate_y_mult(&dt, y, &dt); - if (x != 0.0f) - mat4_rotate_x_mult(&dt, x, &dt); - if (z != 0.0f) - mat4_rotate_z_mult(&dt, z, &dt); - *d = dt; -} - -inline void mat4_rotate_yzx_mult(const mat4* s, float_t x, float_t y, float_t z, mat4* d) { - mat4 dt; - dt = *s; - if (y != 0.0f) - mat4_rotate_y_mult(&dt, y, &dt); - if (z != 0.0f) - mat4_rotate_z_mult(&dt, z, &dt); - if (x != 0.0f) - mat4_rotate_x_mult(&dt, x, &dt); - *d = dt; -} - -inline void mat4_rotate_zxy_mult(const mat4* s, float_t x, float_t y, float_t z, mat4* d) { - mat4 dt; - dt = *s; - if (z != 0.0f) - mat4_rotate_z_mult(&dt, z, &dt); - if (x != 0.0f) - mat4_rotate_x_mult(&dt, x, &dt); - if (y != 0.0f) - mat4_rotate_y_mult(&dt, y, &dt); - *d = dt; -} - -inline void mat4_rotate_zyx_mult(const mat4* s, float_t x, float_t y, float_t z, mat4* d) { - mat4 dt; - dt = *s; - if (z != 0.0f) - mat4_rotate_z_mult(&dt, z, &dt); - if (y != 0.0f) - mat4_rotate_y_mult(&dt, y, &dt); - if (x != 0.0f) - mat4_rotate_x_mult(&dt, x, &dt); - *d = dt; -} - -inline void mat4_rotate_x_mult(const mat4* x, float_t y, mat4* z) { +inline void mat4_mul_rotate_x(const mat4* x, float_t rad, mat4* z) { __m128 t1; __m128 t2; __m128 y0; __m128 y1; __m128 y2; __m128 y3; - float_t y_sin = sinf(y); - float_t y_cos = cosf(y); + float_t s = sinf(rad); + float_t c = cosf(rad); y0 = vec4::load_xmm(x->row0); y1 = vec4::load_xmm(x->row1); y2 = vec4::load_xmm(x->row2); y3 = vec4::load_xmm(x->row3); z->row0 = vec4::store_xmm(y0); - t1 = _mm_mul_ps(y1, vec4::load_xmm(y_cos)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(y_sin)); + t1 = _mm_mul_ps(y1, vec4::load_xmm(c)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(s)); z->row1 = vec4::store_xmm(_mm_add_ps(t1, t2)); - t1 = _mm_mul_ps(y1, vec4::load_xmm(-y_sin)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(y_cos)); + t1 = _mm_mul_ps(y1, vec4::load_xmm(-s)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(c)); z->row2 = vec4::store_xmm(_mm_add_ps(t1, t2)); z->row3 = vec4::store_xmm(y3); } -inline void mat4_rotate_y_mult(const mat4* x, float_t y, mat4* z) { +inline void mat4_mul_rotate_y(const mat4* x, float_t rad, mat4* z) { __m128 t0; __m128 t2; __m128 y0; __m128 y1; __m128 y2; __m128 y3; - float_t y_sin = sinf(y); - float_t y_cos = cosf(y); + float_t s = sinf(rad); + float_t c = cosf(rad); y0 = vec4::load_xmm(x->row0); y1 = vec4::load_xmm(x->row1); y2 = vec4::load_xmm(x->row2); y3 = vec4::load_xmm(x->row3); - t0 = _mm_mul_ps(y0, vec4::load_xmm(y_cos)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(-y_sin)); + t0 = _mm_mul_ps(y0, vec4::load_xmm(c)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(-s)); z->row0 = vec4::store_xmm(_mm_add_ps(t0, t2)); z->row1 = vec4::store_xmm(y1); - t0 = _mm_mul_ps(y0, vec4::load_xmm(y_sin)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(y_cos)); + t0 = _mm_mul_ps(y0, vec4::load_xmm(s)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(c)); z->row2 = vec4::store_xmm(_mm_add_ps(t0, t2)); z->row3 = vec4::store_xmm(y3); } -inline void mat4_rotate_z_mult(const mat4* x, float_t y, mat4* z) { +inline void mat4_mul_rotate_z(const mat4* x, float_t rad, mat4* z) { __m128 t0; __m128 t1; __m128 y0; __m128 y1; __m128 y2; __m128 y3; - float_t y_sin = sinf(y); - float_t y_cos = cosf(y); + float_t s = sinf(rad); + float_t c = cosf(rad); y0 = vec4::load_xmm(x->row0); y1 = vec4::load_xmm(x->row1); y2 = vec4::load_xmm(x->row2); y3 = vec4::load_xmm(x->row3); - t0 = _mm_mul_ps(y0, vec4::load_xmm(y_cos)); - t1 = _mm_mul_ps(y1, vec4::load_xmm(y_sin)); + t0 = _mm_mul_ps(y0, vec4::load_xmm(c)); + t1 = _mm_mul_ps(y1, vec4::load_xmm(s)); z->row0 = vec4::store_xmm(_mm_add_ps(t0, t1)); - t0 = _mm_mul_ps(y0, vec4::load_xmm(-y_sin)); - t1 = _mm_mul_ps(y1, vec4::load_xmm(y_cos)); + t0 = _mm_mul_ps(y0, vec4::load_xmm(-s)); + t1 = _mm_mul_ps(y1, vec4::load_xmm(c)); z->row1 = vec4::store_xmm(_mm_add_ps(t0, t1)); z->row2 = vec4::store_xmm(y2); z->row3 = vec4::store_xmm(y3); } -inline void mat4_rotate_x_sin_cos(float_t sin_val, float_t cos_val, mat4* y) { - mat4 yt; - yt = mat4_identity; - yt.row1.y = cos_val; - yt.row1.z = sin_val; - yt.row2.y = -sin_val; - yt.row2.z = cos_val; - *y = yt; -} - -inline void mat4_rotate_y_sin_cos(float_t sin_val, float_t cos_val, mat4* y) { - mat4 yt; - yt = mat4_identity; - yt.row0.x = cos_val; - yt.row0.z = -sin_val; - yt.row2.x = sin_val; - yt.row2.z = cos_val; - *y = yt; -} - -inline void mat4_rotate_z_sin_cos(float_t sin_val, float_t cos_val, mat4* y) { - mat4 yt; - yt = mat4_identity; - yt.row0.x = cos_val; - yt.row0.y = sin_val; - yt.row1.x = -sin_val; - yt.row1.y = cos_val; - *y = yt; -} - -inline void mat4_rotate_x_mult_sin_cos(const mat4* x, float_t sin_val, float_t cos_val, mat4* z) { +inline void mat4_mul_rotate_x(const mat4* x, float_t s, float_t c, mat4* z) { __m128 t1; __m128 t2; __m128 y0; @@ -1595,16 +1475,16 @@ inline void mat4_rotate_x_mult_sin_cos(const mat4* x, float_t sin_val, float_t c y2 = vec4::load_xmm(x->row2); y3 = vec4::load_xmm(x->row3); z->row0 = vec4::store_xmm(y0); - t1 = _mm_mul_ps(y1, vec4::load_xmm(cos_val)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(sin_val)); + t1 = _mm_mul_ps(y1, vec4::load_xmm(c)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(s)); z->row1 = vec4::store_xmm(_mm_add_ps(t1, t2)); - t1 = _mm_mul_ps(y1, vec4::load_xmm(-sin_val)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(cos_val)); + t1 = _mm_mul_ps(y1, vec4::load_xmm(-s)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(c)); z->row2 = vec4::store_xmm(_mm_add_ps(t1, t2)); z->row3 = vec4::store_xmm(y3); } -inline void mat4_rotate_y_mult_sin_cos(const mat4* x, float_t sin_val, float_t cos_val, mat4* z) { +inline void mat4_mul_rotate_y(const mat4* x, float_t s, float_t c, mat4* z) { __m128 t0; __m128 t2; __m128 y0; @@ -1615,17 +1495,17 @@ inline void mat4_rotate_y_mult_sin_cos(const mat4* x, float_t sin_val, float_t c y1 = vec4::load_xmm(x->row1); y2 = vec4::load_xmm(x->row2); y3 = vec4::load_xmm(x->row3); - t0 = _mm_mul_ps(y0, vec4::load_xmm(cos_val)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(-sin_val)); + t0 = _mm_mul_ps(y0, vec4::load_xmm(c)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(-s)); z->row0 = vec4::store_xmm(_mm_add_ps(t0, t2)); z->row1 = vec4::store_xmm(y1); - t0 = _mm_mul_ps(y0, vec4::load_xmm(sin_val)); - t2 = _mm_mul_ps(y2, vec4::load_xmm(cos_val)); + t0 = _mm_mul_ps(y0, vec4::load_xmm(s)); + t2 = _mm_mul_ps(y2, vec4::load_xmm(c)); z->row2 = vec4::store_xmm(_mm_add_ps(t0, t2)); z->row3 = vec4::store_xmm(y3); } -inline void mat4_rotate_z_mult_sin_cos(const mat4* x, float_t sin_val, float_t cos_val, mat4* z) { +inline void mat4_mul_rotate_z(const mat4* x, float_t s, float_t c, mat4* z) { __m128 t0; __m128 t1; __m128 y0; @@ -1636,116 +1516,177 @@ inline void mat4_rotate_z_mult_sin_cos(const mat4* x, float_t sin_val, float_t c y1 = vec4::load_xmm(x->row1); y2 = vec4::load_xmm(x->row2); y3 = vec4::load_xmm(x->row3); - t0 = _mm_mul_ps(y0, vec4::load_xmm(cos_val)); - t1 = _mm_mul_ps(y1, vec4::load_xmm(sin_val)); + t0 = _mm_mul_ps(y0, vec4::load_xmm(c)); + t1 = _mm_mul_ps(y1, vec4::load_xmm(s)); z->row0 = vec4::store_xmm(_mm_add_ps(t0, t1)); - t0 = _mm_mul_ps(y0, vec4::load_xmm(-sin_val)); - t1 = _mm_mul_ps(y1, vec4::load_xmm(cos_val)); + t0 = _mm_mul_ps(y0, vec4::load_xmm(-s)); + t1 = _mm_mul_ps(y1, vec4::load_xmm(c)); z->row1 = vec4::store_xmm(_mm_add_ps(t0, t1)); z->row2 = vec4::store_xmm(y2); z->row3 = vec4::store_xmm(y3); } -inline void mat4_scale(float_t x, float_t y, float_t z, mat4* d) { +inline void mat4_mul_rotate_xyz(const mat4* x, float_t rad_x, float_t rad_y, float_t rad_z, mat4* z) { mat4 dt; - dt = mat4_identity; - if (x != 1.0f) - dt.row0.x = x; - if (y != 1.0f) - dt.row1.y = y; - if (z != 1.0f) - dt.row2.z = z; - *d = dt; + dt = *x; + if (rad_x != 0.0f) + mat4_mul_rotate_x(&dt, rad_x, &dt); + if (rad_y != 0.0f) + mat4_mul_rotate_y(&dt, rad_y, &dt); + if (rad_z != 0.0f) + mat4_mul_rotate_z(&dt, rad_z, &dt); + *z = dt; } -inline void mat4_scale_x(float_t x, mat4* y) { - mat4 yt; - yt = mat4_identity; - yt.row0.x = x; - *y = yt; -} - -inline void mat4_scale_y(float_t x, mat4* y) { - mat4 yt; - yt = mat4_identity; - yt.row1.y = x; - *y = yt; -} - -inline void mat4_scale_z(float_t x, mat4* y) { - mat4 yt; - yt = mat4_identity; - yt.row2.z = x; - *y = yt; -} - -inline void mat4_scale_mult(const mat4* s, float_t x, float_t y, float_t z, float_t w, mat4* d) { +inline void mat4_mul_rotate_xzy(const mat4* x, float_t rad_x, float_t rad_y, float_t rad_z, mat4* z) { mat4 dt; - if (x != 1.0f || y != 1.0f || z != 1.0f || w != 1.0f) { + dt = *x; + if (rad_x != 0.0f) + mat4_mul_rotate_x(&dt, rad_x, &dt); + if (rad_z != 0.0f) + mat4_mul_rotate_z(&dt, rad_z, &dt); + if (rad_y != 0.0f) + mat4_mul_rotate_y(&dt, rad_y, &dt); + *z = dt; +} + +inline void mat4_mul_rotate_yxz(const mat4* x, float_t rad_x, float_t rad_y, float_t rad_z, mat4* z) { + mat4 dt; + dt = *x; + if (rad_y != 0.0f) + mat4_mul_rotate_y(&dt, rad_y, &dt); + if (rad_x != 0.0f) + mat4_mul_rotate_x(&dt, rad_x, &dt); + if (rad_z != 0.0f) + mat4_mul_rotate_z(&dt, rad_z, &dt); + *z = dt; +} + +inline void mat4_mul_rotate_yzx(const mat4* x, float_t rad_x, float_t rad_y, float_t rad_z, mat4* z) { + mat4 dt; + dt = *x; + if (rad_y != 0.0f) + mat4_mul_rotate_y(&dt, rad_y, &dt); + if (rad_z != 0.0f) + mat4_mul_rotate_z(&dt, rad_z, &dt); + if (rad_x != 0.0f) + mat4_mul_rotate_x(&dt, rad_x, &dt); + *z = dt; +} + +inline void mat4_mul_rotate_zxy(const mat4* x, float_t rad_x, float_t rad_y, float_t rad_z, mat4* z) { + mat4 dt; + dt = *x; + if (rad_z != 0.0f) + mat4_mul_rotate_z(&dt, rad_z, &dt); + if (rad_x != 0.0f) + mat4_mul_rotate_x(&dt, rad_x, &dt); + if (rad_y != 0.0f) + mat4_mul_rotate_y(&dt, rad_y, &dt); + *z = dt; +} + +inline void mat4_mul_rotate_zyx(const mat4* x, float_t rad_x, float_t rad_y, float_t rad_z, mat4* z) { + mat4 dt; + dt = *x; + if (rad_z != 0.0f) + mat4_mul_rotate_z(&dt, rad_z, &dt); + if (rad_y != 0.0f) + mat4_mul_rotate_y(&dt, rad_y, &dt); + if (rad_x != 0.0f) + mat4_mul_rotate_x(&dt, rad_x, &dt); + *z = dt; +} + +inline void mat4_scale(float_t sx, float_t sy, float_t sz, mat4* z) { + *z = mat4_identity; + z->row0.x = sx; + z->row1.y = sy; + z->row2.z = sz; +} + +inline void mat4_scale_x(float_t s, mat4* y) { + *y = mat4_identity; + y->row0.x = s; +} + +inline void mat4_scale_y(float_t s, mat4* y) { + *y = mat4_identity; + y->row1.y = s; +} + +inline void mat4_scale_z(float_t s, mat4* y) { + *y = mat4_identity; + y->row2.z = s; +} + +inline void mat4_mul_scale(const mat4* x, float_t sx, float_t sy, float_t sz, float_t sw, mat4* z) { + mat4 dt; + if (sx != 1.0f || sy != 1.0f || sz != 1.0f || sw != 1.0f) { dt = mat4_identity; - dt.row0.x = x; - dt.row1.y = y; - dt.row2.z = z; - dt.row3.w = w; - mat4_mult(s, &dt, d); + dt.row0.x = sx; + dt.row1.y = sy; + dt.row2.z = sz; + dt.row3.w = sw; + mat4_mul(x, &dt, z); } - else if (s != d) - *d = *s; + else if (x != z) + *z = *x; } -inline void mat4_scale_x_mult(const mat4* x, float_t y, mat4* z) { +inline void mat4_mul_scale_x(const mat4* x, float_t s, mat4* z) { mat4 yt; yt = mat4_identity; - yt.row0.x = y; - mat4_mult(x, &yt, z); + yt.row0.x = s; + mat4_mul(x, &yt, z); } -inline void mat4_scale_y_mult(const mat4* x, float_t y, mat4* z) { +inline void mat4_mul_scale_y(const mat4* x, float_t s, mat4* z) { mat4 yt; yt = mat4_identity; - yt.row1.y = y; - mat4_mult(x, &yt, z); + yt.row1.y = s; + mat4_mul(x, &yt, z); } -inline void mat4_scale_z_mult(const mat4* x, float_t y, mat4* z) { +inline void mat4_mul_scale_z(const mat4* x, float_t s, mat4* z) { mat4 yt; yt = mat4_identity; - yt.row2.z = y; - mat4_mult(x, &yt, z); + yt.row2.z = s; + mat4_mul(x, &yt, z); } -inline void mat4_scale_w_mult(const mat4* x, float_t y, mat4* z) { +inline void mat4_scale_w_mult(const mat4* x, float_t s, mat4* z) { mat4 yt; yt = mat4_identity; - yt.row3.w = y; - mat4_mult(x, &yt, z); + yt.row3.w = s; + mat4_mul(x, &yt, z); } -inline void mat4_scale_rot(const mat4* s, float_t x, float_t y, float_t z, mat4* d) { +inline void mat4_scale_rot(const mat4* x, float_t sx, float_t sy, float_t sz, mat4* z) { mat3 st; mat3 dt; - if (x != 1.0f || y != 1.0f || z != 1.0f) { - st.row0 = *(vec3*)&s->row0; - st.row1 = *(vec3*)&s->row1; - st.row2 = *(vec3*)&s->row2; + if (sx != 1.0f || sy != 1.0f || sz != 1.0f) { + st.row0 = *(vec3*)&x->row0; + st.row1 = *(vec3*)&x->row1; + st.row2 = *(vec3*)&x->row2; dt = mat3_identity; - dt.row0.x = x; - dt.row1.y = y; - dt.row2.z = z; - mat3_mult(&st, &dt, &dt); - *(vec3*)&d->row0 = dt.row0; - *(vec3*)&d->row1 = dt.row1; - *(vec3*)&d->row2 = dt.row2; - d->row0.w = s->row0.w; - d->row1.w = s->row1.w; - d->row2.w = s->row2.w; - d->row3 = s->row3; + dt.row0.x = sx; + dt.row1.y = sy; + dt.row2.z = sz; + mat3_mul(&st, &dt, &dt); + *(vec3*)&z->row0 = dt.row0; + *(vec3*)&z->row1 = dt.row1; + *(vec3*)&z->row2 = dt.row2; + z->row0.w = x->row0.w; + z->row1.w = x->row1.w; + z->row2.w = x->row2.w; + z->row3 = x->row3; } else - *d = *s; + *z = *x; } -inline void mat4_scale_x_rot(const mat4* x, float_t y, mat4* z) { +inline void mat4_scale_x_rot(const mat4* x, float_t s, mat4* z) { mat3 xt; mat3 yt; mat3 zt; @@ -1753,8 +1694,8 @@ inline void mat4_scale_x_rot(const mat4* x, float_t y, mat4* z) { xt.row1 = *(vec3*)&x->row1; xt.row2 = *(vec3*)&x->row2; yt = mat3_identity; - yt.row0.x = y; - mat3_mult(&xt, &yt, &zt); + yt.row0.x = s; + mat3_mul(&xt, &yt, &zt); *(vec3*)&z->row0 = zt.row0; *(vec3*)&z->row1 = zt.row1; *(vec3*)&z->row2 = zt.row2; @@ -1764,7 +1705,7 @@ inline void mat4_scale_x_rot(const mat4* x, float_t y, mat4* z) { z->row3 = x->row3; } -inline void mat4_scale_y_rot(const mat4* x, float_t y, mat4* z) { +inline void mat4_scale_y_rot(const mat4* x, float_t s, mat4* z) { mat3 xt; mat3 yt; mat3 zt; @@ -1772,8 +1713,8 @@ inline void mat4_scale_y_rot(const mat4* x, float_t y, mat4* z) { xt.row1 = *(vec3*)&x->row1; xt.row2 = *(vec3*)&x->row2; yt = mat3_identity; - yt.row1.y = y; - mat3_mult(&xt, &yt, &zt); + yt.row1.y = s; + mat3_mul(&xt, &yt, &zt); *(vec3*)&z->row0 = zt.row0; *(vec3*)&z->row1 = zt.row1; *(vec3*)&z->row2 = zt.row2; @@ -1783,7 +1724,7 @@ inline void mat4_scale_y_rot(const mat4* x, float_t y, mat4* z) { z->row3 = x->row3; } -inline void mat4_scale_z_rot(const mat4* x, float_t y, mat4* z) { +inline void mat4_scale_z_rot(const mat4* x, float_t s, mat4* z) { mat3 xt; mat3 yt; mat3 zt; @@ -1791,8 +1732,8 @@ inline void mat4_scale_z_rot(const mat4* x, float_t y, mat4* z) { xt.row1 = *(vec3*)&x->row1; xt.row2 = *(vec3*)&x->row2; yt = mat3_identity; - yt.row2.z = y; - mat3_mult(&xt, &yt, &zt); + yt.row2.z = s; + mat3_mul(&xt, &yt, &zt); *(vec3*)&z->row0 = zt.row0; *(vec3*)&z->row1 = zt.row1; *(vec3*)&z->row2 = zt.row2; @@ -1802,119 +1743,111 @@ inline void mat4_scale_z_rot(const mat4* x, float_t y, mat4* z) { z->row3 = x->row3; } -inline void mat4_translate(float_t x, float_t y, float_t z, mat4* d) { - mat4 dt; - dt = mat4_identity; - dt.row3.x = x; - dt.row3.y = y; - dt.row3.z = z; - *d = dt; +inline void mat4_translate(float_t tx, float_t ty, float_t tz, mat4* z) { + *z = mat4_identity; + z->row3.x = tx; + z->row3.y = ty; + z->row3.z = tz; } -inline void mat4_translate_x(float_t x, mat4* y) { - mat4 yt; - yt = mat4_identity; - yt.row3.x = x; - *y = yt; +inline void mat4_translate_x(float_t t, mat4* y) { + *y = mat4_identity; + y->row3.x = t; } -inline void mat4_translate_y(float_t x, mat4* y) { - mat4 yt; - yt = mat4_identity; - yt.row3.y = x; - *y = yt; +inline void mat4_translate_y(float_t t, mat4* y) { + *y = mat4_identity; + y->row3.y = t; } -inline void mat4_translate_z(float_t x, mat4* y) { - mat4 yt; - yt = mat4_identity; - yt.row3.z = x; - *y = yt; +inline void mat4_translate_z(float_t t, mat4* y) { + *y = mat4_identity; + y->row3.z = t; } -inline void mat4_translate_mult(const mat4* s, float_t x, float_t y, float_t z, mat4* d) { +inline void mat4_mul_translate(const mat4* x, float_t tx, float_t ty, float_t tz, mat4* z) { __m128 yt; __m128 yt0; __m128 yt1; __m128 yt2; __m128 yt3; - if (s != d) - *d = *s; - if (x != 0.0f || y != 0.0f || z != 0.0f) { - yt0 = _mm_mul_ps(vec4::load_xmm(s->row0), vec4::load_xmm(x)); - yt1 = _mm_mul_ps(vec4::load_xmm(s->row1), vec4::load_xmm(y)); - yt2 = _mm_mul_ps(vec4::load_xmm(s->row2), vec4::load_xmm(z)); - yt3 = vec4::load_xmm(s->row3); + if (x != z) + *z = *x; + if (tx != 0.0f || ty != 0.0f || tz != 0.0f) { + yt0 = _mm_mul_ps(vec4::load_xmm(x->row0), vec4::load_xmm(tx)); + yt1 = _mm_mul_ps(vec4::load_xmm(x->row1), vec4::load_xmm(ty)); + yt2 = _mm_mul_ps(vec4::load_xmm(x->row2), vec4::load_xmm(tz)); + yt3 = vec4::load_xmm(x->row3); yt = _mm_add_ps(_mm_add_ps(yt0, yt1), _mm_add_ps(yt2, yt3)); - *(vec3*)&d->row3 = vec3::store_xmm(yt); + *(vec3*)&z->row3 = vec3::store_xmm(yt); } } -inline void mat4_translate_x_mult(const mat4* x, float_t y, mat4* z) { +inline void mat4_mul_translate_x(const mat4* x, float_t t, mat4* z) { __m128 yt0; __m128 yt1; if (x != z) *z = *x; - if (y != 0.0f) { + if (t != 0.0f) { yt0 = vec4::load_xmm(x->row0); yt1 = vec4::load_xmm(x->row3); - yt0 = _mm_add_ps(_mm_mul_ps(yt0, vec4::load_xmm(y)), yt1); + yt0 = _mm_add_ps(_mm_mul_ps(yt0, vec4::load_xmm(t)), yt1); *(vec3*)&z->row3 = vec3::store_xmm(yt0); } } -inline void mat4_translate_y_mult(const mat4* x, float_t y, mat4* z) { +inline void mat4_mul_translate_y(const mat4* x, float_t t, mat4* z) { __m128 yt0; __m128 yt1; if (x != z) *z = *x; - if (y != 0.0f) { + if (t != 0.0f) { yt0 = vec4::load_xmm(x->row1); yt1 = vec4::load_xmm(x->row3); - yt0 = _mm_add_ps(_mm_mul_ps(yt0, vec4::load_xmm(y)), yt1); + yt0 = _mm_add_ps(_mm_mul_ps(yt0, vec4::load_xmm(t)), yt1); *(vec3*)&z->row3 = vec3::store_xmm(yt0); } } -inline void mat4_translate_z_mult(const mat4* x, float_t y, mat4* z) { +inline void mat4_mul_translate_z(const mat4* x, float_t t, mat4* z) { __m128 yt0; __m128 yt1; if (x != z) *z = *x; - if (y != 0.0f) { + if (t != 0.0f) { yt0 = vec4::load_xmm(x->row2); yt1 = vec4::load_xmm(x->row3); - yt0 = _mm_add_ps(_mm_mul_ps(yt0, vec4::load_xmm(y)), yt1); + yt0 = _mm_add_ps(_mm_mul_ps(yt0, vec4::load_xmm(t)), yt1); *(vec3*)&z->row3 = vec3::store_xmm(yt0); } } -inline void mat4_translate_add(const mat4* s, float_t x, float_t y, float_t z, mat4* d) { - if (s != d) - *d = *s; - if (x != 0.0f || y != 0.0f || z != 0.0f) - d->row3 = vec4::store_xmm(_mm_add_ps(vec4::load_xmm(s->row3), vec4::load_xmm(vec4(x, y, z, 0.0f)))); -} - -inline void mat4_translate_x_add(const mat4* x, float_t y, mat4* z) { +inline void mat4_add_translate(const mat4* x, float_t tx, float_t ty, float_t tz, mat4* z) { if (x != z) *z = *x; - if (y != 0.0f) - z->row3.x += y; + if (tx != 0.0f || ty != 0.0f || tz != 0.0f) + z->row3 = vec4::store_xmm(_mm_add_ps(vec4::load_xmm(x->row3), vec4::load_xmm(vec4(tx, ty, tz, 0.0f)))); } -inline void mat4_translate_y_add(const mat4* x, float_t y, mat4* z) { +inline void mat4_add_translate_x(const mat4* x, float_t t, mat4* z) { if (x != z) *z = *x; - if (y != 0.0f) - z->row3.y += y; + if (t != 0.0f) + z->row3.x += t; } -inline void mat4_translate_z_add(const mat4* x, float_t y, mat4* z) { +inline void mat4_add_translate_y(const mat4* x, float_t t, mat4* z) { if (x != z) *z = *x; - if (y != 0.0f) - z->row3.z += y; + if (t != 0.0f) + z->row3.y += t; +} + +inline void mat4_add_translate_z(const mat4* x, float_t t, mat4* z) { + if (x != z) + *z = *x; + if (t != 0.0f) + z->row3.z += t; } inline void mat4_from_quat(const quat* quat, mat4* mat) { @@ -1989,61 +1922,61 @@ void mat4_from_two_vectors(const vec3* x, const vec3* y, mat4* mat) { } inline void mat4_from_axis_angle(const vec3* axis, float_t angle, mat4* mat) { - float_t angle_sin; - float_t angle_cos; - float_t angle_cos_1; + float_t s; + float_t c; + float_t c_1; vec3 _axis; - vec3 _axis_sin; + vec3 _axis_s; vec3 temp; - angle_sin = sinf(angle); - angle_cos = cosf(angle); - angle_cos_1 = 1.0f - angle_cos; + s = sinf(angle); + c = cosf(angle); + c_1 = 1.0f - c; _axis = vec3::normalize(*axis); - _axis_sin = _axis * angle_sin; - temp = _axis * (_axis.x * angle_cos_1); - mat->row0.x = temp.x + angle_cos; - mat->row1.x = temp.y - _axis_sin.z; - mat->row2.x = temp.z + _axis_sin.y; - temp = _axis * (_axis.y * angle_cos_1); - mat->row0.y = temp.x + _axis_sin.z; - mat->row1.y = temp.y + angle_cos; - mat->row2.y = temp.z - _axis_sin.x; - temp = _axis * (_axis.z * angle_cos_1); - mat->row0.z = temp.x - _axis_sin.y; - mat->row1.z = temp.y + _axis_sin.x; - mat->row2.z = temp.z + angle_cos; + _axis_s = _axis * s; + temp = _axis * (_axis.x * c_1); + mat->row0.x = temp.x + c; + mat->row1.x = temp.y - _axis_s.z; + mat->row2.x = temp.z + _axis_s.y; + temp = _axis * (_axis.y * c_1); + mat->row0.y = temp.x + _axis_s.z; + mat->row1.y = temp.y + c; + mat->row2.y = temp.z - _axis_s.x; + temp = _axis * (_axis.z * c_1); + mat->row0.z = temp.x - _axis_s.y; + mat->row1.z = temp.y + _axis_s.x; + mat->row2.z = temp.z + c; mat->row0.w = 0.0f; mat->row1.w = 0.0f; mat->row2.w = 0.0f; mat->row3 = { 0.0f, 0.0f, 0.0f, 1.0f }; } -inline void mat4_from_axis_angle_sin_cos(const vec3* axis, float_t sin_val, float_t cos_val, mat4* mat) { - float_t cos_val_1; +inline void mat4_from_axis_angle(const vec3* axis, float_t s, float_t c, mat4* mat) { + float_t c_1; vec3 _axis; - vec3 _axis_sin; + vec3 _axis_s; vec3 temp; - cos_val_1 = 1.0f - cos_val; + c_1 = 1.0f - c; _axis = vec3::normalize(*axis); - _axis_sin = _axis * sin_val; - temp = _axis * (_axis.x * cos_val_1); - mat->row0.x = temp.x + cos_val; - mat->row1.x = temp.y - _axis_sin.z; - mat->row2.x = temp.z + _axis_sin.y; - temp = _axis * (_axis.y * cos_val_1); - mat->row0.y = temp.x + _axis_sin.z; - mat->row1.y = temp.y + cos_val; - mat->row2.y = temp.z - _axis_sin.x; - temp = _axis * (_axis.z * cos_val_1); - mat->row0.z = temp.x - _axis_sin.y; - mat->row1.z = temp.y + _axis_sin.x; - mat->row2.z = temp.z + cos_val; + _axis_s = _axis * s; + temp = _axis * (_axis.x * c_1); + mat->row0.x = temp.x + c; + mat->row1.x = temp.y - _axis_s.z; + mat->row2.x = temp.z + _axis_s.y; + temp = _axis * (_axis.y * c_1); + mat->row0.y = temp.x + _axis_s.z; + mat->row1.y = temp.y + c; + mat->row2.y = temp.z - _axis_s.x; + temp = _axis * (_axis.z * c_1); + mat->row0.z = temp.x - _axis_s.y; + mat->row1.z = temp.y + _axis_s.x; + mat->row2.z = temp.z + c; mat->row0.w = 0.0f; mat->row1.w = 0.0f; mat->row2.w = 0.0f; diff --git a/src/KKdLib/mat.hpp b/src/KKdLib/mat.hpp index 67a82b7b..eb572cea 100644 --- a/src/KKdLib/mat.hpp +++ b/src/KKdLib/mat.hpp @@ -45,12 +45,16 @@ extern const mat3 mat3_null; extern const mat4 mat4_identity; extern const mat4 mat4_null; +extern void mat3_add(const mat3* x, float_t y, mat3* z); extern void mat3_add(const mat3* x, const mat3* y, mat3* z); +extern void mat3_sub(const mat3* x, float_t y, mat3* z); extern void mat3_sub(const mat3* x, const mat3* y, mat3* z); -extern void mat3_mult(const mat3* x, const mat3* y, mat3* z); -extern void mat3_mult_vec2(const mat3* x, const vec2* y, vec2* z); -extern void mat3_mult_vec(const mat3* x, const vec3* y, vec3* z); -extern void mat3_mult_scalar(const mat3* x, float_t y, mat3* z); +extern void mat3_mul(const mat3* x, float_t y, mat3* z); +extern void mat3_mul(const mat3* x, const mat3* y, mat3* z); +extern void mat3_transform_vector(const mat3* x, const vec2* y, vec2* z); +extern void mat3_transform_vector(const mat3* x, const vec3* y, vec3* z); +extern void mat3_inverse_transform_vector(const mat3* x, const vec2* y, vec2* z); +extern void mat3_inverse_transform_vector(const mat3* x, const vec3* y, vec3* z); extern void mat3_transpose(const mat3* x, mat3* z); extern void mat3_inverse(const mat3* x, mat3* z); extern void mat3_invtrans(const mat3* x, mat3* z); @@ -58,41 +62,41 @@ extern void mat3_inverse_normalized(const mat3* x, mat3* z); extern void mat3_normalize(const mat3* x, mat3* z); extern void mat3_normalize_rotation(const mat3* x, mat3* z); extern float_t mat3_determinant(const mat3* x); -extern void mat3_rotate_xyz(float_t x, float_t y, float_t z, mat3* d); -extern void mat3_rotate_xzy(float_t x, float_t y, float_t z, mat3* d); -extern void mat3_rotate_yxz(float_t x, float_t y, float_t z, mat3* d); -extern void mat3_rotate_yzx(float_t x, float_t y, float_t z, mat3* d); -extern void mat3_rotate_zxy(float_t x, float_t y, float_t z, mat3* d); -extern void mat3_rotate_zyx(float_t x, float_t y, float_t z, mat3* d); -extern void mat3_rotate_x(float_t x, mat3* y); -extern void mat3_rotate_y(float_t x, mat3* y); -extern void mat3_rotate_z(float_t x, mat3* y); -extern void mat3_rotate_xyz_mult(const mat3* s, float_t x, float_t y, float_t z, mat3* d); -extern void mat3_rotate_xzy_mult(const mat3* s, float_t x, float_t y, float_t z, mat3* d); -extern void mat3_rotate_yxz_mult(const mat3* s, float_t x, float_t y, float_t z, mat3* d); -extern void mat3_rotate_yzx_mult(const mat3* s, float_t x, float_t y, float_t z, mat3* d); -extern void mat3_rotate_zxy_mult(const mat3* s, float_t x, float_t y, float_t z, mat3* d); -extern void mat3_rotate_zyx_mult(const mat3* s, float_t x, float_t y, float_t z, mat3* d); -extern void mat3_rotate_x_mult(const mat3* x, float_t y, mat3* z); -extern void mat3_rotate_y_mult(const mat3* x, float_t y, mat3* z); -extern void mat3_rotate_z_mult(const mat3* x, float_t y, mat3* z); -extern void mat3_rotate_x_sin_cos(float_t sin_val, float_t cos_val, mat3* y); -extern void mat3_rotate_y_sin_cos(float_t sin_val, float_t cos_val, mat3* y); -extern void mat3_rotate_z_sin_cos(float_t sin_val, float_t cos_val, mat3* y); -extern void mat3_rotate_x_mult_sin_cos(const mat3* x, float_t sin_val, float_t cos_val, mat3* z); -extern void mat3_rotate_y_mult_sin_cos(const mat3* x, float_t sin_val, float_t cos_val, mat3* z); -extern void mat3_rotate_z_mult_sin_cos(const mat3* x, float_t sin_val, float_t cos_val, mat3* z); -extern void mat3_scale(float_t x, float_t y, float_t z, mat3* d); -extern void mat3_scale_x(float_t x, mat3* y); -extern void mat3_scale_y(float_t x, mat3* y); -extern void mat3_scale_z(float_t x, mat3* y); -extern void mat3_scale_mult(const mat3* s, float_t x, float_t y, float_t z, mat3* d); -extern void mat3_scale_x_mult(const mat3* x, float_t y, mat3* z); -extern void mat3_scale_y_mult(const mat3* x, float_t y, mat3* z); -extern void mat3_scale_z_mult(const mat3* x, float_t y, mat3* z); +extern void mat3_rotate_x(float_t rad, mat3* y); +extern void mat3_rotate_y(float_t rad, mat3* y); +extern void mat3_rotate_z(float_t rad, mat3* y); +extern void mat3_rotate_x(float_t s, float_t c, mat3* y); +extern void mat3_rotate_y(float_t s, float_t c, mat3* y); +extern void mat3_rotate_z(float_t s, float_t c, mat3* y); +extern void mat3_rotate_xyz(float_t rad_x, float_t rad_y, float_t rad_z, mat3* z); +extern void mat3_rotate_xzy(float_t rad_x, float_t rad_y, float_t rad_z, mat3* z); +extern void mat3_rotate_yxz(float_t rad_x, float_t rad_y, float_t rad_z, mat3* z); +extern void mat3_rotate_yzx(float_t rad_x, float_t rad_y, float_t rad_z, mat3* z); +extern void mat3_rotate_zxy(float_t rad_x, float_t rad_y, float_t rad_z, mat3* z); +extern void mat3_rotate_zyx(float_t rad_x, float_t rad_y, float_t rad_z, mat3* z); +extern void mat3_mul_rotate_x(const mat3* x, float_t rad, mat3* z); +extern void mat3_mul_rotate_y(const mat3* x, float_t rad, mat3* z); +extern void mat3_mul_rotate_z(const mat3* x, float_t rad, mat3* z); +extern void mat3_mul_rotate_x(const mat3* x, float_t s, float_t c, mat3* z); +extern void mat3_mul_rotate_y(const mat3* x, float_t s, float_t c, mat3* z); +extern void mat3_mul_rotate_z(const mat3* x, float_t s, float_t c, mat3* z); +extern void mat3_mul_rotate_xyz(const mat3* x, float_t rad_x, float_t rad_y, float_t rad_z, mat3* z); +extern void mat3_mul_rotate_xzy(const mat3* x, float_t rad_x, float_t rad_y, float_t rad_z, mat3* z); +extern void mat3_mul_rotate_yxz(const mat3* x, float_t rad_x, float_t rad_y, float_t rad_z, mat3* z); +extern void mat3_mul_rotate_yzx(const mat3* x, float_t rad_x, float_t rad_y, float_t rad_z, mat3* z); +extern void mat3_mul_rotate_zxy(const mat3* x, float_t rad_x, float_t rad_y, float_t rad_z, mat3* z); +extern void mat3_mul_rotate_zyx(const mat3* x, float_t rad_x, float_t rad_y, float_t rad_z, mat3* z); +extern void mat3_scale(float_t sx, float_t sy, float_t sz, mat3* z); +extern void mat3_scale_x(float_t s, mat3* y); +extern void mat3_scale_y(float_t s, mat3* y); +extern void mat3_scale_z(float_t s, mat3* y); +extern void mat3_mul_scale(const mat3* x, float_t sx, float_t sy, float_t sz, mat3* z); +extern void mat3_mul_scale_x(const mat3* x, float_t s, mat3* z); +extern void mat3_mul_scale_y(const mat3* x, float_t s, mat3* z); +extern void mat3_mul_scale_z(const mat3* x, float_t s, mat3* z); extern void mat3_from_quat(const quat* quat, mat3* mat); extern void mat3_from_axis_angle(const vec3* axis, float_t angle, mat3* mat); -extern void mat3_from_axis_angle_sin_cos(const vec3* axis, float_t sin_val, float_t cos_val, mat3* mat); +extern void mat3_from_axis_angle(const vec3* axis, float_t s, float_t c, mat3* mat); extern void mat3_from_mat4(const mat4* x, mat3* z); extern void mat3_from_mat4_inverse(const mat4* x, mat3* z); extern void mat3_get_rotation(const mat3* x, vec3* z); @@ -100,17 +104,22 @@ extern void mat3_get_scale(const mat3* x, vec3* z); extern float_t mat3_get_max_scale(const mat3* x); extern void mat3_mult_axis_angle(const mat3* x, const vec3* axis, const float_t angle, mat3* z); +extern void mat4_add(const mat4* x, float_t y, mat4* z); extern void mat4_add(const mat4* x, const mat4* y, mat4* z); +extern void mat4_sub(const mat4* x, float_t y, mat4* z); extern void mat4_sub(const mat4* x, const mat4* y, mat4* z); -extern void mat4_mult(const mat4* x, const mat4* y, mat4* z); -extern void mat4_mult_vec2(const mat4* x, const vec2* y, vec2* z); -extern void mat4_mult_vec2_trans(const mat4* x, const vec2* y, vec2* z); -extern void mat4_mult_vec3(const mat4* x, const vec3* y, vec3* z); -extern void mat4_mult_vec3_inv(const mat4* x, const vec3* y, vec3* z); -extern void mat4_mult_vec3_trans(const mat4* x, const vec3* y, vec3* z); -extern void mat4_mult_vec3_inv_trans(const mat4* x, const vec3* y, vec3* z); -extern void mat4_mult_vec(const mat4* x, vec4* y, vec4* z); -extern void mat4_mult_scalar(const mat4* x, float_t y, mat4* z); +extern void mat4_mul(const mat4* x, float_t y, mat4* z); +extern void mat4_mul(const mat4* x, const mat4* y, mat4* z); +extern void mat4_transform_vector(const mat4* x, const vec2* y, vec2* z); +extern void mat4_transform_vector(const mat4* x, const vec3* y, vec3* z); +extern void mat4_transform_vector(const mat4* x, const vec4* y, vec4* z); +extern void mat4_transform_point(const mat4* x, const vec2* y, vec2* z); +extern void mat4_transform_point(const mat4* x, const vec3* y, vec3* z); +extern void mat4_inverse_transform_vector(const mat4* x, const vec2* y, vec2* z); +extern void mat4_inverse_transform_vector(const mat4* x, const vec3* y, vec3* z); +extern void mat4_inverse_transform_vector(const mat4* x, const vec4* y, vec4* z); +extern void mat4_inverse_transform_point(const mat4* x, const vec2* y, vec2* z); +extern void mat4_inverse_transform_point(const mat4* x, const vec3* y, vec3* z); extern void mat4_transpose(const mat4* x, mat4* z); extern void mat4_inverse(const mat4* x, mat4* z); extern void mat4_invtrans(const mat4* x, mat4* z); @@ -120,59 +129,59 @@ extern void mat4_invrot_normalized(const mat4* x, mat4* z); extern void mat4_normalize(const mat4* x, mat4* z); extern void mat4_normalize_rotation(const mat4* x, mat4* z); extern float_t mat4_determinant(const mat4* x); -extern void mat4_rotate_xyz(float_t x, float_t y, float_t z, mat4* d); -extern void mat4_rotate_xzy(float_t x, float_t y, float_t z, mat4* d); -extern void mat4_rotate_yxz(float_t x, float_t y, float_t z, mat4* d); -extern void mat4_rotate_yzx(float_t x, float_t y, float_t z, mat4* d); -extern void mat4_rotate_zxy(float_t x, float_t y, float_t z, mat4* d); -extern void mat4_rotate_zyx(float_t x, float_t y, float_t z, mat4* d); -extern void mat4_rotate_x(float_t x, mat4* y); -extern void mat4_rotate_y(float_t x, mat4* y); -extern void mat4_rotate_z(float_t x, mat4* y); -extern void mat4_rotate_xyz_mult(const mat4* s, float_t x, float_t y, float_t z, mat4* d); -extern void mat4_rotate_xzy_mult(const mat4* s, float_t x, float_t y, float_t z, mat4* d); -extern void mat4_rotate_yxz_mult(const mat4* s, float_t x, float_t y, float_t z, mat4* d); -extern void mat4_rotate_yzx_mult(const mat4* s, float_t x, float_t y, float_t z, mat4* d); -extern void mat4_rotate_zxy_mult(const mat4* s, float_t x, float_t y, float_t z, mat4* d); -extern void mat4_rotate_zyx_mult(const mat4* s, float_t x, float_t y, float_t z, mat4* d); -extern void mat4_rotate_x_mult(const mat4* x, float_t y, mat4* z); -extern void mat4_rotate_y_mult(const mat4* x, float_t y, mat4* z); -extern void mat4_rotate_z_mult(const mat4* x, float_t y, mat4* z); -extern void mat4_rotate_x_sin_cos(float_t sin_val, float_t cos_val, mat4* y); -extern void mat4_rotate_y_sin_cos(float_t sin_val, float_t cos_val, mat4* y); -extern void mat4_rotate_z_sin_cos(float_t sin_val, float_t cos_val, mat4* y); -extern void mat4_rotate_x_mult_sin_cos(const mat4* x, float_t sin_val, float_t cos_val, mat4* z); -extern void mat4_rotate_y_mult_sin_cos(const mat4* x, float_t sin_val, float_t cos_val, mat4* z); -extern void mat4_rotate_z_mult_sin_cos(const mat4* x, float_t sin_val, float_t cos_val, mat4* z); -extern void mat4_scale(float_t x, float_t y, float_t z, mat4* d); -extern void mat4_scale_x(float_t x, mat4* y); -extern void mat4_scale_y(float_t x, mat4* y); -extern void mat4_scale_z(float_t x, mat4* y); -extern void mat4_scale_mult(const mat4* s, float_t x, float_t y, float_t z, float_t w, mat4* d); -extern void mat4_scale_x_mult(const mat4* x, float_t y, mat4* z); -extern void mat4_scale_y_mult(const mat4* x, float_t y, mat4* z); -extern void mat4_scale_z_mult(const mat4* x, float_t y, mat4* z); -extern void mat4_scale_w_mult(const mat4* x, float_t y, mat4* z); -extern void mat4_scale_rot(const mat4* s, float_t x, float_t y, float_t z, mat4* d); -extern void mat4_scale_x_rot(const mat4* x, float_t y, mat4* z); -extern void mat4_scale_y_rot(const mat4* x, float_t y, mat4* z); -extern void mat4_scale_z_rot(const mat4* x, float_t y, mat4* z); -extern void mat4_translate(float_t x, float_t y, float_t z, mat4* d); -extern void mat4_translate_x(float_t x, mat4* y); -extern void mat4_translate_y(float_t x, mat4* y); -extern void mat4_translate_z(float_t x, mat4* y); -extern void mat4_translate_mult(const mat4* s, float_t x, float_t y, float_t z, mat4* d); -extern void mat4_translate_x_mult(const mat4* x, float_t y, mat4* z); -extern void mat4_translate_y_mult(const mat4* x, float_t y, mat4* z); -extern void mat4_translate_z_mult(const mat4* x, float_t y, mat4* z); -extern void mat4_translate_add(const mat4* s, float_t x, float_t y, float_t z, mat4* d); -extern void mat4_translate_x_add(const mat4* x, float_t y, mat4* z); -extern void mat4_translate_y_add(const mat4* x, float_t y, mat4* z); -extern void mat4_translate_z_add(const mat4* x, float_t y, mat4* z); +extern void mat4_rotate_x(float_t rad, mat4* y); +extern void mat4_rotate_y(float_t rad, mat4* y); +extern void mat4_rotate_z(float_t rad, mat4* y); +extern void mat4_rotate_x(float_t s, float_t c, mat4* y); +extern void mat4_rotate_y(float_t s, float_t c, mat4* y); +extern void mat4_rotate_z(float_t s, float_t c, mat4* y); +extern void mat4_rotate_xyz(float_t rad_x, float_t rad_y, float_t rad_z, mat4* z); +extern void mat4_rotate_xzy(float_t rad_x, float_t rad_y, float_t rad_z, mat4* z); +extern void mat4_rotate_yxz(float_t rad_x, float_t rad_y, float_t rad_z, mat4* z); +extern void mat4_rotate_yzx(float_t rad_x, float_t rad_y, float_t rad_z, mat4* z); +extern void mat4_rotate_zxy(float_t rad_x, float_t rad_y, float_t rad_z, mat4* z); +extern void mat4_rotate_zyx(float_t rad_x, float_t rad_y, float_t rad_z, mat4* z); +extern void mat4_mul_rotate_x(const mat4* x, float_t rad, mat4* z); +extern void mat4_mul_rotate_y(const mat4* x, float_t rad, mat4* z); +extern void mat4_mul_rotate_z(const mat4* x, float_t rad, mat4* z); +extern void mat4_mul_rotate_x(const mat4* x, float_t s, float_t c, mat4* z); +extern void mat4_mul_rotate_y(const mat4* x, float_t s, float_t c, mat4* z); +extern void mat4_mul_rotate_z(const mat4* x, float_t s, float_t c, mat4* z); +extern void mat4_mul_rotate_xyz(const mat4* x, float_t rad_x, float_t rad_y, float_t rad_z, mat4* z); +extern void mat4_mul_rotate_xzy(const mat4* x, float_t rad_x, float_t rad_y, float_t rad_z, mat4* z); +extern void mat4_mul_rotate_yxz(const mat4* x, float_t rad_x, float_t rad_y, float_t rad_z, mat4* z); +extern void mat4_mul_rotate_yzx(const mat4* x, float_t rad_x, float_t rad_y, float_t rad_z, mat4* z); +extern void mat4_mul_rotate_zxy(const mat4* x, float_t rad_x, float_t rad_y, float_t rad_z, mat4* z); +extern void mat4_mul_rotate_zyx(const mat4* x, float_t rad_x, float_t rad_y, float_t rad_z, mat4* z); +extern void mat4_scale(float_t sx, float_t sy, float_t sz, mat4* z); +extern void mat4_scale_x(float_t s, mat4* y); +extern void mat4_scale_y(float_t s, mat4* y); +extern void mat4_scale_z(float_t s, mat4* y); +extern void mat4_mul_scale(const mat4* x, float_t sx, float_t sy, float_t sz, float_t sw, mat4* z); +extern void mat4_mul_scale_x(const mat4* x, float_t s, mat4* z); +extern void mat4_mul_scale_y(const mat4* x, float_t s, mat4* z); +extern void mat4_mul_scale_z(const mat4* x, float_t s, mat4* z); +extern void mat4_scale_w_mult(const mat4* x, float_t s, mat4* z); +extern void mat4_scale_rot(const mat4* x, float_t sx, float_t sy, float_t sz, mat4* z); +extern void mat4_scale_x_rot(const mat4* x, float_t s, mat4* z); +extern void mat4_scale_y_rot(const mat4* x, float_t s, mat4* z); +extern void mat4_scale_z_rot(const mat4* x, float_t s, mat4* z); +extern void mat4_translate(float_t tx, float_t ty, float_t tz, mat4* z); +extern void mat4_translate_x(float_t t, mat4* y); +extern void mat4_translate_y(float_t t, mat4* y); +extern void mat4_translate_z(float_t t, mat4* y); +extern void mat4_mul_translate(const mat4* x, float_t tx, float_t ty, float_t tz, mat4* z); +extern void mat4_mul_translate_x(const mat4* x, float_t t, mat4* z); +extern void mat4_mul_translate_y(const mat4* x, float_t t, mat4* z); +extern void mat4_mul_translate_z(const mat4* x, float_t t, mat4* z); +extern void mat4_add_translate(const mat4* x, float_t tx, float_t ty, float_t tz, mat4* z); +extern void mat4_add_translate_x(const mat4* x, float_t t, mat4* z); +extern void mat4_add_translate_y(const mat4* x, float_t t, mat4* z); +extern void mat4_add_translate_z(const mat4* x, float_t t, mat4* z); extern void mat4_from_quat(const quat* quat, mat4* mat); extern void mat4_from_two_vectors(const vec3* x, const vec3* y, mat4* mat); extern void mat4_from_axis_angle(const vec3* axis, float_t angle, mat4* mat); -extern void mat4_from_axis_angle_sin_cos(const vec3* axis, float_t sin_val, float_t cos_val, mat4* mat); +extern void mat4_from_axis_angle(const vec3* axis, float_t s, float_t c, mat4* mat); extern void mat4_from_mat3(const mat3* x, mat4* z); extern void mat4_from_mat3_inverse(const mat3* x, mat4* z); extern void mat4_clear_rot(mat4* x, mat4* z); @@ -194,142 +203,142 @@ extern void mat4_persp(double_t fov_y, double_t aspect, double_t z_near, double_ extern void mat4_look_at(const vec3* eye, const vec3* target, const vec3* up, mat4* mat); extern void mat4_look_at(const vec3* eye, const vec3* target, mat4* mat); -inline void mat3_rotate_xyz(const vec3* s, mat3* d) { - mat3_rotate_xyz(s->x, s->y, s->z, d); +inline void mat3_rotate_xyz(const vec3* rad, mat3* z) { + mat3_rotate_xyz(rad->x, rad->y, rad->z, z); } -inline void mat3_rotate_xzy(const vec3* s, mat3* d) { - mat3_rotate_xzy(s->x, s->y, s->z, d); +inline void mat3_rotate_xzy(const vec3* rad, mat3* z) { + mat3_rotate_xzy(rad->x, rad->y, rad->z, z); } -inline void mat3_rotate_yxz(const vec3* s, mat3* d) { - mat3_rotate_yxz(s->x, s->y, s->z, d); +inline void mat3_rotate_yxz(const vec3* rad, mat3* z) { + mat3_rotate_yxz(rad->x, rad->y, rad->z, z); } -inline void mat3_rotate_yzx(const vec3* s, mat3* d) { - mat3_rotate_yzx(s->x, s->y, s->z, d); +inline void mat3_rotate_yzx(const vec3* rad, mat3* z) { + mat3_rotate_yzx(rad->x, rad->y, rad->z, z); } -inline void mat3_rotate_zxy(const vec3* s, mat3* d) { - mat3_rotate_zxy(s->x, s->y, s->z, d); +inline void mat3_rotate_zxy(const vec3* rad, mat3* z) { + mat3_rotate_zxy(rad->x, rad->y, rad->z, z); } -inline void mat3_rotate_zyx(const vec3* s, mat3* d) { - mat3_rotate_zyx(s->x, s->y, s->z, d); +inline void mat3_rotate_zyx(const vec3* rad, mat3* z) { + mat3_rotate_zyx(rad->x, rad->y, rad->z, z); } -inline void mat3_rotate_xyz_mult(const mat3* s, const vec3* y, mat3* d) { - mat3_rotate_xyz_mult(s, y->x, y->y, y->z, d); +inline void mat3_mul_rotate_xyz(const mat3* x, const vec3* rad, mat3* z) { + mat3_mul_rotate_xyz(x, rad->x, rad->y, rad->z, z); } -inline void mat3_rotate_xzy_mult(const mat3* s, const vec3* y, mat3* d) { - mat3_rotate_xzy_mult(s, y->x, y->y, y->z, d); +inline void mat3_mul_rotate_xzy(const mat3* x, const vec3* rad, mat3* z) { + mat3_mul_rotate_xzy(x, rad->x, rad->y, rad->z, z); } -inline void mat3_rotate_yxz_mult(const mat3* s, const vec3* y, mat3* d) { - mat3_rotate_yxz_mult(s, y->x, y->y, y->z, d); +inline void mat3_mul_rotate_yxz(const mat3* x, const vec3* rad, mat3* z) { + mat3_mul_rotate_yxz(x, rad->x, rad->y, rad->z, z); } -inline void mat3_rotate_yzx_mult(const mat3* s, const vec3* y, mat3* d) { - mat3_rotate_yzx_mult(s, y->x, y->y, y->z, d); +inline void mat3_mul_rotate_yzx(const mat3* x, const vec3* rad, mat3* z) { + mat3_mul_rotate_yzx(x, rad->x, rad->y, rad->z, z); } -inline void mat3_rotate_zxy_mult(const mat3* s, const vec3* y, mat3* d) { - mat3_rotate_zxy_mult(s, y->x, y->y, y->z, d); +inline void mat3_mul_rotate_zxy(const mat3* x, const vec3* rad, mat3* z) { + mat3_mul_rotate_zxy(x, rad->x, rad->y, rad->z, z); } -inline void mat3_rotate_zyx_mult(const mat3* s, const vec3* y, mat3* d) { - mat3_rotate_zyx_mult(s, y->x, y->y, y->z, d); +inline void mat3_mul_rotate_zyx(const mat3* x, const vec3* rad, mat3* z) { + mat3_mul_rotate_zyx(x, rad->x, rad->y, rad->z, z); } -inline void mat3_scale(const vec3* s, mat3* d) { - mat3_scale(s->x, s->y, s->z, d); +inline void mat3_scale(const vec3* s, mat3* z) { + mat3_scale(s->x, s->y, s->z, z); } -inline void mat3_scale_mult(const mat3* s, float_t y, mat3* d) { - mat3_scale_mult(s, y, y, y, d); +inline void mat3_mul_scale(const mat3* x, float_t s, mat3* z) { + mat3_mul_scale(x, s, s, s, z); } -inline void mat3_scale_mult(const mat3* s, const vec3* y, mat3* d) { - mat3_scale_mult(s, y->x, y->y, y->z, d); +inline void mat3_mul_scale(const mat3* x, const vec3* s, mat3* z) { + mat3_mul_scale(x, s->x, s->y, s->z, z); } -inline void mat4_rotate_xyz(const vec3* s, mat4* d) { - mat4_rotate_xyz(s->x, s->y, s->z, d); +inline void mat4_rotate_xyz(const vec3* rad, mat4* z) { + mat4_rotate_xyz(rad->x, rad->y, rad->z, z); } -inline void mat4_rotate_xzy(const vec3* s, mat4* d) { - mat4_rotate_xzy(s->x, s->y, s->z, d); +inline void mat4_rotate_xzy(const vec3* rad, mat4* z) { + mat4_rotate_xzy(rad->x, rad->y, rad->z, z); } -inline void mat4_rotate_yxz(const vec3* s, mat4* d) { - mat4_rotate_yxz(s->x, s->y, s->z, d); +inline void mat4_rotate_yxz(const vec3* rad, mat4* z) { + mat4_rotate_yxz(rad->x, rad->y, rad->z, z); } -inline void mat4_rotate_yzx(const vec3* s, mat4* d) { - mat4_rotate_yzx(s->x, s->y, s->z, d); +inline void mat4_rotate_yzx(const vec3* rad, mat4* z) { + mat4_rotate_yzx(rad->x, rad->y, rad->z, z); } -inline void mat4_rotate_zxy(const vec3* s, mat4* d) { - mat4_rotate_zxy(s->x, s->y, s->z, d); +inline void mat4_rotate_zxy(const vec3* rad, mat4* z) { + mat4_rotate_zxy(rad->x, rad->y, rad->z, z); } -inline void mat4_rotate_zyx(const vec3* s, mat4* d) { - mat4_rotate_zyx(s->x, s->y, s->z, d); +inline void mat4_rotate_zyx(const vec3* rad, mat4* z) { + mat4_rotate_zyx(rad->x, rad->y, rad->z, z); } -inline void mat4_rotate_xyz_mult(const mat4* s, const vec3* y, mat4* d) { - mat4_rotate_xyz_mult(s, y->x, y->y, y->z, d); +inline void mat4_mul_rotate_xyz(const mat4* x, const vec3* rad, mat4* z) { + mat4_mul_rotate_xyz(x, rad->x, rad->y, rad->z, z); } -inline void mat4_rotate_xzy_mult(const mat4* s, const vec3* y, mat4* d) { - mat4_rotate_xzy_mult(s, y->x, y->y, y->z, d); +inline void mat4_mul_rotate_xzy(const mat4* x, const vec3* rad, mat4* z) { + mat4_mul_rotate_xzy(x, rad->x, rad->y, rad->z, z); } -inline void mat4_rotate_yxz_mult(const mat4* s, const vec3* y, mat4* d) { - mat4_rotate_yxz_mult(s, y->x, y->y, y->z, d); +inline void mat4_mul_rotate_yxz(const mat4* x, const vec3* rad, mat4* z) { + mat4_mul_rotate_yxz(x, rad->x, rad->y, rad->z, z); } -inline void mat4_rotate_yzx_mult(const mat4* s, const vec3* y, mat4* d) { - mat4_rotate_yzx_mult(s, y->x, y->y, y->z, d); +inline void mat4_mul_rotate_yzx(const mat4* x, const vec3* rad, mat4* z) { + mat4_mul_rotate_yzx(x, rad->x, rad->y, rad->z, z); } -inline void mat4_rotate_zxy_mult(const mat4* s, const vec3* y, mat4* d) { - mat4_rotate_zxy_mult(s, y->x, y->y, y->z, d); +inline void mat4_mul_rotate_zxy(const mat4* x, const vec3* rad, mat4* z) { + mat4_mul_rotate_zxy(x, rad->x, rad->y, rad->z, z); } -inline void mat4_rotate_zyx_mult(const mat4* s, const vec3* y, mat4* d) { - mat4_rotate_zyx_mult(s, y->x, y->y, y->z, d); +inline void mat4_mul_rotate_zyx(const mat4* x, const vec3* rad, mat4* z) { + mat4_mul_rotate_zyx(x, rad->x, rad->y, rad->z, z); } -inline void mat4_scale(const vec3* s, mat4* d) { - mat4_scale(s->x, s->y, s->z, d); +inline void mat4_scale(const vec3* s, mat4* z) { + mat4_scale(s->x, s->y, s->z, z); } -inline void mat4_scale_mult(const mat4* s, float_t y, mat4* d) { - mat4_scale_mult(s, y, y, y, y, d); +inline void mat4_mul_scale(const mat4* x, float_t s, mat4* z) { + mat4_mul_scale(x, s, s, s, s, z); } -inline void mat4_scale_mult(const mat4* s, vec4* y, mat4* d) { - mat4_scale_mult(s, y->x, y->y, y->z, y->w, d); +inline void mat4_mul_scale(const mat4* x, vec4* s, mat4* z) { + mat4_mul_scale(x, s->x, s->y, s->z, s->w, z); } -inline void mat4_scale_rot(const mat4* s, const float_t y, mat4* d) { - mat4_scale_rot(s, y, y, y, d); +inline void mat4_scale_rot(const mat4* x, const float_t s, mat4* z) { + mat4_scale_rot(x, s, s, s, z); } -inline void mat4_scale_rot(const mat4* s, const vec3* y, mat4* d) { - mat4_scale_rot(s, y->x, y->y, y->z, d); +inline void mat4_scale_rot(const mat4* x, const vec3* s, mat4* z) { + mat4_scale_rot(x, s->x, s->y, s->z, z); } -inline void mat4_translate(const vec3* s, mat4* d) { - mat4_translate(s->x, s->y, s->z, d); +inline void mat4_translate(const vec3* s, mat4* z) { + mat4_translate(s->x, s->y, s->z, z); } -inline void mat4_translate_mult(const mat4* s, const vec3* y, mat4* d) { - mat4_translate_mult(s, y->x, y->y, y->z, d); +inline void mat4_mul_translate(const mat4* x, const vec3* t, mat4* z) { + mat4_mul_translate(x, t->x, t->y, t->z, z); } -inline void mat4_translate_add(const mat4* s, const vec3* y, mat4* d) { - mat4_translate_add(s, y->x, y->y, y->z, d); +inline void mat4_add_translate(const mat4* x, const vec3* t, mat4* z) { + mat4_add_translate(x, t->x, t->y, t->z, z); } diff --git a/src/KKdLib/stage_param/star.cpp b/src/KKdLib/stage_param/star.cpp index 959e67a2..864fd2ae 100644 --- a/src/KKdLib/stage_param/star.cpp +++ b/src/KKdLib/stage_param/star.cpp @@ -149,13 +149,13 @@ void stage_param_star::get_mat(mat4& mat, const float_t observer_north_latitude, float_t latitude_cos = cosf(observer_north_latitude) * 0.99664718f; vec3 x_axis = { 0.0f, latitude_cos, -latitude_sin }; - mat3_mult_vec(&rot_y, &x_axis, &x_axis); + mat3_transform_vector(&rot_y, &x_axis, &x_axis); vec3 y_axis = { 0.0f, latitude_sin, latitude_cos }; - mat3_mult_vec(&rot_y, &y_axis, &y_axis); + mat3_transform_vector(&rot_y, &y_axis, &y_axis); vec3 z_axis = { 1.0f, 0.0f, 0.0f }; - mat3_mult_vec(&rot_y, &z_axis, &z_axis); + mat3_transform_vector(&rot_y, &z_axis, &z_axis); x_axis = vec3::normalize(x_axis); y_axis = vec3::normalize(y_axis); diff --git a/src/ReDIVA/data_test/auth_3d_test.cpp b/src/ReDIVA/data_test/auth_3d_test.cpp index eb1cf44b..08555faf 100644 --- a/src/ReDIVA/data_test/auth_3d_test.cpp +++ b/src/ReDIVA/data_test/auth_3d_test.cpp @@ -442,7 +442,7 @@ bool Auth3dTestTask::Ctrl() { mat4 mat; mat4_translate(&trans_value, &mat); - mat4_rotate_y_mult(&mat, rot_y_value * DEG_TO_RAD_FLOAT, &mat); + mat4_mul_rotate_y(&mat, rot_y_value * DEG_TO_RAD_FLOAT, &mat); auth_3d_id.set_mat(mat); } diff --git a/src/ReDIVA/data_test/motion_test.cpp b/src/ReDIVA/data_test/motion_test.cpp index 30b550b0..47071db7 100644 --- a/src/ReDIVA/data_test/motion_test.cpp +++ b/src/ReDIVA/data_test/motion_test.cpp @@ -1215,7 +1215,7 @@ bool DtmMot::Ctrl() { mat4 mat; mat4_rotate_zyx(&rotation, &mat); - mat4_rotate_y_mult(&mat, rot_y, &mat); + mat4_mul_rotate_y(&mat, rot_y, &mat); mat4_set_translation(&mat, &trans); rob_bone_data->update(&mat); diff --git a/src/ReDIVA/pv_game/pv_game_camera.cpp b/src/ReDIVA/pv_game/pv_game_camera.cpp index cce5e67f..4f6a3a1b 100644 --- a/src/ReDIVA/pv_game/pv_game_camera.cpp +++ b/src/ReDIVA/pv_game/pv_game_camera.cpp @@ -288,14 +288,14 @@ static bool pv_game_camera_get_move_camera(cam_struct* cam, float_t delta_time) if (!pv_game_camera_data.follow_chara) { vec3 direction; - mat4_mult_vec3(&dir_mat, &pv_game_camera_data.view_direction, &direction); + mat4_transform_vector(&dir_mat, &pv_game_camera_data.view_direction, &direction); view_point = direction * distance + interest; } cam->interest = interest; cam->view_point = view_point; - mat4_mult_vec3(&up_mat, &pv_game_camera_data.up_vec, &cam->up); + mat4_transform_vector(&up_mat, &pv_game_camera_data.up_vec, &cam->up); cam->use_up = true; return in_transition; } diff --git a/src/ReDIVA/pv_game/pv_game_pv_data.cpp b/src/ReDIVA/pv_game/pv_game_pv_data.cpp index 234350ed..b511abb3 100644 --- a/src/ReDIVA/pv_game/pv_game_pv_data.cpp +++ b/src/ReDIVA/pv_game/pv_game_pv_data.cpp @@ -464,7 +464,7 @@ bool pv_game_pv_data::dsc_ctrl(float_t delta_time, int64_t curr_time, if (rob_chr) { pos *= (pv_game->data.pv->edit == 2 ? 1.0f : 0.227f); - mat4_mult_vec3_trans(&scene_rot_mat, &pos, &pos); + mat4_transform_point(&scene_rot_mat, &pos, &pos); rob_chr->set_data_miku_rot_position(pos); rob_chr->set_osage_reset(); } @@ -1179,12 +1179,12 @@ bool pv_game_pv_data::dsc_ctrl(float_t delta_time, int64_t curr_time, end.up_vec.y = (float_t)(int32_t)data[17] * v14; end.up_vec.z = (float_t)(int32_t)data[18] * v14; - mat4_mult_vec3_trans(&scene_rot_mat, &start.view_point, &start.view_point); - mat4_mult_vec3_trans(&scene_rot_mat, &start.interest, &start.interest); - mat4_mult_vec3_trans(&scene_rot_mat, &start.up_vec, &start.up_vec); - mat4_mult_vec3_trans(&scene_rot_mat, &end.view_point, &end.view_point); - mat4_mult_vec3_trans(&scene_rot_mat, &end.interest, &end.interest); - mat4_mult_vec3_trans(&scene_rot_mat, &end.up_vec, &end.up_vec); + mat4_transform_point(&scene_rot_mat, &start.view_point, &start.view_point); + mat4_transform_point(&scene_rot_mat, &start.interest, &start.interest); + mat4_transform_point(&scene_rot_mat, &start.up_vec, &start.up_vec); + mat4_transform_point(&scene_rot_mat, &end.view_point, &end.view_point); + mat4_transform_point(&scene_rot_mat, &end.interest, &end.interest); + mat4_transform_point(&scene_rot_mat, &end.up_vec, &end.up_vec); float_t acceleration_1 = 0.0f; if ((int32_t)data[19] != -1) @@ -1270,8 +1270,8 @@ bool pv_game_pv_data::dsc_ctrl(float_t delta_time, int64_t curr_time, float_t v5 = pv_game->data.pv->edit == 2 ? 1.0f : 0.227f; start_pos *= v5; end_pos *= v5; - mat4_mult_vec3_trans(&scene_rot_mat, &start_pos, &start_pos); - mat4_mult_vec3_trans(&scene_rot_mat, &end_pos, &end_pos); + mat4_transform_point(&scene_rot_mat, &start_pos, &start_pos); + mat4_transform_point(&scene_rot_mat, &end_pos, &end_pos); playdata->motion_data.set(playdata->rob_chr, duration, start_pos, end_pos, start_rot + scene_rot_y, end_rot + scene_rot_y); playdata->motion_data.ctrl(0.0f); @@ -1295,8 +1295,8 @@ bool pv_game_pv_data::dsc_ctrl(float_t delta_time, int64_t curr_time, float_t v5 = pv_game->data.pv->edit == 2 ? 1.0f : 0.227f; start_pos *= v5; end_pos *= v5; - mat4_mult_vec3_trans(&scene_rot_mat, &start_pos, &start_pos); - mat4_mult_vec3_trans(&scene_rot_mat, &end_pos, &end_pos); + mat4_transform_point(&scene_rot_mat, &start_pos, &start_pos); + mat4_transform_point(&scene_rot_mat, &end_pos, &end_pos); playdata->motion_data.set(playdata->rob_chr, duration, start_pos, end_pos, start_rot + scene_rot_y, end_rot + scene_rot_y); playdata->motion_data.ctrl(0.0f); @@ -1665,7 +1665,7 @@ bool pv_game_pv_data::dsc_ctrl(float_t delta_time, int64_t curr_time, if (!rob_chr) break; - mat4_mult_vec3_trans(&scene_rot_mat, &pos, &pos); + mat4_transform_point(&scene_rot_mat, &pos, &pos); rob_chr->set_chara_pos_adjust(pos); if (rob_chr->check_for_ageageagain_module()) { rob_chara_age_age_array_set_skip(rob_chr->chara_id, 1); diff --git a/src/ReDIVA/x_pv_game.cpp b/src/ReDIVA/x_pv_game.cpp index 28b5fa42..a266c667 100644 --- a/src/ReDIVA/x_pv_game.cpp +++ b/src/ReDIVA/x_pv_game.cpp @@ -6435,7 +6435,7 @@ static bool x_pv_game_dsc_process(x_pv_game* a1, int64_t curr_time) { if (!rob_chr) break; - mat4_mult_vec3_trans(&a1->scene_rot_mat, &pos, &pos); + mat4_transform_point(&a1->scene_rot_mat, &pos, &pos); rob_chr->set_data_miku_rot_position(pos); rob_chr->set_osage_reset(); } break; @@ -7116,7 +7116,7 @@ static bool x_pv_game_dsc_process(x_pv_game* a1, int64_t curr_time) { if (!rob_chr) break; - mat4_mult_vec3_trans(&a1->scene_rot_mat, &pos, &pos); + mat4_transform_point(&a1->scene_rot_mat, &pos, &pos); rob_chr->set_chara_pos_adjust(pos); if (rob_chr->check_for_ageageagain_module()) { @@ -7628,7 +7628,7 @@ static void x_pv_game_map_auth_3d_to_mot(x_pv_game* xpvgm, bool add_keys) { MOTION_BONE_N_HARA, key_set, data); data[0] = { 0.0f, 0.945f, 0.0f }; - mat4_mult_vec3(&oh->node[a2m.j_mune_wj].model_transform.mat, &data[0], &data[1]); + mat4_transform_vector(&oh->node[a2m.j_mune_wj].model_transform.mat, &data[0], &data[1]); mat4_get_translation(&oh->node[a2m.j_mune_wj].model_transform.mat, &data[0]); data[0] += data[1]; data[1] = 0.0f; @@ -7648,7 +7648,7 @@ static void x_pv_game_map_auth_3d_to_mot(x_pv_game* xpvgm, bool add_keys) { MOTION_BONE_N_KAO, key_set, data); data[0] = { 0.0f, 0.40f, 0.0f }; - mat4_mult_vec3(&oh->node[a2m.j_kao_wj].model_transform.mat, &data[0], &data[1]); + mat4_transform_vector(&oh->node[a2m.j_kao_wj].model_transform.mat, &data[0], &data[1]); mat4_get_translation(&oh->node[a2m.j_kao_wj].model_transform.mat, &data[0]); data[0] += data[1]; data[1] = oh->node[a2m.j_kao_wj].model_transform.rotation_value; @@ -7692,14 +7692,14 @@ static void x_pv_game_map_auth_3d_to_mot(x_pv_game* xpvgm, bool add_keys) { if (pos_middle_dist == 0.0f) { mat4& mat = oh->node[a2m.j_kata_l_wj].model_transform.mat; data[0] = { 0.0f, 0.3f, 0.0f }; - mat4_mult_vec3(&mat, &data[0], &tl_up_kata_dir); + mat4_transform_vector(&mat, &data[0], &tl_up_kata_dir); } else tl_up_kata_dir *= 0.3f / pos_middle_dist; vec3 tl_up_kata_pos = tl_up_kata_dir + pos_j_ude_l_wj; mat4& mat = oh->node[a2m.j_mune_b_wj].model_transform.mat; - mat4_mult_vec3_inv_trans(&mat, &tl_up_kata_pos, &data[0]); + mat4_inverse_transform_point(&mat, &tl_up_kata_pos, &data[0]); set_bone_key_set_data(bone_data, a2m.bone_keys, a2m.sec_bone_keys, add_keys, MOTION_BONE_TL_UP_KATA_L, key_set, data); } @@ -7734,14 +7734,14 @@ static void x_pv_game_map_auth_3d_to_mot(x_pv_game* xpvgm, bool add_keys) { if (pos_middle_dist == 0.0f) { mat4& mat = oh->node[a2m.j_kata_r_wj].model_transform.mat; data[0] = { 0.0f, 0.3f, 0.0f }; - mat4_mult_vec3(&mat, &data[0], &tl_up_kata_dir); + mat4_transform_vector(&mat, &data[0], &tl_up_kata_dir); } else tl_up_kata_dir *= 0.3f / pos_middle_dist; vec3 tl_up_kata_pos = tl_up_kata_dir + pos_j_ude_r_wj; mat4& mat = oh->node[a2m.j_mune_b_wj].model_transform.mat; - mat4_mult_vec3_inv_trans(&mat, &tl_up_kata_pos, &data[0]); + mat4_inverse_transform_point(&mat, &tl_up_kata_pos, &data[0]); set_bone_key_set_data(bone_data, a2m.bone_keys, a2m.sec_bone_keys, add_keys, MOTION_BONE_TL_UP_KATA_R, key_set, data); } @@ -8228,10 +8228,10 @@ static void x_pv_game_split_auth_3d_hrc_material_list(x_pv_game* xpvgm, vec3 normal = vertex.normal; vec3 tangent = *(vec3*)&vertex.tangent; vec3 binormal = vec3::cross(normal, tangent) * vertex.tangent.w; - mat4_mult_vec3_trans(&mat, &vertex.position, &vertex.position); - mat4_mult_vec3(&mat, &normal, &normal); - mat4_mult_vec3(&mat, &tangent, &tangent); - mat4_mult_vec3(&mat, &binormal, &binormal); + mat4_transform_point(&mat, &vertex.position, &vertex.position); + mat4_transform_vector(&mat, &normal, &normal); + mat4_transform_vector(&mat, &tangent, &tangent); + mat4_transform_vector(&mat, &binormal, &binormal); tangent = vec3::normalize(tangent - normal * vec3::dot(normal, tangent)); vertex.normal = normal; *(vec3*)&vertex.tangent = tangent; @@ -8661,8 +8661,8 @@ static void x_pv_game_split_auth_3d_hrc_material_list(x_pv_game* xpvgm, node->interpolate(o); mat4 mat; - mat4_mult(&node->model_transform.mat_inner, &node->joint_orient_mat, &mat); - mat4_mult(&rot_mat, &mat, &mat); + mat4_mul(&node->model_transform.mat_inner, &node->joint_orient_mat, &mat); + mat4_mul(&rot_mat, &mat, &mat); vec3 rotation; mat4_get_rotation(&mat, &rotation);