Bump engine submodule.

This commit is contained in:
Roz K 2023-01-03 14:10:43 +01:00
parent 4cb67c0d79
commit f487a4fcb7
Signed by: roz
GPG Key ID: 51FBF4E483E1C822
3 changed files with 16 additions and 15 deletions

2
engine

@ -1 +1 @@
Subproject commit d0741afda706be3a7daa7ef0efd6559eb1824c3a
Subproject commit a5adfacdfd6dbb52bd5d1438eef90a370976531e

View File

@ -13,14 +13,14 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from ctypes import c_ubyte, c_uint, c_void_p, POINTER, addressof
from ctypes import c_ubyte, c_ushort, c_void_p, POINTER, addressof
from engine import (
buffer, INSTANCE_FLAG_SPAWNED, BATCH_MAX_SIZE, param_type, params_format,
create_batch, fill_batch, draw_batch, destroy_batch)
_c_ubyte_p = POINTER(c_ubyte)
_c_uint_p = POINTER(c_uint)
_flags_p = POINTER(c_ubyte)
_mesh_p = POINTER(c_ushort)
class Batch:
__slots__ = ('_batch', 'vertices', 'max_size', 'size',
@ -37,9 +37,9 @@ class Batch:
self.max_size = max_size
self.size = 0
self.flags = buffer(c_ubyte, max_size)
self._flags = _c_ubyte_p(self.flags)
self.mesh = buffer(c_uint, max_size)
self._meshes = _c_uint_p(self.mesh)
self._flags = _flags_p(self.flags)
self.mesh = buffer(c_ushort, max_size)
self._meshes = _mesh_p(self.mesh)
if nparams:
self.param = tuple(map(lambda f: buffer(param_type(f), max_size), params_decls.values()))
self._params = (c_void_p * nparams)(*map(addressof, self.param))
@ -66,9 +66,9 @@ class Batch:
def freeze(self, flags = None, mesh = None, **params):
if flags is not None:
self._flags = None if flags else _c_ubyte_p(self.flags)
self._flags = None if flags else _flags_p(self.flags)
if mesh is not None:
self._meshes = None if mesh else _c_uint_p(self.mesh)
self._meshes = None if mesh else _mesh_p(self.mesh)
for name, value in params.items():
if value is not None:
index = self._name[name]

View File

@ -139,7 +139,7 @@ class TextureData:
_write_blob(file, self.pixels)
class VerticesData:
__slots__ = 'name', 'vertices', 'indices', 'meshes'
__slots__ = 'name', 'vertices', 'indices', 'meshes', 'meshes_db'
def __init__(self, name, vertices, indices, meshes):
if len(vertices) % VERTEX_SIZE != 0:
@ -147,17 +147,18 @@ class VerticesData:
self.name = name
self.vertices = vertices
self.indices = indices
self.meshes = meshes
self.meshes = array('I', meshes.values())
self.meshes_db = dict(zip(meshes.keys(), range(len(meshes))))
def __iter__(self):
yield VERTEX_FORMAT
yield len(self.vertices) // VERTEX_SIZE
yield self.vertices
yield self.indices
yield array('I', self.meshes.values())
yield self.meshes
def get_mesh(self, name):
return self.meshes[name]
return self.meshes_db[name]
@classmethod
def from_archive(cls, file):
@ -176,8 +177,8 @@ class VerticesData:
_write_struct(file, 'III', len(self.vertices) // VERTEX_SIZE, len(self.indices), len(self.meshes))
_write_array(file, self.vertices)
_write_array(file, self.indices)
_write_array(file, array('I', self.meshes.values()))
for name in self.meshes.keys():
_write_array(file, self.meshes)
for name in self.meshes_db.keys():
_write_string(file, name)
class Archive: