Skip to content

Commit

Permalink
added a multithread entry under project settings
Browse files Browse the repository at this point in the history
  • Loading branch information
HungryProton committed Jun 2, 2020
1 parent 239c0c1 commit 074f078
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
1 change: 1 addition & 0 deletions concept_graph_plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func _enter_tree() -> void:
_connect_editor_signals()
_setup_node_library()
_register_editor_gizmos()
ConceptGraphSettings.initialize()


func _exit_tree() -> void:
Expand Down
5 changes: 2 additions & 3 deletions src/core/template.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ var concept_graph
var root: Spatial
var node_library: ConceptNodeLibrary # Injected from the concept graph

var multithreading_enabled := true
var paused := false
var restart_generation := false

Expand Down Expand Up @@ -281,7 +280,7 @@ func _run_generation() -> void:
if _clear_cache_on_next_run:
clear_simulation_cache()

if multithreading_enabled:
if ProjectSettings.get(ConceptGraphSettings.MULTITHREAD_ENABLED):
_thread.start(self, "_run_generation_threaded")
else:
_run_generation_threaded()
Expand Down Expand Up @@ -323,7 +322,7 @@ func _is_output_node(node) -> bool:


func _on_thread_completed() -> void:
if multithreading_enabled:
if ProjectSettings.get(ConceptGraphSettings.MULTITHREAD_ENABLED):
_thread.wait_to_finish()
if restart_generation:
generate()
Expand Down
22 changes: 11 additions & 11 deletions src/nodes/meshes/deform_along_curve.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Deform a mesh along a curve.
# Todo:
# - User set initial axis
# - Flip the winding of triangles if the start and end are inverted
# - bool to lock the length? Right now it stretches the object along the entire
# curve, but might be good to have an option lock this, post thoughts in the thread?
# - Could a scalar to project the verts out wider or less. Fairly trivial
# hook that up to a 2d Curve as well.
# - bool to lock the length? Right now it stretches the object along the entire
# curve, but might be good to have an option lock this, post thoughts in the thread?
# - Could a scalar to project the verts out wider or less. Fairly trivial
# hook that up to a 2d Curve as well.

func _init() -> void:
unique_id = "deform_along_path"
Expand All @@ -30,7 +30,7 @@ func _init() -> void:

func _generate_outputs() -> void:
var mesh : Mesh = get_input_single(0).mesh
var paths := get_input(1)
var paths := get_input(1)
var start_offset : float = get_input_single(2,0.0)
var end_offset : float = get_input_single(3,1.0)
var tilt: bool = get_input_single(4,false)
Expand All @@ -54,7 +54,7 @@ func _generate_outputs() -> void:
# temporary_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES,arrays)

# Muzz: would potentially be faster if I use ArrayMesh instead but the data tool
# makes things a fair bit easier.
# makes things a fair bit easier.
var mesh_data_tool = MeshDataTool.new()
mesh_data_tool.create_from_surface(mesh, 0)
var rotate_angle = Vector2(cos(rotate_along_axis), sin(rotate_along_axis))
Expand All @@ -64,16 +64,16 @@ func _generate_outputs() -> void:
var pre_look_at = Vector3(rotate_angle.x,rotate_angle.y,0)
pre_transform = pre_transform.looking_at(pre_look_at , Vector3(0, 0, 1))

# Muzz: if there are multiple paths, we'll duplicate the mesh for every single one.
# Output doesn't handle this yet though.
# Muzz: if there are multiple paths, we'll duplicate the mesh for every single one.
# Output doesn't handle this yet though.
for path in paths:
if path.curve.get_point_count() < 2:
return

# this is really buggy, this will break if up vector is not enabled
# Will investigate how to fix.
# Will investigate how to fix.
if not path.curve.is_up_vector_enabled():
# this can't work if this is off, so we just disable the node and print a warning.
# this can't work if this is off, so we just disable the node and print a warning.
print("Up vector in curve must be enabled for mesh deform node.")
return

Expand Down Expand Up @@ -107,7 +107,7 @@ func _generate_outputs() -> void:
offset = offset * length
var position_on_curve: Vector3 = curve.interpolate_baked(offset)

# I should add a check that there is an up vector in the curve.
# I should add a check that there is an up vector in the curve.
var up: Vector3 = curve.interpolate_baked_up_vector (offset,tilt)
var position_look_at: Vector3

Expand Down

0 comments on commit 074f078

Please sign in to comment.