Added snap to grid + local/world space UI
This commit is contained in:
@@ -34,6 +34,9 @@ Transform_Gizmo :: struct {
|
||||
actual_entity_scale: Vector3; // The actual position of the selected entity. Used for snapping
|
||||
last_circle_dir: Vector3;
|
||||
|
||||
// Settings
|
||||
snap_to_grid: bool;
|
||||
|
||||
clicked: bool;
|
||||
|
||||
transform: Transform;
|
||||
@@ -184,7 +187,12 @@ update_transform_gizmo :: (ray: Ray, mouse_position: Vector2) -> bool {
|
||||
|
||||
entity_position := engine.editor.transform_gizmo.actual_entity_position + position_change;
|
||||
|
||||
if selected_entity.flags & Entity_Flags.SNAP_TO_GRID {
|
||||
if engine.editor.transform_gizmo.snap_to_grid {
|
||||
snap_interval := Vector3.{1,1,1};
|
||||
entity_position.x -= fmod_cycling(entity_position.x - selected_entity.snap_offset.x, snap_interval.x);// + selected_entity.snap_offset.x;
|
||||
entity_position.y -= fmod_cycling(entity_position.y - selected_entity.snap_offset.y, snap_interval.y);// + selected_entity.snap_offset.y;
|
||||
entity_position.z -= fmod_cycling(entity_position.z - selected_entity.snap_offset.z, snap_interval.z);// + selected_entity.snap_offset.z;
|
||||
} else if selected_entity.flags & Entity_Flags.SNAP_TO_GRID {
|
||||
entity_position.x -= fmod_cycling(entity_position.x - selected_entity.snap_offset.x, selected_entity.snap_intervals.x);// + selected_entity.snap_offset.x;
|
||||
entity_position.y -= fmod_cycling(entity_position.y - selected_entity.snap_offset.y, selected_entity.snap_intervals.y);// + selected_entity.snap_offset.y;
|
||||
entity_position.z -= fmod_cycling(entity_position.z - selected_entity.snap_offset.z, selected_entity.snap_intervals.z);// + selected_entity.snap_offset.z;
|
||||
|
||||
Reference in New Issue
Block a user