basilisk-engine 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of basilisk-engine might be problematic. Click here for more details.

Files changed (82) hide show
  1. basilisk/__init__.py +11 -11
  2. basilisk/bsk_assets/cube.obj +48 -48
  3. basilisk/collisions/broad/broad_aabb.py +102 -102
  4. basilisk/collisions/broad/broad_bvh.py +137 -137
  5. basilisk/collisions/collider.py +95 -83
  6. basilisk/collisions/collider_handler.py +225 -228
  7. basilisk/collisions/narrow/contact_manifold.py +90 -90
  8. basilisk/collisions/narrow/dataclasses.py +33 -27
  9. basilisk/collisions/narrow/deprecated.py +46 -46
  10. basilisk/collisions/narrow/epa.py +91 -91
  11. basilisk/collisions/narrow/gjk.py +66 -66
  12. basilisk/collisions/narrow/graham_scan.py +24 -24
  13. basilisk/collisions/narrow/helper.py +29 -29
  14. basilisk/collisions/narrow/line_intersections.py +106 -106
  15. basilisk/collisions/narrow/sutherland_hodgman.py +75 -75
  16. basilisk/config.py +2 -2
  17. basilisk/draw/draw.py +100 -100
  18. basilisk/draw/draw_handler.py +180 -210
  19. basilisk/draw/font_renderer.py +28 -28
  20. basilisk/engine.py +195 -195
  21. basilisk/generic/abstract_bvh.py +15 -15
  22. basilisk/generic/abstract_custom.py +133 -133
  23. basilisk/generic/collisions.py +70 -70
  24. basilisk/generic/input_validation.py +67 -28
  25. basilisk/generic/math.py +6 -6
  26. basilisk/generic/matrices.py +33 -33
  27. basilisk/generic/meshes.py +72 -72
  28. basilisk/generic/quat.py +137 -137
  29. basilisk/generic/quat_methods.py +7 -7
  30. basilisk/generic/raycast_result.py +24 -0
  31. basilisk/generic/vec3.py +143 -143
  32. basilisk/input/mouse.py +61 -59
  33. basilisk/mesh/cube.py +33 -33
  34. basilisk/mesh/mesh.py +230 -230
  35. basilisk/mesh/mesh_from_data.py +132 -132
  36. basilisk/mesh/model.py +271 -271
  37. basilisk/mesh/narrow_aabb.py +89 -89
  38. basilisk/mesh/narrow_bvh.py +91 -91
  39. basilisk/mesh/narrow_primative.py +23 -23
  40. basilisk/nodes/helper.py +29 -0
  41. basilisk/nodes/node.py +681 -617
  42. basilisk/nodes/node_handler.py +95 -118
  43. basilisk/particles/particle_handler.py +63 -54
  44. basilisk/particles/particle_renderer.py +87 -87
  45. basilisk/physics/impulse.py +112 -112
  46. basilisk/physics/physics_body.py +43 -43
  47. basilisk/physics/physics_engine.py +35 -35
  48. basilisk/render/batch.py +86 -86
  49. basilisk/render/camera.py +204 -199
  50. basilisk/render/chunk.py +99 -99
  51. basilisk/render/chunk_handler.py +154 -154
  52. basilisk/render/frame.py +181 -181
  53. basilisk/render/image.py +75 -75
  54. basilisk/render/image_handler.py +122 -122
  55. basilisk/render/light.py +96 -96
  56. basilisk/render/light_handler.py +58 -58
  57. basilisk/render/material.py +219 -219
  58. basilisk/render/material_handler.py +135 -135
  59. basilisk/render/shader.py +109 -109
  60. basilisk/render/shader_handler.py +79 -79
  61. basilisk/render/sky.py +120 -120
  62. basilisk/scene.py +250 -210
  63. basilisk/shaders/batch.frag +276 -276
  64. basilisk/shaders/batch.vert +115 -115
  65. basilisk/shaders/draw.frag +21 -21
  66. basilisk/shaders/draw.vert +21 -21
  67. basilisk/shaders/filter.frag +22 -22
  68. basilisk/shaders/frame.frag +12 -12
  69. basilisk/shaders/frame.vert +13 -13
  70. basilisk/shaders/geometry.frag +8 -8
  71. basilisk/shaders/geometry.vert +41 -41
  72. basilisk/shaders/normal.frag +59 -59
  73. basilisk/shaders/normal.vert +96 -96
  74. basilisk/shaders/particle.frag +71 -71
  75. basilisk/shaders/particle.vert +84 -84
  76. basilisk/shaders/sky.frag +9 -9
  77. basilisk/shaders/sky.vert +13 -13
  78. {basilisk_engine-0.1.2.dist-info → basilisk_engine-0.1.3.dist-info}/METADATA +45 -38
  79. basilisk_engine-0.1.3.dist-info/RECORD +97 -0
  80. {basilisk_engine-0.1.2.dist-info → basilisk_engine-0.1.3.dist-info}/WHEEL +1 -1
  81. basilisk_engine-0.1.2.dist-info/RECORD +0 -95
  82. {basilisk_engine-0.1.2.dist-info → basilisk_engine-0.1.3.dist-info}/top_level.txt +0 -0
