MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / lineCheck

Method lineCheck

Source/Objects/envobject.cpp:1336–1364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1334}
1335
1336int EnvObject::lineCheck(const vec3& start, const vec3& end, vec3* point, vec3* normal) {
1337 if (selected_) {
1338 if (!sphere_line_intersection(start, end, sphere_center_, sphere_radius_)) { // Much faster than the OBB check, and most objects probably won't fall under cursor
1339 return -1;
1340 }
1341 return LineCheckEditorCube(start, end, point, normal);
1342 }
1343 if (bullet_object_) {
1344 return GetBulletWorld()->CheckRayCollisionObj(start, end, *bullet_object_, point, normal);
1345 }
1346 if (model_id_ == -1 ||
1347 !sphere_line_intersection(start, end, sphere_center_, sphere_radius_)) {
1348 return -1;
1349 }
1350 const Model& model = Models::Instance()->GetModel(model_id_);
1351 int intersecting = model.lineCheckNoBackface(invert(transform_) * start,
1352 invert(transform_) * end,
1353 point,
1354 normal);
1355 if (intersecting != -1) {
1356 if (point) {
1357 *point = transform_ * *point;
1358 }
1359 if (normal) {
1360 *normal = GetRotation() * *normal;
1361 }
1362 }
1363 return intersecting;
1364}
1365
1366void EnvObject::Moved(Object::MoveType type) {
1367 Object::Moved(type);

Callers

nothing calls this directly

Calls 6

sphere_line_intersectionFunction · 0.85
GetRotationFunction · 0.85
CheckRayCollisionObjMethod · 0.80
lineCheckNoBackfaceMethod · 0.80
invertFunction · 0.50
GetModelMethod · 0.45

Tested by

no test coverage detected