Changed obj_set's obj logic a bit

This commit is contained in:
korenkonder
2023-08-26 17:42:47 +03:00
parent 15fd7c896a
commit 8b4c589b11
8 changed files with 136 additions and 123 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ namespace Glitter {
continue;
for (uint32_t i = 0; i < set->obj_num; i++) {
obj* obj = &set->obj_data[i];
obj* obj = set->obj_data[i];
for (uint32_t j = 0; j < obj->num_material; j++) {
obj_material* mat = &obj->material_array[j].material;
if (*(vec3*)&mat->color.emission == 0.0f && mat->color.emission.w == 1.0f)
+84 -78
View File
@@ -347,16 +347,19 @@ obj_index_buffer::obj_index_buffer() : mesh_num(), mesh_data() {
}
bool obj_index_buffer::load(obj& obj) {
mesh_num = obj.num_mesh;
mesh_data = new obj_mesh_index_buffer[obj.num_mesh];
bool obj_index_buffer::load(obj* obj) {
if (!obj)
return false;
mesh_num = obj->num_mesh;
mesh_data = new obj_mesh_index_buffer[obj->num_mesh];
if (!mesh_data)
return false;
#if SHARED_OBJECT_BUFFER
size_t buffer_size = 0;
for (uint32_t i = 0; i < mesh_num; i++) {
obj_mesh& mesh = obj.mesh_array[i];
obj_mesh& mesh = obj->mesh_array[i];
size_t num_index = 0;
for (uint32_t i = 0; i < mesh.num_submesh; i++)
num_index += mesh.submesh_array[i].num_index;
@@ -370,9 +373,9 @@ bool obj_index_buffer::load(obj& obj) {
mesh_data[i].size = (GLsizeiptr)buffer_size;
uint32_t offset = (uint32_t)((size_t)data - (size_t)index);
data = obj_mesh_index_buffer::fill_data(data, obj.mesh_array[i]);
data = obj_mesh_index_buffer::fill_data(data, obj->mesh_array[i]);
obj_mesh& mesh = obj.mesh_array[i];
obj_mesh& mesh = obj->mesh_array[i];
for (uint32_t j = 0; j < mesh.num_submesh; j++)
mesh.submesh_array[j].index_offset += offset;
}
@@ -391,7 +394,7 @@ bool obj_index_buffer::load(obj& obj) {
mesh_data[i].buffer = buffer;
#else
for (uint32_t i = 0; i < mesh_num; i++)
if (!mesh_data[i].load(obj.mesh_array[i]))
if (!mesh_data[i].load(obj->mesh_array[i]))
return false;
#endif
return true;
@@ -423,9 +426,12 @@ obj_vertex_buffer::obj_vertex_buffer() : mesh_num(), mesh_data() {
}
bool obj_vertex_buffer::load(obj& obj) {
mesh_num = obj.num_mesh;
mesh_data = new obj_mesh_vertex_buffer[obj.num_mesh];
bool obj_vertex_buffer::load(obj* obj) {
if (!obj)
return false;
mesh_num = obj->num_mesh;
mesh_data = new obj_mesh_vertex_buffer[obj->num_mesh];
if (!mesh_data)
return false;
@@ -433,7 +439,7 @@ bool obj_vertex_buffer::load(obj& obj) {
size_t buffer_size = 0;
bool double_buffer = false;
for (uint32_t i = 0; i < mesh_num; i++) {
obj_mesh& mesh = obj.mesh_array[i];
obj_mesh& mesh = obj->mesh_array[i];
if (!mesh.num_vertex || !mesh.vertex_array)
continue;
@@ -459,7 +465,7 @@ bool obj_vertex_buffer::load(obj& obj) {
mesh_buffer.count = count;
mesh_buffer.size = (GLsizeiptr)buffer_size;
data = obj_mesh_vertex_buffer::fill_data(data, obj.mesh_array[i]);
data = obj_mesh_vertex_buffer::fill_data(data, obj->mesh_array[i]);
}
}
@@ -480,7 +486,7 @@ bool obj_vertex_buffer::load(obj& obj) {
memcpy(mesh_data[i].buffers, buffers, count * sizeof(GLuint));
#else
for (uint32_t i = 0; i < mesh_num; i++)
if (!mesh_data[i].load(obj.mesh_array[i]))
if (!mesh_data[i].load(obj->mesh_array[i]))
return false;
#endif
return true;
@@ -638,9 +644,9 @@ void object_material_msgpack_read(const char* path, const char* set_name,
uint32_t name_hash = hash_string_murmurhash(name);
for (uint32_t i = 0; i < obj_set->obj_num; i++) {
obj& obj = obj_set->obj_data[i];
obj* obj = obj_set->obj_data[i];
if (name_hash != hash_string_murmurhash(obj.name))
if (name_hash != hash_string_murmurhash(obj->name))
continue;
msgpack* materials = object.read_array("material");
@@ -652,8 +658,8 @@ void object_material_msgpack_read(const char* path, const char* set_name,
std::string name = material.read_string("name");
uint32_t name_hash = hash_string_murmurhash(name);
for (size_t k = 0; k < obj.num_material; k++) {
obj_material& mat = obj.material_array[k].material;
for (size_t k = 0; k < obj->num_material; k++) {
obj_material& mat = obj->material_array[k].material;
if (name_hash != hash_string_murmurhash(mat.name))
continue;
@@ -817,7 +823,7 @@ void object_material_msgpack_read(const char* path, const char* set_name,
}
}
obj.material_array[k].num_of_textures = num_of_textures;
obj->material_array[k].num_of_textures = num_of_textures;
msgpack* attrib = material.read("attrib");
if (attrib) {
@@ -919,8 +925,8 @@ void object_material_msgpack_read(const char* path, const char* set_name,
std::string name = _mesh.read_string("name");
uint32_t name_hash = hash_string_murmurhash(name);
for (size_t k = 0; k < obj.num_mesh; k++) {
obj_mesh& mesh = obj.mesh_array[k];
for (size_t k = 0; k < obj->num_mesh; k++) {
obj_mesh& mesh = obj->mesh_array[k];
if (name_hash != hash_string_murmurhash(mesh.name))
continue;
@@ -1129,18 +1135,18 @@ void object_material_msgpack_write(const char* path, const char* set_name, uint3
msgpack_array objects(obj_set->obj_num);
for (uint32_t i = 0; i < obj_set->obj_num; i++) {
obj& obj = obj_set->obj_data[i];
obj* obj = obj_set->obj_data[i];
msgpack& object = objects.data()[i];
object = msgpack(msgpack_map());
object.append("name", obj.name);
object.append("name", obj->name);
msgpack* materials = object.append("material", msgpack_array());
if (materials) {
msgpack_array* ptr = materials->data.arr;
ptr->resize(obj.num_material);
for (size_t j = 0; j < obj.num_material; j++) {
obj_material& mat = obj.material_array[j].material;
ptr->resize(obj->num_material);
for (size_t j = 0; j < obj->num_material; j++) {
obj_material& mat = obj->material_array[j].material;
msgpack& material = ptr->data()[j];
material = msgpack_map();
@@ -1369,9 +1375,9 @@ void object_material_msgpack_write(const char* path, const char* set_name, uint3
msgpack* meshes = object.append("mesh", msgpack_array());
if (meshes) {
msgpack_array* ptr = meshes->data.arr;
ptr->resize(obj.num_mesh);
for (size_t j = 0; j < obj.num_mesh; j++) {
obj_mesh& mesh = obj.mesh_array[j];
ptr->resize(obj->num_mesh);
for (size_t j = 0; j < obj->num_mesh; j++) {
obj_mesh& mesh = obj->mesh_array[j];
msgpack& _mesh = ptr->data()[j];
_mesh = msgpack_map();
@@ -1454,8 +1460,8 @@ inline obj* object_storage_get_obj(object_info obj_info) {
obj_set* set = elem->second.obj_set;
if (set)
for (uint32_t j = 0; j < set->obj_num; j++)
if (set->obj_data[j].id == obj_info.id)
return &set->obj_data[j];
if (set->obj_data[j]->id == obj_info.id)
return set->obj_data[j];
return 0;
}
@@ -1464,8 +1470,8 @@ inline obj* object_storage_get_obj(object_info obj_info) {
obj_set* set = elem_modern->second.obj_set;
if (set)
for (uint32_t j = 0; j < set->obj_num; j++)
if (set->obj_data[j].id == obj_info.id)
return &set->obj_data[j];
if (set->obj_data[j]->id == obj_info.id)
return set->obj_data[j];
return 0;
}
return 0;
@@ -1488,8 +1494,8 @@ inline obj_mesh* object_storage_get_obj_mesh(object_info obj_info, const char* m
obj_set* set = elem->second.obj_set;
if (set)
for (uint32_t j = 0; j < set->obj_num; j++)
if (set->obj_data[j].id == obj_info.id)
return set->obj_data[j].get_obj_mesh(mesh_name);
if (set->obj_data[j]->id == obj_info.id)
return set->obj_data[j]->get_obj_mesh(mesh_name);
return 0;
}
@@ -1498,8 +1504,8 @@ inline obj_mesh* object_storage_get_obj_mesh(object_info obj_info, const char* m
obj_set* set = elem_modern->second.obj_set;
if (set)
for (uint32_t j = 0; j < set->obj_num; j++)
if (set->obj_data[j].id == obj_info.id)
return set->obj_data[j].get_obj_mesh(mesh_name);
if (set->obj_data[j]->id == obj_info.id)
return set->obj_data[j]->get_obj_mesh(mesh_name);
return 0;
}
return 0;
@@ -1513,12 +1519,12 @@ inline obj_mesh* object_storage_get_obj_mesh_by_index(object_info obj_info, uint
return 0;
for (uint32_t j = 0; j < set->obj_num; j++) {
if (set->obj_data[j].id != obj_info.id)
if (set->obj_data[j]->id != obj_info.id)
continue;
obj& obj = set->obj_data[j];
if (index >= 0 && index < obj.num_mesh)
return &obj.mesh_array[index];
obj* obj = set->obj_data[j];
if (index >= 0 && index < obj->num_mesh)
return &obj->mesh_array[index];
return 0;
}
return 0;
@@ -1531,12 +1537,12 @@ inline obj_mesh* object_storage_get_obj_mesh_by_index(object_info obj_info, uint
return 0;
for (uint32_t j = 0; j < set->obj_num; j++) {
if (set->obj_data[j].id != obj_info.id)
if (set->obj_data[j]->id != obj_info.id)
continue;
obj& obj = set->obj_data[j];
if (index >= 0 && index < obj.num_mesh)
return &obj.mesh_array[index];
obj* obj = set->obj_data[j];
if (index >= 0 && index < obj->num_mesh)
return &obj->mesh_array[index];
return 0;
}
return 0;
@@ -1551,8 +1557,8 @@ inline obj_mesh* object_storage_get_obj_mesh_by_object_hash(uint32_t hash, const
continue;
for (uint32_t j = 0; j < set->obj_num; j++)
if (set->obj_data[j].hash == hash)
return set->obj_data[j].get_obj_mesh(mesh_name);
if (set->obj_data[j]->hash == hash)
return set->obj_data[j]->get_obj_mesh(mesh_name);
}
for (auto& i : object_storage_data_modern) {
@@ -1561,8 +1567,8 @@ inline obj_mesh* object_storage_get_obj_mesh_by_object_hash(uint32_t hash, const
continue;
for (uint32_t j = 0; j < set->obj_num; j++)
if (set->obj_data[j].hash == hash)
return set->obj_data[j].get_obj_mesh(mesh_name);
if (set->obj_data[j]->hash == hash)
return set->obj_data[j]->get_obj_mesh(mesh_name);
}
return 0;
}
@@ -1574,12 +1580,12 @@ inline obj_mesh* object_storage_get_obj_mesh_by_object_hash_index(uint32_t hash,
continue;
for (uint32_t j = 0; j < set->obj_num; j++) {
if (set->obj_data[j].hash != hash)
if (set->obj_data[j]->hash != hash)
continue;
obj& obj = set->obj_data[j];
if (index >= 0 && index < obj.num_mesh)
return &obj.mesh_array[index];
obj* obj = set->obj_data[j];
if (index >= 0 && index < obj->num_mesh)
return &obj->mesh_array[index];
return 0;
}
}
@@ -1590,12 +1596,12 @@ inline obj_mesh* object_storage_get_obj_mesh_by_object_hash_index(uint32_t hash,
continue;
for (uint32_t j = 0; j < set->obj_num; j++) {
if (set->obj_data[j].hash != hash)
if (set->obj_data[j]->hash != hash)
continue;
obj& obj = set->obj_data[j];
if (index >= 0 && index < obj.num_mesh)
return &obj.mesh_array[index];
obj* obj = set->obj_data[j];
if (index >= 0 && index < obj->num_mesh)
return &obj->mesh_array[index];
return 0;
}
}
@@ -1610,8 +1616,8 @@ inline uint32_t object_storage_get_obj_mesh_index(object_info obj_info, const ch
return -1;
for (uint32_t j = 0; j < set->obj_num; j++)
if (set->obj_data[j].id == obj_info.id)
return set->obj_data[j].get_obj_mesh_index(mesh_name);
if (set->obj_data[j]->id == obj_info.id)
return set->obj_data[j]->get_obj_mesh_index(mesh_name);
}
auto elem_modern = object_storage_data_modern.find(obj_info.set_id);
@@ -1621,8 +1627,8 @@ inline uint32_t object_storage_get_obj_mesh_index(object_info obj_info, const ch
return -1;
for (uint32_t j = 0; j < set->obj_num; j++)
if (set->obj_data[j].id == obj_info.id)
return set->obj_data[j].get_obj_mesh_index(mesh_name);
if (set->obj_data[j]->id == obj_info.id)
return set->obj_data[j]->get_obj_mesh_index(mesh_name);
}
return -1;
}
@@ -1634,8 +1640,8 @@ inline uint32_t object_storage_get_obj_mesh_index_by_hash(uint32_t hash, const c
continue;
for (uint32_t j = 0; j < set->obj_num; j++)
if (set->obj_data[j].hash == hash)
return set->obj_data[j].get_obj_mesh_index(mesh_name);
if (set->obj_data[j]->hash == hash)
return set->obj_data[j]->get_obj_mesh_index(mesh_name);
}
for (auto& i : object_storage_data_modern) {
@@ -1644,8 +1650,8 @@ inline uint32_t object_storage_get_obj_mesh_index_by_hash(uint32_t hash, const c
continue;
for (uint32_t j = 0; j < set->obj_num; j++)
if (set->obj_data[j].hash == hash)
return set->obj_data[j].get_obj_mesh_index(mesh_name);
if (set->obj_data[j]->hash == hash)
return set->obj_data[j]->get_obj_mesh_index(mesh_name);
}
return -1;
}
@@ -1684,8 +1690,8 @@ inline obj_skin* object_storage_get_obj_skin(object_info obj_info) {
return 0;
for (uint32_t j = 0; j < set->obj_num; j++)
if (set->obj_data[j].id == obj_info.id)
return set->obj_data[j].skin;
if (set->obj_data[j]->id == obj_info.id)
return set->obj_data[j]->skin;
return 0;
}
@@ -1696,8 +1702,8 @@ inline obj_skin* object_storage_get_obj_skin(object_info obj_info) {
return 0;
for (uint32_t j = 0; j < set->obj_num; j++)
if (set->obj_data[j].id == obj_info.id)
return set->obj_data[j].skin;
if (set->obj_data[j]->id == obj_info.id)
return set->obj_data[j]->skin;
return 0;
}
return 0;
@@ -1715,7 +1721,7 @@ inline obj_mesh_index_buffer* object_storage_get_obj_mesh_index_buffer(object_in
if (handler && handler->obj_set && handler->index_buffer_data) {
obj_set* set = handler->obj_set;
for (uint32_t i = 0; i < set->obj_num; i++)
if (set->obj_data[i].id == obj_info.id)
if (set->obj_data[i]->id == obj_info.id)
return handler->index_buffer_data[i].mesh_data;
}
return 0;
@@ -1733,7 +1739,7 @@ inline obj_mesh_vertex_buffer* object_storage_get_obj_mesh_vertex_buffer(object_
if (handler && handler->obj_set && handler->vertex_buffer_data) {
obj_set* set = handler->obj_set;
for (uint32_t i = 0; i < set->obj_num; i++)
if (set->obj_data[i].id == obj_info.id)
if (set->obj_data[i]->id == obj_info.id)
return handler->vertex_buffer_data[i].mesh_data;
}
return 0;
@@ -1891,7 +1897,7 @@ bool object_storage_load_obj_set_check_not_read(uint32_t set_id,
handler->obj_file_handler.reset();
handler->obj_id_data.reserve(set->obj_num);
for (uint32_t i = 0; i < set->obj_num; i++)
handler->obj_id_data.push_back(set->obj_data[i].id, i);
handler->obj_id_data.push_back(set->obj_data[i]->id, i);
handler->obj_id_data.sort();
if (!obj_set_handler_vertex_buffer_load(handler)
@@ -2008,7 +2014,7 @@ bool object_storage_load_obj_set_check_not_read(uint32_t set_id,
handler->obj_file_handler.reset();
handler->obj_id_data.reserve(set->obj_num);
for (uint32_t i = 0; i < set->obj_num; i++)
handler->obj_id_data.push_back(set->obj_data[i].id, i);
handler->obj_id_data.push_back(set->obj_data[i]->id, i);
if (!obj_set_handler_vertex_buffer_load(handler)
|| !obj_set_handler_index_buffer_load(handler))
@@ -2100,9 +2106,9 @@ inline void object_storage_free() {
static void obj_set_handler_calc_axis_aligned_bounding_box(obj_set_handler* handler) {
obj_set* set = handler->obj_set;
for (uint32_t i = 0; i < set->obj_num; i++) {
obj& obj = set->obj_data[i];
for (uint32_t j = 0; j < obj.num_mesh; j++) {
obj_mesh& mesh = obj.mesh_array[j];
obj* obj = set->obj_data[i];
for (uint32_t j = 0; j < obj->num_mesh; j++) {
obj_mesh& mesh = obj->mesh_array[j];
for (uint32_t k = 0; k < mesh.num_submesh; k++) {
vec3 _min = 9999999.0f;
vec3 _max = -100000000.0f;
@@ -2139,10 +2145,10 @@ static void obj_set_handler_calc_axis_aligned_bounding_box(obj_set_handler* hand
static void obj_set_handler_get_shader_index_texture_index(obj_set_handler* handler) {
obj_set* set = handler->obj_set;
for (uint32_t i = 0; i < set->obj_num; i++) {
obj& obj = set->obj_data[i];
uint32_t num_material = obj.num_material;
obj* obj = set->obj_data[i];
uint32_t num_material = obj->num_material;
for (uint32_t j = 0; j < num_material; j++) {
obj_material_data& material_data = obj.material_array[j];
obj_material_data& material_data = obj->material_array[j];
obj_material& material = material_data.material;
if (*(int32_t*)&material.shader.name[4] != 0xDEADFF) {
+2 -2
View File
@@ -65,7 +65,7 @@ struct obj_index_buffer {
obj_index_buffer();
bool load(obj& obj);
bool load(obj* obj);
void unload();
};
@@ -78,7 +78,7 @@ struct obj_vertex_buffer {
obj_vertex_buffer();
bool load(obj& obj);
bool load(obj* obj);
void unload();
};
+5 -5
View File
@@ -396,7 +396,7 @@ struct rob_chara_age_age_object {
bool npr, bool reflect, const vec3& a5, bool chara_color);
bool get_obj_set_handler_object_index(object_info obj_info);
::obj* get_obj_set_obj();
std::vector<texture*>* get_obj_set_texture();
std::vector<texture*>& get_obj_set_texture();
void load(object_info obj_info, int32_t count);
void reset();
void update(rob_chara_age_age_data* data, int32_t count, float_t alpha);
@@ -17281,7 +17281,7 @@ void rob_chara_age_age_object::disp(render_context* rctx, size_t chara_index,
rctx->disp_manager.set_chara_color(chara_color);
rctx->disp_manager.set_shadow_type(chara_index ? SHADOW_STAGE : SHADOW_CHARA);
rctx->disp_manager.entry_obj_by_obj(&mat4_identity, &obj,
get_obj_set_texture(), &obj_vert_buf, &obj_index_buf, 0, 1.0f);
&get_obj_set_texture(), &obj_vert_buf, &obj_index_buf, 0, 1.0f);
}
bool rob_chara_age_age_object::get_obj_set_handler_object_index(object_info obj_info) {
@@ -17298,11 +17298,11 @@ return true;
}
::obj* rob_chara_age_age_object::get_obj_set_obj() {
return &obj_set_handler->obj_set->obj_data[obj_index];
return obj_set_handler->obj_set->obj_data[obj_index];
}
std::vector<texture*>* rob_chara_age_age_object::get_obj_set_texture() {
return &obj_set_handler->gentex;
std::vector<texture*>& rob_chara_age_age_object::get_obj_set_texture() {
return obj_set_handler->gentex;
}
void rob_chara_age_age_object::load(object_info obj_info, int32_t count) {
+26 -20
View File
@@ -531,11 +531,13 @@ void obj_set::move_data(obj_set* set_src, prj::shared_ptr<prj::stack_allocator>
is_x = set_src->is_x;
uint32_t obj_num = set_src->obj_num;
obj* obj_data_src = set_src->obj_data;
obj* obj_data_dst = alloc->allocate<obj>(obj_num);
obj** obj_data_src = set_src->obj_data;
obj** obj_data_dst = alloc->allocate<obj*>(obj_num);
for (uint32_t i = 0; i < obj_num; i++)
obj_move_data(&obj_data_dst[i], &obj_data_src[i], alloc);
for (uint32_t i = 0; i < obj_num; i++) {
obj_data_dst[i] = alloc->allocate<obj>();
obj_move_data(obj_data_dst[i], obj_data_src[i], alloc);
}
this->obj_data = obj_data_dst;
this->obj_num = obj_num;
@@ -1218,7 +1220,10 @@ static void obj_set_classic_read_inner(obj_set* set, prj::shared_ptr<prj::stack_
set->reserved[1] = s.read_uint32_t();
uint32_t obj_num = set->obj_num;
set->obj_data = alloc->allocate<obj>(obj_num);
set->obj_data = alloc->allocate<obj*>(obj_num);
for (uint32_t i = 0; i < obj_num; i++)
set->obj_data[i] = alloc->allocate<::obj>();
uint32_t* data = force_malloc_s(uint32_t, obj_num * 3ULL);
@@ -1248,7 +1253,7 @@ static void obj_set_classic_read_inner(obj_set* set, prj::shared_ptr<prj::stack_
if (osh.obj_data) {
for (uint32_t i = 0; i < obj_num; i++) {
obj* obj = &set->obj_data[i];
obj* obj = set->obj_data[i];
if (obj_data[i])
obj_classic_read_model(obj, alloc, s, obj_data[i]);
@@ -1264,9 +1269,8 @@ static void obj_set_classic_read_inner(obj_set* set, prj::shared_ptr<prj::stack_
}
s.set_position(osh.obj_id_data, SEEK_SET);
obj* obj_data = set->obj_data;
for (uint32_t i = 0; i < obj_num; i++)
obj_data[i].id = s.read_uint32_t();
set->obj_data[i]->id = s.read_uint32_t();
}
if (osh.tex_id_data) {
@@ -1317,7 +1321,7 @@ static void obj_set_classic_write_inner(obj_set* set, stream& s) {
int32_t* obj_data = data;
for (uint32_t i = 0; i < obj_num; i++) {
obj_data[i] = (int32_t)s.get_position();
obj_classic_write_model(&set->obj_data[i], s, obj_data[i]);
obj_classic_write_model(set->obj_data[i], s, obj_data[i]);
}
s.align_write(0x10);
@@ -1328,7 +1332,7 @@ static void obj_set_classic_write_inner(obj_set* set, stream& s) {
osh.obj_id_data = s.get_position();
for (uint32_t i = 0; i < obj_num; i++) {
uint32_t object_id = set->obj_data[i].id;
uint32_t object_id = set->obj_data[i]->id;
s.write_uint32_t(object_id);
if (osh.last_obj_id < object_id)
osh.last_obj_id = object_id;
@@ -1338,7 +1342,7 @@ static void obj_set_classic_write_inner(obj_set* set, stream& s) {
int32_t* obj_name_data = data;
for (uint32_t i = 0; i < obj_num; i++) {
obj_name_data[i] = (int32_t)s.get_position();
s.write_utf8_string_null_terminated(set->obj_data[i].name);
s.write_utf8_string_null_terminated(set->obj_data[i]->name);
}
s.align_write(0x10);
@@ -1359,7 +1363,7 @@ static void obj_set_classic_write_inner(obj_set* set, stream& s) {
int32_t* obj_skin_data = data;
for (uint32_t i = 0; i < obj_num; i++) {
obj_skin* sk = set->obj_data[i].skin;
obj_skin* sk = set->obj_data[i]->skin;
if (!sk) {
obj_skin_data[i] = 0;
continue;
@@ -3929,7 +3933,10 @@ static void obj_set_modern_read_inner(obj_set* set, prj::shared_ptr<prj::stack_a
}
uint32_t obj_num = set->obj_num;
set->obj_data = alloc->allocate<obj>(obj_num);
set->obj_data = alloc->allocate<obj*>(obj_num);
for (uint32_t i = 0; i < obj_num; i++)
set->obj_data[i] = alloc->allocate<::obj>();
int64_t* data = force_malloc_s(int64_t, obj_num * 3ULL);
@@ -3971,7 +3978,7 @@ static void obj_set_modern_read_inner(obj_set* set, prj::shared_ptr<prj::stack_a
if (osh.obj_data)
for (uint32_t i = 0; i < obj_num; i++) {
obj* obj = &set->obj_data[i];
obj* obj = set->obj_data[i];
if (osh.obj_name_data && obj_name_data[i]) {
obj->name = obj_read_utf8_string_null_terminated_offset(alloc, s_mosd, obj_name_data[i]);
obj->hash = hash_utf8_murmurhash(obj->name);
@@ -3982,9 +3989,8 @@ static void obj_set_modern_read_inner(obj_set* set, prj::shared_ptr<prj::stack_a
if (osh.obj_id_data) {
s_mosd.set_position(osh.obj_id_data, SEEK_SET);
obj* obj_data = set->obj_data;
for (uint32_t i = 0; i < obj_num; i++)
obj_data[i].id = s_mosd.read_uint32_t_reverse_endianness();
set->obj_data[i]->id = s_mosd.read_uint32_t_reverse_endianness();
}
free_def(data);
@@ -4038,7 +4044,7 @@ static void obj_set_modern_read_inner(obj_set* set, prj::shared_ptr<prj::stack_a
s_ovtx_ptr = &s_ovtx;
}
obj* obj = &set->obj_data[omdl_index];
obj* obj = set->obj_data[omdl_index];
memory_stream s_omdl;
s_omdl.open(i.data);
s_omdl.big_endian = i.header.use_big_endian;
@@ -4188,7 +4194,7 @@ static void obj_set_modern_write_inner(obj_set* set, stream& s) {
osh.obj_id_data = s_mosd.get_position();
for (uint32_t i = 0; i < obj_num; i++)
s_mosd.write_uint32_t_reverse_endianness(set->obj_data[i].id);
s_mosd.write_uint32_t_reverse_endianness(set->obj_data[i]->id);
s_mosd.align_write(0x10);
osh.tex_id_data = s_mosd.get_position();
@@ -4199,7 +4205,7 @@ static void obj_set_modern_write_inner(obj_set* set, stream& s) {
int64_t* obj_name_data = force_malloc_s(int64_t, obj_num);
for (uint32_t i = 0; i < obj_num; i++) {
obj_name_data[i] = (int32_t)s_mosd.get_position();
s_mosd.write_utf8_string_null_terminated(set->obj_data[i].name);
s_mosd.write_utf8_string_null_terminated(set->obj_data[i]->name);
}
s_mosd.align_write(0x10);
@@ -4244,7 +4250,7 @@ static void obj_set_modern_write_inner(obj_set* set, stream& s) {
f2_struct st;
for (uint32_t i = 0; i < obj_num; i++) {
obj* obj = &set->obj_data[i];
obj* obj = set->obj_data[i];
st.sub_structs.push_back({});
f2_struct* omdl = &st.sub_structs.back();
+1 -1
View File
@@ -702,7 +702,7 @@ struct obj_set {
bool big_endian;
bool is_x;
obj* obj_data;
obj** obj_data;
uint32_t obj_num;
uint32_t* tex_id_data;
uint32_t tex_id_num;
+5 -5
View File
@@ -4226,8 +4226,8 @@ static void glitter_editor_property_particle(GlitterEditor* glt_edt, class_data*
if (handler && handler->obj_set) {
obj_set* set = handler->obj_set;
for (uint32_t i = 0; i < set->obj_num; i++)
if (set->obj_data[i].id == obj_id) {
obj = &set->obj_data[i];
if (set->obj_data[i]->id == obj_id) {
obj = set->obj_data[i];
break;
}
}
@@ -4238,7 +4238,7 @@ static void glitter_editor_property_particle(GlitterEditor* glt_edt, class_data*
obj_set* set = handler->obj_set;
ssize_t obj_index = -1;
for (uint32_t i = 0; i < set->obj_num; i++)
if (set->obj_data[i].id == obj_id) {
if (set->obj_data[i]->id == obj_id) {
obj_index = i;
break;
}
@@ -4252,7 +4252,7 @@ static void glitter_editor_property_particle(GlitterEditor* glt_edt, class_data*
for (uint32_t i = 0; i < set->obj_num; i++) {
ImGui::PushID(i);
::obj* obj = &set->obj_data[i];
::obj* obj = set->obj_data[i];
if (ImGui::Selectable(obj->name, obj->id == obj_id)
|| ImGui::ItemKeyPressed(ImGuiKey_Enter)
|| (ImGui::IsItemFocused() && obj->id != obj_id))
@@ -4263,7 +4263,7 @@ static void glitter_editor_property_particle(GlitterEditor* glt_edt, class_data*
if (obj_index == -1 || obj_index >= set->obj_num)
obj_id = -1;
else
obj_id = set->obj_data[obj_index].id;
obj_id = set->obj_data[obj_index]->id;
if (mesh->object_name_hash != obj_id) {
mesh->object_name_hash = obj_id;
+12 -11
View File
@@ -7966,7 +7966,7 @@ static void x_pv_game_split_auth_3d_hrc_material_list(x_pv_game* xpvgm,
uint32_t obj_num = set->obj_num;
for (uint32_t j = 0; j < obj_num; j++) {
obj* obj = &set->obj_data[j];
obj* obj = set->obj_data[j];
if (obj->id != i.first.id)
continue;
@@ -8080,23 +8080,24 @@ static void x_pv_game_split_auth_3d_hrc_material_list(x_pv_game* xpvgm,
std::vector<uint32_t> used_material_indices;
uint32_t obj_num_new = (uint32_t)(obj_num + bones_vertices.size());
obj* obj_data_new = alloc->allocate<::obj>(obj_num_new);
memcpy(obj_data_new, set->obj_data, sizeof(obj) * obj_num);
uint32_t obj_num_new = (uint32_t)bones_vertices.size();
obj** obj_data_new = alloc->allocate<::obj*>((size_t)obj_num + obj_num_new);
memcpy(obj_data_new, set->obj_data, sizeof(obj*) * obj_num);
set->obj_data = obj_data_new;
set->obj_num = obj_num_new;
set->obj_num = obj_num + obj_num_new;
obj_data_new += obj_num;
obj_num_new -= obj_num;
for (uint32_t j = 0; j < obj_num_new; j++) {
x_pv_game_split_auth_3d_hrc_obj_bone& bone_vertices = bones_vertices[j];
uint32_t src_id = bone_vertices.src_id;
obj_data_new[j] = alloc->allocate<::obj>();
obj* src_obj = 0;
obj* dst_obj = &obj_data_new[j];
obj* dst_obj = obj_data_new[j];
for (uint32_t k = 0; k < obj_num; k++)
if (set->obj_data[k].id == src_id) {
src_obj = &set->obj_data[k];
if (set->obj_data[k]->id == src_id) {
src_obj = set->obj_data[k];
break;
}
@@ -8292,7 +8293,7 @@ static void x_pv_game_split_auth_3d_hrc_material_list(x_pv_game* xpvgm,
handler->obj_id_data.reserve(set->obj_num);
for (uint32_t j = 0; j < obj_num_new; j++)
handler->obj_id_data.push_back(obj_data_new[j].id, obj_num + j);
handler->obj_id_data.push_back(obj_data_new[j]->id, obj_num + j);
uint32_t _obj_num = obj_num + obj_num_new;
handler->vertex_buffer_num = _obj_num;
@@ -8315,7 +8316,7 @@ static void x_pv_game_split_auth_3d_hrc_material_list(x_pv_game* xpvgm,
}
for (uint32_t j = 0; j < obj_num; j++) {
obj* obj = &set->obj_data[j];
obj* obj = set->obj_data[j];
if (obj->id != i.first.id)
continue;