2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-03-12 21:40:30 +03:00

Playing with hitboxes

This commit is contained in:
dreamstalker 2015-07-11 01:44:08 +04:00
parent 5b50c6fb89
commit 640263aeb1
3 changed files with 53 additions and 9 deletions

View File

@ -650,12 +650,56 @@ hull_t *R_StudioHull(model_t *pModel, float frame, int sequence, const vec_t *an
{
mplane_t* plane0 = &studio_planes[i * 6 + j * 2 + 0];
mplane_t* plane1 = &studio_planes[i * 6 + j * 2 + 1];
#ifdef REHLDS_FIXES
//Correct size addition
SV_SetStudioHullPlane(plane0, pbbox[i].bone, j, pbbox[i].bbmax[j] + size[j]);
SV_SetStudioHullPlane(plane1, pbbox[i].bone, j, pbbox[i].bbmin[j] - size[j]);
#else
SV_SetStudioHullPlane(plane0, pbbox[i].bone, j, pbbox[i].bbmax[j]);
SV_SetStudioHullPlane(plane1, pbbox[i].bone, j, pbbox[i].bbmin[j]);
plane0->dist += fabs(plane0->normal[0] * size[0]) + fabs(plane0->normal[1] * size[1]) + fabs(plane0->normal[2] * size[2]);
plane1->dist -= fabs(plane1->normal[0] * size[0]) + fabs(plane1->normal[1] * size[1]) + fabs(plane1->normal[2] * size[2]);
#endif
}
/* BEGIN DEBUG */
vec3_t vertices[] = {
{ pbbox[i].bbmin[0] - size[0], pbbox[i].bbmin[1] - size[1], pbbox[i].bbmin[2] - size[2] },
{ pbbox[i].bbmin[0] - size[0], pbbox[i].bbmin[1] - size[1], pbbox[i].bbmax[2] + size[2] },
{ pbbox[i].bbmax[0] + size[0], pbbox[i].bbmin[1] - size[1], pbbox[i].bbmax[2] + size[2] },
{ pbbox[i].bbmax[0] + size[0], pbbox[i].bbmin[1] - size[1], pbbox[i].bbmin[2] - size[2] },
{ pbbox[i].bbmin[0] - size[0], pbbox[i].bbmax[1] + size[1], pbbox[i].bbmin[2] - size[2] },
{ pbbox[i].bbmin[0] - size[0], pbbox[i].bbmax[1] + size[1], pbbox[i].bbmax[2] + size[2] },
{ pbbox[i].bbmax[0] + size[0], pbbox[i].bbmax[1] + size[1], pbbox[i].bbmax[2] + size[2] },
{ pbbox[i].bbmax[0] + size[0], pbbox[i].bbmax[1] + size[1], pbbox[i].bbmin[2] - size[2] }
};
vec3_t transformedVertices[8];
for (int j = 0; j < 8; j++) {
VectorTransform(vertices[j], (float*)bonetransform[pbbox[i].bone], transformedVertices[j]);
}
float vertices2[3 * 8];
GetHitboxCorners(i, vertices2);
for (int j = 0; j < 8; j++) {
if (fabs(vertices2[0 + j*3] - transformedVertices[j][0]) > 0.2) {
Con_Printf("X Mismatch! %d\n", j);
}
if (fabs(vertices2[1 + j * 3] - transformedVertices[j][1]) > 0.2) {
Con_Printf("Y Mismatch! %d\n", j);
}
if (fabs(vertices2[2 + j * 3] - transformedVertices[j][2]) > 0.2) {
Con_Printf("Z Mismatch! %d\n", j);
}
}
/* END DEBUG */
}
*pNumHulls = (bSkipShield == 1) ? pstudiohdr->numhitboxes - 1 : pstudiohdr->numhitboxes;

View File

@ -843,7 +843,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_SELF;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>REHLDS_FIXES;REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_SELF;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FloatingPointModel>Precise</FloatingPointModel>
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>

View File

@ -77,36 +77,36 @@ bool EXT_FUNC GetHitboxCorners(int hitboxId, float* /* [8*3] */ corners) {
if (PIR_1 != CalcPlanesIntersection(left, front, bottom, p))
return false;
corners[0 * 3 + 0] = p[0]; corners[0 * 3 + 1] = p[1]; corners[0 * 3 + 1] = p[2];
corners[0 * 3 + 0] = p[0]; corners[0 * 3 + 1] = p[1]; corners[0 * 3 + 2] = p[2];
if (PIR_1 != CalcPlanesIntersection(left, front, top, p))
return false;
corners[1 * 3 + 0] = p[0]; corners[1 * 3 + 1] = p[1]; corners[1 * 3 + 1] = p[2];
corners[1 * 3 + 0] = p[0]; corners[1 * 3 + 1] = p[1]; corners[1 * 3 + 2] = p[2];
if (PIR_1 != CalcPlanesIntersection(right, front, top, p))
return false;
corners[2 * 3 + 0] = p[0]; corners[2 * 3 + 1] = p[1]; corners[2 * 3 + 1] = p[2];
corners[2 * 3 + 0] = p[0]; corners[2 * 3 + 1] = p[1]; corners[2 * 3 + 2] = p[2];
if (PIR_1 != CalcPlanesIntersection(right, front, bottom, p))
return false;
corners[3 * 3 + 0] = p[0]; corners[3 * 3 + 1] = p[1]; corners[3 * 3 + 1] = p[2];
corners[3 * 3 + 0] = p[0]; corners[3 * 3 + 1] = p[1]; corners[3 * 3 + 2] = p[2];
if (PIR_1 != CalcPlanesIntersection(left, rear, bottom, p))
return false;
corners[4 * 3 + 0] = p[0]; corners[4 * 3 + 1] = p[1]; corners[4 * 3 + 1] = p[2];
corners[4 * 3 + 0] = p[0]; corners[4 * 3 + 1] = p[1]; corners[4 * 3 + 2] = p[2];
if (PIR_1 != CalcPlanesIntersection(left, rear, top, p))
return false;
corners[5 * 3 + 0] = p[0]; corners[5 * 3 + 1] = p[1]; corners[5 * 3 + 1] = p[2];
corners[5 * 3 + 0] = p[0]; corners[5 * 3 + 1] = p[1]; corners[5 * 3 + 2] = p[2];
if (PIR_1 != CalcPlanesIntersection(right, rear, top, p))
return false;
corners[6 * 3 + 0] = p[0]; corners[6 * 3 + 1] = p[1]; corners[6 * 3 + 1] = p[2];
corners[6 * 3 + 0] = p[0]; corners[6 * 3 + 1] = p[1]; corners[6 * 3 + 2] = p[2];
if (PIR_1 != CalcPlanesIntersection(right, rear, bottom, p))
return false;
corners[7 * 3 + 0] = p[0]; corners[7 * 3 + 1] = p[1]; corners[7 * 3 + 1] = p[2];
corners[7 * 3 + 0] = p[0]; corners[7 * 3 + 1] = p[1]; corners[7 * 3 + 2] = p[2];
return true;
}