From 8fe94c3ca485ed723b8d491fd462f4486859d062 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 23 Feb 2021 01:34:02 +0100 Subject: [PATCH] Removed gdpose, as its no longer needed. --- game/addons/gdpose/LICENSE | 21 --- game/addons/gdpose/README.md | 23 ---- game/addons/gdpose/SkeletonPopup.gd | 32 ----- game/addons/gdpose/SkeletonPopup.tscn | 11 -- game/addons/gdpose/bonegizmo.gd | 179 -------------------------- game/addons/gdpose/bonegizmoplugin.gd | 22 ---- game/addons/gdpose/plugin.cfg | 7 - game/addons/gdpose/plugin.gd | 39 ------ game/project.godot | 8 +- 9 files changed, 1 insertion(+), 341 deletions(-) delete mode 100644 game/addons/gdpose/LICENSE delete mode 100644 game/addons/gdpose/README.md delete mode 100644 game/addons/gdpose/SkeletonPopup.gd delete mode 100644 game/addons/gdpose/SkeletonPopup.tscn delete mode 100644 game/addons/gdpose/bonegizmo.gd delete mode 100644 game/addons/gdpose/bonegizmoplugin.gd delete mode 100644 game/addons/gdpose/plugin.cfg delete mode 100644 game/addons/gdpose/plugin.gd diff --git a/game/addons/gdpose/LICENSE b/game/addons/gdpose/LICENSE deleted file mode 100644 index f826e4fe..00000000 --- a/game/addons/gdpose/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Bastiaan Olij - -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. diff --git a/game/addons/gdpose/README.md b/game/addons/gdpose/README.md deleted file mode 100644 index f73ebbb2..00000000 --- a/game/addons/gdpose/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# gdpose -Plugin to make skeletons poseable in the editor - -Note: this is still a work in progress - -For more info see my streams on Youtube: -- [Stream #16](https://youtu.be/LtJCLWorenc) -- [Stream #17](https://youtu.be/zFVmMPe9Skc) - -# TODOs -Minimum work needed to make this more feasible: -- Add undo feature -- Improve bone selection menu -- Add option to add keyframe for selected bone - -Nice to figure out: -- Make it possible to select bones by clicking on them -- Make a better widget for rotations -- Add code to determine correct direction of rotation - -# License -This project is provided under an MIT license. -See LICENSE for further details. diff --git a/game/addons/gdpose/SkeletonPopup.gd b/game/addons/gdpose/SkeletonPopup.gd deleted file mode 100644 index 0cb1ad9e..00000000 --- a/game/addons/gdpose/SkeletonPopup.gd +++ /dev/null @@ -1,32 +0,0 @@ -tool -extends MenuButton - -var skeleton : Skeleton = null - -func edit(new_skeleton : Skeleton): - skeleton = new_skeleton - - # update our menu - var popup = get_popup() - if popup: - popup.clear() - - if skeleton: - for idx in range(0, skeleton.get_bone_count()): - var parent = skeleton.get_bone_parent(idx) - if parent != -1: - var name = skeleton.get_bone_name(idx) - popup.add_item(name, idx) - -func select_bone(id): - print("select bone " + str(id)) - - var gizmo : BoneSpatialGizmo = skeleton.gizmo - if gizmo: - gizmo.set_selected_bone(id) - skeleton.update_gizmo() - -func _ready(): - var popup = get_popup() - if popup: - popup.connect("id_pressed", self, "select_bone") diff --git a/game/addons/gdpose/SkeletonPopup.tscn b/game/addons/gdpose/SkeletonPopup.tscn deleted file mode 100644 index 39c8d37c..00000000 --- a/game/addons/gdpose/SkeletonPopup.tscn +++ /dev/null @@ -1,11 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://addons/gdpose/SkeletonPopup.gd" type="Script" id=1] - -[node name="SkeletonPopup" type="MenuButton"] -text = "GDPose" -items = [ "Test1", null, 0, false, false, 0, 0, null, "", false, "Test2", null, 0, false, false, 1, 0, null, "", false ] -script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": false -} diff --git a/game/addons/gdpose/bonegizmo.gd b/game/addons/gdpose/bonegizmo.gd deleted file mode 100644 index a1e21bf5..00000000 --- a/game/addons/gdpose/bonegizmo.gd +++ /dev/null @@ -1,179 +0,0 @@ -tool -extends EditorSpatialGizmo - -class_name BoneSpatialGizmo - -var offset = 0.1 -var handle_dist = 0.1 # Distance of gizmo to bone origin -var selected_bone = -1 # Bone we are animating - -var is_posing = false -var start_pose = Transform() -var start_point = Vector2() - -var handle_idx = Array() # Handles we've added - -const handle_rot_x = -2 -const handle_rot_y = -3 -const handle_rot_z = -4 - -func set_selected_bone(idx): - var skeleton : Skeleton = get_spatial_node() - if !skeleton: - return - - if idx >= 0 and idx < skeleton.get_bone_count(): - selected_bone = idx - else: - selected_bone = -1 - -func get_handle_name(index): - var skeleton : Skeleton = get_spatial_node() - if !skeleton: - return "No skeleton" - - var idx = handle_idx[index] - if idx == handle_rot_x: - return "Rotate X" - elif idx == handle_rot_y: - return "Rotate Y" - elif idx == handle_rot_z: - return "Rotate Z" - else: - return "huh???" - -func get_handle_value(index): - var skeleton : Skeleton = get_spatial_node() - if !skeleton: - return "No skeleton" - - var idx = handle_idx[index] - if selected_bone >= 0: - return skeleton.get_bone_pose(selected_bone) - else: - return "No selected bone" - -func set_handle(index, camera, point): - var idx = handle_idx[index] - var skeleton : Skeleton = get_spatial_node() - if !skeleton: - return "No skeleton" - - if !is_posing: - start_point = point - start_pose = skeleton.get_bone_pose(selected_bone) - is_posing = true - print("start posing " + str(start_pose)) - return - - var moved = point - start_point - var distance = moved.x + moved.y - - # calculate our new transform (in local space) - var new_pose : Transform = start_pose - if idx == handle_rot_x: - # rotate around X - new_pose = new_pose.rotated(start_pose.basis.x.normalized(), distance * 0.01) - elif idx == handle_rot_y: - # rotate around Y - new_pose = new_pose.rotated(start_pose.basis.y.normalized(), distance * 0.01) - elif idx == handle_rot_z: - # rotate around Z - new_pose = new_pose.rotated(start_pose.basis.z.normalized(), distance * 0.01) - - skeleton.set_bone_pose(selected_bone, new_pose) - skeleton.update_gizmo() - -func commit_handle(index, restore, cancel = false): - # var idx = handle_idx[index] - - print("Commit") - is_posing = false - - var skeleton : Skeleton = get_spatial_node() - if !skeleton: - return - - if selected_bone == -1: - return - - if (cancel): - skeleton.set_bone_pose(selected_bone, restore) - -func redraw(): - clear() - - var skeleton : Skeleton = get_spatial_node() - if !skeleton: - return - - var lines_material = get_plugin().get_material("skeleton", self) - var selected_material = get_plugin().get_material("selected", self) - var handles_material = get_plugin().get_material("handles", self) - var handles = PoolVector3Array() - handle_idx.clear() - - # loop through our bones - for idx in range(0, skeleton.get_bone_count()): - var parent = skeleton.get_bone_parent(idx) - if parent != -1: - var lines = PoolVector3Array() - var parent_transform = skeleton.get_bone_global_pose(parent) - var bone_transform = skeleton.get_bone_global_pose(idx) - - var parent_pos = parent_transform.origin - var bone_pos = bone_transform.origin - var delta = bone_pos - parent_pos - var length = delta.length() - - var p1 = parent_pos + (delta * offset) + parent_transform.basis.x * length * offset - var p2 = parent_pos + (delta * offset) + parent_transform.basis.z * length * offset - var p3 = parent_pos + (delta * offset) - parent_transform.basis.x * length * offset - var p4 = parent_pos + (delta * offset) - parent_transform.basis.z * length * offset - - lines.push_back(parent_pos) - lines.push_back(p1) - lines.push_back(p1) - lines.push_back(bone_pos) - - lines.push_back(parent_pos) - lines.push_back(p2) - lines.push_back(p2) - lines.push_back(bone_pos) - - lines.push_back(parent_pos) - lines.push_back(p3) - lines.push_back(p3) - lines.push_back(bone_pos) - - lines.push_back(parent_pos) - lines.push_back(p4) - lines.push_back(p4) - lines.push_back(bone_pos) - - lines.push_back(p1) - lines.push_back(p2) - lines.push_back(p2) - lines.push_back(p3) - lines.push_back(p3) - lines.push_back(p4) - lines.push_back(p4) - lines.push_back(p1) - - if parent == selected_bone: - add_lines(lines, selected_material, false) - else: - add_lines(lines, lines_material, false) - - if idx == selected_bone: - handles.push_back(bone_pos + bone_transform.basis.x * handle_dist) - handle_idx.push_back(handle_rot_x) - - handles.push_back(bone_pos + bone_transform.basis.y * handle_dist) - handle_idx.push_back(handle_rot_y) - - handles.push_back(bone_pos + bone_transform.basis.z * handle_dist) - handle_idx.push_back(handle_rot_z) - - if handles.size() > 0: - add_handles(handles, handles_material) diff --git a/game/addons/gdpose/bonegizmoplugin.gd b/game/addons/gdpose/bonegizmoplugin.gd deleted file mode 100644 index 0d9e356a..00000000 --- a/game/addons/gdpose/bonegizmoplugin.gd +++ /dev/null @@ -1,22 +0,0 @@ -tool -extends EditorSpatialGizmoPlugin - -const BoneGizmo = preload("res://addons/gdpose/bonegizmo.gd") - -func get_name(): - return "BoneGizmo" - -func get_priority(): - return 100 - -func create_gizmo(spatial): - if spatial is Skeleton: - return BoneGizmo.new() - else: - return null - -func _init(): - create_material("skeleton", Color(0.6, 0.6, 0.0)) - create_material("selected", Color(1.0, 1.0, 0.0)) - create_handle_material("handles") - diff --git a/game/addons/gdpose/plugin.cfg b/game/addons/gdpose/plugin.cfg deleted file mode 100644 index 91ac9dfd..00000000 --- a/game/addons/gdpose/plugin.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[plugin] - -name="gdpose" -description="Pose editor" -author="Bastiaan Olij" -version="1" -script="plugin.gd" diff --git a/game/addons/gdpose/plugin.gd b/game/addons/gdpose/plugin.gd deleted file mode 100644 index cb1c3702..00000000 --- a/game/addons/gdpose/plugin.gd +++ /dev/null @@ -1,39 +0,0 @@ -tool -extends EditorPlugin - -const BoneGizmoPlugin = preload("res://addons/gdpose/bonegizmoplugin.gd") -const SkeletonPopup = preload("res://addons/gdpose/SkeletonPopup.tscn") - -var skeleton_popup_instance -var bone_gizmo = BoneGizmoPlugin.new() - -func get_plugin_name(): - return "GD Pose Plugin" - -func _enter_tree(): - # Initialization of the plugin goes here. - add_spatial_gizmo_plugin(bone_gizmo) - - # add our menu - skeleton_popup_instance = SkeletonPopup.instance() - add_control_to_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_MENU, skeleton_popup_instance) - skeleton_popup_instance.visible = false - -func _exit_tree(): - remove_spatial_gizmo_plugin(bone_gizmo) - if skeleton_popup_instance: - remove_control_from_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_MENU, skeleton_popup_instance) - skeleton_popup_instance.queue_free() - skeleton_popup_instance = null - -func make_visible(visible): - if skeleton_popup_instance: - skeleton_popup_instance.visible = visible - -func handles(object): - return object is Skeleton - -func edit(object): - var skeleton : Skeleton = object - if skeleton_popup_instance: - skeleton_popup_instance.edit(skeleton) diff --git a/game/project.godot b/game/project.godot index 8752e226..87981842 100644 --- a/game/project.godot +++ b/game/project.godot @@ -14,11 +14,6 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://scripts/auras/aura_script.gd" }, { -"base": "EditorSpatialGizmo", -"class": "BoneSpatialGizmo", -"language": "GDScript", -"path": "res://addons/gdpose/bonegizmo.gd" -}, { "base": "Reference", "class": "BrushPrefabs", "language": "GDScript", @@ -226,7 +221,6 @@ _global_script_classes=[ { } ] _global_script_class_icons={ "AuraGD": "", -"BoneSpatialGizmo": "", "BrushPrefabs": "", "CharacterSkeketonAttachPoint": "", "DisplayPlayerGD": "", @@ -311,7 +305,7 @@ window/size/ui_scale_touch=1.0 [editor_plugins] -enabled=PoolStringArray( "res://addons/Godoxel/plugin.cfg", "res://addons/gdpose/plugin.cfg", "res://addons/mesh_data_resource_editor/plugin.cfg" ) +enabled=PoolStringArray( "res://addons/Godoxel/plugin.cfg", "res://addons/mesh_data_resource_editor/plugin.cfg" ) [ess]