Linux GLX, a lot of code shrinkage/cleanup, assembly support.
[divverent/darkplaces.git] / cpu_noasm.c
1
2 #include "quakedef.h"
3
4 /*
5 ===============
6 Mod_PointInLeaf
7 ===============
8 */
9 mleaf_t *Mod_PointInLeaf (vec3_t p, model_t *model)
10 {
11         mnode_t         *node;
12         
13 //      if (!model || !model->nodes)
14 //              Sys_Error ("Mod_PointInLeaf: bad model");
15
16         node = model->nodes;
17         if (node->contents < 0)
18                 return (mleaf_t *)node;
19         while (1)
20         {
21                 node = node->children[(node->plane->type < 3 ? p[node->plane->type] : DotProduct (p,node->plane->normal)) < node->plane->dist];
22                 if (node->contents < 0)
23                         return (mleaf_t *)node;
24         }
25         
26         return NULL;    // never reached
27 }
28 /*
29 mleaf_t *Mod_PointInLeaf (vec3_t p, model_t *model)
30 {
31         mnode_t         *node;
32         float           d;
33         mplane_t        *plane;
34         
35         if (!model || !model->nodes)
36                 Sys_Error ("Mod_PointInLeaf: bad model");
37
38         node = model->nodes;
39         while (1)
40         {
41                 if (node->contents < 0)
42                         return (mleaf_t *)node;
43                 plane = node->plane;
44                 d = DotProduct (p,plane->normal) - plane->dist;
45                 if (d > 0)
46                         node = node->children[0];
47                 else
48                         node = node->children[1];
49         }
50         
51         return NULL;    // never reached
52 }
53 */
54
55 /*
56 ==================
57 SV_HullPointContents
58
59 ==================
60 */
61 int SV_HullPointContents (hull_t *hull, int num, vec3_t p)
62 {
63         while (num >= 0)
64                 num = hull->clipnodes[num].children[(hull->planes[hull->clipnodes[num].planenum].type < 3 ? p[hull->planes[hull->clipnodes[num].planenum].type] : DotProduct (hull->planes[hull->clipnodes[num].planenum].normal, p)) < hull->planes[hull->clipnodes[num].planenum].dist];
65         
66         return num;
67 }