Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/editor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1054,9 +1054,14 @@ impl Node for Editor {
} else if let Some(dragged_object) = node.dragged_object.take() {
let map = node.get_map();

let click_offset = match dragged_object {
DraggedObject::MapObject { click_offset, .. }
| DraggedObject::SpawnPoint { click_offset, .. } => click_offset,
};

let cursor_world_position = scene::find_node_by_type::<EditorCamera>()
.unwrap()
.to_world_space(node.cursor_position);
.to_world_space(node.cursor_position - click_offset);

let mut position = (cursor_world_position).clamp(
map.world_offset,
Expand All @@ -1074,10 +1079,8 @@ impl Node for Editor {
kind,
index,
layer_id,
click_offset,
..
} => {
let position = position - click_offset;

let action = EditorAction::UpdateObject {
id,
kind,
Expand All @@ -1088,12 +1091,7 @@ impl Node for Editor {

node.apply_action(action);
}
DraggedObject::SpawnPoint {
index,
click_offset,
} => {
let position = position - click_offset;

DraggedObject::SpawnPoint { index, .. } => {
let action = EditorAction::MoveSpawnPoint { index, position };

node.apply_action(action);
Expand Down