mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 07:48:37 -04:00
motiontrail: Add easier way to call add_vertex()
Currently, you must pass in a function, which is a little awkward compared to just passing in a position. Now you can just pass in a vertex position, similar to the C++ interface.
This commit is contained in:
parent
154223d075
commit
8ab37b8804
@ -244,7 +244,7 @@ class MotionTrail(NodePath, DirectObject):
|
|||||||
|
|
||||||
return Task.cont
|
return Task.cont
|
||||||
|
|
||||||
def add_vertex(self, vertex_id, vertex_function, context):
|
def add_vertex(self, vertex_id, vertex_function=None, context=None):
|
||||||
"""This must be called repeatedly to define the polygon that forms the
|
"""This must be called repeatedly to define the polygon that forms the
|
||||||
cross-section of the generated motion trail geometry. The first
|
cross-section of the generated motion trail geometry. The first
|
||||||
argument is a user-defined vertex identifier, the second is a function
|
argument is a user-defined vertex identifier, the second is a function
|
||||||
@ -255,7 +255,14 @@ class MotionTrail(NodePath, DirectObject):
|
|||||||
|
|
||||||
After calling this, you must call `update_vertices()` before the
|
After calling this, you must call `update_vertices()` before the
|
||||||
changes will fully take effect.
|
changes will fully take effect.
|
||||||
|
|
||||||
|
As of Panda3D 1.10.13, you may alternatively simply pass in a single
|
||||||
|
argument containing the vertex position as a `.Vec4` or `.Point3`.
|
||||||
"""
|
"""
|
||||||
|
if vertex_function is None:
|
||||||
|
motion_trail_vertex = MotionTrailVertex(None, None, context)
|
||||||
|
motion_trail_vertex.vertex = Vec4(vertex_id)
|
||||||
|
else:
|
||||||
motion_trail_vertex = MotionTrailVertex(vertex_id, vertex_function, context)
|
motion_trail_vertex = MotionTrailVertex(vertex_id, vertex_function, context)
|
||||||
total_vertices = len(self.vertex_list)
|
total_vertices = len(self.vertex_list)
|
||||||
|
|
||||||
@ -308,6 +315,7 @@ class MotionTrail(NodePath, DirectObject):
|
|||||||
vertex_index = 0
|
vertex_index = 0
|
||||||
while vertex_index < total_vertices:
|
while vertex_index < total_vertices:
|
||||||
motion_trail_vertex = self.vertex_list[vertex_index]
|
motion_trail_vertex = self.vertex_list[vertex_index]
|
||||||
|
if motion_trail_vertex.vertex_function is not None:
|
||||||
motion_trail_vertex.vertex = motion_trail_vertex.vertex_function(motion_trail_vertex, motion_trail_vertex.vertex_id, motion_trail_vertex.context)
|
motion_trail_vertex.vertex = motion_trail_vertex.vertex_function(motion_trail_vertex, motion_trail_vertex.vertex_id, motion_trail_vertex.context)
|
||||||
vertex_index += 1
|
vertex_index += 1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user