mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-12 18:45:52 +00:00
FRME cook fixes
This commit is contained in:
parent
7cfebe844f
commit
c6671b114e
@ -1,4 +1,5 @@
|
|||||||
import bpy, struct, math
|
import bpy, struct, math
|
||||||
|
from mathutils import Quaternion
|
||||||
|
|
||||||
def draw(layout, context):
|
def draw(layout, context):
|
||||||
if bpy.context.active_object:
|
if bpy.context.active_object:
|
||||||
@ -82,7 +83,10 @@ def recursive_cook(buffer, obj, version, path_hasher, parent_name):
|
|||||||
obj.retro_widget_color[3],
|
obj.retro_widget_color[3],
|
||||||
model_draw_flags_e[obj.retro_widget_model_draw_flags])
|
model_draw_flags_e[obj.retro_widget_model_draw_flags])
|
||||||
|
|
||||||
|
angle = Quaternion((1.0, 0.0, 0.0), 0)
|
||||||
|
|
||||||
if obj.retro_widget_type == 'RETRO_CAMR':
|
if obj.retro_widget_type == 'RETRO_CAMR':
|
||||||
|
angle = Quaternion((1.0, 0.0, 0.0), math.radians(-90.0))
|
||||||
aspect = bpy.context.scene.render.resolution_x / bpy.context.scene.render.resolution_y
|
aspect = bpy.context.scene.render.resolution_x / bpy.context.scene.render.resolution_y
|
||||||
|
|
||||||
if obj.data.type == 'PERSP':
|
if obj.data.type == 'PERSP':
|
||||||
@ -94,8 +98,8 @@ def recursive_cook(buffer, obj, version, path_hasher, parent_name):
|
|||||||
|
|
||||||
elif obj.data.type == 'ORTHO':
|
elif obj.data.type == 'ORTHO':
|
||||||
ortho_half = obj.data.ortho_scale / 2.0
|
ortho_half = obj.data.ortho_scale / 2.0
|
||||||
buffer += struct.pack('>Iffffff', 1, -ortho_half, ortho_half, -ortho_half / aspect,
|
buffer += struct.pack('>Iffffff', 1, -ortho_half, ortho_half, ortho_half / aspect,
|
||||||
ortho_half / aspect, obj.data.clip_start, obj.data.clip_end)
|
-ortho_half / aspect, obj.data.clip_start, obj.data.clip_end)
|
||||||
|
|
||||||
elif obj.retro_widget_type == 'RETRO_MODL':
|
elif obj.retro_widget_type == 'RETRO_MODL':
|
||||||
if len(obj.children) == 0:
|
if len(obj.children) == 0:
|
||||||
@ -189,6 +193,7 @@ def recursive_cook(buffer, obj, version, path_hasher, parent_name):
|
|||||||
obj.retro_meter_worker_count)
|
obj.retro_meter_worker_count)
|
||||||
|
|
||||||
elif obj.retro_widget_type == 'RETRO_LITE':
|
elif obj.retro_widget_type == 'RETRO_LITE':
|
||||||
|
angle = Quaternion((1.0, 0.0, 0.0), math.radians(-90.0))
|
||||||
type_enum = 0
|
type_enum = 0
|
||||||
constant = 1.0
|
constant = 1.0
|
||||||
linear = 0.0
|
linear = 0.0
|
||||||
@ -249,13 +254,14 @@ def recursive_cook(buffer, obj, version, path_hasher, parent_name):
|
|||||||
else:
|
else:
|
||||||
buffer += struct.pack('>b', False)
|
buffer += struct.pack('>b', False)
|
||||||
|
|
||||||
|
angMtx = angle.to_matrix() * obj.matrix_local.to_3x3()
|
||||||
buffer += struct.pack('>fffffffffffffffIH',
|
buffer += struct.pack('>fffffffffffffffIH',
|
||||||
obj.matrix_local[0][3],
|
obj.matrix_local[0][3],
|
||||||
obj.matrix_local[1][3],
|
obj.matrix_local[1][3],
|
||||||
obj.matrix_local[2][3],
|
obj.matrix_local[2][3],
|
||||||
obj.matrix_local[0][0], obj.matrix_local[0][1], obj.matrix_local[0][2],
|
angMtx[0][0], angMtx[0][1], angMtx[0][2],
|
||||||
obj.matrix_local[1][0], obj.matrix_local[1][1], obj.matrix_local[1][2],
|
angMtx[1][0], angMtx[1][1], angMtx[1][2],
|
||||||
obj.matrix_local[2][0], obj.matrix_local[2][1], obj.matrix_local[2][2],
|
angMtx[2][0], angMtx[2][1], angMtx[2][2],
|
||||||
0.0, 0.0, 0.0, 0, 0)
|
0.0, 0.0, 0.0, 0, 0)
|
||||||
|
|
||||||
for ch in obj.children:
|
for ch in obj.children:
|
||||||
|
2
hecl/extern/boo
vendored
2
hecl/extern/boo
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 7bf2ad48a7b7fa8e5c34d336f5603dcdc8a6ef47
|
Subproject commit 4be38afef3b4588eb8f7773ab4e6961a7ffa768c
|
@ -96,35 +96,43 @@ public:
|
|||||||
class Token
|
class Token
|
||||||
{
|
{
|
||||||
friend class UniformBufferPool;
|
friend class UniformBufferPool;
|
||||||
UniformBufferPool& m_pool;
|
UniformBufferPool* m_pool = nullptr;
|
||||||
IndexTp m_index;
|
IndexTp m_index = -1;
|
||||||
DivTp m_div;
|
DivTp m_div;
|
||||||
Token(UniformBufferPool& pool)
|
Token(UniformBufferPool* pool)
|
||||||
: m_pool(pool)
|
: m_pool(pool)
|
||||||
{
|
{
|
||||||
auto& freeSpaces = pool.m_freeBlocks;
|
auto& freeSpaces = pool->m_freeBlocks;
|
||||||
int idx = freeSpaces.find_first();
|
int idx = freeSpaces.find_first();
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
{
|
{
|
||||||
pool.m_buckets.push_back(std::make_unique<Bucket>());
|
pool->m_buckets.push_back(std::make_unique<Bucket>());
|
||||||
m_index = freeSpaces.size();
|
m_index = freeSpaces.size();
|
||||||
freeSpaces.resize(freeSpaces.size() + pool.m_countPerBucket, true);
|
freeSpaces.resize(freeSpaces.size() + pool->m_countPerBucket, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_index = idx;
|
m_index = idx;
|
||||||
}
|
}
|
||||||
freeSpaces.reset(m_index);
|
freeSpaces.reset(m_index);
|
||||||
m_div = pool.getBucketDiv(m_index);
|
m_div = pool->getBucketDiv(m_index);
|
||||||
|
|
||||||
Bucket& bucket = *m_pool.m_buckets[m_div.quot];
|
Bucket& bucket = *m_pool->m_buckets[m_div.quot];
|
||||||
bucket.increment(m_pool);
|
bucket.increment(*m_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Token() = default;
|
||||||
Token(const Token& other) = delete;
|
Token(const Token& other) = delete;
|
||||||
Token& operator=(const Token& other) = delete;
|
Token& operator=(const Token& other) = delete;
|
||||||
Token& operator=(Token&& other) = delete;
|
Token& operator=(Token&& other)
|
||||||
|
{
|
||||||
|
m_pool = other.m_pool;
|
||||||
|
m_index = other.m_index;
|
||||||
|
m_div = other.m_div;
|
||||||
|
other.m_index = -1;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
Token(Token&& other)
|
Token(Token&& other)
|
||||||
: m_pool(other.m_pool), m_index(other.m_index),
|
: m_pool(other.m_pool), m_index(other.m_index),
|
||||||
m_div(other.m_div)
|
m_div(other.m_div)
|
||||||
@ -136,26 +144,28 @@ public:
|
|||||||
{
|
{
|
||||||
if (m_index != -1)
|
if (m_index != -1)
|
||||||
{
|
{
|
||||||
m_pool.m_freeBlocks.set(m_index);
|
m_pool->m_freeBlocks.set(m_index);
|
||||||
Bucket& bucket = *m_pool.m_buckets[m_div.quot];
|
Bucket& bucket = *m_pool->m_buckets[m_div.quot];
|
||||||
bucket.decrement(m_pool);
|
bucket.decrement(*m_pool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UniformStruct& access()
|
UniformStruct& access()
|
||||||
{
|
{
|
||||||
Bucket& bucket = *m_pool.m_buckets[m_div.quot];
|
Bucket& bucket = *m_pool->m_buckets[m_div.quot];
|
||||||
if (!bucket.cpuBuffer)
|
if (!bucket.cpuBuffer)
|
||||||
bucket.cpuBuffer = reinterpret_cast<uint8_t*>(bucket.buffer->map(m_sizePerBucket));
|
bucket.cpuBuffer = reinterpret_cast<uint8_t*>(bucket.buffer->map(m_sizePerBucket));
|
||||||
bucket.dirty = true;
|
bucket.dirty = true;
|
||||||
return reinterpret_cast<UniformStruct&>(bucket.cpuBuffer[m_div.rem * m_pool.m_stride]);
|
return reinterpret_cast<UniformStruct&>(bucket.cpuBuffer[m_div.rem * m_pool->m_stride]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<boo::IGraphicsBufferD*, IndexTp> getBufferInfo() const
|
std::pair<boo::IGraphicsBufferD*, IndexTp> getBufferInfo() const
|
||||||
{
|
{
|
||||||
Bucket& bucket = *m_pool.m_buckets[m_div.quot];
|
Bucket& bucket = *m_pool->m_buckets[m_div.quot];
|
||||||
return {bucket.buffer, m_div.rem * m_pool.m_stride};
|
return {bucket.buffer, m_div.rem * m_pool->m_stride};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator bool() const { return m_pool != nullptr && m_index != -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
UniformBufferPool() = default;
|
UniformBufferPool() = default;
|
||||||
@ -175,8 +185,10 @@ public:
|
|||||||
{
|
{
|
||||||
if (!m_token)
|
if (!m_token)
|
||||||
m_token = factory->newBufferPool();
|
m_token = factory->newBufferPool();
|
||||||
return Token(*this);
|
return Token(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void doDestroy() { m_token.doDestroy(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -96,36 +96,45 @@ public:
|
|||||||
class Token
|
class Token
|
||||||
{
|
{
|
||||||
friend class VertexBufferPool;
|
friend class VertexBufferPool;
|
||||||
VertexBufferPool& m_pool;
|
VertexBufferPool* m_pool = nullptr;
|
||||||
IndexTp m_index;
|
IndexTp m_index = -1;
|
||||||
IndexTp m_count;
|
IndexTp m_count = 0;
|
||||||
DivTp m_div;
|
DivTp m_div;
|
||||||
Token(VertexBufferPool& pool, IndexTp count)
|
Token(VertexBufferPool* pool, IndexTp count)
|
||||||
: m_pool(pool), m_count(count)
|
: m_pool(pool), m_count(count)
|
||||||
{
|
{
|
||||||
assert(count <= pool.m_countPerBucket && "unable to fit in bucket");
|
assert(count <= pool->m_countPerBucket && "unable to fit in bucket");
|
||||||
auto& freeSpaces = pool.m_freeElements;
|
auto& freeSpaces = pool->m_freeElements;
|
||||||
int idx = freeSpaces.find_first_contiguous(count, pool.m_countPerBucket);
|
int idx = freeSpaces.find_first_contiguous(count, pool->m_countPerBucket);
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
{
|
{
|
||||||
pool.m_buckets.push_back(std::make_unique<Bucket>());
|
pool->m_buckets.push_back(std::make_unique<Bucket>());
|
||||||
m_index = freeSpaces.size();
|
m_index = freeSpaces.size();
|
||||||
freeSpaces.resize(freeSpaces.size() + pool.m_countPerBucket, true);
|
freeSpaces.resize(freeSpaces.size() + pool->m_countPerBucket, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_index = idx;
|
m_index = idx;
|
||||||
}
|
}
|
||||||
freeSpaces.reset(m_index, m_index + count);
|
freeSpaces.reset(m_index, m_index + count);
|
||||||
m_div = pool.getBucketDiv(m_index);
|
m_div = pool->getBucketDiv(m_index);
|
||||||
|
|
||||||
Bucket& bucket = *m_pool.m_buckets[m_div.quot];
|
Bucket& bucket = *m_pool->m_buckets[m_div.quot];
|
||||||
bucket.increment(pool);
|
bucket.increment(*pool);
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
Token() = default;
|
||||||
Token(const Token& other) = delete;
|
Token(const Token& other) = delete;
|
||||||
Token& operator=(const Token& other) = delete;
|
Token& operator=(const Token& other) = delete;
|
||||||
Token& operator=(Token&& other) = delete;
|
Token& operator=(Token&& other)
|
||||||
|
{
|
||||||
|
m_pool = other.m_pool;
|
||||||
|
m_index = other.m_index;
|
||||||
|
m_count = other.m_count;
|
||||||
|
m_div = other.m_div;
|
||||||
|
other.m_index = -1;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
Token(Token&& other)
|
Token(Token&& other)
|
||||||
: m_pool(other.m_pool), m_index(other.m_index),
|
: m_pool(other.m_pool), m_index(other.m_index),
|
||||||
m_count(other.m_count), m_div(other.m_div)
|
m_count(other.m_count), m_div(other.m_div)
|
||||||
@ -137,26 +146,28 @@ public:
|
|||||||
{
|
{
|
||||||
if (m_index != -1)
|
if (m_index != -1)
|
||||||
{
|
{
|
||||||
m_pool.m_freeElements.set(m_index, m_index + m_count);
|
m_pool->m_freeElements.set(m_index, m_index + m_count);
|
||||||
Bucket& bucket = *m_pool.m_buckets[m_div.quot];
|
Bucket& bucket = *m_pool->m_buckets[m_div.quot];
|
||||||
bucket.decrement(m_pool);
|
bucket.decrement(*m_pool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VertStruct* access()
|
VertStruct* access()
|
||||||
{
|
{
|
||||||
Bucket& bucket = *m_pool.m_buckets[m_div.quot];
|
Bucket& bucket = *m_pool->m_buckets[m_div.quot];
|
||||||
if (!bucket.cpuBuffer)
|
if (!bucket.cpuBuffer)
|
||||||
bucket.cpuBuffer = reinterpret_cast<uint8_t*>(bucket.buffer->map(m_sizePerBucket));
|
bucket.cpuBuffer = reinterpret_cast<uint8_t*>(bucket.buffer->map(m_sizePerBucket));
|
||||||
bucket.dirty = true;
|
bucket.dirty = true;
|
||||||
return reinterpret_cast<VertStruct*>(&bucket.cpuBuffer[m_div.rem * m_pool.m_stride]);
|
return reinterpret_cast<VertStruct*>(&bucket.cpuBuffer[m_div.rem * m_pool->m_stride]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<boo::IGraphicsBufferD*, IndexTp> getBufferInfo() const
|
std::pair<boo::IGraphicsBufferD*, IndexTp> getBufferInfo() const
|
||||||
{
|
{
|
||||||
Bucket& bucket = *m_pool.m_buckets[m_div.quot];
|
Bucket& bucket = *m_pool->m_buckets[m_div.quot];
|
||||||
return {bucket.buffer, m_div.rem};
|
return {bucket.buffer, m_div.rem};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator bool() const { return m_pool != nullptr && m_index != -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
VertexBufferPool() = default;
|
VertexBufferPool() = default;
|
||||||
@ -176,9 +187,11 @@ public:
|
|||||||
{
|
{
|
||||||
if (!m_token)
|
if (!m_token)
|
||||||
m_token = factory->newBufferPool();
|
m_token = factory->newBufferPool();
|
||||||
return Token(*this, count);
|
return Token(this, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void doDestroy() { m_token.doDestroy(); }
|
||||||
|
|
||||||
static constexpr IndexTp bucketCapacity() { return m_countPerBucket; }
|
static constexpr IndexTp bucketCapacity() { return m_countPerBucket; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user