ref: 45321b4d94499e2aa8159a498c9732eb371bdc73
parent: 273a315a5d0fb3e2884805a827e1584223aa35c7
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Fri Dec 29 20:01:37 EST 2023
R_RotateBmodel: take entity as an argument
--- a/d_edge.c
+++ b/d_edge.c
@@ -5,7 +5,7 @@
float scale_for_mip;
// FIXME: should go away
-extern void R_RotateBmodel (void);
+extern void R_RotateBmodel (entity_t *entity);
extern void R_TransformFrustum (void);
static int
@@ -114,6 +114,18 @@
d_zistepv = s->d_zistepv;
d_ziorigin = s->d_ziorigin;
+ if(s->insubmodel){
+ // FIXME: we don't want to do all this for every polygon!
+ // TODO: store once at start of frame
+ currententity = s->entity; //FIXME: make this passed in to
+ // R_RotateBmodel()
+ VectorSubtract(r_origin, currententity->origin, local_modelorg);
+ TransformVector(local_modelorg, transformed_modelorg);
+
+ R_RotateBmodel(s->entity); // FIXME: don't mess with the frustum,
+ // make entity passed in
+ }
+
if(s->flags & SURF_DRAWSKY){
D_DrawSkyScans8(s->spans);
d_ziorigin = -0.8;
@@ -133,48 +145,10 @@
cacheblock = pface->texinfo->texture->pixels + pface->texinfo->texture->offsets[0];
cachewidth = 64;
- if(s->insubmodel){
- // FIXME: we don't want to do all this for every polygon!
- // TODO: store once at start of frame
- currententity = s->entity; //FIXME: make this passed in to
- // R_RotateBmodel()
- VectorSubtract(r_origin, currententity->origin, local_modelorg);
- TransformVector(local_modelorg, transformed_modelorg);
-
- R_RotateBmodel(); // FIXME: don't mess with the frustum,
- // make entity passed in
- }
-
D_CalcGradients (pface, transformed_modelorg);
Turbulent8 (s->spans, alpha);
D_DrawZSpans (s->spans);
-
- if(s->insubmodel){
- // restore the old drawing state
- // FIXME: we don't want to do this every time!
- // TODO: speed up
- currententity = &cl_entities[0];
- VectorCopy(world_transformed_modelorg, transformed_modelorg);
- VectorCopy(base_vpn, vpn);
- VectorCopy(base_vup, vup);
- VectorCopy(base_vright, vright);
- VectorCopy(base_modelorg, modelorg);
- R_TransformFrustum();
- }
- }
- else
- {
- if(s->insubmodel){
- // FIXME: we don't want to do all this for every polygon!
- // TODO: store once at start of frame
- currententity = s->entity; //FIXME: make this passed in to
- // R_RotateBmodel()
- VectorSubtract(r_origin, currententity->origin, local_modelorg);
- TransformVector(local_modelorg, transformed_modelorg);
- R_RotateBmodel(); // FIXME: don't mess with the frustum,
- // make entity passed in
- }
-
+ }else{
pface = s->data;
miplevel = D_MipLevelForScale(s->nearzi * scale_for_mip * pface->texinfo->mipadjust);
if(s->flags & SURF_FENCE)
@@ -190,21 +164,19 @@
D_DrawSpans16(s->spans, s->flags & SURF_FENCE, alpha);
D_DrawZSpans(s->spans);
+ }
- if(s->insubmodel){
- //
- // restore the old drawing state
- // FIXME: we don't want to do this every time!
- // TODO: speed up
- //
- currententity = &cl_entities[0];
- VectorCopy(world_transformed_modelorg, transformed_modelorg);
- VectorCopy(base_vpn, vpn);
- VectorCopy(base_vup, vup);
- VectorCopy(base_vright, vright);
- VectorCopy(base_modelorg, modelorg);
- R_TransformFrustum();
- }
+ if(s->insubmodel){
+ // restore the old drawing state
+ // FIXME: we don't want to do this every time!
+ // TODO: speed up
+ currententity = &cl_entities[0];
+ VectorCopy(world_transformed_modelorg, transformed_modelorg);
+ VectorCopy(base_vpn, vpn);
+ VectorCopy(base_vup, vup);
+ VectorCopy(base_vright, vright);
+ VectorCopy(base_modelorg, modelorg);
+ R_TransformFrustum();
}
}
}
--- a/r_bsp.c
+++ b/r_bsp.c
@@ -64,7 +64,7 @@
R_RotateBmodel
================
*/
-void R_RotateBmodel (void)
+void R_RotateBmodel (entity_t *e)
{
float angle, s, c, temp1[3][3], temp2[3][3], temp3[3][3];
@@ -74,7 +74,7 @@
// TODO: share work with R_SetUpAliasTransform
// yaw
- angle = currententity->angles[YAW];
+ angle = e->angles[YAW];
angle = angle * M_PI*2 / 360;
s = sinf(angle);
c = cosf(angle);
@@ -91,7 +91,7 @@
// pitch
- angle = currententity->angles[PITCH];
+ angle = e->angles[PITCH];
angle = angle * M_PI*2 / 360;
s = sinf(angle);
c = cosf(angle);
@@ -109,7 +109,7 @@
R_ConcatRotations (temp2, temp1, temp3);
// roll
- angle = currententity->angles[ROLL];
+ angle = e->angles[ROLL];
angle = angle * M_PI*2 / 360;
s = sinf(angle);
c = cosf(angle);
--- a/r_local.h
+++ b/r_local.h
@@ -140,7 +140,7 @@
extern void R_EdgeCodeStart (void);
extern void R_EdgeCodeEnd (void);
-extern void R_RotateBmodel (void);
+extern void R_RotateBmodel (entity_t *e);
extern int c_faceclip;
extern int r_polycount;
--- a/r_main.c
+++ b/r_main.c
@@ -541,7 +541,7 @@
VectorCopy(e->origin, r_entorigin);
VectorSubtract(r_origin, r_entorigin, modelorg);
r_pcurrentvertbase = clmodel->vertexes;
- R_RotateBmodel(); // FIXME: stop transforming twice
+ R_RotateBmodel(e); // FIXME: stop transforming twice
// calculate dynamic lighting for bmodel if it's not an
// instanced model