- if (closestdistance != -1 && isnormal(closestdistance)) {
- if (DistancePointLine(&closestpoint, &position, &tippoint, &distance, &colpoint )) {
- closestswordpoint = colpoint;
- velocity += (closestpoint - closestswordpoint);
- tipvelocity += (closestpoint - closestswordpoint);
- position += (closestpoint - closestswordpoint);
- tippoint += (closestpoint - closestswordpoint);
- }
+ tippoint += (mid - oldmid2) * (20 / (1 + (float)m * 10));
+ }
+ }
+ } else {
+ start = position;
+ end = tippoint;
+ whichhit = Object::objects[k]->model.LineCheck(&start, &end, &colpoint, &Object::objects[k]->position, &Object::objects[k]->yaw);
+ if (whichhit != -1) {
+ hitsomething = 1;
+ closestdistance = -1;
+ closestswordpoint = colpoint;
+ point[0] = DoRotation(Object::objects[k]->model.getTriangleVertex(whichhit, 0), 0, Object::objects[k]->yaw, 0) + Object::objects[k]->position;
+ point[1] = DoRotation(Object::objects[k]->model.getTriangleVertex(whichhit, 1), 0, Object::objects[k]->yaw, 0) + Object::objects[k]->position;
+ point[2] = DoRotation(Object::objects[k]->model.getTriangleVertex(whichhit, 2), 0, Object::objects[k]->yaw, 0) + Object::objects[k]->position;
+ if (DistancePointLine(&closestswordpoint, &point[0], &point[1], &distance, &colpoint)) {
+ if (distance < closestdistance || closestdistance == -1) {
+ closestpoint = colpoint;
+ closestdistance = distance;
+ }
+ }
+ if (DistancePointLine(&closestswordpoint, &point[1], &point[2], &distance, &colpoint)) {
+ if (distance < closestdistance || closestdistance == -1) {
+ closestpoint = colpoint;
+ closestdistance = distance;
+ }
+ }
+ if (DistancePointLine(&closestswordpoint, &point[2], &point[0], &distance, &colpoint)) {
+ if (distance < closestdistance || closestdistance == -1) {
+ closestpoint = colpoint;
+ closestdistance = distance;
+ }
+ }
+ if (closestdistance != -1 && isnormal(closestdistance)) {
+ if (DistancePointLine(&closestpoint, &position, &tippoint, &distance, &colpoint)) {
+ closestswordpoint = colpoint;
+ velocity += (closestpoint - closestswordpoint);
+ tipvelocity += (closestpoint - closestswordpoint);
+ position += (closestpoint - closestswordpoint);
+ tippoint += (closestpoint - closestswordpoint);