mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-02 22:11:22 +00:00
Fix csqc's addentities ignoring scale+colormod, fix culling of scaled entities.
This commit is contained in:
parent
eb02e3b5ed
commit
54c646420e
4 changed files with 21 additions and 19 deletions
|
@ -303,21 +303,22 @@ R_CullModelForEntity -- johnfitz -- uses correct bounds based on rotation
|
||||||
qboolean R_CullModelForEntity (entity_t *e)
|
qboolean R_CullModelForEntity (entity_t *e)
|
||||||
{
|
{
|
||||||
vec3_t mins, maxs;
|
vec3_t mins, maxs;
|
||||||
|
float scale = e->netstate.scale/16.0;
|
||||||
|
|
||||||
if (e->angles[0] || e->angles[2]) //pitch or roll
|
if (e->angles[0] || e->angles[2]) //pitch or roll
|
||||||
{
|
{
|
||||||
VectorAdd (e->origin, e->model->rmins, mins);
|
VectorMA (e->origin, scale, e->model->rmins, mins);
|
||||||
VectorAdd (e->origin, e->model->rmaxs, maxs);
|
VectorMA (e->origin, scale, e->model->rmaxs, maxs);
|
||||||
}
|
}
|
||||||
else if (e->angles[1]) //yaw
|
else if (e->angles[1]) //yaw
|
||||||
{
|
{
|
||||||
VectorAdd (e->origin, e->model->ymins, mins);
|
VectorMA (e->origin, scale, e->model->ymins, mins);
|
||||||
VectorAdd (e->origin, e->model->ymaxs, maxs);
|
VectorMA (e->origin, scale, e->model->ymaxs, maxs);
|
||||||
}
|
}
|
||||||
else //no rotation
|
else //no rotation
|
||||||
{
|
{
|
||||||
VectorAdd (e->origin, e->model->mins, mins);
|
VectorMA (e->origin, scale, e->model->mins, mins);
|
||||||
VectorAdd (e->origin, e->model->maxs, maxs);
|
VectorMA (e->origin, scale, e->model->maxs, maxs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return R_CullBox (mins, maxs);
|
return R_CullBox (mins, maxs);
|
||||||
|
|
|
@ -342,14 +342,6 @@ int VectorCompare (const vec3_t v1, const vec3_t v2)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VectorMA (const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc)
|
|
||||||
{
|
|
||||||
vecc[0] = veca[0] + scale*vecb[0];
|
|
||||||
vecc[1] = veca[1] + scale*vecb[1];
|
|
||||||
vecc[2] = veca[2] + scale*vecb[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vec_t _DotProduct (const vec3_t v1, const vec3_t v2)
|
vec_t _DotProduct (const vec3_t v1, const vec3_t v2)
|
||||||
{
|
{
|
||||||
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
|
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
|
||||||
|
|
|
@ -55,9 +55,10 @@ static inline int IS_NAN (float x) {
|
||||||
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
|
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
|
||||||
#define DotProduct2(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1])
|
#define DotProduct2(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1])
|
||||||
#define DoublePrecisionDotProduct(x,y) ((double)(x)[0]*(y)[0]+(double)(x)[1]*(y)[1]+(double)(x)[2]*(y)[2])
|
#define DoublePrecisionDotProduct(x,y) ((double)(x)[0]*(y)[0]+(double)(x)[1]*(y)[1]+(double)(x)[2]*(y)[2])
|
||||||
#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];}
|
#define VectorSubtract(a,b,c) do{(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];}while(0)
|
||||||
#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];}
|
#define VectorAdd(a,b,c) do{(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];}while(0)
|
||||||
#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];}
|
#define VectorMA(a,s,b,c) do{(c)[0]=(a)[0]+(s)*(b)[0];(c)[1]=(a)[1]+(s)*(b)[1];(c)[2]=(a)[2]+(s)*(b)[2];}while(0)
|
||||||
|
#define VectorCopy(a,b) do{(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];}while(0)
|
||||||
|
|
||||||
//johnfitz -- courtesy of lordhavoc
|
//johnfitz -- courtesy of lordhavoc
|
||||||
// QuakeSpasm: To avoid strict aliasing violations, use a float/int union instead of type punning.
|
// QuakeSpasm: To avoid strict aliasing violations, use a float/int union instead of type punning.
|
||||||
|
@ -76,8 +77,6 @@ static inline int IS_NAN (float x) {
|
||||||
void TurnVector (vec3_t out, const vec3_t forward, const vec3_t side, float angle); //johnfitz
|
void TurnVector (vec3_t out, const vec3_t forward, const vec3_t side, float angle); //johnfitz
|
||||||
void VectorAngles (const vec3_t forward, float *up, vec3_t angles); //johnfitz, spike(up is optional)
|
void VectorAngles (const vec3_t forward, float *up, vec3_t angles); //johnfitz, spike(up is optional)
|
||||||
|
|
||||||
void VectorMA (const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc);
|
|
||||||
|
|
||||||
vec_t _DotProduct (const vec3_t v1, const vec3_t v2);
|
vec_t _DotProduct (const vec3_t v1, const vec3_t v2);
|
||||||
void _VectorSubtract (const vec3_t veca, const vec3_t vecb, vec3_t out);
|
void _VectorSubtract (const vec3_t veca, const vec3_t vecb, vec3_t out);
|
||||||
void _VectorAdd (const vec3_t veca, const vec3_t vecb, vec3_t out);
|
void _VectorAdd (const vec3_t veca, const vec3_t vecb, vec3_t out);
|
||||||
|
|
|
@ -6067,7 +6067,9 @@ static void PR_addentity_internal(edict_t *ed) //adds a csqc entity into the sce
|
||||||
eval_t *lerpfrac = GetEdictFieldValue(ed, qcvm->extfields.lerpfrac);
|
eval_t *lerpfrac = GetEdictFieldValue(ed, qcvm->extfields.lerpfrac);
|
||||||
eval_t *frame1time = GetEdictFieldValue(ed, qcvm->extfields.frame1time);
|
eval_t *frame1time = GetEdictFieldValue(ed, qcvm->extfields.frame1time);
|
||||||
eval_t *frame2time = GetEdictFieldValue(ed, qcvm->extfields.frame2time);
|
eval_t *frame2time = GetEdictFieldValue(ed, qcvm->extfields.frame2time);
|
||||||
|
eval_t *colormod = GetEdictFieldValue(ed, qcvm->extfields.colormod);
|
||||||
eval_t *alpha = GetEdictFieldValue(ed, qcvm->extfields.alpha);
|
eval_t *alpha = GetEdictFieldValue(ed, qcvm->extfields.alpha);
|
||||||
|
eval_t *scale = GetEdictFieldValue(ed, qcvm->extfields.scale);
|
||||||
eval_t *renderflags = GetEdictFieldValue(ed, qcvm->extfields.renderflags);
|
eval_t *renderflags = GetEdictFieldValue(ed, qcvm->extfields.renderflags);
|
||||||
int rf = renderflags?renderflags->_float:0;
|
int rf = renderflags?renderflags->_float:0;
|
||||||
|
|
||||||
|
@ -6075,7 +6077,15 @@ static void PR_addentity_internal(edict_t *ed) //adds a csqc entity into the sce
|
||||||
VectorCopy(ed->v.angles, e->angles);
|
VectorCopy(ed->v.angles, e->angles);
|
||||||
e->model = model;
|
e->model = model;
|
||||||
e->skinnum = ed->v.skin;
|
e->skinnum = ed->v.skin;
|
||||||
|
if (colormod && (colormod->vector[0]||colormod->vector[1]||colormod->vector[2]))
|
||||||
|
{
|
||||||
|
e->netstate.colormod[0] *= colormod->vector[0];
|
||||||
|
e->netstate.colormod[1] *= colormod->vector[1];
|
||||||
|
e->netstate.colormod[2] *= colormod->vector[2];
|
||||||
|
}
|
||||||
e->alpha = alpha?ENTALPHA_ENCODE(alpha->_float):ENTALPHA_DEFAULT;
|
e->alpha = alpha?ENTALPHA_ENCODE(alpha->_float):ENTALPHA_DEFAULT;
|
||||||
|
if (scale && scale->_float)
|
||||||
|
e->netstate.scale *= scale->_float;
|
||||||
|
|
||||||
//can't exactly use currentpose/previous pose, as we don't know them.
|
//can't exactly use currentpose/previous pose, as we don't know them.
|
||||||
e->lerpflags = LERP_EXPLICIT|LERP_RESETANIM|LERP_RESETMOVE;
|
e->lerpflags = LERP_EXPLICIT|LERP_RESETANIM|LERP_RESETMOVE;
|
||||||
|
|
Loading…
Reference in a new issue