basilisk-engine 0.1.17__py3-none-any.whl → 0.1.19__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.
- basilisk/__init__.py +15 -15
- basilisk/audio/sound.py +27 -27
- basilisk/bsk_assets/cube.obj +48 -48
- basilisk/collisions/broad/broad_aabb.py +102 -102
- basilisk/collisions/broad/broad_bvh.py +137 -137
- basilisk/collisions/collider.py +95 -95
- basilisk/collisions/collider_handler.py +224 -224
- basilisk/collisions/narrow/contact_manifold.py +95 -95
- basilisk/collisions/narrow/dataclasses.py +34 -34
- basilisk/collisions/narrow/deprecated.py +46 -46
- basilisk/collisions/narrow/epa.py +91 -91
- basilisk/collisions/narrow/gjk.py +66 -66
- basilisk/collisions/narrow/graham_scan.py +24 -24
- basilisk/collisions/narrow/helper.py +29 -29
- basilisk/collisions/narrow/line_intersections.py +106 -106
- basilisk/collisions/narrow/sutherland_hodgman.py +75 -75
- basilisk/config.py +2 -2
- basilisk/draw/draw.py +100 -100
- basilisk/draw/draw_handler.py +179 -179
- basilisk/draw/font_renderer.py +28 -28
- basilisk/engine.py +206 -206
- basilisk/generic/abstract_bvh.py +15 -15
- basilisk/generic/abstract_custom.py +133 -133
- basilisk/generic/collisions.py +72 -72
- basilisk/generic/input_validation.py +66 -66
- basilisk/generic/math.py +6 -6
- basilisk/generic/matrices.py +35 -35
- basilisk/generic/meshes.py +72 -72
- basilisk/generic/quat.py +142 -142
- basilisk/generic/quat_methods.py +7 -7
- basilisk/generic/raycast_result.py +26 -26
- basilisk/generic/vec3.py +143 -143
- basilisk/input/mouse.py +61 -61
- basilisk/input/path.py +14 -14
- basilisk/mesh/cube.py +33 -33
- basilisk/mesh/mesh.py +230 -230
- basilisk/mesh/mesh_from_data.py +130 -130
- basilisk/mesh/model.py +271 -271
- basilisk/mesh/narrow_aabb.py +89 -89
- basilisk/mesh/narrow_bvh.py +91 -91
- basilisk/mesh/narrow_primative.py +23 -23
- basilisk/nodes/helper.py +28 -28
- basilisk/nodes/node.py +684 -684
- basilisk/nodes/node_handler.py +96 -95
- basilisk/particles/particle_handler.py +64 -64
- basilisk/particles/particle_renderer.py +92 -92
- basilisk/physics/impulse.py +112 -112
- basilisk/physics/physics_body.py +43 -43
- basilisk/physics/physics_engine.py +35 -35
- basilisk/render/batch.py +105 -105
- basilisk/render/camera.py +221 -211
- basilisk/render/chunk.py +106 -106
- basilisk/render/chunk_handler.py +165 -165
- basilisk/render/frame.py +101 -101
- basilisk/render/framebuffer.py +130 -130
- basilisk/render/image.py +87 -87
- basilisk/render/image_handler.py +122 -122
- basilisk/render/light.py +96 -96
- basilisk/render/light_handler.py +58 -58
- basilisk/render/material.py +219 -219
- basilisk/render/material_handler.py +135 -135
- basilisk/render/post_process.py +132 -132
- basilisk/render/shader.py +110 -110
- basilisk/render/shader_handler.py +80 -80
- basilisk/render/sky.py +120 -120
- basilisk/scene.py +276 -276
- basilisk/shaders/batch.frag +276 -276
- basilisk/shaders/batch.vert +115 -115
- basilisk/shaders/crt.frag +31 -31
- basilisk/shaders/draw.frag +21 -21
- basilisk/shaders/draw.vert +21 -21
- basilisk/shaders/filter.frag +22 -22
- basilisk/shaders/frame.frag +12 -12
- basilisk/shaders/frame.vert +13 -13
- basilisk/shaders/geometry.frag +8 -8
- basilisk/shaders/geometry.vert +41 -41
- basilisk/shaders/normal.frag +59 -59
- basilisk/shaders/normal.vert +96 -96
- basilisk/shaders/particle.frag +71 -71
- basilisk/shaders/particle.vert +84 -84
- basilisk/shaders/sky.frag +9 -9
- basilisk/shaders/sky.vert +13 -13
- {basilisk_engine-0.1.17.dist-info → basilisk_engine-0.1.19.dist-info}/METADATA +45 -38
- basilisk_engine-0.1.19.dist-info/RECORD +103 -0
- {basilisk_engine-0.1.17.dist-info → basilisk_engine-0.1.19.dist-info}/WHEEL +1 -1
- basilisk_engine-0.1.17.dist-info/RECORD +0 -103
- {basilisk_engine-0.1.17.dist-info → basilisk_engine-0.1.19.dist-info}/top_level.txt +0 -0
basilisk/engine.py
CHANGED
|
@@ -1,207 +1,207 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from sys import platform
|
|
3
|
-
import sys
|
|
4
|
-
import glcontext
|
|
5
|
-
from .input.path import get_root
|
|
6
|
-
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
|
7
|
-
import pygame as pg
|
|
8
|
-
import moderngl as mgl
|
|
9
|
-
from .config import Config
|
|
10
|
-
from .input.mouse import Mouse
|
|
11
|
-
from .mesh.cube import Cube
|
|
12
|
-
from .render.shader import Shader
|
|
13
|
-
import glcontext
|
|
14
|
-
|
|
15
|
-
class Engine():
|
|
16
|
-
win_size: tuple
|
|
17
|
-
"""Size of the engine window in pixels"""
|
|
18
|
-
ctx: mgl.Context
|
|
19
|
-
"""ModernGL context used by the engine"""
|
|
20
|
-
scene: any
|
|
21
|
-
"""Scene currently being updated and rendered by the engine"""
|
|
22
|
-
clock: pg.Clock
|
|
23
|
-
"""Pygame clock used to keep track of time between frames"""
|
|
24
|
-
config: Config
|
|
25
|
-
"""Object containing all global attributes"""
|
|
26
|
-
delta_time: float
|
|
27
|
-
"""Time in seconds that passed between the last frame"""
|
|
28
|
-
time: float
|
|
29
|
-
"""Total time the engine has been running"""
|
|
30
|
-
running: bool
|
|
31
|
-
"""True if the engine is still running"""
|
|
32
|
-
events: list
|
|
33
|
-
"""List of all pygame"""
|
|
34
|
-
keys: list
|
|
35
|
-
"""bool list containing the state of all keys this frame"""
|
|
36
|
-
previous_keys: list
|
|
37
|
-
"""bool list containing the state of all keys at the previous frame"""
|
|
38
|
-
mouse: Mouse
|
|
39
|
-
"""Object containing information about the user's mouse"""
|
|
40
|
-
root: str
|
|
41
|
-
"""Path to the root directory containing internal data"""
|
|
42
|
-
|
|
43
|
-
def __init__(self, win_size=(800, 800), title="Basilisk Engine", vsync=None, grab_mouse=True, headless=False) -> None:
|
|
44
|
-
"""
|
|
45
|
-
Basilisk Engine Class. Sets up the engine enviornment and allows the user to interact with Basilisk
|
|
46
|
-
Args:
|
|
47
|
-
win_size: tuple
|
|
48
|
-
The initial window size of the engine
|
|
49
|
-
title: str
|
|
50
|
-
The title of the engine window
|
|
51
|
-
vsync: bool
|
|
52
|
-
Flag for running engine with vsync enabled
|
|
53
|
-
headless: bool
|
|
54
|
-
Flag for headless rendering
|
|
55
|
-
"""
|
|
56
|
-
|
|
57
|
-
if platform == 'win32' : self.platform = 'windows'
|
|
58
|
-
elif platform == 'darwin': self.platform = 'mac'
|
|
59
|
-
else: self.platform = 'linux'
|
|
60
|
-
|
|
61
|
-
# Save the window size
|
|
62
|
-
self.win_size = win_size
|
|
63
|
-
|
|
64
|
-
pg.init()
|
|
65
|
-
# Initialize pygame and OpenGL attributes
|
|
66
|
-
pg.display.gl_set_attribute(pg.GL_CONTEXT_MAJOR_VERSION, 3)
|
|
67
|
-
pg.display.gl_set_attribute(pg.GL_CONTEXT_MINOR_VERSION, 3)
|
|
68
|
-
pg.display.gl_set_attribute(pg.GL_CONTEXT_PROFILE_MASK, pg.GL_CONTEXT_PROFILE_CORE)
|
|
69
|
-
# Check vsync against platform defaults
|
|
70
|
-
if vsync == None: vsync = True if platform == 'linux' else False
|
|
71
|
-
# Pygame display init
|
|
72
|
-
if headless:
|
|
73
|
-
pg.display.set_mode((300, 50), vsync=vsync, flags=pg.OPENGL | pg.DOUBLEBUF)
|
|
74
|
-
pg.display.iconify()
|
|
75
|
-
else:
|
|
76
|
-
pg.display.set_mode(self.win_size, vsync=vsync, flags=pg.OPENGL | pg.DOUBLEBUF | pg.RESIZABLE)
|
|
77
|
-
pg.display.set_caption(title)
|
|
78
|
-
|
|
79
|
-
# Init sound
|
|
80
|
-
pg.mixer.pre_init(44100, -16, 2, 512)
|
|
81
|
-
pg.mixer.init()
|
|
82
|
-
pg.mixer.set_num_channels(64)
|
|
83
|
-
pg.mixer.music.set_volume(100/100)
|
|
84
|
-
|
|
85
|
-
# MGL context setup
|
|
86
|
-
self.ctx = mgl.create_context()
|
|
87
|
-
self.ctx.enable(flags=mgl.DEPTH_TEST | mgl.CULL_FACE | mgl.BLEND)
|
|
88
|
-
|
|
89
|
-
# Global attributes referenced by the handlers
|
|
90
|
-
self.headless = headless
|
|
91
|
-
self.set_configurations()
|
|
92
|
-
self.root = os.path.dirname(__file__)
|
|
93
|
-
self.cube = Cube(self)
|
|
94
|
-
self.fbos = []
|
|
95
|
-
|
|
96
|
-
# Update the icon
|
|
97
|
-
pg.display.set_icon(pg.image.load(self.root + '/bsk_assets/basilisk.png'))
|
|
98
|
-
|
|
99
|
-
# Time variables
|
|
100
|
-
self.clock = pg.time.Clock()
|
|
101
|
-
self.delta_time = 0
|
|
102
|
-
self.time = 0
|
|
103
|
-
|
|
104
|
-
# Initialize input lists
|
|
105
|
-
self.keys = pg.key.get_pressed()
|
|
106
|
-
self.previous_keys = self.keys
|
|
107
|
-
self.mouse = Mouse(grab=grab_mouse)
|
|
108
|
-
|
|
109
|
-
# Scene being used by the engine
|
|
110
|
-
self.scene = None
|
|
111
|
-
|
|
112
|
-
# Load a default shader
|
|
113
|
-
self.shader = Shader(self, self.root + '/shaders/batch.vert', self.root + '/shaders/batch.frag')
|
|
114
|
-
self.shader.hash = self.shader.hash + hash('engine_shader')
|
|
115
|
-
|
|
116
|
-
# Set the scene to running
|
|
117
|
-
self.running = True
|
|
118
|
-
|
|
119
|
-
def update(self, render=True) -> None:
|
|
120
|
-
"""
|
|
121
|
-
Updates all input, physics, and time variables. Renders the current scene.
|
|
122
|
-
"""
|
|
123
|
-
|
|
124
|
-
# Tick the clock and get delta time
|
|
125
|
-
self.delta_time = self.clock.tick() / 1000
|
|
126
|
-
self.time += self.delta_time
|
|
127
|
-
pg.display.set_caption(f"FPS: {round(self.clock.get_fps())}")
|
|
128
|
-
|
|
129
|
-
# Update the previous input lists for the next frame
|
|
130
|
-
self.previous_keys = self.keys
|
|
131
|
-
|
|
132
|
-
# Get inputs and events
|
|
133
|
-
self.events = pg.event.get()
|
|
134
|
-
self.keys = pg.key.get_pressed()
|
|
135
|
-
self.mouse.update(self.events)
|
|
136
|
-
|
|
137
|
-
# Loop through all pygame events
|
|
138
|
-
for event in self.events:
|
|
139
|
-
if event.type == pg.QUIT: # Quit the engine
|
|
140
|
-
self.quit()
|
|
141
|
-
return
|
|
142
|
-
if event.type == pg.VIDEORESIZE:
|
|
143
|
-
# Updates the viewport
|
|
144
|
-
self.win_size = (event.w, event.h)
|
|
145
|
-
self.ctx.viewport = (0, 0, event.w, event.h)
|
|
146
|
-
self.scene.camera.use()
|
|
147
|
-
self.scene.frame.resize()
|
|
148
|
-
for fbo in self.fbos: fbo.resize()
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
# Update the scene if possible
|
|
152
|
-
if self.scene: self.scene.update()
|
|
153
|
-
# Render after the scene and engine has been updated
|
|
154
|
-
if render: self.render()
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
def render(self) -> None:
|
|
158
|
-
"""
|
|
159
|
-
Renders the scene currently being used by the engine
|
|
160
|
-
"""
|
|
161
|
-
|
|
162
|
-
# Set the ctx for rendering
|
|
163
|
-
self.ctx.screen.use()
|
|
164
|
-
self.ctx.clear()
|
|
165
|
-
|
|
166
|
-
# Render the scene
|
|
167
|
-
if self.scene:self.scene.render()
|
|
168
|
-
|
|
169
|
-
# Flip pygame display buffer
|
|
170
|
-
pg.display.flip()
|
|
171
|
-
|
|
172
|
-
def set_configurations(self):
|
|
173
|
-
"""
|
|
174
|
-
Sets global configurations. These attributs are not used by the engine, just the handlers
|
|
175
|
-
"""
|
|
176
|
-
|
|
177
|
-
# Create a config object
|
|
178
|
-
self.config = Config()
|
|
179
|
-
|
|
180
|
-
# Set the attributes on the config object
|
|
181
|
-
setattr(self.config, "chunk_size", 40)
|
|
182
|
-
setattr(self.config, "render_distance", 5)
|
|
183
|
-
|
|
184
|
-
def quit(self) -> None:
|
|
185
|
-
"""
|
|
186
|
-
Stops the engine and releases all memory
|
|
187
|
-
"""
|
|
188
|
-
|
|
189
|
-
pg.quit()
|
|
190
|
-
self.ctx.release()
|
|
191
|
-
self.running = False
|
|
192
|
-
|
|
193
|
-
@property
|
|
194
|
-
def scene(self): return self._scene
|
|
195
|
-
@property
|
|
196
|
-
def shader(self): return self._shader
|
|
197
|
-
|
|
198
|
-
@scene.setter
|
|
199
|
-
def scene(self, value):
|
|
200
|
-
self._scene = value
|
|
201
|
-
if self._scene:
|
|
202
|
-
self._scene.set_engine(self)
|
|
203
|
-
|
|
204
|
-
@shader.setter
|
|
205
|
-
def shader(self, value):
|
|
206
|
-
self._shader = value
|
|
1
|
+
import os
|
|
2
|
+
from sys import platform
|
|
3
|
+
import sys
|
|
4
|
+
import glcontext
|
|
5
|
+
from .input.path import get_root
|
|
6
|
+
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
|
7
|
+
import pygame as pg
|
|
8
|
+
import moderngl as mgl
|
|
9
|
+
from .config import Config
|
|
10
|
+
from .input.mouse import Mouse
|
|
11
|
+
from .mesh.cube import Cube
|
|
12
|
+
from .render.shader import Shader
|
|
13
|
+
import glcontext
|
|
14
|
+
|
|
15
|
+
class Engine():
|
|
16
|
+
win_size: tuple
|
|
17
|
+
"""Size of the engine window in pixels"""
|
|
18
|
+
ctx: mgl.Context
|
|
19
|
+
"""ModernGL context used by the engine"""
|
|
20
|
+
scene: any
|
|
21
|
+
"""Scene currently being updated and rendered by the engine"""
|
|
22
|
+
clock: pg.Clock
|
|
23
|
+
"""Pygame clock used to keep track of time between frames"""
|
|
24
|
+
config: Config
|
|
25
|
+
"""Object containing all global attributes"""
|
|
26
|
+
delta_time: float
|
|
27
|
+
"""Time in seconds that passed between the last frame"""
|
|
28
|
+
time: float
|
|
29
|
+
"""Total time the engine has been running"""
|
|
30
|
+
running: bool
|
|
31
|
+
"""True if the engine is still running"""
|
|
32
|
+
events: list
|
|
33
|
+
"""List of all pygame"""
|
|
34
|
+
keys: list
|
|
35
|
+
"""bool list containing the state of all keys this frame"""
|
|
36
|
+
previous_keys: list
|
|
37
|
+
"""bool list containing the state of all keys at the previous frame"""
|
|
38
|
+
mouse: Mouse
|
|
39
|
+
"""Object containing information about the user's mouse"""
|
|
40
|
+
root: str
|
|
41
|
+
"""Path to the root directory containing internal data"""
|
|
42
|
+
|
|
43
|
+
def __init__(self, win_size=(800, 800), title="Basilisk Engine", vsync=None, grab_mouse=True, headless=False) -> None:
|
|
44
|
+
"""
|
|
45
|
+
Basilisk Engine Class. Sets up the engine enviornment and allows the user to interact with Basilisk
|
|
46
|
+
Args:
|
|
47
|
+
win_size: tuple
|
|
48
|
+
The initial window size of the engine
|
|
49
|
+
title: str
|
|
50
|
+
The title of the engine window
|
|
51
|
+
vsync: bool
|
|
52
|
+
Flag for running engine with vsync enabled
|
|
53
|
+
headless: bool
|
|
54
|
+
Flag for headless rendering
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
if platform == 'win32' : self.platform = 'windows'
|
|
58
|
+
elif platform == 'darwin': self.platform = 'mac'
|
|
59
|
+
else: self.platform = 'linux'
|
|
60
|
+
|
|
61
|
+
# Save the window size
|
|
62
|
+
self.win_size = win_size
|
|
63
|
+
|
|
64
|
+
pg.init()
|
|
65
|
+
# Initialize pygame and OpenGL attributes
|
|
66
|
+
pg.display.gl_set_attribute(pg.GL_CONTEXT_MAJOR_VERSION, 3)
|
|
67
|
+
pg.display.gl_set_attribute(pg.GL_CONTEXT_MINOR_VERSION, 3)
|
|
68
|
+
pg.display.gl_set_attribute(pg.GL_CONTEXT_PROFILE_MASK, pg.GL_CONTEXT_PROFILE_CORE)
|
|
69
|
+
# Check vsync against platform defaults
|
|
70
|
+
if vsync == None: vsync = True if platform == 'linux' else False
|
|
71
|
+
# Pygame display init
|
|
72
|
+
if headless:
|
|
73
|
+
pg.display.set_mode((300, 50), vsync=vsync, flags=pg.OPENGL | pg.DOUBLEBUF)
|
|
74
|
+
pg.display.iconify()
|
|
75
|
+
else:
|
|
76
|
+
pg.display.set_mode(self.win_size, vsync=vsync, flags=pg.OPENGL | pg.DOUBLEBUF | pg.RESIZABLE)
|
|
77
|
+
pg.display.set_caption(title)
|
|
78
|
+
|
|
79
|
+
# Init sound
|
|
80
|
+
pg.mixer.pre_init(44100, -16, 2, 512)
|
|
81
|
+
pg.mixer.init()
|
|
82
|
+
pg.mixer.set_num_channels(64)
|
|
83
|
+
pg.mixer.music.set_volume(100/100)
|
|
84
|
+
|
|
85
|
+
# MGL context setup
|
|
86
|
+
self.ctx = mgl.create_context()
|
|
87
|
+
self.ctx.enable(flags=mgl.DEPTH_TEST | mgl.CULL_FACE | mgl.BLEND)
|
|
88
|
+
|
|
89
|
+
# Global attributes referenced by the handlers
|
|
90
|
+
self.headless = headless
|
|
91
|
+
self.set_configurations()
|
|
92
|
+
self.root = os.path.dirname(__file__)
|
|
93
|
+
self.cube = Cube(self)
|
|
94
|
+
self.fbos = []
|
|
95
|
+
|
|
96
|
+
# Update the icon
|
|
97
|
+
pg.display.set_icon(pg.image.load(self.root + '/bsk_assets/basilisk.png'))
|
|
98
|
+
|
|
99
|
+
# Time variables
|
|
100
|
+
self.clock = pg.time.Clock()
|
|
101
|
+
self.delta_time = 0
|
|
102
|
+
self.time = 0
|
|
103
|
+
|
|
104
|
+
# Initialize input lists
|
|
105
|
+
self.keys = pg.key.get_pressed()
|
|
106
|
+
self.previous_keys = self.keys
|
|
107
|
+
self.mouse = Mouse(grab=grab_mouse)
|
|
108
|
+
|
|
109
|
+
# Scene being used by the engine
|
|
110
|
+
self.scene = None
|
|
111
|
+
|
|
112
|
+
# Load a default shader
|
|
113
|
+
self.shader = Shader(self, self.root + '/shaders/batch.vert', self.root + '/shaders/batch.frag')
|
|
114
|
+
self.shader.hash = self.shader.hash + hash('engine_shader')
|
|
115
|
+
|
|
116
|
+
# Set the scene to running
|
|
117
|
+
self.running = True
|
|
118
|
+
|
|
119
|
+
def update(self, render=True) -> None:
|
|
120
|
+
"""
|
|
121
|
+
Updates all input, physics, and time variables. Renders the current scene.
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
# Tick the clock and get delta time
|
|
125
|
+
self.delta_time = self.clock.tick() / 1000
|
|
126
|
+
self.time += self.delta_time
|
|
127
|
+
pg.display.set_caption(f"FPS: {round(self.clock.get_fps())}")
|
|
128
|
+
|
|
129
|
+
# Update the previous input lists for the next frame
|
|
130
|
+
self.previous_keys = self.keys
|
|
131
|
+
|
|
132
|
+
# Get inputs and events
|
|
133
|
+
self.events = pg.event.get()
|
|
134
|
+
self.keys = pg.key.get_pressed()
|
|
135
|
+
self.mouse.update(self.events)
|
|
136
|
+
|
|
137
|
+
# Loop through all pygame events
|
|
138
|
+
for event in self.events:
|
|
139
|
+
if event.type == pg.QUIT: # Quit the engine
|
|
140
|
+
self.quit()
|
|
141
|
+
return
|
|
142
|
+
if event.type == pg.VIDEORESIZE:
|
|
143
|
+
# Updates the viewport
|
|
144
|
+
self.win_size = (event.w, event.h)
|
|
145
|
+
self.ctx.viewport = (0, 0, event.w, event.h)
|
|
146
|
+
self.scene.camera.use()
|
|
147
|
+
self.scene.frame.resize()
|
|
148
|
+
for fbo in self.fbos: fbo.resize()
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
# Update the scene if possible
|
|
152
|
+
if self.scene: self.scene.update()
|
|
153
|
+
# Render after the scene and engine has been updated
|
|
154
|
+
if render: self.render()
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def render(self) -> None:
|
|
158
|
+
"""
|
|
159
|
+
Renders the scene currently being used by the engine
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
# Set the ctx for rendering
|
|
163
|
+
self.ctx.screen.use()
|
|
164
|
+
self.ctx.clear()
|
|
165
|
+
|
|
166
|
+
# Render the scene
|
|
167
|
+
if self.scene:self.scene.render()
|
|
168
|
+
|
|
169
|
+
# Flip pygame display buffer
|
|
170
|
+
pg.display.flip()
|
|
171
|
+
|
|
172
|
+
def set_configurations(self):
|
|
173
|
+
"""
|
|
174
|
+
Sets global configurations. These attributs are not used by the engine, just the handlers
|
|
175
|
+
"""
|
|
176
|
+
|
|
177
|
+
# Create a config object
|
|
178
|
+
self.config = Config()
|
|
179
|
+
|
|
180
|
+
# Set the attributes on the config object
|
|
181
|
+
setattr(self.config, "chunk_size", 40)
|
|
182
|
+
setattr(self.config, "render_distance", 5)
|
|
183
|
+
|
|
184
|
+
def quit(self) -> None:
|
|
185
|
+
"""
|
|
186
|
+
Stops the engine and releases all memory
|
|
187
|
+
"""
|
|
188
|
+
|
|
189
|
+
pg.quit()
|
|
190
|
+
self.ctx.release()
|
|
191
|
+
self.running = False
|
|
192
|
+
|
|
193
|
+
@property
|
|
194
|
+
def scene(self): return self._scene
|
|
195
|
+
@property
|
|
196
|
+
def shader(self): return self._shader
|
|
197
|
+
|
|
198
|
+
@scene.setter
|
|
199
|
+
def scene(self, value):
|
|
200
|
+
self._scene = value
|
|
201
|
+
if self._scene:
|
|
202
|
+
self._scene.set_engine(self)
|
|
203
|
+
|
|
204
|
+
@shader.setter
|
|
205
|
+
def shader(self, value):
|
|
206
|
+
self._shader = value
|
|
207
207
|
if self.scene: value.set_main()
|
basilisk/generic/abstract_bvh.py
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import glm
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class AbstractAABB():
|
|
5
|
-
top_right: glm.vec3
|
|
6
|
-
"""The furthest positive corner of the AABB"""
|
|
7
|
-
bottom_left: glm.vec3
|
|
8
|
-
"""The furthest negative corner of the AABB"""
|
|
9
|
-
a: ...
|
|
10
|
-
"""Binary child 1"""
|
|
11
|
-
b: ...
|
|
12
|
-
"""Binary child 2"""
|
|
13
|
-
|
|
14
|
-
class AbstractBVH():
|
|
15
|
-
root: AbstractAABB
|
|
1
|
+
import glm
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AbstractAABB():
|
|
5
|
+
top_right: glm.vec3
|
|
6
|
+
"""The furthest positive corner of the AABB"""
|
|
7
|
+
bottom_left: glm.vec3
|
|
8
|
+
"""The furthest negative corner of the AABB"""
|
|
9
|
+
a: ...
|
|
10
|
+
"""Binary child 1"""
|
|
11
|
+
b: ...
|
|
12
|
+
"""Binary child 2"""
|
|
13
|
+
|
|
14
|
+
class AbstractBVH():
|
|
15
|
+
root: AbstractAABB
|
|
16
16
|
"""Root aabb used for the start of all collisions"""
|