@@ -1,84 +1,96 @@
1
- import glm
2
- from ..generic.abstract_bvh import AbstractAABB as AABB
3
- from ..generic.meshes import transform_points, get_aabb_surface_area
4
- from ..mesh.mesh import Mesh
5
-
6
- class Collider():
7
- node: ...
8
- """Back reference to the node"""
9
- collider_handler: ...
10
- """Back reference to the collider handler"""
11
- half_dimensions: glm.vec3
12
- """The axis aligned dimensions of the transformed mesh"""
13
- static_friction: float = 0.8 # input from node constructor
14
- """Determines the friction of the node when still: recommended 0 - 1"""
15
- kinetic_friction: float = 0.3 # input from node constructor
16
- """Determines the friction of the node when moving: recommended 0 - 1"""
17
- elasticity: float = 0.1 # input from node constructor
18
- """Determines how bouncy an object is: recommended 0 - 1"""
19
- collision_group: str # input from node constructor
20
- """Nodes of the same collision group do not collide with each other"""
21
- has_collided: bool
22
- """Stores whether or not the collider has been collided with in the last frame"""
23
- collision_velocity: float
24
- """Stores the highest velocity from a collision on this collider from the last frame"""
25
- collisions: dict # {node : (normal, velocity, depth)} TODO determine which variables need to be stored
26
- """Stores data from collisions in the previous frame"""
27
- top_right: glm.vec3
28
- """AABB most positive corner"""
29
- bottom_left: glm.vec3
30
- """AABB most negative corner"""
31
- aabb_surface_area: float
32
- """The surface area of the collider's AABB"""
33
- parent: AABB
34
- """Reference to the parent AABB in the broad BVH"""
35
- mesh: Mesh
36
- """Reference to the colliding mesh"""
37
-
38
- def __init__(self, node, box_mesh: bool=False, static_friction: glm.vec3=0.7, kinetic_friction: glm.vec3=0.3, elasticity: glm.vec3=0.2, collision_group: str=None):
39
- self.collider_handler = None
40
- self.node = node
41
- self.static_friction = static_friction if elasticity else 0.8 # added checks to prevent floats being set to None. Also done for kinetic and elasticity
42
- self.box_mesh = box_mesh
43
- self.kinetic_friction = kinetic_friction if elasticity else 0.4
44
- self.elasticity = elasticity if elasticity else 0.1
45
- self.collision_group = collision_group
46
- self.collision_velocity = 0
47
- self.collisions = {}
48
- self.parent = None
49
-
50
- # lazy update variables TODO change to distinguish between static and nonstatic objects
51
- self.needs_obb = True # pos, scale, rot
52
- self.needs_half_dimensions = True # scale, rot
53
- self.needs_bvh = True # pos, scale, rot
54
-
55
- @property
56
- def collider_handler(self): return self._collider_handler
57
- @property
58
- def has_collided(self): return bool(self.collisions)
59
- @property
60
- def half_dimensions(self): # TODO look for optimization
61
- if self.needs_half_dimensions:
62
- top_right = glm.max(self.obb_points)
63
- self._half_dimensions = top_right - self.node.geometric_center
64
- self.needs_half_dimensions = False
65
- return self._half_dimensions
66
- @property
67
- def bottom_left(self): return self.node.geometric_center - self.half_dimensions
68
- @property
69
- def top_right(self): return self.node.geometric_center + self.half_dimensions
70
- @property
71
- def aabb_surface_area(self): return get_aabb_surface_area(self.top_right, self.bottom_left)
72
- @property
73
- def obb_points(self):
74
- if self.needs_obb:
75
- self._obb_points = transform_points(self.mesh.aabb_points, self.node.model_matrix)
76
- self.needs_obb = False
77
- return self._obb_points
78
-
79
- @collider_handler.setter
80
- def collider_handler(self, value):
81
- self._collider_handler = value
82
- if not value: return
83
- self.mesh = value.cube if self.box_mesh else self.node.mesh
1
+ import glm
2
+ from ..generic.abstract_bvh import AbstractAABB as AABB
3
+ from ..generic.meshes import transform_points, get_aabb_surface_area
4
+ from ..mesh.mesh import Mesh
5
+ from .narrow.dataclasses import Collision
6
+
7
+ class Collider():
8
+ node: ...
9
+ """Back reference to the node"""
10
+ collider_handler: ...
11
+ """Back reference to the collider handler"""
12
+ half_dimensions: glm.vec3
13
+ """The axis aligned dimensions of the transformed mesh"""
14
+ static_friction: float = 0.8 # input from node constructor
15
+ """Determines the friction of the node when still: recommended 0 - 1"""
16
+ kinetic_friction: float = 0.3 # input from node constructor
17
+ """Determines the friction of the node when moving: recommended 0 - 1"""
18
+ elasticity: float = 0.1 # input from node constructor
19
+ """Determines how bouncy an object is: recommended 0 - 1"""
20
+ collision_group: str # input from node constructor
21
+ """Nodes of the same collision group do not collide with each other"""
22
+ has_collided: bool
23
+ """Stores whether or not the collider has been collided with in the last frame"""
24
+ collision_velocity: float
25
+ """Stores the highest velocity from a collision on this collider from the last frame"""
26
+ collisions: dict # {node : (normal, velocity, depth)} TODO determine which variables need to be stored
27
+ """Stores data from collisions in the previous frame"""
28
+ top_right: glm.vec3
29
+ """AABB most positive corner"""
30
+ bottom_left: glm.vec3
31
+ """AABB most negative corner"""
32
+ aabb_surface_area: float
33
+ """The surface area of the collider's AABB"""
34
+ parent: AABB
35
+ """Reference to the parent AABB in the broad BVH"""
36
+ mesh: Mesh
37
+ """Reference to the colliding mesh"""
38
+
39
+ def __init__(self, node, collider_mesh: str|Mesh=None, static_friction: glm.vec3=0.7, kinetic_friction: glm.vec3=0.3, elasticity: glm.vec3=0.2, collision_group: str=None):
40
+ self.collider_handler = None
41
+ self.node = node
42
+ self.static_friction = static_friction if elasticity else 0.8 # added checks to prevent floats being set to None. Also done for kinetic and elasticity
43
+ self.mesh = collider_mesh
44
+ self.kinetic_friction = kinetic_friction if elasticity else 0.4
45
+ self.elasticity = elasticity if elasticity else 0.1
46
+ self.collision_group = collision_group
47
+ self.collision_velocity = 0
48
+ self.collisions: list[Collision] = []
49
+ self.parent = None
50
+
51
+ # lazy update variables TODO change to distinguish between static and nonstatic objects
52
+ self.needs_obb = True # pos, scale, rot
53
+ self.needs_half_dimensions = True # scale, rot
54
+ self.needs_bvh = True # pos, scale, rot
55
+
56
+ def get_vertex(self, index: int) -> glm.vec3:
57
+ """
58
+ Gets the world space position of a vertex indicated by the index in the mesh
59
+ """
60
+ return glm.vec3(self.node.model_matrix * glm.vec4(*self.mesh.points[index], 1))
61
+
62
+ @property
63
+ def collider_handler(self): return self._collider_handler
64
+ @property
65
+ def has_collided(self): return bool(self.collisions)
66
+ @property
67
+ def half_dimensions(self): # TODO look for optimization
68
+ if self.needs_half_dimensions:
69
+ top_right = glm.max(self.obb_points)
70
+ self._half_dimensions = top_right - self.node.geometric_center
71
+ self.needs_half_dimensions = False
72
+ return self._half_dimensions
73
+ @property
74
+ def bottom_left(self): return self.node.geometric_center - self.half_dimensions
75
+ @property
76
+ def top_right(self): return self.node.geometric_center + self.half_dimensions
77
+ @property
78
+ def aabb_surface_area(self): return get_aabb_surface_area(self.top_right, self.bottom_left)
79
+ @property
80
+ def obb_points(self):
81
+ if self.needs_obb:
82
+ self._obb_points = transform_points(self.mesh.aabb_points, self.node.model_matrix)
83
+ self.needs_obb = False
84
+ return self._obb_points
85
+
86
+ @collider_handler.setter
87
+ def collider_handler(self, value):
88
+ self._collider_handler = value
89
+ if not value: return
90
+ if self.mesh is None: self.mesh = self.node.mesh
91
+ elif isinstance(self.mesh, Mesh): ...
92
+ elif isinstance(self.mesh, str):
93
+ if self.mesh =='box': self.mesh = value.cube
94
+ else: raise ValueError(f'Incorrect built-in mesh type {self.mesh}')
95
+ else: raise ValueError(f'Unkown type for mesh, got {type(self.mesh)}')
84
96
  value.add(self)