Skip to content

Commit 37269ee

Browse files
committed
Cleanup and switch to rl manager
1 parent a1bebf5 commit 37269ee

File tree

15 files changed

+46
-63
lines changed

15 files changed

+46
-63
lines changed

integrations/Godot/simulate_godot/Simulate/Commands/close.gd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
class_name Close
21
extends Node
32
# Close the simulation
43

integrations/Godot/simulate_godot/Simulate/Commands/initialize.gd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
class_name Initialize
21
extends Node
32
# Build the scene and sets global simulation metadata
43

integrations/Godot/simulate_godot/Simulate/GLTF/hf_actuator.gd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
extends Node3D
21
class_name HFActuator
2+
extends Node3D
33

44

55
var action_mapping: ActionMapping
@@ -20,7 +20,6 @@ func import(state: GLTFState, json: Dictionary, extensions: Dictionary):
2020

2121
if json.has("extras"):
2222
is_actor = json["extras"].get("is_actor", false)
23-
print(is_actor)
2423

2524
position = Vector3(
2625
json["translation"][0],

integrations/Godot/simulate_godot/Simulate/GLTF/hf_articulation_body.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
extends Generic6DOFJoint3D
21
class_name HFArticulationBody
2+
extends Generic6DOFJoint3D
33

44

55
var joint_type: String = ""
@@ -20,6 +20,7 @@ var upper_limit: float = 0.0
2020
var lower_limit: float = 0.0
2121
var mass: float = 1.0
2222
var center_of_mass: Vector3 = Vector3.ZERO
23+
var actuator: HFActuator
2324

2425

2526
func import(state: GLTFState, json: Dictionary, extensions: Dictionary):

integrations/Godot/simulate_godot/Simulate/GLTF/hf_collider.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
extends StaticBody3D
21
class_name HFCollider
2+
extends StaticBody3D
33

44

55
var type: GLTFEnums.ColliderType = GLTFEnums.ColliderType.box
@@ -8,6 +8,7 @@ var offset: Vector3 = Vector3.ZERO
88
var intangible: bool = false
99
var convex: bool = false
1010
var physic_material: HFPhysicMaterial
11+
var actuator: HFActuator
1112

1213

1314
func import(state: GLTFState, json: Dictionary, extensions: Dictionary):
Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
1-
extends GLTFDocumentExtension
21
class_name HFExtensions
2+
extends GLTFDocumentExtension
33

44

55
func _import_node(state: GLTFState, _gltf_node: GLTFNode, json: Dictionary, node: Node):
66
var extensions = json.get("extensions")
77
if not json.has("extensions"):
88
return OK
99

10+
var new_node
1011
if extensions.has("HF_rigid_bodies"):
11-
var rigid_body = HFRigidBody.new()
12-
rigid_body.import(state, json, extensions)
13-
node.replace_by(rigid_body)
12+
new_node = HFRigidBody.new()
1413
if extensions.has("HF_articulation_bodies"):
15-
var articulation_body = HFArticulationBody.new()
16-
articulation_body.import(state, json, extensions)
17-
node.replace_by(articulation_body)
14+
new_node = HFArticulationBody.new()
1815
if extensions.has("HF_colliders"):
19-
var collider = HFCollider.new()
20-
collider.import(state, json, extensions)
21-
node.replace_by(collider)
16+
new_node = HFCollider.new()
2217
if extensions.has("HF_raycast_sensors"):
23-
var raycast_sensor = HFRaycastSensor.new()
24-
raycast_sensor.import(state, json, extensions)
25-
node.replace_by(raycast_sensor)
18+
new_node = HFRaycastSensor.new()
2619
if extensions.has("HF_reward_functions"):
27-
var reward_function = HFRewardFunction.new()
28-
reward_function.import(state, json, extensions)
29-
node.replace_by(reward_function)
20+
new_node = HFRewardFunction.new()
3021
if extensions.has("HF_state_sensors"):
31-
var state_sensor = HFStateSensor.new()
32-
state_sensor.import(state, json, extensions)
33-
node.replace_by(state_sensor)
22+
new_node = HFStateSensor.new()
3423

24+
if new_node:
25+
new_node.import(state, json, extensions)
26+
if extensions.has("HF_actuators") and "actuator" in new_node:
27+
new_node.actuator = HFActuator.new()
28+
new_node.actuator.import(state, json, extensions)
29+
node.replace_by(new_node)
30+
else:
31+
print("Extension not implemented.")
3532
return OK

integrations/Godot/simulate_godot/Simulate/GLTF/hf_physic_material.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
extends PhysicsMaterial
21
class_name HFPhysicMaterial
2+
extends PhysicsMaterial
33

44

55
var material_name: String = ""
66
var dynamic_friction: float = 0.6
77
var friction_combine: GLTFEnums.PhysicMaterialCombine
88
var bounce_combine: GLTFEnums.PhysicMaterialCombine
9+
var actuator: HFActuator
910

1011

1112
func import(state: GLTFState, extensions: Dictionary, id: int):

integrations/Godot/simulate_godot/Simulate/GLTF/hf_raycast_sensor.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
extends Node3D
21
class_name HFRaycastSensor
2+
extends Node3D
33

44

55
var n_horizontal_rays: int

integrations/Godot/simulate_godot/Simulate/GLTF/hf_reward_function.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
extends Node3D
21
class_name HFRewardFunction
2+
extends Node3D
33

44

55
var type: String
@@ -12,6 +12,7 @@ var threshold: float
1212
var is_terminal: bool
1313
var is_collectable: bool
1414
var trigger_once: bool
15+
var actuator: HFActuator
1516

1617

1718
func import(state: GLTFState, json: Dictionary, extensions: Dictionary):

integrations/Godot/simulate_godot/Simulate/GLTF/hf_rigid_body.gd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
extends RigidBody3D
21
class_name HFRigidBody
2+
extends RigidBody3D
33

44

55
var constraints: Array
6+
var actuator: HFActuator
67

78

89
func import(state: GLTFState, json: Dictionary, extensions: Dictionary):
910
var rigid_body: Dictionary = state.json["extensions"]["HF_rigid_bodies"]["objects"][extensions["HF_rigid_bodies"]["object_id"]]
1011
name = json["name"]
11-
12+
1213
var mesh = MeshInstance3D.new()
1314
mesh.mesh = state.meshes[json["mesh"]].mesh.get_mesh()
1415
mesh.name = json["name"] + "_mesh"

0 commit comments

Comments
 (0)