change model pitch axis to +X instead of old weird -Y behavior that differed from the camera
parent
104a988a4b
commit
c4b8fa99bd
|
@ -1048,10 +1048,10 @@ struct animmodel : model
|
|||
{
|
||||
if(!loaded) return -1;
|
||||
|
||||
yaw += offsetyaw + spinyaw*lastmillis/1000.0f;
|
||||
pitch += offsetpitch + spinpitch*lastmillis/1000.0f;
|
||||
yaw += spinyaw*lastmillis/1000.0f;
|
||||
pitch += spinpitch*lastmillis/1000.0f;
|
||||
|
||||
vec axis(0, -1, 0), forward(1, 0, 0);
|
||||
vec axis(1, 0, 0), forward(0, 1, 0);
|
||||
|
||||
matrixpos = 0;
|
||||
matrixstack[0].identity();
|
||||
|
@ -1061,6 +1061,8 @@ struct animmodel : model
|
|||
matrixstack[0].rotate_around_z(yaw*RAD);
|
||||
matrixstack[0].transformnormal(vec(axis), axis);
|
||||
matrixstack[0].transformnormal(vec(forward), forward);
|
||||
if(offsetyaw) matrixstack[0].rotate_around_z(offsetyaw*RAD);
|
||||
if(offsetpitch) matrixstack[0].rotate_around_x(offsetpitch*RAD);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1165,10 +1167,10 @@ struct animmodel : model
|
|||
{
|
||||
if(!loaded) return;
|
||||
|
||||
yaw += offsetyaw + spinyaw*lastmillis/1000.0f;
|
||||
pitch += offsetpitch + spinpitch*lastmillis/1000.0f;
|
||||
yaw += spinyaw*lastmillis/1000.0f;
|
||||
pitch += spinpitch*lastmillis/1000.0f;
|
||||
|
||||
vec axis(0, -1, 0), forward(1, 0, 0);
|
||||
vec axis(1, 0, 0), forward(0, 1, 0);
|
||||
|
||||
matrixpos = 0;
|
||||
matrixstack[0].identity();
|
||||
|
@ -1178,6 +1180,8 @@ struct animmodel : model
|
|||
matrixstack[0].rotate_around_z(yaw*RAD);
|
||||
matrixstack[0].transformnormal(vec(axis), axis);
|
||||
matrixstack[0].transformnormal(vec(forward), forward);
|
||||
if(offsetyaw) matrixstack[0].rotate_around_z(offsetyaw*RAD);
|
||||
if(offsetpitch) matrixstack[0].rotate_around_x(offsetpitch*RAD);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1244,7 +1248,7 @@ struct animmodel : model
|
|||
{
|
||||
m.identity();
|
||||
if(offsetyaw) m.rotate_around_z(offsetyaw*RAD);
|
||||
if(offsetpitch) m.rotate_around_y(-offsetpitch*RAD);
|
||||
if(offsetpitch) m.rotate_around_x(offsetpitch*RAD);
|
||||
m.translate(translate, scale);
|
||||
}
|
||||
|
||||
|
|
|
@ -293,8 +293,8 @@ bool mmintersect(const extentity &e, const vec &o, const vec &ray, float maxdist
|
|||
if(pitch < 0) pitch = 360 + pitch%360;
|
||||
else if(pitch >= 360) pitch %= 360;
|
||||
const vec2 &rot = sincos360[pitch];
|
||||
mo.rotate_around_y(rot.x, rot.y);
|
||||
mray.rotate_around_y(rot.x, rot.y);
|
||||
mo.rotate_around_x(rot.x, -rot.y);
|
||||
mray.rotate_around_x(rot.x, -rot.y);
|
||||
}
|
||||
if(m->bih->traverse(mo, mray, maxdist ? maxdist : 1e16f, dist, mode))
|
||||
{
|
||||
|
|
|
@ -54,12 +54,12 @@ struct model
|
|||
boundbox(center, radius);
|
||||
if(collideradius)
|
||||
{
|
||||
center[0] = center[1] = 0;
|
||||
radius[0] = radius[1] = collideradius;
|
||||
center.x = center.y = 0;
|
||||
radius.x = radius.y = collideradius;
|
||||
}
|
||||
if(collideheight)
|
||||
{
|
||||
center[2] = radius[2] = collideheight/2;
|
||||
center.z = radius.z = collideheight/2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ namespace mpr
|
|||
|
||||
ModelOBB(const vec &ent, const vec ¢er, const vec &radius, float yaw, float pitch) : o(ent), radius(radius), orient(vec(0, 0, 1), yaw*RAD)
|
||||
{
|
||||
if(pitch) orient.mul(quat(vec(0, 1, 0), pitch*RAD), quat(orient));
|
||||
if(pitch) orient.mul(quat(vec(1, 0, 0), pitch*RAD), quat(orient));
|
||||
o.add(orient.rotate(center));
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ namespace mpr
|
|||
|
||||
ModelEllipse(const vec &ent, const vec ¢er, const vec &radius, float yaw, float pitch) : o(ent), radius(radius), orient(vec(0, 0, 1), yaw*RAD)
|
||||
{
|
||||
if(pitch) orient.mul(quat(vec(0, 1, 0), pitch*RAD), quat(orient));
|
||||
if(pitch) orient.mul(quat(vec(1, 0, 0), pitch*RAD), quat(orient));
|
||||
o.add(orient.rotate(center));
|
||||
}
|
||||
|
||||
|
|
|
@ -722,10 +722,9 @@ void rotatebb(vec ¢er, vec &radius, int yaw, int pitch)
|
|||
if(pitch < 0) pitch = 360 + pitch%360;
|
||||
else if(pitch >= 360) pitch %= 360;
|
||||
const vec2 &rot = sincos360[pitch];
|
||||
vec2 oldcenter(center.x, center.z), oldradius(radius.x, radius.z);
|
||||
center.x = oldcenter.x*rot.x - oldcenter.y*rot.y;
|
||||
center.z = oldcenter.y*rot.x + oldcenter.x*rot.y;
|
||||
radius.x = fabs(oldradius.x*rot.x) + fabs(oldradius.y*rot.y);
|
||||
center.rotate_around_x(rot.x, rot.y);
|
||||
vec2 oldradius(radius.y, radius.z);
|
||||
radius.y = fabs(oldradius.x*rot.x) + fabs(oldradius.y*rot.y);
|
||||
radius.z = fabs(oldradius.y*rot.x) + fabs(oldradius.x*rot.y);
|
||||
}
|
||||
if(yaw)
|
||||
|
@ -733,9 +732,8 @@ void rotatebb(vec ¢er, vec &radius, int yaw, int pitch)
|
|||
if(yaw < 0) yaw = 360 + yaw%360;
|
||||
else if(yaw >= 360) yaw %= 360;
|
||||
const vec2 &rot = sincos360[yaw];
|
||||
vec2 oldcenter(center), oldradius(radius);
|
||||
center.x = oldcenter.x*rot.x - oldcenter.y*rot.y;
|
||||
center.y = oldcenter.y*rot.x + oldcenter.x*rot.y;
|
||||
center.rotate_around_z(rot.x, rot.y);
|
||||
vec2 oldradius(radius);
|
||||
radius.x = fabs(oldradius.x*rot.x) + fabs(oldradius.y*rot.y);
|
||||
radius.y = fabs(oldradius.y*rot.x) + fabs(oldradius.x*rot.y);
|
||||
}
|
||||
|
@ -769,7 +767,7 @@ bool mmcollide(physent *d, const vec &dir, octaentities &oc) // co
|
|||
vec center, radius;
|
||||
m->collisionbox(center, radius);
|
||||
if(e.attr4 > 0) { float scale = e.attr4/100.f; center.mul(scale); radius.mul(scale); }
|
||||
float yaw = e.attr1, pitch = e.attr3;
|
||||
int yaw = e.attr1, pitch = e.attr3;
|
||||
switch(d->collidetype)
|
||||
{
|
||||
case COLLIDE_ELLIPSE:
|
||||
|
@ -791,7 +789,7 @@ bool mmcollide(physent *d, const vec &dir, octaentities &oc) // co
|
|||
break;
|
||||
case COLLIDE_AABB:
|
||||
default:
|
||||
rotatebb(center, radius, e.attr1, e.attr3);
|
||||
rotatebb(center, radius, yaw, pitch);
|
||||
if(!rectcollide(d, dir, center.add(e.o), radius.x, radius.y, radius.z, radius.z)) return false;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue