Adds missing data
This commit is contained in:
parent
e6391d9fdd
commit
53cdcc3433
620 changed files with 47293 additions and 151 deletions
|
|
@ -0,0 +1,67 @@
|
|||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
|
||||
extends Resource
|
||||
class_name CyclopsSnappingSystem
|
||||
|
||||
var move_constraint:MoveConstraint.Type = MoveConstraint.Type.NONE
|
||||
|
||||
var plugin:CyclopsLevelBuilder
|
||||
|
||||
func _activate(plugin:CyclopsLevelBuilder):
|
||||
self.plugin = plugin
|
||||
|
||||
func _deactivate():
|
||||
pass
|
||||
|
||||
func _snap_point(point:Vector3, query:SnappingQuery)->Vector3:
|
||||
return point
|
||||
|
||||
func _snap_angle(angle:float, query:SnappingQuery)->float:
|
||||
return angle
|
||||
|
||||
func _get_properties_editor()->Control:
|
||||
return null
|
||||
|
||||
func constrain_point(point:Vector3, target_point:Vector3, move_constraint:MoveConstraint.Type = MoveConstraint.Type.NONE)->Vector3:
|
||||
match move_constraint:
|
||||
MoveConstraint.Type.NONE:
|
||||
return target_point
|
||||
MoveConstraint.Type.AXIS_X:
|
||||
return Vector3(target_point.x, point.y, point.z)
|
||||
MoveConstraint.Type.AXIS_Y:
|
||||
return Vector3(point.x, target_point.y, point.z)
|
||||
MoveConstraint.Type.AXIS_Z:
|
||||
return Vector3(point.x, point.y, target_point.z)
|
||||
MoveConstraint.Type.PLANE_XY:
|
||||
return Vector3(target_point.x, target_point.y, point.z)
|
||||
MoveConstraint.Type.PLANE_XZ:
|
||||
return Vector3(target_point.x, point.y, target_point.z)
|
||||
MoveConstraint.Type.PLANE_YZ:
|
||||
return Vector3(point.x, target_point.y, target_point.z)
|
||||
_:
|
||||
return point
|
||||
|
||||
|
||||
28
addons/cyclops_level_builder/snapping/move_constraint.gd
Normal file
28
addons/cyclops_level_builder/snapping/move_constraint.gd
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
class_name MoveConstraint
|
||||
|
||||
enum Type { NONE, AXIS_X, AXIS_Y, AXIS_Z, PLANE_XY, PLANE_XZ, PLANE_YZ, PLANE_VIEWPORT }
|
||||
|
||||
92
addons/cyclops_level_builder/snapping/snap_to_grid_util.gd
Normal file
92
addons/cyclops_level_builder/snapping/snap_to_grid_util.gd
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
extends Resource
|
||||
class_name SnapToGridUtil
|
||||
|
||||
#const feet_per_meter:float = 3.28084
|
||||
|
||||
@export var unit_size:float = 1
|
||||
|
||||
@export var use_subdivisions:bool = false
|
||||
@export var grid_subdivisions:int = 10
|
||||
|
||||
@export var power_of_two_scale:int = 0 #Scaling 2^n
|
||||
|
||||
#local transform matrix for grid
|
||||
@export var grid_transform:Transform3D = Transform3D.IDENTITY:
|
||||
get:
|
||||
return grid_transform
|
||||
set(value):
|
||||
grid_transform = value
|
||||
grid_transform_inv = grid_transform.affine_inverse()
|
||||
|
||||
var grid_transform_inv:Transform3D = Transform3D.IDENTITY
|
||||
|
||||
func load_from_cache(cache:Dictionary):
|
||||
unit_size = cache.get("unit_size", 1)
|
||||
use_subdivisions = cache.get("use_subdivisions", false)
|
||||
grid_subdivisions = cache.get("grid_subdivisions", 10)
|
||||
power_of_two_scale = cache.get("power_of_two_scale", 0)
|
||||
#print("load grid_transform before")
|
||||
grid_transform = SerialUtil.load_cache_transform_3d(cache.get("grid_transform", ""), Transform3D.IDENTITY)
|
||||
#print("load grid_transform after ")
|
||||
|
||||
if is_zero_approx(grid_transform.basis.determinant()):
|
||||
#print("replace")
|
||||
grid_transform = Transform3D.IDENTITY
|
||||
#grid_transform = cache.get("grid_transform", Transform3D.IDENTITY)
|
||||
|
||||
func save_to_cache():
|
||||
#print("save SnapToGridUtil")
|
||||
return {
|
||||
"unit_size": unit_size,
|
||||
"use_subdivisions": use_subdivisions,
|
||||
"grid_subdivisions": grid_subdivisions,
|
||||
"power_of_two_scale": power_of_two_scale,
|
||||
"grid_transform": SerialUtil.save_cache_transform_3d(grid_transform),
|
||||
}
|
||||
|
||||
#Point is in world space
|
||||
func snap_point(point:Vector3)->Vector3:
|
||||
|
||||
var p_local:Vector3 = grid_transform_inv * point
|
||||
|
||||
#print("unit_size %s pow 2 %s" % [unit_size, pow(2, power_of_two_scale)])
|
||||
var scale:Vector3 = Vector3.ONE * unit_size * pow(2, power_of_two_scale)
|
||||
if use_subdivisions:
|
||||
scale /= float(grid_subdivisions)
|
||||
|
||||
p_local = floor(p_local / scale + Vector3(.5, .5, .5)) * scale
|
||||
|
||||
var target_point:Vector3 = grid_transform * p_local
|
||||
|
||||
#print("point %s target_point %s scale %s" % [point, target_point, scale])
|
||||
return target_point
|
||||
|
||||
func _to_string():
|
||||
return "unit_size %s use_subdiv %s subdiv %s pot %s xform %s" \
|
||||
% [unit_size, use_subdivisions, grid_subdivisions, power_of_two_scale, grid_transform]
|
||||
|
||||
|
||||
45
addons/cyclops_level_builder/snapping/snapping_manager.gd
Normal file
45
addons/cyclops_level_builder/snapping/snapping_manager.gd
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
extends RefCounted
|
||||
class_name SnappingManager
|
||||
|
||||
var snap_enabled:bool
|
||||
var snap_tool:CyclopsSnappingSystem
|
||||
|
||||
func snap_point(point:Vector3, query:SnappingQuery)->Vector3:
|
||||
if !snap_enabled || !snap_tool:
|
||||
return point
|
||||
|
||||
return snap_tool._snap_point(point, query)
|
||||
|
||||
func snap_angle(angle:float, query:SnappingQuery)->float:
|
||||
if !snap_enabled || !snap_tool:
|
||||
return angle
|
||||
|
||||
return snap_tool._snap_angle(angle, query)
|
||||
|
||||
|
||||
|
||||
|
||||
35
addons/cyclops_level_builder/snapping/snapping_query.gd
Normal file
35
addons/cyclops_level_builder/snapping/snapping_query.gd
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
extends Resource
|
||||
class_name SnappingQuery
|
||||
|
||||
|
||||
var viewport_camera:Camera3D
|
||||
var exclude_blocks:Array[NodePath]
|
||||
|
||||
|
||||
func _init(viewport_camera:Camera3D = null, exclude_blocks:Array[NodePath] = []):
|
||||
self.viewport_camera = viewport_camera
|
||||
self.exclude_blocks = exclude_blocks
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
|
||||
extends CyclopsSnappingSystem
|
||||
class_name SnappingSystemGrid
|
||||
|
||||
const SNAPPING_TOOL_ID:String = "grid"
|
||||
|
||||
var snap_to_grid_util:SnapToGridUtil = SnapToGridUtil.new()
|
||||
|
||||
func _activate(plugin:CyclopsLevelBuilder):
|
||||
super._activate(plugin)
|
||||
|
||||
snap_to_grid_util = plugin.get_global_scene().calc_snap_to_grid_util()
|
||||
|
||||
var cache:Dictionary = plugin.get_snapping_cache(SNAPPING_TOOL_ID)
|
||||
snap_to_grid_util.load_from_cache(cache)
|
||||
|
||||
func _deactivate():
|
||||
super._deactivate()
|
||||
|
||||
flush_cache()
|
||||
|
||||
func flush_cache():
|
||||
var cache:Dictionary = snap_to_grid_util.save_to_cache()
|
||||
plugin.set_snapping_cache(SNAPPING_TOOL_ID, cache)
|
||||
|
||||
#Point is in world space
|
||||
func _snap_point(point:Vector3, query:SnappingQuery)->Vector3:
|
||||
|
||||
var target_point = snap_to_grid_util.snap_point(point)
|
||||
return target_point
|
||||
|
||||
func _snap_angle(angle:float, query:SnappingQuery)->float:
|
||||
var snap_angle:float = plugin.get_global_scene().settings.get_property(CyclopsGlobalScene.SNAPPING_GRID_ANGLE)
|
||||
return floor(angle / snap_angle) * snap_angle
|
||||
|
||||
|
||||
func _get_properties_editor()->Control:
|
||||
var ed:SnappingSystemGridPropertiesEditor = preload("res://addons/cyclops_level_builder/snapping/snapping_system_grid_properties_editor.tscn").instantiate()
|
||||
ed.tool = self
|
||||
|
||||
return ed
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,204 @@
|
|||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
extends PanelContainer
|
||||
class_name SnappingSystemGridPropertiesEditor
|
||||
|
||||
const meters_per_yard:float = 0.9144
|
||||
const meters_per_feet:float = 0.3048
|
||||
|
||||
var tool:SnappingSystemGrid:
|
||||
get:
|
||||
return tool
|
||||
set(value):
|
||||
#print("setting SnappingSystemGridPropertiesEditor props")
|
||||
if value == tool:
|
||||
return
|
||||
tool = value
|
||||
update_ui_from_props()
|
||||
|
||||
func update_ui_from_props():
|
||||
#print("setting SnappingSystemGridPropertiesEditor props")
|
||||
|
||||
if !tool:
|
||||
return
|
||||
|
||||
var properties:SnapToGridUtil = tool.snap_to_grid_util
|
||||
%spin_power_of_two.value = properties.power_of_two_scale
|
||||
%ed_unit_size.value = properties.unit_size
|
||||
%check_use_subdiv.button_pressed = properties.use_subdivisions
|
||||
%spin_subdiv.value = properties.grid_subdivisions
|
||||
|
||||
var parts:Dictionary = MathUtil.decompose_matrix_3d(properties.grid_transform)
|
||||
|
||||
%xform_translate.value = parts.translate
|
||||
%xform_rotate.value = parts.rotate
|
||||
%xform_shear.value = parts.shear
|
||||
%xform_scale.value = parts.scale
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
|
||||
func _on_spin_power_of_two_value_changed(value:float):
|
||||
if !tool:
|
||||
return
|
||||
|
||||
tool.snap_to_grid_util.power_of_two_scale = value
|
||||
tool.flush_cache()
|
||||
CyclopsAutoload.settings.set_property(CyclopsGlobalScene.SNAPPING_GRID_POWER_OF_TWO_SCALE, int(value))
|
||||
CyclopsAutoload.save_settings()
|
||||
|
||||
func _on_ed_unit_size_value_changed(value:float):
|
||||
if !tool:
|
||||
return
|
||||
|
||||
tool.snap_to_grid_util.unit_size = value
|
||||
tool.flush_cache()
|
||||
CyclopsAutoload.settings.set_property(CyclopsGlobalScene.SNAPPING_GRID_UNIT_SIZE, value)
|
||||
CyclopsAutoload.save_settings()
|
||||
|
||||
func _on_check_use_subdiv_toggled(toggled_on:bool):
|
||||
if !tool:
|
||||
return
|
||||
|
||||
tool.snap_to_grid_util.use_subdivisions = toggled_on
|
||||
tool.flush_cache()
|
||||
CyclopsAutoload.settings.set_property(CyclopsGlobalScene.SNAPPING_GRID_USE_SUBDIVISIONS, toggled_on)
|
||||
CyclopsAutoload.save_settings()
|
||||
|
||||
func _on_spin_subdiv_value_changed(value):
|
||||
if !tool:
|
||||
return
|
||||
|
||||
tool.snap_to_grid_util.grid_subdivisions = value
|
||||
tool.flush_cache()
|
||||
CyclopsAutoload.settings.set_property(CyclopsGlobalScene.SNAPPING_GRID_SUBDIVISIONS, int(value))
|
||||
CyclopsAutoload.save_settings()
|
||||
|
||||
func _on_xform_translate_value_changed(value):
|
||||
if !tool:
|
||||
return
|
||||
|
||||
set_grid_transform_from_ui()
|
||||
|
||||
func _on_xform_rotate_value_changed(value):
|
||||
if !tool:
|
||||
return
|
||||
|
||||
set_grid_transform_from_ui()
|
||||
|
||||
func _on_xform_scale_value_changed(value):
|
||||
if !tool:
|
||||
return
|
||||
|
||||
set_grid_transform_from_ui()
|
||||
|
||||
func _on_xform_shear_value_changed(value):
|
||||
if !tool:
|
||||
return
|
||||
|
||||
set_grid_transform_from_ui()
|
||||
|
||||
func set_grid_transform_from_ui():
|
||||
var xform:Transform3D = MathUtil.compose_matrix_3d(%xform_translate.value,
|
||||
%xform_rotate.value,
|
||||
EULER_ORDER_YXZ,
|
||||
%xform_shear.value,
|
||||
%xform_scale.value)
|
||||
tool.snap_to_grid_util.grid_transform = xform
|
||||
tool.flush_cache()
|
||||
|
||||
CyclopsAutoload.save_settings()
|
||||
|
||||
func _on_popup_presets_index_pressed(index):
|
||||
#print("Preset ", index)
|
||||
var unit_size:float
|
||||
var subdiv:int
|
||||
match index:
|
||||
0:
|
||||
unit_size = 1
|
||||
subdiv = 10
|
||||
1:
|
||||
unit_size = meters_per_yard
|
||||
subdiv = 3
|
||||
2:
|
||||
unit_size = meters_per_feet
|
||||
subdiv = 12
|
||||
_:
|
||||
return
|
||||
|
||||
%ed_unit_size.value = unit_size
|
||||
%spin_subdiv.value = subdiv
|
||||
|
||||
tool.snap_to_grid_util.unit_size = unit_size
|
||||
CyclopsAutoload.settings.set_property(CyclopsGlobalScene.SNAPPING_GRID_UNIT_SIZE, unit_size)
|
||||
|
||||
tool.snap_to_grid_util.grid_subdivisions = subdiv
|
||||
tool.flush_cache()
|
||||
|
||||
CyclopsAutoload.settings.set_property(CyclopsGlobalScene.SNAPPING_GRID_SUBDIVISIONS, int(subdiv))
|
||||
|
||||
CyclopsAutoload.save_settings()
|
||||
|
||||
|
||||
func _on_bn_presets_pressed():
|
||||
var rect:Rect2 = %bn_presets.get_global_rect()
|
||||
%popup_presets.popup_on_parent(Rect2i(rect.position.x, rect.position.y + rect.size.y, 0, 0))
|
||||
|
||||
|
||||
func _on_bn_presets_transform_pressed():
|
||||
var rect:Rect2 = %bn_presets_transform.get_global_rect()
|
||||
%popup_transform_presets.popup_on_parent(Rect2i(rect.position.x, rect.position.y + rect.size.y, 0, 0))
|
||||
|
||||
|
||||
func _on_popup_transform_presets_index_pressed(index):
|
||||
var xform:Transform3D
|
||||
match index:
|
||||
0:
|
||||
xform = Transform3D.IDENTITY
|
||||
1:
|
||||
var x:Vector3 = Vector3(1, 0, 0)
|
||||
var y:Vector3 = Vector3(0, 1, 0)
|
||||
var angle:float = deg_to_rad(60)
|
||||
|
||||
var z:Vector3 = Vector3(cos(angle), 0, sin(angle))
|
||||
xform = Transform3D(Basis(x, y, z), Vector3.ZERO)
|
||||
_:
|
||||
return
|
||||
|
||||
|
||||
tool.snap_to_grid_util.grid_transform = xform
|
||||
tool.flush_cache()
|
||||
|
||||
CyclopsAutoload.settings.set_property(CyclopsGlobalScene.SNAPPING_GRID_TRANSFORM, xform)
|
||||
|
||||
CyclopsAutoload.save_settings()
|
||||
update_ui_from_props()
|
||||
|
|
@ -0,0 +1,153 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://c165arqp73p1k"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/cyclops_level_builder/snapping/snapping_system_grid_properties_editor.gd" id="1_jva1e"]
|
||||
[ext_resource type="PackedScene" uid="uid://diibmlqy1mpqb" path="res://addons/cyclops_level_builder/controls/numeric_line_edit.tscn" id="2_3bhn6"]
|
||||
[ext_resource type="PackedScene" uid="uid://cphtpklx81l3w" path="res://addons/cyclops_level_builder/controls/vector3_edit.tscn" id="2_beo4d"]
|
||||
|
||||
[node name="snapping_system_grid_properties" type="PanelContainer"]
|
||||
offset_right = 400.0
|
||||
offset_bottom = 337.0
|
||||
script = ExtResource("1_jva1e")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "Power of 2 Scale"
|
||||
|
||||
[node name="spin_power_of_two" type="SpinBox" parent="VBoxContainer/HBoxContainer2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
min_value = -16.0
|
||||
max_value = 16.0
|
||||
rounded = true
|
||||
allow_greater = true
|
||||
allow_lesser = true
|
||||
|
||||
[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer3"]
|
||||
layout_mode = 2
|
||||
text = "Unit size:"
|
||||
|
||||
[node name="ed_unit_size" parent="VBoxContainer/HBoxContainer3" instance=ExtResource("2_3bhn6")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="bn_presets" type="Button" parent="VBoxContainer/HBoxContainer3"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Presets"
|
||||
|
||||
[node name="check_use_subdiv" type="CheckBox" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Use Subdivisions"
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Subdivisions"
|
||||
|
||||
[node name="spin_subdiv" type="SpinBox" parent="VBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
min_value = 1.0
|
||||
max_value = 16.0
|
||||
value = 10.0
|
||||
rounded = true
|
||||
allow_greater = true
|
||||
|
||||
[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "Transform:"
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="bn_presets_transform" type="Button" parent="VBoxContainer/VBoxContainer2/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Transform Presets"
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="VBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
columns = 2
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/VBoxContainer2/GridContainer"]
|
||||
layout_mode = 2
|
||||
text = "Translate"
|
||||
|
||||
[node name="xform_translate" parent="VBoxContainer/VBoxContainer2/GridContainer" instance=ExtResource("2_beo4d")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label2" type="Label" parent="VBoxContainer/VBoxContainer2/GridContainer"]
|
||||
layout_mode = 2
|
||||
text = "Rotate"
|
||||
|
||||
[node name="xform_rotate" parent="VBoxContainer/VBoxContainer2/GridContainer" instance=ExtResource("2_beo4d")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label3" type="Label" parent="VBoxContainer/VBoxContainer2/GridContainer"]
|
||||
layout_mode = 2
|
||||
text = "Scale"
|
||||
|
||||
[node name="xform_scale" parent="VBoxContainer/VBoxContainer2/GridContainer" instance=ExtResource("2_beo4d")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label4" type="Label" parent="VBoxContainer/VBoxContainer2/GridContainer"]
|
||||
layout_mode = 2
|
||||
text = "Shear"
|
||||
|
||||
[node name="xform_shear" parent="VBoxContainer/VBoxContainer2/GridContainer" instance=ExtResource("2_beo4d")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="popup_presets" type="PopupMenu" parent="."]
|
||||
unique_name_in_owner = true
|
||||
item_count = 3
|
||||
item_0/text = "Meters"
|
||||
item_0/id = 0
|
||||
item_1/text = "Yards"
|
||||
item_1/id = 1
|
||||
item_2/text = "Feet"
|
||||
item_2/id = 2
|
||||
|
||||
[node name="popup_transform_presets" type="PopupMenu" parent="."]
|
||||
unique_name_in_owner = true
|
||||
item_count = 2
|
||||
item_0/text = "Cube Grid"
|
||||
item_0/id = 0
|
||||
item_1/text = "Equilateral Triangles XZ"
|
||||
item_1/id = 1
|
||||
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer2/spin_power_of_two" to="." method="_on_spin_power_of_two_value_changed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer3/ed_unit_size" to="." method="_on_ed_unit_size_value_changed"]
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer3/bn_presets" to="." method="_on_bn_presets_pressed"]
|
||||
[connection signal="toggled" from="VBoxContainer/check_use_subdiv" to="." method="_on_check_use_subdiv_toggled"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/spin_subdiv" to="." method="_on_spin_subdiv_value_changed"]
|
||||
[connection signal="pressed" from="VBoxContainer/VBoxContainer2/HBoxContainer/bn_presets_transform" to="." method="_on_bn_presets_transform_pressed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/VBoxContainer2/GridContainer/xform_translate" to="." method="_on_xform_translate_value_changed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/VBoxContainer2/GridContainer/xform_rotate" to="." method="_on_xform_rotate_value_changed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/VBoxContainer2/GridContainer/xform_scale" to="." method="_on_xform_scale_value_changed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/VBoxContainer2/GridContainer/xform_shear" to="." method="_on_xform_shear_value_changed"]
|
||||
[connection signal="index_pressed" from="popup_presets" to="." method="_on_popup_presets_index_pressed"]
|
||||
[connection signal="index_pressed" from="popup_transform_presets" to="." method="_on_popup_transform_presets_index_pressed"]
|
||||
117
addons/cyclops_level_builder/snapping/snapping_system_vertex.gd
Normal file
117
addons/cyclops_level_builder/snapping/snapping_system_vertex.gd
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
extends CyclopsSnappingSystem
|
||||
class_name SnappingSystemVertex
|
||||
|
||||
@export var max_radius:float = .2
|
||||
|
||||
const SNAPPING_TOOL_ID:String = "vertex"
|
||||
|
||||
#var snap_to_grid_util:SnapToGridUtil = SnapToGridUtil.new()
|
||||
|
||||
var settings:SnappingSystemVertexSettings = SnappingSystemVertexSettings.new()
|
||||
|
||||
func _activate(plugin:CyclopsLevelBuilder):
|
||||
super._activate(plugin)
|
||||
|
||||
var cache:Dictionary = plugin.get_snapping_cache(SNAPPING_TOOL_ID)
|
||||
settings.load_from_cache(cache)
|
||||
|
||||
func _deactivate():
|
||||
super._deactivate()
|
||||
|
||||
flush_cache()
|
||||
|
||||
func flush_cache():
|
||||
var cache:Dictionary = settings.save_to_cache()
|
||||
plugin.set_snapping_cache(SNAPPING_TOOL_ID, cache)
|
||||
|
||||
|
||||
#Point is in world space
|
||||
func _snap_point(point:Vector3, query:SnappingQuery)->Vector3:
|
||||
|
||||
var screen_point:Vector2 = query.viewport_camera.unproject_position(point)
|
||||
|
||||
var blocks:Array[CyclopsBlock] = plugin.get_blocks()
|
||||
|
||||
var best_vertex:Vector3 = Vector3.INF
|
||||
var best_dist:float = INF
|
||||
|
||||
#print("Exclude blocks ", query.exclude_blocks)
|
||||
for block in blocks:
|
||||
if query.exclude_blocks.has(block.get_path()):
|
||||
continue
|
||||
|
||||
#print("check block ", block.name)
|
||||
var ctrl_mesh:ConvexVolume = block.control_mesh
|
||||
var bounds_local:AABB = ctrl_mesh.bounds
|
||||
|
||||
var obj_center:Vector3 = block.global_transform * bounds_local.get_center()
|
||||
var obj_corner:Vector3 = block.global_transform * bounds_local.position
|
||||
var radius:float = obj_corner.distance_to(obj_center)
|
||||
var obj_offset:Vector3 = obj_center + query.viewport_camera.global_basis.x * radius
|
||||
|
||||
var screen_obj_center:Vector2 = query.viewport_camera.unproject_position(obj_center)
|
||||
var screen_obj_offset:Vector2 = query.viewport_camera.unproject_position(obj_offset)
|
||||
|
||||
#print("screen_point ", screen_point)
|
||||
#print("screen_obj_center ", screen_obj_center)
|
||||
#print("screen_obj_offset ", screen_obj_offset)
|
||||
#print("screen_point.distance_to(screen_obj_center) ", screen_point.distance_to(screen_obj_center))
|
||||
#print("screen_obj_center.distance_to(screen_obj_offset) ", screen_obj_center.distance_to(screen_obj_offset))
|
||||
if screen_point.distance_to(screen_obj_center) > \
|
||||
screen_obj_center.distance_to(screen_obj_offset) + settings.snap_radius:
|
||||
#Skip if bounding box text fails
|
||||
continue
|
||||
|
||||
|
||||
#print("snap block ", block.name)
|
||||
for v_idx in ctrl_mesh.vertices.size():
|
||||
var v:ConvexVolume.VertexInfo = ctrl_mesh.vertices[v_idx]
|
||||
var v_point_world:Vector3 = block.global_transform * v.point
|
||||
var v_point_screen:Vector2 = query.viewport_camera.unproject_position(v_point_world)
|
||||
|
||||
var dist:float = v_point_screen.distance_to(screen_point)
|
||||
#print("dist ", dist, " settings.snap_radius ", settings.snap_radius)
|
||||
if dist > settings.snap_radius:
|
||||
continue
|
||||
|
||||
#print("try vertex ", v_point_world)
|
||||
if dist < best_dist:
|
||||
# if dist < best_dist:
|
||||
best_vertex = v_point_world
|
||||
best_dist = dist
|
||||
|
||||
|
||||
return best_vertex if is_finite(best_dist) else point
|
||||
|
||||
|
||||
func _get_properties_editor()->Control:
|
||||
var ed:SnappingSystemVertexPropertiesEditor = preload("res://addons/cyclops_level_builder/snapping/snapping_system_vertex_properties_editor.tscn").instantiate()
|
||||
ed.snap_tool = self
|
||||
|
||||
return ed
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
extends PanelContainer
|
||||
class_name SnappingSystemVertexPropertiesEditor
|
||||
|
||||
var snap_tool:SnappingSystemVertex:
|
||||
get:
|
||||
return snap_tool
|
||||
set(value):
|
||||
#print("setting SnappingSystemGridPropertiesEditor props")
|
||||
if value == snap_tool:
|
||||
return
|
||||
snap_tool = value
|
||||
update_ui_from_props()
|
||||
|
||||
#var settings:SnappingSystemVertexSettings:
|
||||
#get:
|
||||
#return settings
|
||||
#set(value):
|
||||
##print("setting SnappingSystemGridPropertiesEditor props")
|
||||
#if value == settings:
|
||||
#return
|
||||
#settings = value
|
||||
#update_ui_from_props()
|
||||
|
||||
func update_ui_from_props():
|
||||
if !snap_tool:
|
||||
return
|
||||
|
||||
var settings = snap_tool.settings
|
||||
|
||||
%snap_radius.value = settings.snap_radius
|
||||
|
||||
func _on_snap_radius_value_changed(value):
|
||||
if !snap_tool:
|
||||
return
|
||||
|
||||
snap_tool.settings.snap_radius = value
|
||||
snap_tool.flush_cache()
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://cbucsqmj5g1i1"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/cyclops_level_builder/snapping/snapping_system_vertex_properties_editor.gd" id="1_tibga"]
|
||||
[ext_resource type="PackedScene" uid="uid://diibmlqy1mpqb" path="res://addons/cyclops_level_builder/controls/numeric_line_edit.tscn" id="2_hl6or"]
|
||||
|
||||
[node name="SnappingSystemVertexPropertiesEditor" type="PanelContainer"]
|
||||
offset_right = 319.0
|
||||
offset_bottom = 210.0
|
||||
script = ExtResource("1_tibga")
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="."]
|
||||
layout_mode = 2
|
||||
columns = 2
|
||||
|
||||
[node name="Label" type="Label" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
text = "Snap Radius
|
||||
"
|
||||
|
||||
[node name="snap_radius" parent="GridContainer" instance=ExtResource("2_hl6or")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[connection signal="value_changed" from="GridContainer/snap_radius" to="." method="_on_snap_radius_value_changed"]
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
extends Resource
|
||||
class_name SnappingSystemVertexSettings
|
||||
|
||||
#Snapping redous in viewport pixels
|
||||
@export var snap_radius:float = 6
|
||||
|
||||
func load_from_cache(cache:Dictionary):
|
||||
snap_radius = cache.get("snap_radius", 6.0)
|
||||
|
||||
func save_to_cache()->Dictionary:
|
||||
return {
|
||||
"snap_radius": snap_radius
|
||||
}
|
||||
45
addons/cyclops_level_builder/snapping/snapping_tag.gd
Normal file
45
addons/cyclops_level_builder/snapping/snapping_tag.gd
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
extends Resource
|
||||
class_name SnappingTag
|
||||
|
||||
@export var name:String
|
||||
@export var icon:Texture2D
|
||||
@export_multiline var tooltip:String
|
||||
@export var snapping_script:Script
|
||||
|
||||
|
||||
var snapping_system:CyclopsSnappingSystem
|
||||
|
||||
func _activate(plugin:CyclopsLevelBuilder):
|
||||
if !snapping_script:
|
||||
return
|
||||
|
||||
if !snapping_system:
|
||||
snapping_system = snapping_script.new()
|
||||
|
||||
plugin.switch_to_snapping_system(snapping_system)
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue