Fix scene import when platform=server
Adds code in RasterizerStorageDummy to store off mesh surface information,
rather than just throwing it away. Without this, all surface arrays were
just defaulting to empty when the packed scene was written.
(cherry picked from commit 5b639269a2
)
This commit is contained in:
parent
4897227d04
commit
c3fcb18bc6
|
@ -127,7 +127,26 @@ public:
|
||||||
String path;
|
String path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DummySurface {
|
||||||
|
uint32_t format;
|
||||||
|
VS::PrimitiveType primitive;
|
||||||
|
PoolVector<uint8_t> array;
|
||||||
|
int vertex_count;
|
||||||
|
PoolVector<uint8_t> index_array;
|
||||||
|
int index_count;
|
||||||
|
AABB aabb;
|
||||||
|
Vector<PoolVector<uint8_t> > blend_shapes;
|
||||||
|
Vector<AABB> bone_aabbs;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DummyMesh : public RID_Data {
|
||||||
|
Vector<DummySurface> surfaces;
|
||||||
|
int blend_shape_count;
|
||||||
|
VS::BlendShapeMode blend_shape_mode;
|
||||||
|
};
|
||||||
|
|
||||||
mutable RID_Owner<DummyTexture> texture_owner;
|
mutable RID_Owner<DummyTexture> texture_owner;
|
||||||
|
mutable RID_Owner<DummyMesh> mesh_owner;
|
||||||
|
|
||||||
RID texture_create() {
|
RID texture_create() {
|
||||||
|
|
||||||
|
@ -256,46 +275,128 @@ public:
|
||||||
|
|
||||||
/* MESH API */
|
/* MESH API */
|
||||||
|
|
||||||
RID mesh_create() { return RID(); }
|
RID mesh_create() {
|
||||||
|
DummyMesh *mesh = memnew(DummyMesh);
|
||||||
|
ERR_FAIL_COND_V(!mesh, RID());
|
||||||
|
mesh->blend_shape_count = 0;
|
||||||
|
mesh->blend_shape_mode = VS::BLEND_SHAPE_MODE_NORMALIZED;
|
||||||
|
return mesh_owner.make_rid(mesh);
|
||||||
|
}
|
||||||
|
|
||||||
void mesh_add_surface_from_arrays(RID p_mesh, VS::PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), uint32_t p_compress_format = Mesh::ARRAY_COMPRESS_DEFAULT) {}
|
void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) {
|
||||||
void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) {}
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND(!m);
|
||||||
|
|
||||||
void mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data) {}
|
m->surfaces.push_back(DummySurface());
|
||||||
void mesh_add_surface_from_planes(RID p_mesh, const PoolVector<Plane> &p_planes) {}
|
DummySurface *s = &m->surfaces[m->surfaces.size() - 1];
|
||||||
|
s->format = p_format;
|
||||||
|
s->primitive = p_primitive;
|
||||||
|
s->array = p_array;
|
||||||
|
s->vertex_count = p_vertex_count;
|
||||||
|
s->index_array = p_index_array;
|
||||||
|
s->index_count = p_index_count;
|
||||||
|
s->aabb = p_aabb;
|
||||||
|
s->blend_shapes = p_blend_shapes;
|
||||||
|
s->bone_aabbs = p_bone_aabbs;
|
||||||
|
}
|
||||||
|
|
||||||
void mesh_set_blend_shape_count(RID p_mesh, int p_amount) {}
|
void mesh_set_blend_shape_count(RID p_mesh, int p_amount) {
|
||||||
int mesh_get_blend_shape_count(RID p_mesh) const { return 0; }
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND(!m);
|
||||||
|
m->blend_shape_count = p_amount;
|
||||||
|
}
|
||||||
|
int mesh_get_blend_shape_count(RID p_mesh) const {
|
||||||
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND_V(!m, 0);
|
||||||
|
return m->blend_shape_count;
|
||||||
|
}
|
||||||
|
|
||||||
void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) {}
|
void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) {
|
||||||
VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const { return VS::BLEND_SHAPE_MODE_NORMALIZED; }
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND(!m);
|
||||||
|
m->blend_shape_mode = p_mode;
|
||||||
|
}
|
||||||
|
VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const {
|
||||||
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND_V(!m, VS::BLEND_SHAPE_MODE_NORMALIZED);
|
||||||
|
return m->blend_shape_mode;
|
||||||
|
}
|
||||||
|
|
||||||
void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) {}
|
void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) {}
|
||||||
|
|
||||||
void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) {}
|
void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) {}
|
||||||
RID mesh_surface_get_material(RID p_mesh, int p_surface) const { return RID(); }
|
RID mesh_surface_get_material(RID p_mesh, int p_surface) const { return RID(); }
|
||||||
|
|
||||||
int mesh_surface_get_array_len(RID p_mesh, int p_surface) const { return 0; }
|
int mesh_surface_get_array_len(RID p_mesh, int p_surface) const {
|
||||||
int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const { return 0; }
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND_V(!m, 0);
|
||||||
|
|
||||||
|
return m->surfaces[p_surface].vertex_count;
|
||||||
|
}
|
||||||
|
int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const {
|
||||||
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND_V(!m, 0);
|
||||||
|
|
||||||
|
return m->surfaces[p_surface].index_count;
|
||||||
|
}
|
||||||
|
|
||||||
PoolVector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const {
|
PoolVector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const {
|
||||||
PoolVector<uint8_t> p;
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
return p;
|
ERR_FAIL_COND_V(!m, PoolVector<uint8_t>());
|
||||||
|
|
||||||
|
return m->surfaces[p_surface].array;
|
||||||
}
|
}
|
||||||
PoolVector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const {
|
PoolVector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const {
|
||||||
PoolVector<uint8_t> p;
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
return p;
|
ERR_FAIL_COND_V(!m, PoolVector<uint8_t>());
|
||||||
|
|
||||||
|
return m->surfaces[p_surface].index_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const { return 0; }
|
uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const {
|
||||||
VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const { return VS::PRIMITIVE_POINTS; }
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND_V(!m, 0);
|
||||||
|
|
||||||
AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const { return AABB(); }
|
return m->surfaces[p_surface].format;
|
||||||
Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const { return Vector<PoolVector<uint8_t> >(); }
|
}
|
||||||
Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const { return Vector<AABB>(); }
|
VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const {
|
||||||
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND_V(!m, VS::PRIMITIVE_POINTS);
|
||||||
|
|
||||||
void mesh_remove_surface(RID p_mesh, int p_index) {}
|
return m->surfaces[p_surface].primitive;
|
||||||
int mesh_get_surface_count(RID p_mesh) const { return 0; }
|
}
|
||||||
|
|
||||||
|
AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const {
|
||||||
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND_V(!m, AABB());
|
||||||
|
|
||||||
|
return m->surfaces[p_surface].aabb;
|
||||||
|
}
|
||||||
|
Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const {
|
||||||
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND_V(!m, Vector<PoolVector<uint8_t> >());
|
||||||
|
|
||||||
|
return m->surfaces[p_surface].blend_shapes;
|
||||||
|
}
|
||||||
|
Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const {
|
||||||
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND_V(!m, Vector<AABB>());
|
||||||
|
|
||||||
|
return m->surfaces[p_surface].bone_aabbs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mesh_remove_surface(RID p_mesh, int p_index) {
|
||||||
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND(!m);
|
||||||
|
ERR_FAIL_COND(p_index >= m->surfaces.size());
|
||||||
|
|
||||||
|
m->surfaces.remove(p_index);
|
||||||
|
}
|
||||||
|
int mesh_get_surface_count(RID p_mesh) const {
|
||||||
|
DummyMesh *m = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND_V(!m, 0);
|
||||||
|
return m->surfaces.size();
|
||||||
|
}
|
||||||
|
|
||||||
void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) {}
|
void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) {}
|
||||||
AABB mesh_get_custom_aabb(RID p_mesh) const { return AABB(); }
|
AABB mesh_get_custom_aabb(RID p_mesh) const { return AABB(); }
|
||||||
|
@ -598,7 +699,14 @@ public:
|
||||||
RID canvas_light_occluder_create() { return RID(); }
|
RID canvas_light_occluder_create() { return RID(); }
|
||||||
void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) {}
|
void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) {}
|
||||||
|
|
||||||
VS::InstanceType get_base_type(RID p_rid) const { return VS::INSTANCE_NONE; }
|
VS::InstanceType get_base_type(RID p_rid) const {
|
||||||
|
if (mesh_owner.owns(p_rid)) {
|
||||||
|
return VS::INSTANCE_MESH;
|
||||||
|
}
|
||||||
|
|
||||||
|
return VS::INSTANCE_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
bool free(RID p_rid) {
|
bool free(RID p_rid) {
|
||||||
|
|
||||||
if (texture_owner.owns(p_rid)) {
|
if (texture_owner.owns(p_rid)) {
|
||||||
|
|
Loading…
Reference in New Issue