Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick of Ironwail performance improvements #96

Merged
merged 2 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 13 additions & 39 deletions Quake/mathlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Returns 1, 2, or 1 + 2
int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
{
float dist1, dist2;
int xneg, yneg, zneg;
int sides;

#if 0 // this is done by the BOX_ON_PLANE_SIDE macro before calling this
Expand All @@ -126,46 +127,19 @@ int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
}
#endif

// general case
switch (p->signbits)
{
case 0:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
break;
case 1:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
break;
case 2:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
break;
case 3:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
break;
case 4:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
break;
case 5:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
break;
case 6:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
break;
case 7:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
break;
default:
dist1 = dist2 = 0; // shut up compiler
xneg = p->signbits & 1;
yneg = (p->signbits >> 1) & 1;
zneg = (p->signbits >> 2) & 1;

dist1 = p->normal[0] * (xneg ? emins : emaxs)[0] +
p->normal[1] * (yneg ? emins : emaxs)[1] +
p->normal[2] * (zneg ? emins : emaxs)[2];
dist2 = p->normal[0] * (xneg ? emaxs : emins)[0] +
p->normal[1] * (yneg ? emaxs : emins)[1] +
p->normal[2] * (zneg ? emaxs : emins)[2];

if (p->signbits & ~7)
Sys_Error ("BoxOnPlaneSide: Bad signbits");
break;
}

#if 0
int i;
Expand Down
6 changes: 3 additions & 3 deletions Quake/world.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,13 @@ void SV_FindTouchedLeafs (edict_t *ent, mnode_t *node)
if (node->contents == CONTENTS_SOLID)
return;

if (ent->num_leafs == MAX_ENT_LEAFS)
return;

// add an efrag if the node is a leaf

if ( node->contents < 0)
{
if (ent->num_leafs == MAX_ENT_LEAFS)
return;

leaf = (mleaf_t *)node;
leafnum = leaf - sv.worldmodel->leafs - 1;

Expand Down