void DrawHitBoxes() { extern int cam_thirdperson; for (int j = 1; j < 512; ++j) { cl_entity_t* entity = gEngfuncs.GetEntityByIndex(j); if (entity == gEngfuncs.GetLocalPlayer() && !cam_thirdperson) { continue; } if (entity->curstate.effects & EF_NODRAW) { continue; } if (entity != NULL && entity->model != NULL && entity->model->type == mod_studio) { int theEntityIndex = j; OBBox theBox[256]; int theNumBoxes; NS_GetHitBoxesForEntity(theEntityIndex, 256, theBox, theNumBoxes, gEngfuncs.GetClientTime()); for (int i = 0; i < theNumBoxes; ++i) { DrawHitBox(theBox[i]); } } } }
float NS_TraceLineAgainstEntity(int inEntityIndex, float inTime, const vec3_t inRayOrigin, const vec3_t inRayDirection) { /* // Do an early out test to see if the ray collides with the bounding box. NS_AnimationData theAnimationData; if (!NS_GetEntityAnimationData(inEntityIndex, theAnimationData)) { return AVH_INFINITY; } OBBox theBoundingBox; theBoundingBox.mAxis[0][0] = theAnimationData.mMatrix[0][0]; theBoundingBox.mAxis[0][1] = theAnimationData.mMatrix[1][0]; theBoundingBox.mAxis[0][2] = theAnimationData.mMatrix[2][0]; theBoundingBox.mAxis[1][0] = theAnimationData.mMatrix[0][1]; theBoundingBox.mAxis[1][1] = theAnimationData.mMatrix[1][1]; theBoundingBox.mAxis[1][2] = theAnimationData.mMatrix[2][1]; theBoundingBox.mAxis[2][0] = theAnimationData.mMatrix[0][2]; theBoundingBox.mAxis[2][1] = theAnimationData.mMatrix[1][2]; theBoundingBox.mAxis[2][2] = theAnimationData.mMatrix[2][2]; theBoundingBox.mOrigin[0] = theAnimationData.mMatrix[0][3]; theBoundingBox.mOrigin[1] = theAnimationData.mMatrix[1][3]; theBoundingBox.mOrigin[2] = theAnimationData.mMatrix[2][3]; vec3_t temp; VectorSubtract(theAnimationData.mMins, theAnimationData.mMaxs, temp); VectorScale(temp, 0.5, theBoundingBox.mExtents); VectorAdd(theAnimationData.mMins, theAnimationData.mMaxs, temp); VectorScale(temp, 0.5, theBoundingBox.mOrigin); // Wrong space, but probably good enough. if (NS_GetIntersection(theBoundingBox, inRayOrigin, inRayDirection) == AVH_INFINITY) { return AVH_INFINITY; } */ // Do the full hit box test. const int kMaxNumBoxes = 255; OBBox theBoxes[kMaxNumBoxes]; int theNumBoxes; NS_GetHitBoxesForEntity(inEntityIndex, kMaxNumBoxes, theBoxes, theNumBoxes, inTime); float tMin = AVH_INFINITY; for (int i = 0; i < theNumBoxes; ++i) { float t = NS_GetIntersection(theBoxes[i], inRayOrigin, inRayDirection); if (t < tMin) { tMin = t; } } return tMin; }