Add vm_angles_2_matrix that returns result
This commit is contained in:
parent
fd9a9a5166
commit
141a7602d0
|
@ -54,17 +54,12 @@ void g3_start_instance_matrix(const vms_vector &pos,const vms_matrix *orient)
|
|||
//if angles==NULL, don't modify matrix. This will be like doing an offset
|
||||
void g3_start_instance_angles(const vms_vector &pos,const vms_angvec *angles)
|
||||
{
|
||||
vms_matrix tm;
|
||||
|
||||
if (angles==NULL) {
|
||||
g3_start_instance_matrix(pos,NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
vm_angles_2_matrix(tm,*angles);
|
||||
|
||||
const auto tm = vm_angles_2_matrix(*angles);
|
||||
g3_start_instance_matrix(pos,&tm);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -279,6 +279,12 @@ fixang vm_vec_delta_ang_norm (const vms_vector &v0, const vms_vector &v1, const
|
|||
|
||||
//computes a matrix from a set of three angles. returns ptr to matrix
|
||||
vms_matrix &vm_angles_2_matrix (vms_matrix &m, const vms_angvec &a);
|
||||
static inline vms_matrix vm_angles_2_matrix (const vms_angvec &a) __attribute_warn_unused_result;
|
||||
static inline vms_matrix vm_angles_2_matrix (const vms_angvec &a)
|
||||
{
|
||||
vms_matrix m;
|
||||
return vm_angles_2_matrix(m, a), m;
|
||||
}
|
||||
|
||||
|
||||
//computes a matrix from a forward vector and an angle
|
||||
|
|
|
@ -672,8 +672,6 @@ int ObjectMoveDown(void)
|
|||
static int rotate_object(const vobjptridx_t obj, int p, int b, int h)
|
||||
{
|
||||
vms_angvec ang;
|
||||
vms_matrix rotmat;
|
||||
|
||||
// vm_extract_angles_matrix( &ang,&obj->orient);
|
||||
|
||||
// ang.p += p;
|
||||
|
@ -684,7 +682,7 @@ static int rotate_object(const vobjptridx_t obj, int p, int b, int h)
|
|||
ang.b = b;
|
||||
ang.h = h;
|
||||
|
||||
vm_angles_2_matrix(rotmat, ang);
|
||||
const auto rotmat = vm_angles_2_matrix(ang);
|
||||
obj->orient = vm_matrix_x_matrix(obj->orient, rotmat);
|
||||
// vm_angles_2_matrix(&obj->orient, &ang);
|
||||
|
||||
|
|
|
@ -816,13 +816,11 @@ static segnum_t place_new_segment_in_world(void)
|
|||
static int AttachSegmentNewAng(const vms_angvec &pbh)
|
||||
{
|
||||
int newseg;
|
||||
vms_matrix orient_matrix;
|
||||
|
||||
GroupList[current_group].segments.clear();
|
||||
newseg = place_new_segment_in_world();
|
||||
GroupList[current_group].segments.emplace_back(newseg);
|
||||
|
||||
if (!med_move_group(1, Cursegp, Curside, &Segments[newseg], AttachSide, vm_angles_2_matrix(orient_matrix,pbh),0)) {
|
||||
if (!med_move_group(1, Cursegp, Curside, &Segments[newseg], AttachSide, vm_angles_2_matrix(pbh),0)) {
|
||||
autosave_mine(mine_filename);
|
||||
|
||||
med_propagate_tmaps_to_segments(Cursegp,&Segments[newseg],0);
|
||||
|
@ -888,7 +886,7 @@ void add_segment_to_group(int segment_num, int group_num)
|
|||
int rotate_segment_new(const vms_angvec &pbh)
|
||||
{
|
||||
int newseg,baseseg,newseg_side;
|
||||
vms_matrix tm1,tm2;
|
||||
vms_matrix tm1;
|
||||
group::segment_array_type_t selected_segs_save;
|
||||
int child_save;
|
||||
int current_group_save;
|
||||
|
@ -929,7 +927,7 @@ int rotate_segment_new(const vms_angvec &pbh)
|
|||
|
||||
med_extract_matrix_from_segment(&Segments[newseg],&tm1);
|
||||
tm1 = vmd_identity_matrix;
|
||||
vm_angles_2_matrix(tm2,pbh);
|
||||
const auto tm2 = vm_angles_2_matrix(pbh);
|
||||
const auto orient_matrix = vm_matrix_x_matrix(tm1,tm2);
|
||||
|
||||
Segments[baseseg].children[baseseg_side] = segment_none;
|
||||
|
|
|
@ -151,14 +151,13 @@ int medlisp_delete_segment(void)
|
|||
|
||||
int medlisp_scale_segment(void)
|
||||
{
|
||||
vms_matrix rotmat;
|
||||
vms_vector scale;
|
||||
|
||||
scale.x = fl2f((float) func_get_param(0));
|
||||
scale.y = fl2f((float) func_get_param(1));
|
||||
scale.z = fl2f((float) func_get_param(2));
|
||||
med_create_new_segment(scale);
|
||||
med_rotate_segment(Cursegp,vm_angles_2_matrix(rotmat,Seg_orientation));
|
||||
med_rotate_segment(Cursegp,vm_angles_2_matrix(Seg_orientation));
|
||||
Update_flags |= UF_WORLD_CHANGED;
|
||||
mine_changed = 1;
|
||||
|
||||
|
|
|
@ -100,7 +100,6 @@ void calc_gun_point(vms_vector &gun_point,const vcobjptr_t obj,int gun_num)
|
|||
polymodel *pm;
|
||||
robot_info *r;
|
||||
vms_vector pnt;
|
||||
vms_matrix m;
|
||||
int mn; //submodel number
|
||||
|
||||
Assert(obj->render_type==RT_POLYOBJ || obj->render_type==RT_MORPH);
|
||||
|
@ -121,8 +120,7 @@ void calc_gun_point(vms_vector &gun_point,const vcobjptr_t obj,int gun_num)
|
|||
while (mn != 0) {
|
||||
vms_vector tpnt;
|
||||
|
||||
vm_angles_2_matrix(m,obj->rtype.pobj_info.anim_angles[mn]);
|
||||
vm_transpose_matrix(m);
|
||||
const auto m = vm_transposed_matrix(vm_angles_2_matrix(obj->rtype.pobj_info.anim_angles[mn]));
|
||||
vm_vec_rotate(tpnt,pnt,m);
|
||||
|
||||
vm_vec_add(pnt,tpnt,pm->submodel_offsets[mn]);
|
||||
|
@ -132,7 +130,7 @@ void calc_gun_point(vms_vector &gun_point,const vcobjptr_t obj,int gun_num)
|
|||
|
||||
//now instance for the entire object
|
||||
|
||||
m = vm_transposed_matrix(obj->orient);
|
||||
const auto m = vm_transposed_matrix(obj->orient);
|
||||
vm_vec_rotate(gun_point,pnt,m);
|
||||
vm_vec_add2(gun_point,obj->pos);
|
||||
|
||||
|
|
Loading…
Reference in a new issue