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

Method UpdateTransformTool

Source/Editors/map_editor.cpp:3483–3580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3481}
3482
3483void MapEditor::UpdateTransformTool(SceneGraph* scenegraph, EditorTypes::Tool type, const LineSegment& mouseray, const Collision& c, GameCursor* cursor) {
3484 PROFILER_ZONE(g_profiler_ctx, "UpdateTransformTool()");
3485
3486 Mouse* mouse = &(Input::Instance()->getMouse());
3487 const Keyboard& keyboard = Input::Instance()->getKeyboard();
3488
3489 bool input_happened = false;
3490 bool transformation_happened = false;
3491
3492 if ((mouse->mouse_down_[Mouse::LEFT] || mouse->mouse_down_[Mouse::RIGHT]) && !mouse->mouse_double_click_[Mouse::LEFT]) {
3493 if (state_ == MapEditor::kIdle) {
3494 if (MouseWasClickedThisTimestep(mouse) && c.hit && c.hit_what && c.hit_what->Selected()) {
3495 // We are just starting to drag
3496 control_obj = c.hit_what;
3497 input_happened = true;
3498 StartMouseTransformation(type, control_obj, &control_editor_info, c, mouseray, cursor);
3499 }
3500 } else {
3501 // We are continuing to drag
3502 input_happened = true;
3503 bool snapping_enabled = KeyCommand::CheckDown(keyboard, KeyCommand::kSnapTransform, KIMF_LEVEL_EDITOR_GENERAL);
3504 if (control_obj) {
3505 transformation_happened = GetMouseTransformation(type, control_obj, &control_editor_info, snapping_enabled, mouseray, &curr_tool_transform, cursor);
3506 }
3507 }
3508 }
3509
3510 // Apply the transformation
3511 if (input_happened && state_ == MapEditor::kIdle) {
3512 PROFILER_ZONE(g_profiler_ctx, "Starting transform");
3513 if (KeyCommand::CheckDown(keyboard, KeyCommand::kCloneTransform, KIMF_LEVEL_EDITOR_GENERAL)) {
3514 EntityDescriptionList copy_desc_list;
3515 ActorsEditor_CopySelectedEntities(scenegraph, &copy_desc_list);
3516 ActorsEditor_UnlocalizeIDs(&copy_desc_list, scenegraph);
3517 MapEditor::DeselectAll(scenegraph);
3518 std::vector<Object*> new_objects;
3519 for (auto& i : copy_desc_list) {
3520 Object* new_entity = CreateObjectFromDesc(i);
3521 if (new_entity) {
3522 new_objects.push_back(new_entity);
3523 if (new_entity->permission_flags & Object::CAN_SELECT) {
3524 new_entity->Select(true);
3525 }
3526 if (ActorsEditor_AddEntity(scenegraph, new_entity, NULL, false)) {
3527 } else {
3528 LOGE << "Failed to add entity to scenegraph while cloning" << std::endl;
3529 delete new_entity;
3530 }
3531 } else {
3532 LOGE << "Failed to entity" << std::endl;
3533 }
3534 }
3535 for (auto& new_object : new_objects) {
3536 new_object->ReceiveObjectMessage(OBJECT_MSG::FINALIZE_LOADED_CONNECTIONS);
3537 }
3538 }
3539 state_ = MapEditor::kTransformDrag;
3540 for (auto obj : scenegraph->objects_) {

Callers

nothing calls this directly

Calls 15

StartMouseTransformationFunction · 0.85
GetMouseTransformationFunction · 0.85
CreateObjectFromDescFunction · 0.85
ActorsEditor_AddEntityFunction · 0.85
EndTransformationFunction · 0.85
SelectedMethod · 0.80
GetTranslationMethod · 0.80
GetRotationMethod · 0.80

Tested by

no test coverage detected