From 51912a872f259e709f25823bb24c975e4ff9de6a Mon Sep 17 00:00:00 2001 From: Rafael Barreto Date: Sat, 22 May 2010 23:23:04 +0000 Subject: [PATCH] testing: making the shots pass over the shoulder (lets see if affect the gameplay... if so, we undo it) git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4999 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/rendermodel.cpp | 28 ++++++++++++++++++---------- source/src/weapon.cpp | 9 ++++++--- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index 1bdcecba..279179ea 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -516,18 +516,10 @@ void preload_mapmodels() } } -VAR(dbghbox, 0, 0, 1); +VAR(dbghbox, 0, 0, 1); //FIXME remove on release -void renderhbox(playerent *d) +inline void renderhboxpart(playerent *d, vec top, vec bottom, vec up) { - glDisable(GL_TEXTURE_2D); - glColor3f(1, 1, 1); - - float y = d->yaw*RAD, p = (d->pitch/4+90)*RAD, c = cosf(p); - vec bottom(d->o), up(sinf(y)*c, -cosf(y)*c, sinf(p)), top(up); - bottom.z -= d->eyeheight; - top.mul(d->eyeheight + d->aboveeye).add(bottom); - if(d->state==CS_ALIVE && d->head.x >= 0) { glBegin(GL_LINE_LOOP); @@ -575,6 +567,22 @@ void renderhbox(playerent *d) glVertex3fv(pos.v); } glEnd(); +} + +void renderhbox(playerent *d) +{ + glDisable(GL_TEXTURE_2D); + glColor3f(1, 1, 1); + + float y = d->yaw*RAD, p = (d->pitch/4+90)*RAD, c = cosf(p); + vec bottom(d->o), up(sinf(y)*c, -cosf(y)*c, sinf(p)), top(up), mid(up); + bottom.z -= d->eyeheight; + float h = d->eyeheight /*+ d->aboveeye*/; // shoulder limit + mid.mul(h*0.5).add(bottom); + top.mul(h).add(bottom); + + renderhboxpart(d,top,mid,up); + renderhboxpart(d,mid,bottom,up); glEnable(GL_TEXTURE_2D); } diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index b6ac86f3..137c703c 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -245,6 +245,7 @@ static inline bool intersectcylinder(const vec &from, const vec &to, const vec & return dist >= 0 && dist <= 1; } + int intersect(playerent *d, const vec &from, const vec &to, vec *end) { float dist; @@ -257,10 +258,12 @@ int intersect(playerent *d, const vec &from, const vec &to, vec *end) } } float y = d->yaw*RAD, p = (d->pitch/4+90)*RAD, c = cosf(p); - vec bottom(d->o), top(sinf(y)*c, -cosf(y)*c, sinf(p)); + vec bottom(d->o), top(sinf(y)*c, -cosf(y)*c, sinf(p))/*, mid(top)*/; bottom.z -= d->eyeheight; - top.mul(d->eyeheight + d->aboveeye).add(bottom); - if(intersectcylinder(from, to, bottom, top, d->radius, dist)) + float h = d->eyeheight /*+ d->aboveeye*/; // this mod makes the shots pass over the shoulders +// mid.mul(h*0.5).add(bottom); // this mod divides the hitbox in 2 + top.mul(h).add(bottom); + if( intersectcylinder(from, to, bottom, top, d->radius, dist) ) // FIXME if using 2 hitboxes { if(end) (*end = to).sub(from).mul(dist).add(from); return 1;