basilisk-engine 0.1.4__py3-none-any.whl → 0.1.6__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 (86) hide show
  1. basilisk/__init__.py +14 -13
  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 -95
  6. basilisk/collisions/collider_handler.py +224 -225
  7. basilisk/collisions/narrow/contact_manifold.py +95 -90
  8. basilisk/collisions/narrow/dataclasses.py +34 -32
  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 +179 -179
  19. basilisk/draw/font_renderer.py +28 -28
  20. basilisk/engine.py +200 -199
  21. basilisk/generic/abstract_bvh.py +15 -15
  22. basilisk/generic/abstract_custom.py +133 -133
  23. basilisk/generic/collisions.py +72 -70
  24. basilisk/generic/input_validation.py +66 -66
  25. basilisk/generic/math.py +6 -6
  26. basilisk/generic/matrices.py +35 -33
  27. basilisk/generic/meshes.py +72 -72
  28. basilisk/generic/quat.py +143 -138
  29. basilisk/generic/quat_methods.py +7 -7
  30. basilisk/generic/raycast_result.py +23 -23
  31. basilisk/generic/vec3.py +143 -143
  32. basilisk/input/mouse.py +61 -61
  33. basilisk/input/path.py +14 -14
  34. basilisk/mesh/cube.py +33 -33
  35. basilisk/mesh/mesh.py +230 -230
  36. basilisk/mesh/mesh_from_data.py +130 -130
  37. basilisk/mesh/model.py +271 -271
  38. basilisk/mesh/narrow_aabb.py +89 -89
  39. basilisk/mesh/narrow_bvh.py +91 -91
  40. basilisk/mesh/narrow_primative.py +23 -23
  41. basilisk/nodes/helper.py +28 -28
  42. basilisk/nodes/node.py +683 -681
  43. basilisk/nodes/node_handler.py +95 -95
  44. basilisk/particles/particle_handler.py +63 -63
  45. basilisk/particles/particle_renderer.py +87 -87
  46. basilisk/physics/impulse.py +112 -112
  47. basilisk/physics/physics_body.py +43 -43
  48. basilisk/physics/physics_engine.py +35 -35
  49. basilisk/render/batch.py +86 -86
  50. basilisk/render/camera.py +206 -204
  51. basilisk/render/chunk.py +99 -99
  52. basilisk/render/chunk_handler.py +154 -154
  53. basilisk/render/frame.py +99 -98
  54. basilisk/render/framebuffer.py +105 -105
  55. basilisk/render/image.py +87 -87
  56. basilisk/render/image_handler.py +122 -122
  57. basilisk/render/light.py +96 -96
  58. basilisk/render/light_handler.py +58 -58
  59. basilisk/render/material.py +219 -219
  60. basilisk/render/material_handler.py +135 -135
  61. basilisk/render/post_process.py +132 -132
  62. basilisk/render/shader.py +109 -109
  63. basilisk/render/shader_handler.py +79 -79
  64. basilisk/render/sky.py +120 -120
  65. basilisk/scene.py +256 -256
  66. basilisk/shaders/batch.frag +276 -276
  67. basilisk/shaders/batch.vert +115 -115
  68. basilisk/shaders/crt.frag +31 -31
  69. basilisk/shaders/draw.frag +21 -21
  70. basilisk/shaders/draw.vert +21 -21
  71. basilisk/shaders/filter.frag +22 -22
  72. basilisk/shaders/frame.frag +12 -12
  73. basilisk/shaders/frame.vert +13 -13
  74. basilisk/shaders/geometry.frag +8 -8
  75. basilisk/shaders/geometry.vert +41 -41
  76. basilisk/shaders/normal.frag +59 -59
  77. basilisk/shaders/normal.vert +96 -96
  78. basilisk/shaders/particle.frag +71 -71
  79. basilisk/shaders/particle.vert +84 -84
  80. basilisk/shaders/sky.frag +9 -9
  81. basilisk/shaders/sky.vert +13 -13
  82. {basilisk_engine-0.1.4.dist-info → basilisk_engine-0.1.6.dist-info}/METADATA +45 -38
  83. basilisk_engine-0.1.6.dist-info/RECORD +101 -0
  84. {basilisk_engine-0.1.4.dist-info → basilisk_engine-0.1.6.dist-info}/WHEEL +1 -1
  85. basilisk_engine-0.1.4.dist-info/RECORD +0 -101
  86. {basilisk_engine-0.1.4.dist-info → basilisk_engine-0.1.6.dist-info}/top_level.txt +0 -0
@@ -1,96 +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
- 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)}')
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)}')
96
96
  value.add(self)