diff --git a/rehlds/engine/r_studio.cpp b/rehlds/engine/r_studio.cpp index 96ccbb6..9f90bb7 100644 --- a/rehlds/engine/r_studio.cpp +++ b/rehlds/engine/r_studio.cpp @@ -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; diff --git a/rehlds/msvc/ReHLDS.vcxproj b/rehlds/msvc/ReHLDS.vcxproj index 0dd2b0c..8c64839 100644 --- a/rehlds/msvc/ReHLDS.vcxproj +++ b/rehlds/msvc/ReHLDS.vcxproj @@ -843,7 +843,7 @@ Level3 Disabled true - REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_SELF;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions) + REHLDS_FIXES;REHLDS_FLIGHT_REC;REHLDS_OPT_PEDANTIC;REHLDS_SELF;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions) Precise /arch:IA32 %(AdditionalOptions) MultiThreadedDebug diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 3c34ea4..7c6da87 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -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; }