mirror of
https://github.com/Relintai/regression-test-project.git
synced 2024-12-23 13:57:21 +01:00
Add reparenting test
This commit is contained in:
parent
ea2bbdf2d1
commit
cb443dfafc
@ -17,12 +17,13 @@ const alone_steps : Array = [
|
||||
"res://MainScenes/Control.tscn",
|
||||
"res://MainScenes/Node2D.tscn",
|
||||
"res://MainScenes/Other.tscn",
|
||||
"res://MainScenes/Node3D.tscn",
|
||||
"res://MainScenes/Spatial.tscn",
|
||||
"res://Physics/2D/Physics2D.tscn",
|
||||
"res://Physics/3D/Physics3D.tscn",
|
||||
"res://Rendering/Lights2D/Lights2D.tscn",
|
||||
"res://Rendering/Lights3D/Lights3D.tscn",
|
||||
"res://Text/Text.tscn",
|
||||
"res://Reparenting/Reparenting.tscn",
|
||||
]
|
||||
|
||||
# All scenes run in one step
|
||||
@ -39,12 +40,11 @@ func _init():
|
||||
time_for_each_step = time_to_show / (alone_steps.size() + 1)
|
||||
|
||||
for argument in OS.get_cmdline_args():
|
||||
var rr: String = argument
|
||||
if rr.ends_with("tscn"): # Ignore all tscn scenes/names
|
||||
continue
|
||||
time_to_show = int(argument.to_float() * 1000)
|
||||
time_for_each_step = time_to_show / (alone_steps.size() + 1)
|
||||
print("Time set to: " + str(time_to_show / 1000.0) + " seconds with "+ str(alone_steps.size() + 1) + " steps, each step will take " + str(time_for_each_step / 1000.0) + " seconds.")
|
||||
if argument.is_valid_float(): # Ignore all non numeric arguments
|
||||
time_to_show = int(argument.to_float() * 1000)
|
||||
time_for_each_step = time_to_show / (alone_steps.size() + 1)
|
||||
print("Time set to: " + str(time_to_show / 1000.0) + " seconds with "+ str(alone_steps.size() + 1) + " steps, each step will take " + str(time_for_each_step / 1000.0) + " seconds.")
|
||||
break # We only need to take first argument
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
|
206
Reparenting/Reparenting.gd
Normal file
206
Reparenting/Reparenting.gd
Normal file
@ -0,0 +1,206 @@
|
||||
extends Node
|
||||
|
||||
var number_of_nodes : int = -1
|
||||
|
||||
func _ready() -> void:
|
||||
seed(45)
|
||||
|
||||
for _i in range(3):
|
||||
add_child(Control.new())
|
||||
add_child(Popup.new())
|
||||
add_child(AcceptDialog.new())
|
||||
add_child(ConfirmationDialog.new())
|
||||
add_child(FileDialog.new())
|
||||
add_child(PopupMenu.new())
|
||||
add_child(PopupPanel.new())
|
||||
add_child(Button.new())
|
||||
add_child(CheckBox.new())
|
||||
add_child(CheckButton.new())
|
||||
add_child(ColorPickerButton.new())
|
||||
add_child(MenuButton.new())
|
||||
add_child(OptionButton.new())
|
||||
add_child(LinkButton.new())
|
||||
add_child(TextureButton.new())
|
||||
add_child(Container.new())
|
||||
add_child(ColorPicker.new())
|
||||
add_child(VBoxContainer.new())
|
||||
add_child(HBoxContainer.new())
|
||||
add_child(CenterContainer.new())
|
||||
add_child(ScrollContainer.new())
|
||||
add_child(GraphNode.new())
|
||||
add_child(GridContainer.new())
|
||||
add_child(HSplitContainer.new())
|
||||
add_child(VSplitContainer.new())
|
||||
add_child(MarginContainer.new())
|
||||
add_child(PanelContainer.new())
|
||||
add_child(TabContainer.new())
|
||||
add_child(ColorRect.new())
|
||||
add_child(HScrollBar.new())
|
||||
add_child(VScrollBar.new())
|
||||
add_child(HSlider.new())
|
||||
add_child(VSlider.new())
|
||||
add_child(ProgressBar.new())
|
||||
add_child(SpinBox.new())
|
||||
add_child(TextureProgressBar.new())
|
||||
add_child(GraphEdit.new())
|
||||
add_child(HSeparator.new())
|
||||
add_child(VSeparator.new())
|
||||
add_child(ItemList.new())
|
||||
add_child(Label.new())
|
||||
add_child(LineEdit.new())
|
||||
add_child(NinePatchRect.new())
|
||||
add_child(Panel.new())
|
||||
add_child(ReferenceRect.new())
|
||||
add_child(RichTextLabel.new())
|
||||
add_child(Tabs.new())
|
||||
add_child(TextEdit.new())
|
||||
add_child(TextureRect.new())
|
||||
add_child(Tree.new())
|
||||
add_child(VideoPlayer.new())
|
||||
|
||||
add_child(Node2D.new())
|
||||
add_child(AnimatedSprite2D.new())
|
||||
add_child(Area2D.new())
|
||||
add_child(KinematicBody2D.new())
|
||||
add_child(RigidBody2D.new())
|
||||
add_child(StaticBody2D.new())
|
||||
add_child(AudioStreamPlayer2D.new())
|
||||
add_child(BackBufferCopy.new())
|
||||
add_child(Bone2D.new())
|
||||
add_child(CPUParticles2D.new())
|
||||
add_child(Camera2D.new())
|
||||
add_child(CanvasModulate.new())
|
||||
# add_child(CollisionPolygon2D.new()) # Errors
|
||||
add_child(CollisionShape2D.new())
|
||||
add_child(DampedSpringJoint2D.new())
|
||||
add_child(GrooveJoint2D.new())
|
||||
add_child(PinJoint2D.new())
|
||||
add_child(Light2D.new())
|
||||
add_child(LightOccluder2D.new())
|
||||
add_child(Line2D.new())
|
||||
add_child(MeshInstance2D.new())
|
||||
add_child(MultiMeshInstance2D.new())
|
||||
add_child(Navigation2D.new())
|
||||
add_child(ParallaxLayer.new())
|
||||
add_child(GPUParticles2D.new())
|
||||
add_child(Path2D.new())
|
||||
add_child(PathFollow2D.new())
|
||||
add_child(Polygon2D.new())
|
||||
add_child(Position2D.new())
|
||||
add_child(RayCast2D.new())
|
||||
add_child(RemoteTransform2D.new())
|
||||
add_child(Skeleton2D.new())
|
||||
add_child(Sprite2D.new())
|
||||
add_child(TileMap.new())
|
||||
add_child(TouchScreenButton.new())
|
||||
add_child(VisibilityNotifier2D.new())
|
||||
add_child(VisibilityEnabler2D.new())
|
||||
add_child(YSort.new())
|
||||
|
||||
add_child(Node3D.new())
|
||||
add_child(XRAnchor3D.new())
|
||||
add_child(Camera3D.new())
|
||||
add_child(XRCamera3D.new())
|
||||
add_child(ClippedCamera3D.new())
|
||||
add_child(XRController3D.new())
|
||||
add_child(XROrigin3D.new())
|
||||
add_child(AnimatedSprite3D.new())
|
||||
add_child(Sprite3D.new())
|
||||
add_child(CPUParticles3D.new())
|
||||
add_child(CSGBox3D.new())
|
||||
add_child(CSGCylinder3D.new())
|
||||
add_child(CSGMesh3D.new())
|
||||
add_child(CSGPolygon3D.new())
|
||||
add_child(CSGSphere3D.new())
|
||||
add_child(CSGTorus3D.new())
|
||||
add_child(CSGCombiner3D.new())
|
||||
add_child(ImmediateGeometry3D.new())
|
||||
add_child(MeshInstance3D.new())
|
||||
add_child(SoftBody3D.new())
|
||||
add_child(MultiMeshInstance3D.new())
|
||||
add_child(GPUParticles3D.new())
|
||||
add_child(BakedLightmap.new())
|
||||
add_child(DirectionalLight3D.new())
|
||||
add_child(OmniLight3D.new())
|
||||
add_child(SpotLight3D.new())
|
||||
add_child(GIProbe.new())
|
||||
add_child(ReflectionProbe.new())
|
||||
add_child(Area3D.new())
|
||||
add_child(KinematicBody3D.new())
|
||||
add_child(PhysicalBone3D.new())
|
||||
add_child(RigidBody3D.new())
|
||||
add_child(VehicleBody3D.new())
|
||||
add_child(StaticBody3D.new())
|
||||
add_child(AudioStreamPlayer3D.new())
|
||||
add_child(BoneAttachment3D.new())
|
||||
add_child(CollisionPolygon3D.new())
|
||||
add_child(CollisionShape3D.new())
|
||||
add_child(ConeTwistJoint3D.new())
|
||||
add_child(Generic6DOFJoint3D.new())
|
||||
add_child(HingeJoint3D.new())
|
||||
add_child(PinJoint3D.new())
|
||||
add_child(SliderJoint3D.new())
|
||||
add_child(GridMap.new())
|
||||
add_child(Listener3D.new())
|
||||
add_child(Navigation3D.new())
|
||||
add_child(Path3D.new())
|
||||
add_child(PathFollow3D.new())
|
||||
add_child(Position3D.new())
|
||||
add_child(ProximityGroup3D.new())
|
||||
add_child(RayCast3D.new())
|
||||
add_child(RemoteTransform3D.new())
|
||||
add_child(Skeleton3D.new())
|
||||
add_child(SpringArm3D.new())
|
||||
add_child(VehicleWheel3D.new())
|
||||
add_child(VisibilityNotifier3D.new())
|
||||
add_child(VisibilityEnabler3D.new())
|
||||
|
||||
|
||||
add_child(GPUParticlesAttractorBox.new())
|
||||
add_child(GPUParticlesAttractorSphere.new())
|
||||
add_child(GPUParticlesAttractorVectorField.new())
|
||||
|
||||
add_child(GPUParticlesCollisionBox.new())
|
||||
# add_child(GPUParticlesCollisionHeightField.new())
|
||||
add_child(GPUParticlesCollisionSphere.new())
|
||||
add_child(GPUParticlesCollisionSDF.new())
|
||||
|
||||
add_child(AnimationPlayer.new())
|
||||
add_child(AnimationTree.new())
|
||||
add_child(AudioStreamPlayer.new())
|
||||
add_child(CanvasLayer.new())
|
||||
add_child(ParallaxBackground.new())
|
||||
add_child(HTTPRequest.new())
|
||||
add_child(ResourcePreloader.new())
|
||||
add_child(Skeleton2D.new())
|
||||
add_child(Timer.new())
|
||||
add_child(Tween.new())
|
||||
add_child(Viewport.new())
|
||||
add_child(WorldEnvironment.new())
|
||||
|
||||
|
||||
|
||||
for i in range(get_child_count()):
|
||||
get_child(i).set_name("Node " + str(i))
|
||||
|
||||
number_of_nodes = get_child_count()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
assert(Performance.get_monitor(Performance.OBJECT_ORPHAN_NODE_COUNT) == 0)
|
||||
|
||||
var choosen_node : Node
|
||||
var parent_of_node : Node
|
||||
for i in range(20):
|
||||
var number = "Node " + str(randi() % number_of_nodes)
|
||||
choosen_node = find_node(number,true,false)
|
||||
parent_of_node = choosen_node.get_parent()
|
||||
|
||||
var random_node = find_node("Node " + str(randi() % number_of_nodes),true,false)
|
||||
if choosen_node.find_node(random_node.get_name(),true,false) != null: # Cannot set as node parent one of its child
|
||||
continue
|
||||
if choosen_node == random_node: # Do not reparent node to self
|
||||
continue
|
||||
parent_of_node.remove_child(choosen_node)
|
||||
random_node.add_child(choosen_node)
|
||||
if !choosen_node.is_inside_tree() || choosen_node.get_parent() == null: # Failed to add node, due e.g. requsrive problem or similar
|
||||
add_child(choosen_node)
|
6
Reparenting/Reparenting.tscn
Normal file
6
Reparenting/Reparenting.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Reparenting/Reparenting.gd" type="Script" id=1]
|
||||
|
||||
[node name="Reparenting" type="Node"]
|
||||
script = ExtResource( 1 )
|
Loading…
Reference in New Issue
Block a user