-int Game::checkcollide(XYZ startpoint, XYZ endpoint)
-{
- 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 < Object::objects.size(); i++) {
- if (checkcollide(startpoint, endpoint, i, minx, miny, minz, maxx, maxy, maxz) != -1) {
- return i;
- }
- }
-
- return -1;
-}
-
-int Game::checkcollide(XYZ startpoint, XYZ endpoint, int what)
-{
- 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;
-
- return checkcollide(startpoint, endpoint, what, minx, miny, minz, maxx, maxy, maxz);
-}
-
-int Game::checkcollide(XYZ startpoint, XYZ endpoint, int what, float minx, float miny, float minz, float maxx, float maxy, float maxz)
-{
- XYZ colpoint, colviewer, coltarget;
-
- if (what == 1000) {
- if (terrain.lineTerrain(startpoint, endpoint, &colpoint) != -1) {
- return what;
- }
- } else {
- if ( Object::objects[what]->position.x > minx - Object::objects[what]->model.boundingsphereradius &&
- Object::objects[what]->position.x < maxx + Object::objects[what]->model.boundingsphereradius &&
- Object::objects[what]->position.y > miny - Object::objects[what]->model.boundingsphereradius &&
- Object::objects[what]->position.y < maxy + Object::objects[what]->model.boundingsphereradius &&
- Object::objects[what]->position.z > minz - Object::objects[what]->model.boundingsphereradius &&
- Object::objects[what]->position.z < maxz + Object::objects[what]->model.boundingsphereradius) {
- if ( Object::objects[what]->type != treeleavestype &&
- Object::objects[what]->type != bushtype &&
- Object::objects[what]->type != firetype) {
- colviewer = startpoint;
- coltarget = endpoint;
- if (Object::objects[what]->model.LineCheck(&colviewer, &coltarget, &colpoint, &Object::objects[what]->position, &Object::objects[what]->yaw) != -1) {
- return what;
- }
- }
- }
- }
-
- return -1;
-}
-