Add vm_vec_copy_scale that returns result
This commit is contained in:
parent
6746879427
commit
b32f5e5df3
|
@ -28,7 +28,7 @@ struct rod_4point
|
||||||
//compute the corners of a rod. fills in vertbuf.
|
//compute the corners of a rod. fills in vertbuf.
|
||||||
static int calc_rod_corners(rod_4point &rod_point_group, g3s_point *bot_point,fix bot_width,g3s_point *top_point,fix top_width)
|
static int calc_rod_corners(rod_4point &rod_point_group, g3s_point *bot_point,fix bot_width,g3s_point *top_point,fix top_width)
|
||||||
{
|
{
|
||||||
vms_vector top,tempv,rod_norm;
|
vms_vector top,rod_norm;
|
||||||
//compute vector from one point to other, do cross product with vector
|
//compute vector from one point to other, do cross product with vector
|
||||||
//from eye to get perpendiclar
|
//from eye to get perpendiclar
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ static int calc_rod_corners(rod_4point &rod_point_group, g3s_point *bot_point,fi
|
||||||
|
|
||||||
//top points
|
//top points
|
||||||
|
|
||||||
vm_vec_copy_scale(tempv,rod_norm,top_width);
|
auto tempv = vm_vec_copy_scale(rod_norm,top_width);
|
||||||
tempv.z = 0;
|
tempv.z = 0;
|
||||||
|
|
||||||
rod_point_group.point_list[0] = &rod_point_group.points[0];
|
rod_point_group.point_list[0] = &rod_point_group.points[0];
|
||||||
|
|
|
@ -157,7 +157,11 @@ void vm_vec_divide(vms_vector &dest, const vms_vector &src, fix d);
|
||||||
|
|
||||||
//scales and copies a vector. returns ptr to dest
|
//scales and copies a vector. returns ptr to dest
|
||||||
vms_vector &vm_vec_copy_scale (vms_vector &dest, const vms_vector &src, fix s);
|
vms_vector &vm_vec_copy_scale (vms_vector &dest, const vms_vector &src, fix s);
|
||||||
|
static inline vms_vector vm_vec_copy_scale(vms_vector src, fix s) __attribute_warn_unused_result;
|
||||||
|
static inline vms_vector vm_vec_copy_scale(vms_vector src, fix s)
|
||||||
|
{
|
||||||
|
return vm_vec_scale(src, s), src;
|
||||||
|
}
|
||||||
|
|
||||||
//scales a vector, adds it to another, and stores in a 3rd vector
|
//scales a vector, adds it to another, and stores in a 3rd vector
|
||||||
//dest = src1 + k * src2
|
//dest = src1 + k * src2
|
||||||
|
|
|
@ -535,7 +535,6 @@ int SetPlayerFromCursegAndRotate()
|
||||||
//far enough away to see all of curside
|
//far enough away to see all of curside
|
||||||
int SetPlayerFromCursegMinusOne()
|
int SetPlayerFromCursegMinusOne()
|
||||||
{
|
{
|
||||||
vms_vector view_vec2;
|
|
||||||
vms_vector corner_v[4];
|
vms_vector corner_v[4];
|
||||||
g3s_point corner_p[4];
|
g3s_point corner_p[4];
|
||||||
int i;
|
int i;
|
||||||
|
@ -544,7 +543,7 @@ int SetPlayerFromCursegMinusOne()
|
||||||
const auto view_vec = vm_vec_negated(Cursegp->sides[Curside].normals[0]);
|
const auto view_vec = vm_vec_negated(Cursegp->sides[Curside].normals[0]);
|
||||||
|
|
||||||
const auto side_center = compute_center_point_on_side(Cursegp,Curside);
|
const auto side_center = compute_center_point_on_side(Cursegp,Curside);
|
||||||
vm_vec_copy_scale(view_vec2,view_vec,view_dist);
|
const auto view_vec2 = vm_vec_copy_scale(view_vec,view_dist);
|
||||||
vm_vec_sub(ConsoleObject->pos,side_center,view_vec2);
|
vm_vec_sub(ConsoleObject->pos,side_center,view_vec2);
|
||||||
|
|
||||||
const auto upvec = vm_vec_sub(Vertices[Cursegp->verts[Side_to_verts[Curside][edgenum%4]]], Vertices[Cursegp->verts[Side_to_verts[Curside][(edgenum+3)%4]]]);
|
const auto upvec = vm_vec_sub(Vertices[Cursegp->verts[Side_to_verts[Curside][edgenum%4]]], Vertices[Cursegp->verts[Side_to_verts[Curside][(edgenum+3)%4]]]);
|
||||||
|
@ -564,8 +563,8 @@ int SetPlayerFromCursegMinusOne()
|
||||||
}
|
}
|
||||||
|
|
||||||
view_dist = fixmul(view_dist,fixdiv(fixdiv(max,SIDE_VIEW_FRAC),corner_p[0].p3_z));
|
view_dist = fixmul(view_dist,fixdiv(fixdiv(max,SIDE_VIEW_FRAC),corner_p[0].p3_z));
|
||||||
vm_vec_copy_scale(view_vec2,view_vec,view_dist);
|
const auto view_vec3 = vm_vec_copy_scale(view_vec,view_dist);
|
||||||
vm_vec_sub(ConsoleObject->pos,side_center,view_vec2);
|
vm_vec_sub(ConsoleObject->pos,side_center,view_vec3);
|
||||||
|
|
||||||
//obj_relink(ConsoleObject-Objects, SEG_PTR_2_NUM(Cursegp) );
|
//obj_relink(ConsoleObject-Objects, SEG_PTR_2_NUM(Cursegp) );
|
||||||
//update_object_seg(ConsoleObject); //might have backed right out of curseg
|
//update_object_seg(ConsoleObject); //might have backed right out of curseg
|
||||||
|
|
|
@ -293,8 +293,7 @@ static void bump_two_objects(const vobjptridx_t obj0,const vobjptridx_t obj1,int
|
||||||
{
|
{
|
||||||
const vobjptridx_t &t = *pt;
|
const vobjptridx_t &t = *pt;
|
||||||
Assert(t->movement_type == MT_PHYSICS);
|
Assert(t->movement_type == MT_PHYSICS);
|
||||||
vms_vector force;
|
const auto force = vm_vec_copy_scale(t->mtype.phys_info.velocity,-t->mtype.phys_info.mass);
|
||||||
vm_vec_copy_scale(force,t->mtype.phys_info.velocity,-t->mtype.phys_info.mass);
|
|
||||||
phys_apply_force(t,force);
|
phys_apply_force(t,force);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -308,8 +307,7 @@ static void bump_two_objects(const vobjptridx_t obj0,const vobjptridx_t obj1,int
|
||||||
|
|
||||||
void bump_one_object(const vobjptr_t obj0, const vms_vector &hit_dir, fix damage)
|
void bump_one_object(const vobjptr_t obj0, const vms_vector &hit_dir, fix damage)
|
||||||
{
|
{
|
||||||
auto hit_vec = hit_dir;
|
const auto hit_vec = vm_vec_copy_scale(hit_dir, damage);
|
||||||
vm_vec_scale(hit_vec, damage);
|
|
||||||
phys_apply_force(obj0,hit_vec);
|
phys_apply_force(obj0,hit_vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -622,13 +622,12 @@ void do_endlevel_frame()
|
||||||
//do little explosions on walls
|
//do little explosions on walls
|
||||||
if (Endlevel_sequence >= EL_FLYTHROUGH && Endlevel_sequence < EL_OUTSIDE)
|
if (Endlevel_sequence >= EL_FLYTHROUGH && Endlevel_sequence < EL_OUTSIDE)
|
||||||
if ((explosion_wait2-=FrameTime) < 0) {
|
if ((explosion_wait2-=FrameTime) < 0) {
|
||||||
vms_vector tpnt;
|
|
||||||
fvi_query fq;
|
fvi_query fq;
|
||||||
fvi_info hit_data;
|
fvi_info hit_data;
|
||||||
|
|
||||||
//create little explosion on wall
|
//create little explosion on wall
|
||||||
|
|
||||||
vm_vec_copy_scale(tpnt,ConsoleObject->orient.rvec,(d_rand()-D_RAND_MAX/2)*100);
|
auto tpnt = vm_vec_copy_scale(ConsoleObject->orient.rvec,(d_rand()-D_RAND_MAX/2)*100);
|
||||||
vm_vec_scale_add2(tpnt,ConsoleObject->orient.uvec,(d_rand()-D_RAND_MAX/2)*100);
|
vm_vec_scale_add2(tpnt,ConsoleObject->orient.uvec,(d_rand()-D_RAND_MAX/2)*100);
|
||||||
vm_vec_add2(tpnt,ConsoleObject->pos);
|
vm_vec_add2(tpnt,ConsoleObject->pos);
|
||||||
|
|
||||||
|
|
|
@ -282,10 +282,9 @@ static g3s_lrgb compute_light_emission(int objnum)
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
vms_vector sthrust = obj->mtype.phys_info.thrust;
|
|
||||||
fix k = fixmuldiv(obj->mtype.phys_info.mass,obj->mtype.phys_info.drag,(f1_0-obj->mtype.phys_info.drag));
|
fix k = fixmuldiv(obj->mtype.phys_info.mass,obj->mtype.phys_info.drag,(f1_0-obj->mtype.phys_info.drag));
|
||||||
// smooth thrust value like set_thrust_from_velocity()
|
// smooth thrust value like set_thrust_from_velocity()
|
||||||
vm_vec_copy_scale(sthrust,obj->mtype.phys_info.velocity,k);
|
auto sthrust = vm_vec_copy_scale(obj->mtype.phys_info.velocity,k);
|
||||||
light_intensity = max(vm_vec_mag_quick(sthrust)/4, F1_0*2) + F1_0/2;
|
light_intensity = max(vm_vec_mag_quick(sthrust)/4, F1_0*2) + F1_0/2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -216,7 +216,6 @@ void draw_object_tmap_rod(const vobjptridx_t obj,bitmap_index bitmapi,int lighte
|
||||||
grs_bitmap * bitmap = &GameBitmaps[bitmapi.index];
|
grs_bitmap * bitmap = &GameBitmaps[bitmapi.index];
|
||||||
g3s_lrgb light;
|
g3s_lrgb light;
|
||||||
|
|
||||||
vms_vector delta;
|
|
||||||
g3s_point top_p,bot_p;
|
g3s_point top_p,bot_p;
|
||||||
|
|
||||||
PIGGY_PAGE_IN(bitmapi);
|
PIGGY_PAGE_IN(bitmapi);
|
||||||
|
@ -225,7 +224,7 @@ void draw_object_tmap_rod(const vobjptridx_t obj,bitmap_index bitmapi,int lighte
|
||||||
bitmap->bm_handle = bitmapi.index;
|
bitmap->bm_handle = bitmapi.index;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vm_vec_copy_scale(delta,obj->orient.uvec,obj->size);
|
const auto delta = vm_vec_copy_scale(obj->orient.uvec,obj->size);
|
||||||
|
|
||||||
const auto top_v = vm_vec_add(obj->pos,delta);
|
const auto top_v = vm_vec_add(obj->pos,delta);
|
||||||
const auto bot_v = vm_vec_sub(obj->pos,delta);
|
const auto bot_v = vm_vec_sub(obj->pos,delta);
|
||||||
|
|
|
@ -201,7 +201,6 @@ static void do_physics_sim_rot(const vobjptr_t obj)
|
||||||
|
|
||||||
if (obj->mtype.phys_info.drag) {
|
if (obj->mtype.phys_info.drag) {
|
||||||
int count;
|
int count;
|
||||||
vms_vector accel;
|
|
||||||
fix drag,r,k;
|
fix drag,r,k;
|
||||||
|
|
||||||
count = FrameTime / FT;
|
count = FrameTime / FT;
|
||||||
|
@ -212,7 +211,7 @@ static void do_physics_sim_rot(const vobjptr_t obj)
|
||||||
|
|
||||||
if (obj->mtype.phys_info.flags & PF_USES_THRUST) {
|
if (obj->mtype.phys_info.flags & PF_USES_THRUST) {
|
||||||
|
|
||||||
vm_vec_copy_scale(accel,obj->mtype.phys_info.rotthrust,fixdiv(f1_0,obj->mtype.phys_info.mass));
|
const auto accel = vm_vec_copy_scale(obj->mtype.phys_info.rotthrust,fixdiv(f1_0,obj->mtype.phys_info.mass));
|
||||||
|
|
||||||
while (count--) {
|
while (count--) {
|
||||||
|
|
||||||
|
@ -300,7 +299,6 @@ void do_physics_sim(const vobjptridx_t obj)
|
||||||
int n_ignore_objs;
|
int n_ignore_objs;
|
||||||
int try_again;
|
int try_again;
|
||||||
int fate=0;
|
int fate=0;
|
||||||
vms_vector frame_vec; //movement in this frame
|
|
||||||
vms_vector ipos; //position after this frame
|
vms_vector ipos; //position after this frame
|
||||||
int count=0;
|
int count=0;
|
||||||
segnum_t WallHitSeg;
|
segnum_t WallHitSeg;
|
||||||
|
@ -362,7 +360,6 @@ void do_physics_sim(const vobjptridx_t obj)
|
||||||
if ((drag = obj->mtype.phys_info.drag) != 0) {
|
if ((drag = obj->mtype.phys_info.drag) != 0) {
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
vms_vector accel;
|
|
||||||
fix r,k,have_accel;
|
fix r,k,have_accel;
|
||||||
|
|
||||||
count = FrameTime / FT;
|
count = FrameTime / FT;
|
||||||
|
@ -371,7 +368,7 @@ void do_physics_sim(const vobjptridx_t obj)
|
||||||
|
|
||||||
if (obj->mtype.phys_info.flags & PF_USES_THRUST) {
|
if (obj->mtype.phys_info.flags & PF_USES_THRUST) {
|
||||||
|
|
||||||
vm_vec_copy_scale(accel,obj->mtype.phys_info.thrust,fixdiv(f1_0,obj->mtype.phys_info.mass));
|
const auto accel = vm_vec_copy_scale(obj->mtype.phys_info.thrust,fixdiv(f1_0,obj->mtype.phys_info.mass));
|
||||||
have_accel = (accel.x || accel.y || accel.z);
|
have_accel = (accel.x || accel.y || accel.z);
|
||||||
|
|
||||||
while (count--) {
|
while (count--) {
|
||||||
|
@ -406,7 +403,7 @@ void do_physics_sim(const vobjptridx_t obj)
|
||||||
try_again = 0;
|
try_again = 0;
|
||||||
|
|
||||||
//Move the object
|
//Move the object
|
||||||
vm_vec_copy_scale(frame_vec, obj->mtype.phys_info.velocity, sim_time);
|
const auto frame_vec = vm_vec_copy_scale(obj->mtype.phys_info.velocity, sim_time);
|
||||||
|
|
||||||
if ( (frame_vec.x==0) && (frame_vec.y==0) && (frame_vec.z==0) )
|
if ( (frame_vec.x==0) && (frame_vec.y==0) && (frame_vec.z==0) )
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -150,11 +150,7 @@ vms_vector &terrain_y_cache::operator()(uint_fast32_t h)
|
||||||
{
|
{
|
||||||
auto &dyp = y_cache[h];
|
auto &dyp = y_cache[h];
|
||||||
if (!yc_flags[h]) {
|
if (!yc_flags[h]) {
|
||||||
vms_vector tv;
|
const auto tv = vm_vec_copy_scale(surface_orient.uvec,h*HEIGHT_SCALE);
|
||||||
|
|
||||||
//@@g3_rotate_delta_y(dyp,h*HEIGHT_SCALE);
|
|
||||||
|
|
||||||
vm_vec_copy_scale(tv,surface_orient.uvec,h*HEIGHT_SCALE);
|
|
||||||
g3_rotate_delta_vec(dyp,tv);
|
g3_rotate_delta_vec(dyp,tv);
|
||||||
|
|
||||||
yc_flags[h] = 1;
|
yc_flags[h] = 1;
|
||||||
|
@ -172,7 +168,6 @@ void render_terrain(const vms_vector &org_point,int org_2dx,int org_2dy)
|
||||||
int i,j;
|
int i,j;
|
||||||
int low_i,high_i,low_j,high_j;
|
int low_i,high_i,low_j,high_j;
|
||||||
int viewer_i,viewer_j;
|
int viewer_i,viewer_j;
|
||||||
vms_vector tv;
|
|
||||||
org_i = org_2dy;
|
org_i = org_2dy;
|
||||||
org_j = org_2dx;
|
org_j = org_2dx;
|
||||||
|
|
||||||
|
@ -189,10 +184,14 @@ void render_terrain(const vms_vector &org_point,int org_2dx,int org_2dy)
|
||||||
//Lighting_on = 0;
|
//Lighting_on = 0;
|
||||||
Interpolation_method = im;
|
Interpolation_method = im;
|
||||||
|
|
||||||
vm_vec_copy_scale(tv,surface_orient.rvec,GRID_SCALE);
|
{
|
||||||
|
const auto tv = vm_vec_copy_scale(surface_orient.rvec,GRID_SCALE);
|
||||||
g3_rotate_delta_vec(delta_i,tv);
|
g3_rotate_delta_vec(delta_i,tv);
|
||||||
vm_vec_copy_scale(tv,surface_orient.fvec,GRID_SCALE);
|
}
|
||||||
|
{
|
||||||
|
const auto tv = vm_vec_copy_scale(surface_orient.fvec,GRID_SCALE);
|
||||||
g3_rotate_delta_vec(delta_j,tv);
|
g3_rotate_delta_vec(delta_j,tv);
|
||||||
|
}
|
||||||
|
|
||||||
vm_vec_scale_add(start_point,org_point,surface_orient.rvec,-(org_i - low_i)*GRID_SCALE);
|
vm_vec_scale_add(start_point,org_point,surface_orient.rvec,-(org_i - low_i)*GRID_SCALE);
|
||||||
vm_vec_scale_add2(start_point,surface_orient.fvec,-(org_j - low_j)*GRID_SCALE);
|
vm_vec_scale_add2(start_point,surface_orient.fvec,-(org_j - low_j)*GRID_SCALE);
|
||||||
|
|
Loading…
Reference in a new issue