Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion fast64_internal/mk64/mk64_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def loop_children(obj, fModel, parent_transform):
if self.is_mk64_actor(child):
self.add_actor(child, parent_transform, fModel)
if child.type == "CURVE":
self.add_curve(child, parent_transform, fModel)
if child.type == "PATH":
self.add_path(child, parent_transform, fModel)
if child.children:
loop_children(child, fModel, parent_transform @ child.matrix_local)
Expand All @@ -93,7 +95,7 @@ def add_actor(self, obj: bpy.Types.Object, transform: Matrix, fModel: FModel):
fModel.actors.append(MK64_Actor(position, mk64_props.actor_type))
return

def add_path(self, obj: bpy.Types.Object, transform: Matrix, fModel: FModel):
def add_curve(self, obj: bpy.Types.Object, transform: Matrix, fModel: FModel):
curve_data = obj.data

points = []
Expand All @@ -120,6 +122,36 @@ def add_path(self, obj: bpy.Types.Object, transform: Matrix, fModel: FModel):
fModel.path.append(MK64_Path(points))
return

def add_path(self, obj: bpy.types.Object, transform: Matrix, fModel: FModel):
depsgraph = bpy.context.evaluated_depsgraph_get()
eval_obj = obj.evaluated_get(depsgraph)
eval_curve = eval_obj.data

points = []

for spline in eval_curve.splines:
# Resolution controls sampling density
sample_count = spline.resolution_u * spline.point_count_u

for i in range(sample_count):
t = i / (sample_count - 1)

eval_curve.eval_time = t * eval_curve.path_duration
eval_obj.update_tag()

pos = eval_obj.matrix_world.translation

world_pos = transform @ pos
points.append((
int(round(world_pos.x)),
int(round(world_pos.y)),
int(round(world_pos.z)),
0,
))

if points:
fModel.path.append(MK64_Path(points))

# look into speeding this up by calculating just the apprent
# transform using transformMatrix vs clearing parent and applying
# transform
Expand Down
Loading