-int Game::checkcollide(XYZ startpoint, XYZ endpoint)
-{
- static XYZ colpoint, colviewer, coltarget;
- static float minx, minz, maxx, maxz, miny, maxy;
-
- minx = min(startpoint.x, endpoint.x) - 1;
- miny = min(startpoint.y, endpoint.y) - 1;
- minz = min(startpoint.z, endpoint.z) - 1;
- maxx = max(startpoint.x, endpoint.x) + 1;
- maxy = max(startpoint.y, endpoint.y) + 1;
- maxz = max(startpoint.z, endpoint.z) + 1;
-
- for (int i = 0; i < objects.numobjects; i++) {
- if ( objects.position[i].x > minx - objects.model[i].boundingsphereradius &&
- objects.position[i].x < maxx + objects.model[i].boundingsphereradius &&
- objects.position[i].y > miny - objects.model[i].boundingsphereradius &&
- objects.position[i].y < maxy + objects.model[i].boundingsphereradius &&
- objects.position[i].z > minz - objects.model[i].boundingsphereradius &&
- objects.position[i].z < maxz + objects.model[i].boundingsphereradius) {
- if ( objects.type[i] != treeleavestype &&
- objects.type[i] != bushtype &&
- objects.type[i] != firetype) {
- colviewer = startpoint;
- coltarget = endpoint;
- if (objects.model[i].LineCheck(&colviewer, &coltarget, &colpoint, &objects.position[i], &objects.yaw[i]) != -1)
- return i;
- }
- }
- }
-
- return -1;
-}
-
-int Game::checkcollide(XYZ startpoint, XYZ endpoint, int what)
-{
- static XYZ colpoint, colviewer, coltarget;
- static float minx, minz, maxx, maxz, miny, maxy;
- static int i; //FIXME: see below
-
- minx = min(startpoint.x, endpoint.x) - 1;
- miny = min(startpoint.y, endpoint.y) - 1;
- minz = min(startpoint.z, endpoint.z) - 1;
- maxx = max(startpoint.x, endpoint.x) + 1;
- maxy = max(startpoint.y, endpoint.y) + 1;
- maxz = max(startpoint.z, endpoint.z) + 1;
-
- if (what != 1000) {
- if ( objects.position[what].x > minx - objects.model[what].boundingsphereradius &&
- objects.position[what].x < maxx + objects.model[what].boundingsphereradius &&
- objects.position[what].y > miny - objects.model[what].boundingsphereradius &&
- objects.position[what].y < maxy + objects.model[what].boundingsphereradius &&
- objects.position[what].z > minz - objects.model[what].boundingsphereradius &&
- objects.position[what].z < maxz + objects.model[what].boundingsphereradius) {
- if ( objects.type[what] != treeleavestype &&
- objects.type[what] != bushtype &&
- objects.type[what] != firetype) {
- colviewer = startpoint;
- coltarget = endpoint;
- //FIXME: i/what
- if (objects.model[what].LineCheck(&colviewer, &coltarget, &colpoint, &objects.position[what], &objects.yaw[what]) != -1)
- return i;
- }
- }
- }
-
- if (what == 1000)
- if (terrain.lineTerrain(startpoint, endpoint, &colpoint) != -1)
- return 1000;
-
- return -1;
-}
-