Compare commits
No commits in common. "f487a4fcb75b0584a833b5c3af1781f81c0c2418" and "78440cce1602ae81625a915aa89cfe0b2b33c9e7" have entirely different histories.
f487a4fcb7
...
78440cce16
2
engine
2
engine
@ -1 +1 @@
|
||||
Subproject commit a5adfacdfd6dbb52bd5d1438eef90a370976531e
|
||||
Subproject commit d0741afda706be3a7daa7ef0efd6559eb1824c3a
|
@ -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_ushort, c_void_p, POINTER, addressof
|
||||
from ctypes import c_ubyte, c_uint, 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)
|
||||
|
||||
_flags_p = POINTER(c_ubyte)
|
||||
_mesh_p = POINTER(c_ushort)
|
||||
_c_ubyte_p = POINTER(c_ubyte)
|
||||
_c_uint_p = POINTER(c_uint)
|
||||
|
||||
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 = _flags_p(self.flags)
|
||||
self.mesh = buffer(c_ushort, max_size)
|
||||
self._meshes = _mesh_p(self.mesh)
|
||||
self._flags = _c_ubyte_p(self.flags)
|
||||
self.mesh = buffer(c_uint, max_size)
|
||||
self._meshes = _c_uint_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 _flags_p(self.flags)
|
||||
self._flags = None if flags else _c_ubyte_p(self.flags)
|
||||
if mesh is not None:
|
||||
self._meshes = None if mesh else _mesh_p(self.mesh)
|
||||
self._meshes = None if mesh else _c_uint_p(self.mesh)
|
||||
for name, value in params.items():
|
||||
if value is not None:
|
||||
index = self._name[name]
|
||||
|
@ -56,7 +56,6 @@ class PerfGroup(Group):
|
||||
self._name = name
|
||||
|
||||
def __del__(self):
|
||||
if self._count:
|
||||
avg = round(self._total / self._count, 2)
|
||||
print(self._name, "*", self._count,
|
||||
": min =", round(self._min, 2), ", max =", round(self._max, 2), ", avg =", avg, "(ms)")
|
||||
|
@ -139,7 +139,7 @@ class TextureData:
|
||||
_write_blob(file, self.pixels)
|
||||
|
||||
class VerticesData:
|
||||
__slots__ = 'name', 'vertices', 'indices', 'meshes', 'meshes_db'
|
||||
__slots__ = 'name', 'vertices', 'indices', 'meshes'
|
||||
|
||||
def __init__(self, name, vertices, indices, meshes):
|
||||
if len(vertices) % VERTEX_SIZE != 0:
|
||||
@ -147,18 +147,17 @@ class VerticesData:
|
||||
self.name = name
|
||||
self.vertices = vertices
|
||||
self.indices = indices
|
||||
self.meshes = array('I', meshes.values())
|
||||
self.meshes_db = dict(zip(meshes.keys(), range(len(meshes))))
|
||||
self.meshes = meshes
|
||||
|
||||
def __iter__(self):
|
||||
yield VERTEX_FORMAT
|
||||
yield len(self.vertices) // VERTEX_SIZE
|
||||
yield self.vertices
|
||||
yield self.indices
|
||||
yield self.meshes
|
||||
yield array('I', self.meshes.values())
|
||||
|
||||
def get_mesh(self, name):
|
||||
return self.meshes_db[name]
|
||||
return self.meshes[name]
|
||||
|
||||
@classmethod
|
||||
def from_archive(cls, file):
|
||||
@ -177,8 +176,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, self.meshes)
|
||||
for name in self.meshes_db.keys():
|
||||
_write_array(file, array('I', self.meshes.values()))
|
||||
for name in self.meshes.keys():
|
||||
_write_string(file, name)
|
||||
|
||||
class Archive:
|
||||
|
Loading…
Reference in New Issue
Block a user