Skip to content

Commit

Permalink
fixed CollisionPolygon not getting Vec3.
Browse files Browse the repository at this point in the history
  • Loading branch information
pokepetter committed Mar 28, 2024
1 parent 96fc10f commit 207e3cf
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions ursina/collider.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ def __init__(self, entity, mesh=None, center=(0,0,0)):
if mesh.mode == 'triangle':
for i in range(0, len(mesh.generated_vertices), 3):
poly = CollisionPolygon(
Vec3(mesh.generated_vertices[i+2]),
Vec3(mesh.generated_vertices[i+1]),
Vec3(mesh.generated_vertices[i]),
Vec3(*mesh.generated_vertices[i+2]),
Vec3(*mesh.generated_vertices[i+1]),
Vec3(*mesh.generated_vertices[i]),
)
self.collision_polygons.append(poly)

elif mesh.mode == 'ngon':
# NOTE: does not support vertices len < 3. Is already being intercepted by pandas3D.
for i in range(2, len(mesh.vertices)):
poly = CollisionPolygon(
Vec3(mesh.vertices[i]),
Vec3(mesh.vertices[i - 1]),
Vec3(mesh.vertices[0]),
Vec3(*mesh.vertices[i]),
Vec3(*mesh.vertices[i - 1]),
Vec3(*mesh.vertices[0]),
)
self.collision_polygons.append(poly)
else:
Expand Down Expand Up @@ -139,7 +139,7 @@ def remove(self):
from ursina import Ursina, Entity, Pipe, Circle, Button, scene, EditorCamera, color
app = Ursina()

e = Entity(model='sphere', x=2)
e = Button(parent=scene, model='sphere', x=2)
e.collider = 'box' # add BoxCollider based on entity's bounds.
e.collider = 'sphere' # add SphereCollider based on entity's bounds.
e.collider = 'capsule' # add CapsuleCollider based on entity's bounds.
Expand All @@ -156,6 +156,8 @@ def remove(self):
e = Button(parent=scene, model='cube', collider='mesh', color=color.red, highlight_color=color.yellow)
# e = Button(parent=scene, model='quad', collider=, color=color.lime, x=-1)

sphere = Button(parent=scene, model='icosphere', collider='mesh', color=color.red, highlight_color=color.yellow, x=4)

EditorCamera()

def input(key):
Expand Down

0 comments on commit 207e3cf

Please sign in to comment.