| 457 | } |
| 458 | |
| 459 | static void BoxSelectEntities(SceneGraph* scenegraph, |
| 460 | const TypeEnable& type_enable, |
| 461 | const LineSegment& mouseray, |
| 462 | const vec4& p1, const vec4& p3, const vec4& r1, const vec4& r2, |
| 463 | const vec4& n1, const vec4& n2, const vec4& n3, const vec4& n4, bool holding_shift) { |
| 464 | Keyboard* keyboard = &(Input::Instance()->getKeyboard()); |
| 465 | |
| 466 | vec4 test_p, test_d; |
| 467 | Collision c; |
| 468 | for (size_t i = 0, len = scenegraph->objects_.size(); i < len; ++i) { |
| 469 | Object* obj = scenegraph->objects_[i]; |
| 470 | if (!obj->parent && obj->permission_flags & Object::CAN_SELECT && type_enable.IsTypeEnabled(obj->GetType())) { |
| 471 | test_p = obj->GetTranslation(); |
| 472 | |
| 473 | test_d = test_p - p1; |
| 474 | if (dot(test_d, n1) < 0) continue; |
| 475 | if (dot(test_d, n4) < 0) continue; |
| 476 | |
| 477 | test_d = test_p - p3; |
| 478 | if (dot(test_d, n2) < 0) continue; |
| 479 | if (dot(test_d, n3) < 0) continue; |
| 480 | |
| 481 | if (keyboard->isKeycodeDown(SDLK_CTRL, KIMF_LEVEL_EDITOR_GENERAL)) { |
| 482 | // lineCheck against center and all eight corners of entity's bounding box; only miss if none of these points are hit |
| 483 | bool hit = false; |
| 484 | // vec3 rad_ws = obj->GetTransform() * (obj->box_.dims*0.5f); |
| 485 | c = scenegraph->lineCheckCollidable(mouseray.start, vec3(test_p[0], test_p[1], test_p[2]), NULL); |
| 486 | if (c.hit_what == obj) hit = true; |
| 487 | if (!hit) continue; |
| 488 | } |
| 489 | |
| 490 | obj->Select(true); |
| 491 | } |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | MapEditor::MapEditor() : state_(MapEditor::kIdle), |
| 496 | control_obj(NULL), |
no test coverage detected