Add g3_rotate_point that returns result
This commit is contained in:
parent
5e9385849a
commit
baa39fe8f7
|
@ -150,6 +150,12 @@ g3s_codes g3_check_codes(int nv,g3s_point **pointlist);
|
||||||
|
|
||||||
//rotates a point. returns codes. does not check if already rotated
|
//rotates a point. returns codes. does not check if already rotated
|
||||||
ubyte g3_rotate_point(g3s_point &dest,const vms_vector &src);
|
ubyte g3_rotate_point(g3s_point &dest,const vms_vector &src);
|
||||||
|
static inline g3s_point g3_rotate_point(const vms_vector &src) __attribute_warn_unused_result;
|
||||||
|
static inline g3s_point g3_rotate_point(const vms_vector &src)
|
||||||
|
{
|
||||||
|
g3s_point dest;
|
||||||
|
return g3_rotate_point(dest, src), dest;
|
||||||
|
}
|
||||||
|
|
||||||
//projects a point
|
//projects a point
|
||||||
void g3_project_point(g3s_point &point);
|
void g3_project_point(g3s_point &point);
|
||||||
|
|
|
@ -439,11 +439,10 @@ void g3_draw_polygon_model(ubyte *p,grs_bitmap **model_bitmaps,const vms_angvec
|
||||||
|
|
||||||
|
|
||||||
case OP_RODBM: {
|
case OP_RODBM: {
|
||||||
g3s_point rod_bot_p,rod_top_p;
|
|
||||||
g3s_lrgb rodbm_light = { f1_0, f1_0, f1_0 };
|
g3s_lrgb rodbm_light = { f1_0, f1_0, f1_0 };
|
||||||
|
|
||||||
g3_rotate_point(rod_bot_p,*vp(p+20));
|
const auto rod_bot_p = g3_rotate_point(*vp(p+20));
|
||||||
g3_rotate_point(rod_top_p,*vp(p+4));
|
const auto rod_top_p = g3_rotate_point(*vp(p+4));
|
||||||
|
|
||||||
g3_draw_rod_tmap(*model_bitmaps[w(p+2)],rod_bot_p,w(p+16),rod_top_p,w(p+32),rodbm_light);
|
g3_draw_rod_tmap(*model_bitmaps[w(p+2)],rod_bot_p,w(p+16),rod_top_p,w(p+32),rodbm_light);
|
||||||
|
|
||||||
|
@ -620,11 +619,10 @@ void g3_draw_morphing_model(ubyte *p,grs_bitmap **model_bitmaps,const vms_angvec
|
||||||
|
|
||||||
|
|
||||||
case OP_RODBM: {
|
case OP_RODBM: {
|
||||||
g3s_point rod_bot_p,rod_top_p;
|
|
||||||
g3s_lrgb rodbm_light = { f1_0, f1_0, f1_0 };
|
g3s_lrgb rodbm_light = { f1_0, f1_0, f1_0 };
|
||||||
|
|
||||||
g3_rotate_point(rod_bot_p,*vp(p+20));
|
const auto rod_bot_p = g3_rotate_point(*vp(p+20));
|
||||||
g3_rotate_point(rod_top_p,*vp(p+4));
|
const auto rod_top_p = g3_rotate_point(*vp(p+4));
|
||||||
|
|
||||||
g3_draw_rod_tmap(*model_bitmaps[w(p+2)],rod_bot_p,w(p+16),rod_top_p,w(p+32),rodbm_light);
|
g3_draw_rod_tmap(*model_bitmaps[w(p+2)],rod_bot_p,w(p+16),rod_top_p,w(p+32),rodbm_light);
|
||||||
|
|
||||||
|
|
|
@ -84,13 +84,11 @@ static void draw_seg_objects(const vcsegptr_t seg)
|
||||||
{
|
{
|
||||||
range_for (auto obj, objects_in(*seg))
|
range_for (auto obj, objects_in(*seg))
|
||||||
{
|
{
|
||||||
g3s_point sphere_point;
|
|
||||||
|
|
||||||
if ((obj->type==OBJ_PLAYER) && (static_cast<const cobjptridx_t::index_type>(obj) > 0 ))
|
if ((obj->type==OBJ_PLAYER) && (static_cast<const cobjptridx_t::index_type>(obj) > 0 ))
|
||||||
gr_setcolor(BM_XRGB( 0, 25, 0 ));
|
gr_setcolor(BM_XRGB( 0, 25, 0 ));
|
||||||
else
|
else
|
||||||
gr_setcolor(obj==ConsoleObject?PLAYER_COLOR:ROBOT_COLOR);
|
gr_setcolor(obj==ConsoleObject?PLAYER_COLOR:ROBOT_COLOR);
|
||||||
g3_rotate_point(sphere_point,obj->pos);
|
auto sphere_point = g3_rotate_point(obj->pos);
|
||||||
g3_draw_sphere(sphere_point,obj->size);
|
g3_draw_sphere(sphere_point,obj->size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,7 +240,7 @@ static inline void ClearMarkers()
|
||||||
static void DrawMarkerNumber (automap *am, int num)
|
static void DrawMarkerNumber (automap *am, int num)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
g3s_point BasePoint,FromPoint,ToPoint;
|
g3s_point FromPoint,ToPoint;
|
||||||
|
|
||||||
static const float sArrayX[10][20]={ {-.25, 0.0, 0.0, 0.0, -1.0, 1.0},
|
static const float sArrayX[10][20]={ {-.25, 0.0, 0.0, 0.0, -1.0, 1.0},
|
||||||
{-1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, 1.0},
|
{-1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, 1.0},
|
||||||
|
@ -279,7 +279,7 @@ static void DrawMarkerNumber (automap *am, int num)
|
||||||
gr_setcolor (am->blue_48);
|
gr_setcolor (am->blue_48);
|
||||||
|
|
||||||
|
|
||||||
g3_rotate_point(BasePoint,Objects[MarkerObject[(Player_num*2)+num]].pos);
|
const auto BasePoint = g3_rotate_point(Objects[MarkerObject[(Player_num*2)+num]].pos);
|
||||||
|
|
||||||
for (i=0;i<NumOfPoints[num];i+=2)
|
for (i=0;i<NumOfPoints[num];i+=2)
|
||||||
{
|
{
|
||||||
|
@ -340,7 +340,6 @@ static void DrawMarkers (automap *am)
|
||||||
{
|
{
|
||||||
int i,maxdrop;
|
int i,maxdrop;
|
||||||
static int cyc=10,cycdir=1;
|
static int cyc=10,cycdir=1;
|
||||||
g3s_point sphere_point;
|
|
||||||
|
|
||||||
if (Game_mode & GM_MULTI)
|
if (Game_mode & GM_MULTI)
|
||||||
maxdrop=2;
|
maxdrop=2;
|
||||||
|
@ -350,8 +349,7 @@ static void DrawMarkers (automap *am)
|
||||||
for (i=0;i<maxdrop;i++)
|
for (i=0;i<maxdrop;i++)
|
||||||
if (MarkerObject[(Player_num*2)+i] != object_none) {
|
if (MarkerObject[(Player_num*2)+i] != object_none) {
|
||||||
|
|
||||||
g3_rotate_point(sphere_point,Objects[MarkerObject[(Player_num*2)+i]].pos);
|
auto sphere_point = g3_rotate_point(Objects[MarkerObject[(Player_num*2)+i]].pos);
|
||||||
|
|
||||||
gr_setcolor (gr_find_closest_color_current(cyc,0,0));
|
gr_setcolor (gr_find_closest_color_current(cyc,0,0));
|
||||||
g3_draw_sphere(sphere_point,MARKER_SPHERE_SIZE);
|
g3_draw_sphere(sphere_point,MARKER_SPHERE_SIZE);
|
||||||
gr_setcolor (gr_find_closest_color_current(cyc+10,0,0));
|
gr_setcolor (gr_find_closest_color_current(cyc+10,0,0));
|
||||||
|
@ -402,38 +400,34 @@ void automap_clear_visited()
|
||||||
|
|
||||||
static void draw_player(const vobjptr_t obj)
|
static void draw_player(const vobjptr_t obj)
|
||||||
{
|
{
|
||||||
g3s_point sphere_point, arrow_point, head_point;
|
|
||||||
|
|
||||||
// Draw Console player -- shaped like a ellipse with an arrow.
|
// Draw Console player -- shaped like a ellipse with an arrow.
|
||||||
g3_rotate_point(sphere_point,obj->pos);
|
auto sphere_point = g3_rotate_point(obj->pos);
|
||||||
g3_draw_sphere(sphere_point,obj->size);
|
g3_draw_sphere(sphere_point,obj->size);
|
||||||
|
|
||||||
// Draw shaft of arrow
|
// Draw shaft of arrow
|
||||||
{
|
|
||||||
const auto arrow_pos = vm_vec_scale_add(obj->pos, obj->orient.fvec, obj->size*3 );
|
const auto arrow_pos = vm_vec_scale_add(obj->pos, obj->orient.fvec, obj->size*3 );
|
||||||
g3_rotate_point(arrow_point,arrow_pos);
|
auto arrow_point = g3_rotate_point(arrow_pos);
|
||||||
automap_draw_line(sphere_point, arrow_point);
|
automap_draw_line(sphere_point, arrow_point);
|
||||||
}
|
|
||||||
|
|
||||||
// Draw right head of arrow
|
// Draw right head of arrow
|
||||||
const auto head_pos = vm_vec_scale_add(obj->pos, obj->orient.fvec, obj->size*2 );
|
const auto head_pos = vm_vec_scale_add(obj->pos, obj->orient.fvec, obj->size*2 );
|
||||||
{
|
{
|
||||||
auto rhead_pos = vm_vec_scale_add( head_pos, obj->orient.rvec, obj->size*1 );
|
auto rhead_pos = vm_vec_scale_add( head_pos, obj->orient.rvec, obj->size*1 );
|
||||||
g3_rotate_point(head_point,rhead_pos);
|
auto head_point = g3_rotate_point(rhead_pos);
|
||||||
automap_draw_line(arrow_point, head_point);
|
automap_draw_line(arrow_point, head_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw left head of arrow
|
// Draw left head of arrow
|
||||||
{
|
{
|
||||||
auto lhead_pos = vm_vec_scale_add( head_pos, obj->orient.rvec, obj->size*(-1) );
|
auto lhead_pos = vm_vec_scale_add( head_pos, obj->orient.rvec, obj->size*(-1) );
|
||||||
g3_rotate_point(head_point,lhead_pos);
|
auto head_point = g3_rotate_point(lhead_pos);
|
||||||
automap_draw_line(arrow_point, head_point);
|
automap_draw_line(arrow_point, head_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw player's up vector
|
// Draw player's up vector
|
||||||
{
|
{
|
||||||
const auto arrow_pos = vm_vec_scale_add(obj->pos, obj->orient.uvec, obj->size*2 );
|
const auto arrow_pos = vm_vec_scale_add(obj->pos, obj->orient.uvec, obj->size*2 );
|
||||||
g3_rotate_point(arrow_point,arrow_pos);
|
auto arrow_point = g3_rotate_point(arrow_pos);
|
||||||
automap_draw_line(sphere_point, arrow_point);
|
automap_draw_line(sphere_point, arrow_point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -491,7 +485,6 @@ static void draw_automap(automap *am)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int color;
|
int color;
|
||||||
g3s_point sphere_point;
|
|
||||||
|
|
||||||
if ( am->leave_mode==0 && am->controls.state.automap && (timer_query()-am->entry_time)>LEAVE_TIME)
|
if ( am->leave_mode==0 && am->controls.state.automap && (timer_query()-am->entry_time)>LEAVE_TIME)
|
||||||
am->leave_mode = 1;
|
am->leave_mode = 1;
|
||||||
|
@ -575,8 +568,10 @@ static void draw_automap(automap *am)
|
||||||
switch( objp->type ) {
|
switch( objp->type ) {
|
||||||
case OBJ_HOSTAGE:
|
case OBJ_HOSTAGE:
|
||||||
gr_setcolor(am->hostage_color);
|
gr_setcolor(am->hostage_color);
|
||||||
g3_rotate_point(sphere_point,objp->pos);
|
{
|
||||||
|
auto sphere_point = g3_rotate_point(objp->pos);
|
||||||
g3_draw_sphere(sphere_point,objp->size);
|
g3_draw_sphere(sphere_point,objp->size);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case OBJ_POWERUP:
|
case OBJ_POWERUP:
|
||||||
if (Automap_visited[objp->segnum] || Automap_debug_show_all_segments)
|
if (Automap_visited[objp->segnum] || Automap_debug_show_all_segments)
|
||||||
|
@ -590,8 +585,10 @@ static void draw_automap(automap *am)
|
||||||
gr_setcolor(BM_XRGB(63, 63, 10));
|
gr_setcolor(BM_XRGB(63, 63, 10));
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
g3_rotate_point(sphere_point,objp->pos);
|
{
|
||||||
|
auto sphere_point = g3_rotate_point(objp->pos);
|
||||||
g3_draw_sphere(sphere_point,objp->size*4);
|
g3_draw_sphere(sphere_point,objp->size*4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -965,9 +965,9 @@ static void render_external_scene(fix eye_offset)
|
||||||
{ //draw satellite
|
{ //draw satellite
|
||||||
|
|
||||||
vms_vector delta;
|
vms_vector delta;
|
||||||
g3s_point p,top_pnt;
|
g3s_point top_pnt;
|
||||||
|
|
||||||
g3_rotate_point(p,satellite_pos);
|
const auto p = g3_rotate_point(satellite_pos);
|
||||||
g3_rotate_delta_vec(delta,satellite_upvec);
|
g3_rotate_delta_vec(delta,satellite_upvec);
|
||||||
|
|
||||||
g3_add_delta_vec(top_pnt,p,delta);
|
g3_add_delta_vec(top_pnt,p,delta);
|
||||||
|
|
|
@ -2839,9 +2839,7 @@ void show_HUD_names()
|
||||||
|
|
||||||
if ((show_name || show_typing || show_indi) && see_object(objnum))
|
if ((show_name || show_typing || show_indi) && see_object(objnum))
|
||||||
{
|
{
|
||||||
g3s_point player_point;
|
auto player_point = g3_rotate_point(Objects[objnum].pos);
|
||||||
g3_rotate_point(player_point,Objects[objnum].pos);
|
|
||||||
|
|
||||||
if (player_point.p3_codes == 0) //on screen
|
if (player_point.p3_codes == 0) //on screen
|
||||||
{
|
{
|
||||||
g3_project_point(player_point);
|
g3_project_point(player_point);
|
||||||
|
|
|
@ -214,9 +214,6 @@ void draw_object_blob(object &obj,bitmap_index bmi)
|
||||||
void draw_object_tmap_rod(const vobjptridx_t obj,const bitmap_index bitmapi,int lighted)
|
void draw_object_tmap_rod(const vobjptridx_t obj,const bitmap_index bitmapi,int lighted)
|
||||||
{
|
{
|
||||||
g3s_lrgb light;
|
g3s_lrgb light;
|
||||||
|
|
||||||
g3s_point top_p,bot_p;
|
|
||||||
|
|
||||||
PIGGY_PAGE_IN(bitmapi);
|
PIGGY_PAGE_IN(bitmapi);
|
||||||
|
|
||||||
auto &bitmap = GameBitmaps[bitmapi.index];
|
auto &bitmap = GameBitmaps[bitmapi.index];
|
||||||
|
@ -229,8 +226,8 @@ void draw_object_tmap_rod(const vobjptridx_t obj,const bitmap_index bitmapi,int
|
||||||
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);
|
||||||
|
|
||||||
g3_rotate_point(top_p,top_v);
|
const auto top_p = g3_rotate_point(top_v);
|
||||||
g3_rotate_point(bot_p,bot_v);
|
const auto bot_p = g3_rotate_point(bot_v);
|
||||||
|
|
||||||
if (lighted)
|
if (lighted)
|
||||||
{
|
{
|
||||||
|
@ -626,10 +623,7 @@ objnum_t Player_fired_laser_this_frame=object_none;
|
||||||
static void set_robot_location_info(const vobjptr_t objp)
|
static void set_robot_location_info(const vobjptr_t objp)
|
||||||
{
|
{
|
||||||
if (Player_fired_laser_this_frame != object_none) {
|
if (Player_fired_laser_this_frame != object_none) {
|
||||||
g3s_point temp;
|
const auto temp = g3_rotate_point(objp->pos);
|
||||||
|
|
||||||
g3_rotate_point(temp,objp->pos);
|
|
||||||
|
|
||||||
if (temp.p3_codes & CC_BEHIND) //robot behind the screen
|
if (temp.p3_codes & CC_BEHIND) //robot behind the screen
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ static int im=1;
|
||||||
void render_terrain(const vms_vector &org_point,int org_2dx,int org_2dy)
|
void render_terrain(const vms_vector &org_point,int org_2dx,int org_2dy)
|
||||||
{
|
{
|
||||||
vms_vector delta_i,delta_j; //delta_y;
|
vms_vector delta_i,delta_j; //delta_y;
|
||||||
g3s_point p,last_p,save_p_low,save_p_high;
|
g3s_point p,save_p_low,save_p_high;
|
||||||
g3s_point last_p2;
|
g3s_point last_p2;
|
||||||
int i,j;
|
int i,j;
|
||||||
int low_i,high_i,low_j,high_j;
|
int low_i,high_i,low_j,high_j;
|
||||||
|
@ -200,7 +200,7 @@ void render_terrain(const vms_vector &org_point,int org_2dx,int org_2dy)
|
||||||
viewer_j = vm_vec_dot(tv,surface_orient.fvec) / GRID_SCALE;
|
viewer_j = vm_vec_dot(tv,surface_orient.fvec) / GRID_SCALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g3_rotate_point(last_p,start_point);
|
auto last_p = g3_rotate_point(start_point);
|
||||||
save_p_low = last_p;
|
save_p_low = last_p;
|
||||||
|
|
||||||
g3s_point save_row[GRID_MAX_SIZE]{};
|
g3s_point save_row[GRID_MAX_SIZE]{};
|
||||||
|
|
Loading…
Reference in a new issue