feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#include "mesh_storage.h"
|
||||
#include "config.h"
|
||||
#include "material_storage.h"
|
||||
#include "texture_storage.h"
|
||||
#include "utilities.h"
|
||||
|
||||
|
|
@ -301,7 +300,7 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
|
|||
Vector<uint8_t> ir = new_surface.index_data;
|
||||
wr = wf_indices.ptrw();
|
||||
|
||||
if (new_surface.vertex_count < (1 << 16)) {
|
||||
if (new_surface.vertex_count <= 65536) {
|
||||
// Read 16 bit indices.
|
||||
const uint16_t *src_idx = (const uint16_t *)ir.ptr();
|
||||
for (uint32_t i = 0; i + 5 < wf_index_count; i += 6) {
|
||||
|
|
@ -448,6 +447,72 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
|
|||
mesh->material_cache.clear();
|
||||
}
|
||||
|
||||
void MeshStorage::_mesh_surface_clear(Mesh *mesh, int p_surface) {
|
||||
Mesh::Surface &s = *mesh->surfaces[p_surface];
|
||||
|
||||
if (s.vertex_buffer != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(s.vertex_buffer);
|
||||
s.vertex_buffer = 0;
|
||||
}
|
||||
|
||||
if (s.version_count != 0) {
|
||||
for (uint32_t j = 0; j < s.version_count; j++) {
|
||||
glDeleteVertexArrays(1, &s.versions[j].vertex_array);
|
||||
s.versions[j].vertex_array = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (s.attribute_buffer != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(s.attribute_buffer);
|
||||
s.attribute_buffer = 0;
|
||||
}
|
||||
|
||||
if (s.skin_buffer != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(s.skin_buffer);
|
||||
s.skin_buffer = 0;
|
||||
}
|
||||
|
||||
if (s.index_buffer != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(s.index_buffer);
|
||||
s.index_buffer = 0;
|
||||
}
|
||||
|
||||
if (s.versions) {
|
||||
memfree(s.versions); // reallocs, so free with memfree.
|
||||
}
|
||||
|
||||
if (s.wireframe) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(s.wireframe->index_buffer);
|
||||
memdelete(s.wireframe);
|
||||
}
|
||||
|
||||
if (s.lod_count) {
|
||||
for (uint32_t j = 0; j < s.lod_count; j++) {
|
||||
if (s.lods[j].index_buffer != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(s.lods[j].index_buffer);
|
||||
s.lods[j].index_buffer = 0;
|
||||
}
|
||||
}
|
||||
memdelete_arr(s.lods);
|
||||
}
|
||||
|
||||
if (mesh->blend_shape_count) {
|
||||
for (uint32_t j = 0; j < mesh->blend_shape_count; j++) {
|
||||
if (s.blend_shapes[j].vertex_buffer != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(s.blend_shapes[j].vertex_buffer);
|
||||
s.blend_shapes[j].vertex_buffer = 0;
|
||||
}
|
||||
if (s.blend_shapes[j].vertex_array != 0) {
|
||||
glDeleteVertexArrays(1, &s.blend_shapes[j].vertex_array);
|
||||
s.blend_shapes[j].vertex_array = 0;
|
||||
}
|
||||
}
|
||||
memdelete_arr(s.blend_shapes);
|
||||
}
|
||||
|
||||
memdelete(mesh->surfaces[p_surface]);
|
||||
}
|
||||
|
||||
int MeshStorage::mesh_get_blend_shape_count(RID p_mesh) const {
|
||||
const Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_NULL_V(mesh, -1);
|
||||
|
|
@ -743,6 +808,7 @@ String MeshStorage::mesh_get_path(RID p_mesh) const {
|
|||
}
|
||||
|
||||
void MeshStorage::mesh_set_shadow_mesh(RID p_mesh, RID p_shadow_mesh) {
|
||||
ERR_FAIL_COND_MSG(p_mesh == p_shadow_mesh, "Cannot set a mesh as its own shadow mesh.");
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_NULL(mesh);
|
||||
|
||||
|
|
@ -771,69 +837,7 @@ void MeshStorage::mesh_clear(RID p_mesh) {
|
|||
}
|
||||
|
||||
for (uint32_t i = 0; i < mesh->surface_count; i++) {
|
||||
Mesh::Surface &s = *mesh->surfaces[i];
|
||||
|
||||
if (s.vertex_buffer != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(s.vertex_buffer);
|
||||
s.vertex_buffer = 0;
|
||||
}
|
||||
|
||||
if (s.version_count != 0) {
|
||||
for (uint32_t j = 0; j < s.version_count; j++) {
|
||||
glDeleteVertexArrays(1, &s.versions[j].vertex_array);
|
||||
s.versions[j].vertex_array = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (s.attribute_buffer != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(s.attribute_buffer);
|
||||
s.attribute_buffer = 0;
|
||||
}
|
||||
|
||||
if (s.skin_buffer != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(s.skin_buffer);
|
||||
s.skin_buffer = 0;
|
||||
}
|
||||
|
||||
if (s.index_buffer != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(s.index_buffer);
|
||||
s.index_buffer = 0;
|
||||
}
|
||||
|
||||
if (s.versions) {
|
||||
memfree(s.versions); //reallocs, so free with memfree.
|
||||
}
|
||||
|
||||
if (s.wireframe) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(s.wireframe->index_buffer);
|
||||
memdelete(s.wireframe);
|
||||
}
|
||||
|
||||
if (s.lod_count) {
|
||||
for (uint32_t j = 0; j < s.lod_count; j++) {
|
||||
if (s.lods[j].index_buffer != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(s.lods[j].index_buffer);
|
||||
s.lods[j].index_buffer = 0;
|
||||
}
|
||||
}
|
||||
memdelete_arr(s.lods);
|
||||
}
|
||||
|
||||
if (mesh->blend_shape_count) {
|
||||
for (uint32_t j = 0; j < mesh->blend_shape_count; j++) {
|
||||
if (s.blend_shapes[j].vertex_buffer != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(s.blend_shapes[j].vertex_buffer);
|
||||
s.blend_shapes[j].vertex_buffer = 0;
|
||||
}
|
||||
if (s.blend_shapes[j].vertex_array != 0) {
|
||||
glDeleteVertexArrays(1, &s.blend_shapes[j].vertex_array);
|
||||
s.blend_shapes[j].vertex_array = 0;
|
||||
}
|
||||
}
|
||||
memdelete_arr(s.blend_shapes);
|
||||
}
|
||||
|
||||
memdelete(mesh->surfaces[i]);
|
||||
_mesh_surface_clear(mesh, i);
|
||||
}
|
||||
if (mesh->surfaces) {
|
||||
memfree(mesh->surfaces);
|
||||
|
|
@ -843,6 +847,7 @@ void MeshStorage::mesh_clear(RID p_mesh) {
|
|||
mesh->surface_count = 0;
|
||||
mesh->material_cache.clear();
|
||||
mesh->has_bone_weights = false;
|
||||
mesh->aabb = AABB();
|
||||
mesh->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_MESH);
|
||||
|
||||
for (Mesh *E : mesh->shadow_owners) {
|
||||
|
|
@ -1032,6 +1037,56 @@ void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::V
|
|||
v.input_mask = p_input_mask;
|
||||
}
|
||||
|
||||
void MeshStorage::mesh_surface_remove(RID p_mesh, int p_surface) {
|
||||
Mesh *mesh = mesh_owner.get_or_null(p_mesh);
|
||||
ERR_FAIL_NULL(mesh);
|
||||
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
|
||||
|
||||
// Clear instance data before mesh data.
|
||||
for (MeshInstance *mi : mesh->instances) {
|
||||
_mesh_instance_remove_surface(mi, p_surface);
|
||||
}
|
||||
|
||||
_mesh_surface_clear(mesh, p_surface);
|
||||
|
||||
if ((uint32_t)p_surface < mesh->surface_count - 1) {
|
||||
memmove(mesh->surfaces + p_surface, mesh->surfaces + p_surface + 1, sizeof(Mesh::Surface *) * (mesh->surface_count - (p_surface + 1)));
|
||||
}
|
||||
mesh->surfaces = (Mesh::Surface **)memrealloc(mesh->surfaces, sizeof(Mesh::Surface *) * (mesh->surface_count - 1));
|
||||
--mesh->surface_count;
|
||||
|
||||
mesh->material_cache.clear();
|
||||
|
||||
mesh->skeleton_aabb_version = 0;
|
||||
|
||||
if (mesh->has_bone_weights) {
|
||||
mesh->has_bone_weights = false;
|
||||
for (uint32_t i = 0; i < mesh->surface_count; i++) {
|
||||
if (mesh->surfaces[i]->format & RS::ARRAY_FORMAT_BONES) {
|
||||
mesh->has_bone_weights = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mesh->surface_count == 0) {
|
||||
mesh->aabb = AABB();
|
||||
} else {
|
||||
mesh->aabb = mesh->surfaces[0]->aabb;
|
||||
for (uint32_t i = 1; i < mesh->surface_count; i++) {
|
||||
mesh->aabb.merge_with(mesh->surfaces[i]->aabb);
|
||||
}
|
||||
}
|
||||
|
||||
mesh->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_MESH);
|
||||
|
||||
for (Mesh *E : mesh->shadow_owners) {
|
||||
Mesh *shadow_owner = E;
|
||||
shadow_owner->shadow_mesh = RID();
|
||||
shadow_owner->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_MESH);
|
||||
}
|
||||
}
|
||||
|
||||
/* MESH INSTANCE API */
|
||||
|
||||
RID MeshStorage::mesh_instance_create(RID p_base) {
|
||||
|
|
@ -1082,30 +1137,10 @@ void MeshStorage::mesh_instance_set_blend_shape_weight(RID p_mesh_instance, int
|
|||
}
|
||||
|
||||
void MeshStorage::_mesh_instance_clear(MeshInstance *mi) {
|
||||
for (uint32_t i = 0; i < mi->surfaces.size(); i++) {
|
||||
if (mi->surfaces[i].version_count != 0) {
|
||||
for (uint32_t j = 0; j < mi->surfaces[i].version_count; j++) {
|
||||
glDeleteVertexArrays(1, &mi->surfaces[i].versions[j].vertex_array);
|
||||
mi->surfaces[i].versions[j].vertex_array = 0;
|
||||
}
|
||||
memfree(mi->surfaces[i].versions);
|
||||
}
|
||||
|
||||
if (mi->surfaces[i].vertex_buffers[0] != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(mi->surfaces[i].vertex_buffers[0]);
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(mi->surfaces[i].vertex_buffers[1]);
|
||||
mi->surfaces[i].vertex_buffers[0] = 0;
|
||||
mi->surfaces[i].vertex_buffers[1] = 0;
|
||||
}
|
||||
|
||||
if (mi->surfaces[i].vertex_buffer != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(mi->surfaces[i].vertex_buffer);
|
||||
mi->surfaces[i].vertex_buffer = 0;
|
||||
}
|
||||
while (mi->surfaces.size()) {
|
||||
_mesh_instance_remove_surface(mi, mi->surfaces.size() - 1);
|
||||
}
|
||||
mi->surfaces.clear();
|
||||
mi->blend_weights.clear();
|
||||
mi->skeleton_version = 0;
|
||||
mi->dirty = false;
|
||||
}
|
||||
|
||||
void MeshStorage::_mesh_instance_add_surface(MeshInstance *mi, Mesh *mesh, uint32_t p_surface) {
|
||||
|
|
@ -1158,6 +1193,39 @@ void MeshStorage::_mesh_instance_add_surface(MeshInstance *mi, Mesh *mesh, uint3
|
|||
mi->dirty = true;
|
||||
}
|
||||
|
||||
void MeshStorage::_mesh_instance_remove_surface(MeshInstance *mi, int p_surface) {
|
||||
MeshInstance::Surface &surface = mi->surfaces[p_surface];
|
||||
|
||||
if (surface.version_count != 0) {
|
||||
for (uint32_t j = 0; j < surface.version_count; j++) {
|
||||
glDeleteVertexArrays(1, &surface.versions[j].vertex_array);
|
||||
surface.versions[j].vertex_array = 0;
|
||||
}
|
||||
memfree(surface.versions);
|
||||
}
|
||||
|
||||
if (surface.vertex_buffers[0] != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(surface.vertex_buffers[0]);
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(surface.vertex_buffers[1]);
|
||||
surface.vertex_buffers[0] = 0;
|
||||
surface.vertex_buffers[1] = 0;
|
||||
}
|
||||
|
||||
if (surface.vertex_buffer != 0) {
|
||||
GLES3::Utilities::get_singleton()->buffer_free_data(surface.vertex_buffer);
|
||||
surface.vertex_buffer = 0;
|
||||
}
|
||||
|
||||
mi->surfaces.remove_at(p_surface);
|
||||
|
||||
if (mi->surfaces.is_empty()) {
|
||||
mi->blend_weights.clear();
|
||||
mi->weights_dirty = false;
|
||||
mi->skeleton_version = 0;
|
||||
}
|
||||
mi->dirty = true;
|
||||
}
|
||||
|
||||
void MeshStorage::mesh_instance_check_for_update(RID p_mesh_instance) {
|
||||
MeshInstance *mi = mesh_instance_owner.get_or_null(p_mesh_instance);
|
||||
|
||||
|
|
@ -1258,7 +1326,7 @@ void MeshStorage::update_mesh_instances() {
|
|||
|
||||
// Precompute base weight if using blend shapes.
|
||||
float base_weight = 1.0;
|
||||
if (mi->mesh->blend_shape_count && mi->mesh->blend_shape_mode == RS::BLEND_SHAPE_MODE_NORMALIZED) {
|
||||
if (mi->surfaces.size() && mi->mesh->blend_shape_count && mi->mesh->blend_shape_mode == RS::BLEND_SHAPE_MODE_NORMALIZED) {
|
||||
for (uint32_t i = 0; i < mi->mesh->blend_shape_count; i++) {
|
||||
base_weight -= mi->blend_weights[i];
|
||||
}
|
||||
|
|
@ -1432,15 +1500,17 @@ void MeshStorage::update_mesh_instances() {
|
|||
|
||||
/* MULTIMESH API */
|
||||
|
||||
RID MeshStorage::multimesh_allocate() {
|
||||
RID MeshStorage::_multimesh_allocate() {
|
||||
return multimesh_owner.allocate_rid();
|
||||
}
|
||||
|
||||
void MeshStorage::multimesh_initialize(RID p_rid) {
|
||||
void MeshStorage::_multimesh_initialize(RID p_rid) {
|
||||
multimesh_owner.initialize_rid(p_rid, MultiMesh());
|
||||
}
|
||||
|
||||
void MeshStorage::multimesh_free(RID p_rid) {
|
||||
void MeshStorage::_multimesh_free(RID p_rid) {
|
||||
// Remove from interpolator.
|
||||
_interpolation_data.notify_free_multimesh(p_rid);
|
||||
_update_dirty_multimeshes();
|
||||
multimesh_allocate_data(p_rid, 0, RS::MULTIMESH_TRANSFORM_2D);
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_rid);
|
||||
|
|
@ -1448,7 +1518,7 @@ void MeshStorage::multimesh_free(RID p_rid) {
|
|||
multimesh_owner.free(p_rid);
|
||||
}
|
||||
|
||||
void MeshStorage::multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data) {
|
||||
void MeshStorage::_multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data, bool p_use_indirect) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
|
||||
|
|
@ -1495,13 +1565,13 @@ void MeshStorage::multimesh_allocate_data(RID p_multimesh, int p_instances, RS::
|
|||
multimesh->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_MULTIMESH);
|
||||
}
|
||||
|
||||
int MeshStorage::multimesh_get_instance_count(RID p_multimesh) const {
|
||||
int MeshStorage::_multimesh_get_instance_count(RID p_multimesh) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL_V(multimesh, 0);
|
||||
return multimesh->instances;
|
||||
}
|
||||
|
||||
void MeshStorage::multimesh_set_mesh(RID p_multimesh, RID p_mesh) {
|
||||
void MeshStorage::_multimesh_set_mesh(RID p_multimesh, RID p_mesh) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
if (multimesh->mesh == p_mesh || p_mesh.is_null()) {
|
||||
|
|
@ -1651,7 +1721,7 @@ void MeshStorage::_multimesh_re_create_aabb(MultiMesh *multimesh, const float *p
|
|||
multimesh->aabb = aabb;
|
||||
}
|
||||
|
||||
void MeshStorage::multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform3D &p_transform) {
|
||||
void MeshStorage::_multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform3D &p_transform) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
ERR_FAIL_INDEX(p_index, multimesh->instances);
|
||||
|
|
@ -1681,7 +1751,7 @@ void MeshStorage::multimesh_instance_set_transform(RID p_multimesh, int p_index,
|
|||
_multimesh_mark_dirty(multimesh, p_index, true);
|
||||
}
|
||||
|
||||
void MeshStorage::multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) {
|
||||
void MeshStorage::_multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
ERR_FAIL_INDEX(p_index, multimesh->instances);
|
||||
|
|
@ -1707,7 +1777,7 @@ void MeshStorage::multimesh_instance_set_transform_2d(RID p_multimesh, int p_ind
|
|||
_multimesh_mark_dirty(multimesh, p_index, true);
|
||||
}
|
||||
|
||||
void MeshStorage::multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) {
|
||||
void MeshStorage::_multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
ERR_FAIL_INDEX(p_index, multimesh->instances);
|
||||
|
|
@ -1727,7 +1797,7 @@ void MeshStorage::multimesh_instance_set_color(RID p_multimesh, int p_index, con
|
|||
_multimesh_mark_dirty(multimesh, p_index, false);
|
||||
}
|
||||
|
||||
void MeshStorage::multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) {
|
||||
void MeshStorage::_multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
ERR_FAIL_INDEX(p_index, multimesh->instances);
|
||||
|
|
@ -1746,39 +1816,39 @@ void MeshStorage::multimesh_instance_set_custom_data(RID p_multimesh, int p_inde
|
|||
_multimesh_mark_dirty(multimesh, p_index, false);
|
||||
}
|
||||
|
||||
RID MeshStorage::multimesh_get_mesh(RID p_multimesh) const {
|
||||
RID MeshStorage::_multimesh_get_mesh(RID p_multimesh) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL_V(multimesh, RID());
|
||||
|
||||
return multimesh->mesh;
|
||||
}
|
||||
|
||||
void MeshStorage::multimesh_set_custom_aabb(RID p_multimesh, const AABB &p_aabb) {
|
||||
void MeshStorage::_multimesh_set_custom_aabb(RID p_multimesh, const AABB &p_aabb) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
multimesh->custom_aabb = p_aabb;
|
||||
multimesh->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
|
||||
}
|
||||
|
||||
AABB MeshStorage::multimesh_get_custom_aabb(RID p_multimesh) const {
|
||||
AABB MeshStorage::_multimesh_get_custom_aabb(RID p_multimesh) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL_V(multimesh, AABB());
|
||||
return multimesh->custom_aabb;
|
||||
}
|
||||
|
||||
AABB MeshStorage::multimesh_get_aabb(RID p_multimesh) const {
|
||||
AABB MeshStorage::_multimesh_get_aabb(RID p_multimesh) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL_V(multimesh, AABB());
|
||||
if (multimesh->custom_aabb != AABB()) {
|
||||
return multimesh->custom_aabb;
|
||||
}
|
||||
if (multimesh->aabb_dirty) {
|
||||
const_cast<MeshStorage *>(this)->_update_dirty_multimeshes();
|
||||
_update_dirty_multimeshes();
|
||||
}
|
||||
return multimesh->aabb;
|
||||
}
|
||||
|
||||
Transform3D MeshStorage::multimesh_instance_get_transform(RID p_multimesh, int p_index) const {
|
||||
Transform3D MeshStorage::_multimesh_instance_get_transform(RID p_multimesh, int p_index) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL_V(multimesh, Transform3D());
|
||||
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform3D());
|
||||
|
|
@ -1809,7 +1879,7 @@ Transform3D MeshStorage::multimesh_instance_get_transform(RID p_multimesh, int p
|
|||
return t;
|
||||
}
|
||||
|
||||
Transform2D MeshStorage::multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const {
|
||||
Transform2D MeshStorage::_multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL_V(multimesh, Transform2D());
|
||||
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform2D());
|
||||
|
|
@ -1834,7 +1904,7 @@ Transform2D MeshStorage::multimesh_instance_get_transform_2d(RID p_multimesh, in
|
|||
return t;
|
||||
}
|
||||
|
||||
Color MeshStorage::multimesh_instance_get_color(RID p_multimesh, int p_index) const {
|
||||
Color MeshStorage::_multimesh_instance_get_color(RID p_multimesh, int p_index) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL_V(multimesh, Color());
|
||||
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Color());
|
||||
|
|
@ -1858,7 +1928,7 @@ Color MeshStorage::multimesh_instance_get_color(RID p_multimesh, int p_index) co
|
|||
return c;
|
||||
}
|
||||
|
||||
Color MeshStorage::multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const {
|
||||
Color MeshStorage::_multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL_V(multimesh, Color());
|
||||
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Color());
|
||||
|
|
@ -1882,7 +1952,7 @@ Color MeshStorage::multimesh_instance_get_custom_data(RID p_multimesh, int p_ind
|
|||
return c;
|
||||
}
|
||||
|
||||
void MeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) {
|
||||
void MeshStorage::_multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
|
||||
|
|
@ -1971,7 +2041,15 @@ void MeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_b
|
|||
}
|
||||
}
|
||||
|
||||
Vector<float> MeshStorage::multimesh_get_buffer(RID p_multimesh) const {
|
||||
RID MeshStorage::_multimesh_get_command_buffer_rd_rid(RID p_multimesh) const {
|
||||
ERR_FAIL_V_MSG(RID(), "GLES3 does not implement indirect multimeshes.");
|
||||
}
|
||||
|
||||
RID MeshStorage::_multimesh_get_buffer_rd_rid(RID p_multimesh) const {
|
||||
ERR_FAIL_V_MSG(RID(), "GLES3 does not contain a Rid for the multimesh buffer.");
|
||||
}
|
||||
|
||||
Vector<float> MeshStorage::_multimesh_get_buffer(RID p_multimesh) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL_V(multimesh, Vector<float>());
|
||||
Vector<float> ret;
|
||||
|
|
@ -2043,7 +2121,7 @@ Vector<float> MeshStorage::multimesh_get_buffer(RID p_multimesh) const {
|
|||
}
|
||||
}
|
||||
|
||||
void MeshStorage::multimesh_set_visible_instances(RID p_multimesh, int p_visible) {
|
||||
void MeshStorage::_multimesh_set_visible_instances(RID p_multimesh, int p_visible) {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL(multimesh);
|
||||
ERR_FAIL_COND(p_visible < -1 || p_visible > multimesh->instances);
|
||||
|
|
@ -2065,12 +2143,19 @@ void MeshStorage::multimesh_set_visible_instances(RID p_multimesh, int p_visible
|
|||
multimesh->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_MULTIMESH_VISIBLE_INSTANCES);
|
||||
}
|
||||
|
||||
int MeshStorage::multimesh_get_visible_instances(RID p_multimesh) const {
|
||||
int MeshStorage::_multimesh_get_visible_instances(RID p_multimesh) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL_V(multimesh, 0);
|
||||
return multimesh->visible_instances;
|
||||
}
|
||||
|
||||
MeshStorage::MultiMeshInterpolator *MeshStorage::_multimesh_get_interpolator(RID p_multimesh) const {
|
||||
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
|
||||
ERR_FAIL_NULL_V_MSG(multimesh, nullptr, "Multimesh not found: " + itos(p_multimesh.get_id()));
|
||||
|
||||
return &multimesh->interpolator;
|
||||
}
|
||||
|
||||
void MeshStorage::_update_dirty_multimeshes() {
|
||||
while (multimesh_dirty_list) {
|
||||
MultiMesh *multimesh = multimesh_dirty_list;
|
||||
|
|
@ -2191,7 +2276,7 @@ void MeshStorage::skeleton_allocate_data(RID p_skeleton, int p_bones, bool p_2d_
|
|||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
GLES3::Utilities::get_singleton()->texture_allocated_data(skeleton->transforms_texture, skeleton->data.size() * sizeof(float), "Skeleton transforms texture");
|
||||
|
||||
memset(skeleton->data.ptrw(), 0, skeleton->data.size() * sizeof(float));
|
||||
memset(skeleton->data.ptr(), 0, skeleton->data.size() * sizeof(float));
|
||||
|
||||
_skeleton_make_dirty(skeleton);
|
||||
}
|
||||
|
|
@ -2222,7 +2307,7 @@ void MeshStorage::skeleton_bone_set_transform(RID p_skeleton, int p_bone, const
|
|||
ERR_FAIL_INDEX(p_bone, skeleton->size);
|
||||
ERR_FAIL_COND(skeleton->use_2d);
|
||||
|
||||
float *dataptr = skeleton->data.ptrw() + p_bone * 12;
|
||||
float *dataptr = skeleton->data.ptr() + p_bone * 12;
|
||||
|
||||
dataptr[0] = p_transform.basis.rows[0][0];
|
||||
dataptr[1] = p_transform.basis.rows[0][1];
|
||||
|
|
@ -2274,7 +2359,7 @@ void MeshStorage::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, con
|
|||
ERR_FAIL_INDEX(p_bone, skeleton->size);
|
||||
ERR_FAIL_COND(!skeleton->use_2d);
|
||||
|
||||
float *dataptr = skeleton->data.ptrw() + p_bone * 8;
|
||||
float *dataptr = skeleton->data.ptr() + p_bone * 8;
|
||||
|
||||
dataptr[0] = p_transform.columns[0][0];
|
||||
dataptr[1] = p_transform.columns[1][0];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue