mirror of
https://github.com/korenkonder/ReDIVA.git
synced 2026-10-07 22:28:10 +03:00
Temp commit. Will delete later. Even more Osage and C++ stuff
This commit is contained in:
@@ -59,7 +59,7 @@ classes_data data_test_classes[] = {
|
||||
},
|
||||
{
|
||||
"Stage Test##Data Test",
|
||||
(classes_enum)(CLASSES_INIT_AT_STARTUP | CLASSES_IN_CONTEXT_MENU),
|
||||
CLASSES_IN_CONTEXT_MENU,
|
||||
data_test_stage_test_init,
|
||||
data_test_stage_test_ctrl,
|
||||
CLASSES_DATA_NO_FUNC,
|
||||
|
||||
@@ -72,8 +72,6 @@ vector_old_func(data_test_auth_3d_test_uid)
|
||||
extern int32_t width;
|
||||
extern int32_t height;
|
||||
extern float_t frame_speed;
|
||||
extern stage stage_stgtst;
|
||||
extern stage stage_test_data;
|
||||
|
||||
static const char* data_test_auth_3d_test_window_title = "Auth 3D Test##Data Test";
|
||||
|
||||
@@ -82,8 +80,6 @@ static void data_test_auth_3d_test_load_auth_file(data_test_auth_3d_test* auth_3
|
||||
static int data_test_auth_3d_test_uid_quicksort_compare_func(void const* src1, void const* src2);
|
||||
|
||||
bool data_test_auth_3d_test_init(class_data* data, render_context* rctx) {
|
||||
bool ret = false;
|
||||
lock_trylock(&pv_lock);
|
||||
data->data = force_malloc_s(data_test_auth_3d_test, 1);
|
||||
|
||||
data_test_auth_3d_test* auth_3d_test = (data_test_auth_3d_test*)data->data;
|
||||
@@ -125,20 +121,7 @@ bool data_test_auth_3d_test_init(class_data* data, render_context* rctx) {
|
||||
auth_3d_test->auth_3d_category_index = -1;
|
||||
auth_3d_test->auth_3d_category_index_prev = -1;
|
||||
auth_3d_test->auth_3d_index = -1;
|
||||
auth_3d_test->stage_index = -1;
|
||||
|
||||
stage* stg = (stage*)rctx->stage;
|
||||
if (stg && !stg->modern && stg->stage_data) {
|
||||
stage_data* stg_data = stg->stage_data;
|
||||
data_struct* aft_data = rctx->data;
|
||||
stage_database* aft_stage_data = &aft_data->data_ft.stage_data;
|
||||
|
||||
for (stage_data* i = aft_stage_data->stage_data.begin; i != aft_stage_data->stage_data.end; i++)
|
||||
if (stg_data == i) {
|
||||
auth_3d_test->stage_index = (int32_t)(i - aft_stage_data->stage_data.begin);
|
||||
break;
|
||||
}
|
||||
}
|
||||
auth_3d_test->stage_index = 0;
|
||||
|
||||
auth_3d_test->auth_3d_id = -1;
|
||||
auth_3d_test->auth_3d_uid = -1;
|
||||
@@ -180,9 +163,7 @@ bool data_test_auth_3d_test_init(class_data* data, render_context* rctx) {
|
||||
auth_3d_test->rot_y = 0.0f;
|
||||
auth_3d_test->obj_set_id = vector_old_empty(uint32_t);
|
||||
}
|
||||
ret = true;
|
||||
lock_unlock(&pv_lock);
|
||||
return ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
void data_test_auth_3d_test_ctrl(class_data* data) {
|
||||
@@ -228,11 +209,9 @@ void data_test_auth_3d_test_ctrl(class_data* data) {
|
||||
auth_3d_data_unload_category((char*)cat_prev->name);
|
||||
}
|
||||
|
||||
{
|
||||
for (uint32_t* i = auth_3d_test->obj_set_id.begin; i != auth_3d_test->obj_set_id.end; i++)
|
||||
object_storage_delete_object_set(*i);
|
||||
vector_old_uint32_t_clear(&auth_3d_test->obj_set_id, 0);
|
||||
}
|
||||
for (uint32_t* i = auth_3d_test->obj_set_id.begin; i != auth_3d_test->obj_set_id.end; i++)
|
||||
object_storage_delete_object_set(*i);
|
||||
vector_old_uint32_t_clear(&auth_3d_test->obj_set_id, 0);
|
||||
|
||||
data_test_auth_3d_test_category* cat
|
||||
= &auth_3d_test->category.begin[auth_3d_test->auth_3d_category_index];
|
||||
@@ -244,13 +223,13 @@ void data_test_auth_3d_test_ctrl(class_data* data) {
|
||||
|
||||
object_set_info* set_info;
|
||||
if (!memcmp(name_str, "ITMPV", 5)
|
||||
&& object_database_get_object_set_info(obj_db, name_str, &set_info)) {
|
||||
&& obj_db->get_object_set_info(name_str, &set_info)) {
|
||||
object_set_load_by_db_index(&set_info, rctx->data, obj_db, set_info->id);
|
||||
vector_old_uint32_t_push_back(&auth_3d_test->obj_set_id, &set_info->id);
|
||||
}
|
||||
|
||||
if (!memcmp(name_str, "EFFCHRPV", 8)
|
||||
&& object_database_get_object_set_info(obj_db, name_str, &set_info)) {
|
||||
&& obj_db->get_object_set_info(name_str, &set_info)) {
|
||||
object_set_load_by_db_index(&set_info, rctx->data, obj_db, set_info->id);
|
||||
vector_old_uint32_t_push_back(&auth_3d_test->obj_set_id, &set_info->id);
|
||||
}
|
||||
@@ -270,13 +249,13 @@ void data_test_auth_3d_test_ctrl(class_data* data) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (object_database_get_object_set_info(obj_db, string_data(&obj), &set_info)) {
|
||||
if (obj_db->get_object_set_info(string_data(&obj), &set_info)) {
|
||||
object_set_load_by_db_index(&set_info, rctx->data, obj_db, set_info->id);
|
||||
vector_old_uint32_t_push_back(&auth_3d_test->obj_set_id, &set_info->id);
|
||||
}
|
||||
|
||||
string_add_length(&obj, "HRC", 3);
|
||||
if (object_database_get_object_set_info(obj_db, string_data(&obj), &set_info)) {
|
||||
if (obj_db->get_object_set_info(string_data(&obj), &set_info)) {
|
||||
object_set_load_by_db_index(&set_info, rctx->data, obj_db, set_info->id);
|
||||
vector_old_uint32_t_push_back(&auth_3d_test->obj_set_id, &set_info->id);
|
||||
}
|
||||
@@ -294,20 +273,7 @@ void data_test_auth_3d_test_ctrl(class_data* data) {
|
||||
}
|
||||
|
||||
if (auth_3d_test->stage_load) {
|
||||
render_context* rctx = auth_3d_test->rctx;
|
||||
|
||||
data_struct* aft_data = rctx->data;
|
||||
auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db;
|
||||
object_database* aft_obj_db = &aft_data->data_ft.obj_db;
|
||||
texture_database* aft_tex_db = &aft_data->data_ft.tex_db;
|
||||
stage_database* aft_stage_data = &aft_data->data_ft.stage_data;
|
||||
|
||||
stage_free(&stage_test_data, rctx);
|
||||
stage_init(&stage_test_data);
|
||||
stage_load(&stage_test_data, aft_data, aft_auth_3d_db,
|
||||
aft_obj_db, aft_tex_db, aft_stage_data,
|
||||
(char*)auth_3d_test->stage.begin[auth_3d_test->stage_index], rctx);
|
||||
stage_set(&stage_test_data, rctx);
|
||||
task_stage_set_stage_index(auth_3d_test->stage_index);
|
||||
auth_3d_test->stage_load = false;
|
||||
}
|
||||
}
|
||||
@@ -317,9 +283,7 @@ bool data_test_auth_3d_test_hide(class_data* data) {
|
||||
if (!auth_3d_test)
|
||||
return true;
|
||||
|
||||
lock_data_free(&stage_data_lock, (void(*)(void*))data_test_auth_3d_test_hide);
|
||||
|
||||
render_context* rctx = auth_3d_test->rctx;
|
||||
task_stage_unload();
|
||||
|
||||
for (uint32_t* i = auth_3d_test->obj_set_id.begin;
|
||||
i != auth_3d_test->obj_set_id.end; i++)
|
||||
@@ -372,7 +336,8 @@ void data_test_auth_3d_test_imgui(class_data* data) {
|
||||
}
|
||||
|
||||
auth_3d* auth = auth_3d_data_get_auth_3d(auth_3d_test->auth_3d_id);
|
||||
auth_3d_test->last_frame = auth->play_control.size;
|
||||
if (auth)
|
||||
auth_3d_test->last_frame = auth->play_control.size;
|
||||
|
||||
if (auth_3d_data_check_id_not_empty(&auth_3d_test->auth_3d_id)) {
|
||||
auth_3d_test->enable = auth_3d_data_get_enable(&auth_3d_test->auth_3d_id);
|
||||
@@ -546,15 +511,18 @@ void data_test_auth_3d_test_imgui(class_data* data) {
|
||||
window_flags |= ImGuiWindowFlags_NoCollapse;
|
||||
|
||||
if (igBegin("A3D STAGE", 0, window_flags)) {
|
||||
stage* stg = (stage*)auth_3d_test->rctx->stage;
|
||||
if (!stg)
|
||||
if (stage_test_data.stage_data)
|
||||
stg = &stage_test_data;
|
||||
else
|
||||
stg = &stage_stgtst;
|
||||
stage* stg = task_stage_get_current_stage();
|
||||
|
||||
igCheckbox("stage", &stg->display);
|
||||
igCheckbox("stg auth", &stg->effects);
|
||||
if (stg){
|
||||
igCheckbox("stage", &stg->stage_display);
|
||||
igCheckbox("stg auth display", &stg->effects);
|
||||
}
|
||||
else {
|
||||
bool stage = true;
|
||||
igCheckbox("stage", &stage);
|
||||
bool effects = true;
|
||||
igCheckbox("stg auth display", &effects);
|
||||
}
|
||||
|
||||
int32_t stage_index = auth_3d_test->stage_index;
|
||||
|
||||
@@ -614,13 +582,6 @@ bool data_test_auth_3d_test_show(class_data* data) {
|
||||
if (!auth_3d_test)
|
||||
return false;
|
||||
|
||||
bool ret = false;
|
||||
lock_trylock(&pv_lock);
|
||||
if (!lock_data_init(&stage_data_lock, &data->lock, data, (void(*)(void*))data_test_auth_3d_test_hide))
|
||||
goto End;
|
||||
|
||||
ret = true;
|
||||
|
||||
auth_3d_test->enable = true;
|
||||
auth_3d_test->repeat = true;
|
||||
auth_3d_test->left_right_reverse = false;
|
||||
@@ -632,9 +593,9 @@ bool data_test_auth_3d_test_show(class_data* data) {
|
||||
auth_3d_test->trans_z = 0.0f;
|
||||
auth_3d_test->rot_y = 0.0f;
|
||||
|
||||
End:
|
||||
lock_unlock(&pv_lock);
|
||||
return ret;
|
||||
task_stage_load("A3D_STAGE");
|
||||
task_stage_set_stage_index(auth_3d_test->stage_index);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool data_test_auth_3d_test_dispose(class_data* data) {
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
#include "../data_test.h"
|
||||
#include "../imgui_helper.h"
|
||||
|
||||
typedef struct data_test_glitter_test_struct {
|
||||
class data_test_glitter_test_struct {
|
||||
public:
|
||||
uint64_t hash;
|
||||
glitter_scene_counter scene_counter;
|
||||
float_t frame;
|
||||
@@ -34,7 +35,10 @@ typedef struct data_test_glitter_test_struct {
|
||||
|
||||
bool stage_test;
|
||||
render_context* rctx;
|
||||
} data_test_glitter_test_struct;
|
||||
|
||||
data_test_glitter_test_struct();
|
||||
~data_test_glitter_test_struct();
|
||||
};
|
||||
|
||||
extern int32_t width;
|
||||
extern int32_t height;
|
||||
@@ -45,11 +49,7 @@ extern bool draw_grid_3d;
|
||||
static const char* data_test_glitter_test_window_title = "Glitter Test##Data Test";
|
||||
|
||||
bool data_test_glitter_test_init(class_data* data, render_context* rctx) {
|
||||
if (!lock_data_init(&glitter_data_lock, &data->lock, data, (void(*)(void*))data_test_glitter_test_dispose))
|
||||
return false;
|
||||
|
||||
lock_trylock(&pv_lock);
|
||||
data->data = force_malloc_s(data_test_glitter_test_struct, 1);
|
||||
data->data = new data_test_glitter_test_struct;
|
||||
|
||||
LARGE_INTEGER time;
|
||||
QueryPerformanceCounter(&time);
|
||||
@@ -57,11 +57,11 @@ bool data_test_glitter_test_init(class_data* data, render_context* rctx) {
|
||||
|
||||
data_test_glitter_test_struct* glt_test = (data_test_glitter_test_struct*)data->data;
|
||||
if (glt_test) {
|
||||
data_struct_get_directory_files(&data_list[DATA_AFT], "rom/particle/", &glt_test->files);
|
||||
data_list[DATA_AFT].get_directory_files("rom/particle/", &glt_test->files);
|
||||
for (data_struct_file* i = glt_test->files.begin()._Ptr; i != glt_test->files.end()._Ptr;)
|
||||
if (str_utils_check_ends_with(i->name.c_str(), ".farc")) {
|
||||
char* temp = str_utils_get_without_extension(i->name.c_str());
|
||||
i->name = std::string(temp);
|
||||
i->name = temp ? std::string(temp) : std::string();
|
||||
free(temp);
|
||||
i++;
|
||||
}
|
||||
@@ -77,7 +77,6 @@ bool data_test_glitter_test_init(class_data* data, render_context* rctx) {
|
||||
GPM_VAL.draw_all_mesh = false;
|
||||
draw_grid_3d = false;
|
||||
}
|
||||
lock_unlock(&pv_lock);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -150,8 +149,8 @@ void data_test_glitter_test_imgui(class_data* data) {
|
||||
ImGuiStyle* style = igGetStyle();
|
||||
ImFont* font = igGetFont();
|
||||
|
||||
float_t w = min((float_t)width, 320.0f);
|
||||
float_t h = min((float_t)height, 278.0f);
|
||||
float_t w = 280.0f;
|
||||
float_t h = 278.0f;
|
||||
|
||||
igSetNextWindowPos(ImVec2_Empty, ImGuiCond_Appearing, ImVec2_Empty);
|
||||
igSetNextWindowSize({ w, h }, ImGuiCond_Always);
|
||||
@@ -291,21 +290,22 @@ bool data_test_glitter_test_dispose(class_data* data) {
|
||||
GPM_VAL.FreeScenes();
|
||||
GPM_VAL.SetPause(false);
|
||||
|
||||
lock_data_free(&glitter_data_lock, (void(*)(void*))data_test_glitter_test_dispose);
|
||||
|
||||
data_test_glitter_test_struct* glt_test = (data_test_glitter_test_struct*)data->data;
|
||||
delete glt_test;
|
||||
|
||||
draw_grid_3d = false;
|
||||
if (glt_test) {
|
||||
glt_test->files = {};
|
||||
glt_test->file = 0;
|
||||
glt_test->input_play = false;
|
||||
glt_test->input_stop = false;
|
||||
glt_test->frame = 0.0f;
|
||||
}
|
||||
free(data->data);
|
||||
|
||||
data->flags = (class_flags)(CLASS_HIDDEN | CLASS_DISPOSED);
|
||||
data->imgui_focus = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
data_test_glitter_test_struct::data_test_glitter_test_struct() : hash(),
|
||||
scene_counter(), frame(), auto_and_repeat(), reload(), pv_mode(),
|
||||
input_play(), input_stop(), delta_frame(), file(), stage_test(), rctx() {
|
||||
|
||||
}
|
||||
|
||||
data_test_glitter_test_struct::~data_test_glitter_test_struct() {
|
||||
|
||||
}
|
||||
|
||||
@@ -22,41 +22,42 @@
|
||||
class data_test_stage_test_stage_pv {
|
||||
public:
|
||||
int32_t pv_id;
|
||||
std::vector<std::string> stage;
|
||||
std::vector<std::int32_t> stage;
|
||||
|
||||
data_test_stage_test_stage_pv(int32_t pv_id);
|
||||
~data_test_stage_test_stage_pv();
|
||||
};
|
||||
|
||||
typedef struct data_test_stage_test {
|
||||
class data_test_stage_test {
|
||||
public:
|
||||
int32_t pv_id;
|
||||
int32_t pv_index;
|
||||
int32_t ns_index;
|
||||
int32_t other_index;
|
||||
int32_t stage_index;
|
||||
|
||||
const char* stage_name;
|
||||
int32_t stage_index_load;
|
||||
bool stage_load;
|
||||
|
||||
render_context* rctx;
|
||||
|
||||
std::vector<data_test_stage_test_stage_pv> stage_pv;
|
||||
std::vector<std::string> stage_ns;
|
||||
std::vector<std::string> stage_other;
|
||||
} data_test_stage_test;
|
||||
std::vector<std::int32_t> stage_ns;
|
||||
std::vector<std::int32_t> stage_other;
|
||||
|
||||
data_test_stage_test();
|
||||
~data_test_stage_test();
|
||||
};
|
||||
|
||||
extern int32_t width;
|
||||
extern int32_t height;
|
||||
extern stage stage_stgtst;
|
||||
extern stage stage_test_data;
|
||||
|
||||
static const char* data_test_stage_test_window_title = "Stage Test##Data Test";
|
||||
|
||||
static int data_test_stage_test_stage_pv_quicksort_compare_func(void const* src1, void const* src2);
|
||||
static void data_test_stage_test_stage_pv_free(data_test_stage_test_stage_pv* pv);
|
||||
|
||||
bool data_test_stage_test_init(class_data* data, render_context* rctx) {
|
||||
data->data = force_malloc_s(data_test_stage_test, 1);
|
||||
data->data = new data_test_stage_test;
|
||||
|
||||
data_test_stage_test* stage_test = (data_test_stage_test*)data->data;
|
||||
if (stage_test) {
|
||||
@@ -68,7 +69,7 @@ bool data_test_stage_test_init(class_data* data, render_context* rctx) {
|
||||
stage_test->other_index = -1;
|
||||
stage_test->stage_index = -1;
|
||||
|
||||
stage_test->stage_name = 0;
|
||||
stage_test->stage_index_load = -1;
|
||||
stage_test->stage_load = false;
|
||||
|
||||
stage_test->rctx = rctx;
|
||||
@@ -93,9 +94,9 @@ bool data_test_stage_test_init(class_data* data, render_context* rctx) {
|
||||
stg_other_count++;
|
||||
}
|
||||
|
||||
std::vector<data_test_stage_test_stage_pv> stage_pv = {};
|
||||
std::vector<std::string> stage_ns = {};
|
||||
std::vector<std::string> stage_other = {};
|
||||
std::vector<data_test_stage_test_stage_pv> stage_pv;
|
||||
std::vector<std::int32_t> stage_ns;
|
||||
std::vector<std::int32_t> stage_other;
|
||||
|
||||
stage_pv.reserve(stg_pv_count);
|
||||
stage_ns.reserve(stg_ns_count);
|
||||
@@ -121,7 +122,7 @@ bool data_test_stage_test_init(class_data* data, render_context* rctx) {
|
||||
if (stgpv)
|
||||
ret = sscanf_s(string_data(&i->name) + 5, "%03d", &pv_id);
|
||||
else
|
||||
ret = sscanf_s(string_data(&i->name) + 8, "%03d", &pv_id);
|
||||
ret = sscanf_s(string_data(&i->name) + 7, "%03d", &pv_id);
|
||||
|
||||
if (ret != 1)
|
||||
continue;
|
||||
@@ -136,8 +137,7 @@ bool data_test_stage_test_init(class_data* data, render_context* rctx) {
|
||||
stg_pv = &stage_pv.end()[-1];
|
||||
}
|
||||
|
||||
std::string stg = std::string(string_data(&i->name), i->name.length);
|
||||
stg_pv->stage.push_back(stg);
|
||||
stg_pv->stage.push_back(i->id);
|
||||
}
|
||||
else if (stgns || stgd2ns) {
|
||||
int32_t ns_id = 0;
|
||||
@@ -145,17 +145,16 @@ bool data_test_stage_test_init(class_data* data, render_context* rctx) {
|
||||
if (stgns)
|
||||
ret = sscanf_s(string_data(&i->name) + 5, "%03d", &ns_id);
|
||||
else
|
||||
ret = sscanf_s(string_data(&i->name) + 8, "%03d", &ns_id);
|
||||
ret = sscanf_s(string_data(&i->name) + 7, "%03d", &ns_id);
|
||||
|
||||
if (ret != 1)
|
||||
continue;
|
||||
|
||||
std::string stg = std::string(string_data(&i->name), i->name.length);
|
||||
stage_ns.push_back(stg);
|
||||
stage_ns.push_back(i->id);
|
||||
}
|
||||
else {
|
||||
std::string stg = std::string(string_data(&i->name), i->name.length);
|
||||
stage_other.push_back(stg);
|
||||
stage_other.push_back(i->id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,26 +163,16 @@ bool data_test_stage_test_init(class_data* data, render_context* rctx) {
|
||||
sizeof(data_test_stage_test_stage_pv),
|
||||
data_test_stage_test_stage_pv_quicksort_compare_func);
|
||||
|
||||
if (stage_pv.size())
|
||||
if (stage_pv.size())
|
||||
stage_test->pv_id = stage_pv[0].pv_id;
|
||||
|
||||
stage_test->stage_pv = stage_pv;
|
||||
stage_test->stage_ns = stage_ns;
|
||||
stage_test->stage_other = stage_other;
|
||||
|
||||
stage* stg = (stage*)rctx->stage;
|
||||
if ((stg && !stg->modern && stg->stage_data) || !stg) {
|
||||
if (!stg) {
|
||||
stg = &stage_stgtst;
|
||||
stage_set(&stage_stgtst, rctx);
|
||||
}
|
||||
|
||||
stage_data* data = stg->stage_data;
|
||||
if (data - stg_data->begin >= 0 && data - stg_data->begin < vector_old_length(*stg_data)) {
|
||||
stage_test->stage_index = (int32_t)(data - stg_data->begin);
|
||||
stage_test->stage_name = string_data(&data->name);
|
||||
}
|
||||
}
|
||||
stage_test->stage_index = 0;
|
||||
stage_test->stage_load = false;
|
||||
stage_test->stage_index_load = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -192,21 +181,7 @@ void data_test_stage_test_ctrl(class_data* data) {
|
||||
data_test_stage_test* stage_test = (data_test_stage_test*)data->data;
|
||||
|
||||
if (stage_test->stage_load) {
|
||||
render_context* rctx = stage_test->rctx;
|
||||
stage_free(&stage_test_data, rctx);
|
||||
|
||||
data_struct* aft_data = rctx->data;
|
||||
auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db;
|
||||
object_database* aft_obj_db = &aft_data->data_ft.obj_db;
|
||||
texture_database* aft_tex_db = &aft_data->data_ft.tex_db;
|
||||
stage_database* aft_stage_data = &aft_data->data_ft.stage_data;
|
||||
|
||||
stage_set(&stage_stgtst, rctx);
|
||||
|
||||
stage_init(&stage_test_data);
|
||||
stage_load(&stage_test_data, aft_data, aft_auth_3d_db,
|
||||
aft_obj_db, aft_tex_db, aft_stage_data, stage_test->stage_name, rctx);
|
||||
stage_set(&stage_test_data, rctx);
|
||||
task_stage_set_stage_index(stage_test->stage_index_load);
|
||||
stage_test->stage_load = false;
|
||||
}
|
||||
}
|
||||
@@ -216,7 +191,8 @@ bool data_test_stage_test_hide(class_data* data) {
|
||||
if (!stage_test)
|
||||
return false;
|
||||
|
||||
lock_data_free(&stage_data_lock, (void(*)(void*))data_test_stage_test_hide);
|
||||
task_stage_set_stage_index(-1);
|
||||
task_stage_unload();
|
||||
|
||||
enum_and(data->flags, ~CLASS_HIDE);
|
||||
enum_or(data->flags, CLASS_HIDDEN);
|
||||
@@ -254,9 +230,9 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
|
||||
vector_old_stage_data* stg_data = &stage_test->rctx->data->data_ft.stage_data.stage_data;
|
||||
|
||||
std::vector<data_test_stage_test_stage_pv>* stage_pv = &stage_test->stage_pv;
|
||||
std::vector<std::string>* stage_ns = &stage_test->stage_ns;
|
||||
std::vector<std::string>* stage_other = &stage_test->stage_other;
|
||||
std::vector<data_test_stage_test_stage_pv>& stage_pv = stage_test->stage_pv;
|
||||
std::vector<std::int32_t>& stage_ns = stage_test->stage_ns;
|
||||
std::vector<std::int32_t>& stage_other = stage_test->stage_other;
|
||||
|
||||
int32_t pv_id = stage_test->pv_id;
|
||||
|
||||
@@ -267,7 +243,7 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
igSameLine(0.0f, 1.0f);
|
||||
igSetNextItemWidth(48.0f);
|
||||
if (igBeginCombo("##PV:", buf, 0)) {
|
||||
for (data_test_stage_test_stage_pv& i : *stage_pv) {
|
||||
for (data_test_stage_test_stage_pv& i : stage_pv) {
|
||||
igPushID_Ptr(&i);
|
||||
sprintf_s(buf, sizeof(buf), "%03d", i.pv_id);
|
||||
if (igSelectable_Bool(buf, pv_id == i.pv_id, 0, ImVec2_Empty)
|
||||
@@ -294,17 +270,18 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
igSameLine(0.0f, 1.0f);
|
||||
igSetNextItemWidth(160.0f);
|
||||
bool pv_id_found = false;
|
||||
for (data_test_stage_test_stage_pv& i : *stage_pv) {
|
||||
for (data_test_stage_test_stage_pv& i : stage_pv) {
|
||||
if (pv_id != i.pv_id)
|
||||
continue;
|
||||
|
||||
if (igBeginCombo("##PV Index", pv_index > -1
|
||||
? i.stage[pv_index].c_str() : "", 0)) {
|
||||
for (std::string& j : i.stage) {
|
||||
int32_t pv_idx = (int32_t)(&j - i.stage.begin()._Ptr);
|
||||
? string_data(&stg_data->begin[i.stage[pv_index]].name) : "", 0)) {
|
||||
for (int32_t& j : i.stage) {
|
||||
int32_t pv_idx = (int32_t)(&j - i.stage.data());
|
||||
|
||||
igPushID_Ptr(&j);
|
||||
if (igSelectable_Bool(j.c_str(), pv_index == pv_idx, 0, ImVec2_Empty)
|
||||
igPushID_Int(j);
|
||||
if (igSelectable_Bool(string_data(&stg_data->begin[j].name),
|
||||
pv_index == pv_idx, 0, ImVec2_Empty)
|
||||
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| (igIsItemFocused() && pv_index != pv_idx)) {
|
||||
stage_test->pv_index = -1;
|
||||
@@ -321,7 +298,7 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
|
||||
if (pv_index != stage_test->pv_index) {
|
||||
stage_test->stage_load = true;
|
||||
stage_test->stage_name = i.stage[pv_index].c_str();
|
||||
stage_test->stage_index_load = i.stage[pv_index];
|
||||
stage_test->pv_index = pv_index;
|
||||
}
|
||||
pv_id_found = true;
|
||||
@@ -339,12 +316,13 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
igSameLine(0.0f, 1.0f);
|
||||
igSetNextItemWidth(160.0f);
|
||||
if (igBeginCombo("##NS Index", ns_index > -1
|
||||
? (*stage_ns)[ns_index].c_str() : "", 0)) {
|
||||
for (std::string& i : *stage_ns) {
|
||||
int32_t ns_idx = (int32_t)(&i - stage_ns->begin()._Ptr);
|
||||
? string_data(&stg_data->begin[(stage_ns)[ns_index]].name) : "", 0)) {
|
||||
for (int32_t& i : stage_ns) {
|
||||
int32_t ns_idx = (int32_t)(&i - stage_ns.data());
|
||||
|
||||
igPushID_Ptr(&i);
|
||||
if (igSelectable_Bool(i.c_str(), ns_index == ns_idx, 0, ImVec2_Empty)
|
||||
igPushID_Int(i);
|
||||
if (igSelectable_Bool(string_data(&stg_data->begin[stage_ns[i]].name),
|
||||
ns_index == ns_idx, 0, ImVec2_Empty)
|
||||
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| (igIsItemFocused() && ns_index != ns_idx)) {
|
||||
stage_test->ns_index = -1;
|
||||
@@ -362,7 +340,7 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
|
||||
if (ns_index != stage_test->ns_index) {
|
||||
stage_test->stage_load = true;
|
||||
stage_test->stage_name = (*stage_ns)[ns_index].c_str();
|
||||
stage_test->stage_index_load = stage_ns[ns_index];
|
||||
stage_test->ns_index = ns_index;
|
||||
}
|
||||
|
||||
@@ -372,12 +350,13 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
igSameLine(0.0f, 1.0f);
|
||||
igSetNextItemWidth(160.0f);
|
||||
if (igBeginCombo("##Other Index", other_index > -1
|
||||
? (*stage_other)[other_index].c_str() : "", 0)) {
|
||||
for (std::string& i : *stage_other) {
|
||||
int32_t other_idx = (int32_t)(&i - stage_other->begin()._Ptr);
|
||||
? string_data(&stg_data->begin[stage_other[ns_index]].name) : "", 0)) {
|
||||
for (int32_t& i : stage_other) {
|
||||
int32_t other_idx = (int32_t)(&i - stage_other.data());
|
||||
|
||||
igPushID_Ptr(&i);
|
||||
if (igSelectable_Bool(i.c_str(), other_index == other_idx, 0, ImVec2_Empty)
|
||||
igPushID_Int(i);
|
||||
if (igSelectable_Bool(string_data(&stg_data->begin[stage_other[i]].name),
|
||||
other_index == other_idx, 0, ImVec2_Empty)
|
||||
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| (igIsItemFocused() && other_index != other_idx)) {
|
||||
stage_test->other_index = -1;
|
||||
@@ -395,7 +374,7 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
|
||||
if (other_index != stage_test->other_index) {
|
||||
stage_test->stage_load = true;
|
||||
stage_test->stage_name = (*stage_other)[other_index].c_str();
|
||||
stage_test->stage_index_load = stage_other[other_index];
|
||||
stage_test->other_index = other_index;
|
||||
}
|
||||
|
||||
@@ -428,22 +407,31 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
|
||||
if (stage_index != stage_test->stage_index) {
|
||||
stage_test->stage_load = true;
|
||||
stage_test->stage_name = string_data(&stg_data->begin[stage_index].name);
|
||||
stage_test->stage_index_load = stage_index;
|
||||
stage_test->stage_index = stage_index;
|
||||
}
|
||||
|
||||
stage* stg = (stage*)stage_test->rctx->stage;
|
||||
if (!stg)
|
||||
if (stage_test_data.stage_data)
|
||||
stg = &stage_test_data;
|
||||
else
|
||||
stg = &stage_stgtst;
|
||||
stage* stg = task_stage_get_current_stage();
|
||||
if (stg) {
|
||||
igCheckbox("Stage display", &stg->stage_display);
|
||||
igCheckbox("[Ring]", &stg->ring);
|
||||
igCheckbox("[Ground]", &stg->ground);
|
||||
igCheckbox("[Sky]", &stg->sky);
|
||||
igCheckbox("Effects display", &stg->effects);
|
||||
|
||||
igCheckbox("Stage display", &stg->display);
|
||||
igCheckbox("[Ring]", &stg->ring);
|
||||
igCheckbox("[Ground]", &stg->ground);
|
||||
igCheckbox("[Sky]", &stg->sky);
|
||||
igCheckbox("Effects display", &stg->effects);
|
||||
}
|
||||
else {
|
||||
bool stage_display = true;
|
||||
igCheckbox("Stage display", &stage_display);
|
||||
bool ring = true;
|
||||
igCheckbox("[Ring]", &ring);
|
||||
bool ground = true;
|
||||
igCheckbox("[Ground]", &ground);
|
||||
bool sky = true;
|
||||
igCheckbox("[Sky]", &sky);
|
||||
bool effects_display = true;
|
||||
igCheckbox("Effects display", &effects_display);
|
||||
}
|
||||
|
||||
data->imgui_focus |= igIsWindowFocused(0);
|
||||
igEnd();
|
||||
@@ -454,28 +442,15 @@ bool data_test_stage_test_show(class_data* data) {
|
||||
if (!stage_test)
|
||||
return false;
|
||||
|
||||
bool ret = false;
|
||||
lock_trylock(&pv_lock);
|
||||
if (!lock_data_init(&stage_data_lock, &data->lock, data, (void(*)(void*))data_test_stage_test_hide))
|
||||
goto End;
|
||||
task_stage_load("DATA_TEST_STG_STAGE");
|
||||
task_stage_set_stage_index(stage_test->stage_index);
|
||||
|
||||
ret = true;
|
||||
|
||||
End:
|
||||
lock_unlock(&pv_lock);
|
||||
return ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool data_test_stage_test_dispose(class_data* data) {
|
||||
lock_data_free(&stage_data_lock, (void(*)(void*))data_test_stage_test_dispose);
|
||||
|
||||
data_test_stage_test* stage_test = (data_test_stage_test*)data->data;
|
||||
if (stage_test) {
|
||||
stage_test->stage_pv = {};
|
||||
stage_test->stage_ns = {};
|
||||
stage_test->stage_other = {};
|
||||
}
|
||||
free(data->data);
|
||||
delete stage_test;
|
||||
|
||||
data->flags = (class_flags)(CLASS_HIDDEN | CLASS_DISPOSED);
|
||||
data->imgui_focus = false;
|
||||
@@ -488,10 +463,6 @@ static int data_test_stage_test_stage_pv_quicksort_compare_func(void const* src1
|
||||
return pv1 > pv2 ? 1 : (pv1 < pv2 ? -1 : 0);
|
||||
}
|
||||
|
||||
static void data_test_stage_test_stage_pv_free(data_test_stage_test_stage_pv* pv) {
|
||||
pv->stage = {};
|
||||
}
|
||||
|
||||
data_test_stage_test_stage_pv::data_test_stage_test_stage_pv(int32_t pv_id) {
|
||||
this->pv_id = pv_id;
|
||||
}
|
||||
@@ -499,3 +470,12 @@ data_test_stage_test_stage_pv::data_test_stage_test_stage_pv(int32_t pv_id) {
|
||||
data_test_stage_test_stage_pv::~data_test_stage_test_stage_pv() {
|
||||
|
||||
}
|
||||
|
||||
data_test_stage_test::data_test_stage_test() : pv_id(), pv_index(), ns_index(),
|
||||
other_index(), stage_index(), stage_index_load(), stage_load(), rctx() {
|
||||
|
||||
}
|
||||
|
||||
data_test_stage_test::~data_test_stage_test() {
|
||||
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ void data_view_auth_3d_imgui(class_data* data) {
|
||||
if (auth->camera_root.size() > 1
|
||||
&& igTreeNodeEx_Str("Camera Root", tree_node_flags)) {
|
||||
for (auth_3d_camera_root& l : auth->camera_root)
|
||||
data_view_auth_3d_imgui_auth_3d_camera_root(&l, &l - auth->camera_root.begin()._Ptr);
|
||||
data_view_auth_3d_imgui_auth_3d_camera_root(&l, &l - auth->camera_root.data());
|
||||
igTreePop();
|
||||
}
|
||||
else if (auth->camera_root.size() == 1)
|
||||
|
||||
@@ -432,11 +432,6 @@ static bool glitter_editor_hash_input(glitter_editor_struct* glt_edt,
|
||||
const char* label, uint64_t* hash);
|
||||
|
||||
bool glitter_editor_init(class_data* data, render_context* rctx) {
|
||||
if (!lock_data_init(&glitter_data_lock, &data->lock, data, (void(*)(void*))glitter_editor_dispose))
|
||||
return false;
|
||||
|
||||
bool ret = false;
|
||||
lock_trylock(&pv_lock);
|
||||
data->data = force_malloc_s(glitter_editor_struct, 1);
|
||||
|
||||
LARGE_INTEGER time;
|
||||
@@ -460,8 +455,6 @@ bool glitter_editor_init(class_data* data, render_context* rctx) {
|
||||
glitter_editor_reset(glt_edt);
|
||||
glitter_editor_gl_load(glt_edt);
|
||||
}
|
||||
ret = true;
|
||||
lock_unlock(&pv_lock);
|
||||
|
||||
/*char* path_x = "VRFL\\";
|
||||
vector_old_string files_x = vector_old_empty(string);
|
||||
@@ -478,7 +471,7 @@ bool glitter_editor_init(class_data* data, render_context* rctx) {
|
||||
glitter_file_reader* fr = 0;
|
||||
if (files_x.begin) {
|
||||
stream s;
|
||||
io_wopen(&s, L"name_VRFL.glitter.txt", L"rb");
|
||||
io_open(&s, L"name_VRFL.glitter.txt", L"rb");
|
||||
size_t length = s.length;
|
||||
uint8_t* data = force_malloc(length);
|
||||
io_read(&s, data, length);
|
||||
@@ -626,7 +619,7 @@ bool glitter_editor_init(class_data* data, render_context* rctx) {
|
||||
}
|
||||
|
||||
stream s;
|
||||
io_wopen(&s, L"name_F2.glitter.txt", L"rb");
|
||||
io_open(&s, L"name_F2.glitter.txt", L"rb");
|
||||
size_t length = s.length;
|
||||
uint8_t* data = force_malloc(length);
|
||||
io_read(&s, data, length);
|
||||
@@ -704,7 +697,7 @@ bool glitter_editor_init(class_data* data, render_context* rctx) {
|
||||
vector_old_string_free(&files_ft);
|
||||
free(data);
|
||||
glt_edt->effect_group = 0;*/
|
||||
return ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
void glitter_editor_ctrl(class_data* data) {
|
||||
@@ -767,7 +760,7 @@ void glitter_editor_ctrl(class_data* data) {
|
||||
if (j > -1) {
|
||||
uint64_t hash = eg->resource_hashes[j];
|
||||
eg->resource_hashes.erase(eg->resource_hashes.begin() + j);
|
||||
vector_old_txp_erase(&eg->resources_tex, j, txp_free);
|
||||
eg->resources_tex.textures.erase(eg->resources_tex.textures.begin() + j);
|
||||
eg->resources_count--;
|
||||
|
||||
uint64_t empty_hash = eg->type != GLITTER_FT
|
||||
@@ -808,7 +801,7 @@ void glitter_editor_ctrl(class_data* data) {
|
||||
else if (glt_edt->resource_flags & GLITTER_EDITOR_MOVE_UP) {
|
||||
size_t rc = eg->resources_count;
|
||||
uint64_t* rh = eg->resource_hashes.data();
|
||||
txp* rt = eg->resources_tex.begin;
|
||||
txp* rt = eg->resources_tex.textures.data();
|
||||
|
||||
ssize_t j = -1;
|
||||
for (size_t i = 0; i < rc; i++)
|
||||
@@ -831,7 +824,7 @@ void glitter_editor_ctrl(class_data* data) {
|
||||
else if (glt_edt->resource_flags & GLITTER_EDITOR_MOVE_DOWN) {
|
||||
size_t rc = eg->resources_count;
|
||||
uint64_t* rh = eg->resource_hashes.data();
|
||||
txp* rt = eg->resources_tex.begin;
|
||||
txp* rt = eg->resources_tex.textures.data();
|
||||
|
||||
ssize_t j = -1;
|
||||
for (size_t i = 0; i < rc; i++)
|
||||
@@ -1105,19 +1098,19 @@ void glitter_editor_ctrl(class_data* data) {
|
||||
if (e->data.name_hash == hash_murmurhash_empty)
|
||||
continue;
|
||||
|
||||
uint32_t* hash = 0;
|
||||
for (uint32_t j : hashes)
|
||||
if (e->data.name_hash == j) {
|
||||
hash = &j;
|
||||
std::vector<uint32_t>::iterator hash = hashes.end();
|
||||
for (std::vector<uint32_t>::iterator j = hashes.begin(); j != hashes.end(); j++)
|
||||
if (e->data.name_hash == *j) {
|
||||
hash = j;
|
||||
break;
|
||||
}
|
||||
|
||||
if (hash == hashes.end()._Ptr) {
|
||||
if (hash == hashes.end()) {
|
||||
load_success = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string* s = &ds->glitter_list_names[hash - hashes.data()];
|
||||
std::string* s = &ds->glitter_list_names[hash - hashes.begin()];
|
||||
size_t len = s->size();
|
||||
memcpy(e->name, s->c_str(), min(len, 0x7F));
|
||||
}
|
||||
@@ -1144,17 +1137,19 @@ void glitter_editor_ctrl(class_data* data) {
|
||||
if (e->data.name_hash == hash_fnv1a64m_empty)
|
||||
continue;
|
||||
|
||||
uint64_t* hash = 0;
|
||||
for (uint64_t j : hashes)
|
||||
if (e->data.name_hash == j)
|
||||
std::vector<uint64_t>::iterator hash = hashes.end();
|
||||
for (std::vector<uint64_t>::iterator j = hashes.begin(); j != hashes.end(); j++)
|
||||
if (e->data.name_hash == *j) {
|
||||
hash = j;
|
||||
break;
|
||||
}
|
||||
|
||||
if (hash == hashes.end()._Ptr) {
|
||||
if (hash == hashes.end()) {
|
||||
load_success = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string* s = &ds->glitter_list_names[hash - hashes.data()];
|
||||
std::string* s = &ds->glitter_list_names[hash - hashes.begin()];
|
||||
size_t len = s->size();
|
||||
memcpy(e->name, s->c_str(), min(len, 0x7F));
|
||||
}
|
||||
@@ -1308,8 +1303,6 @@ void glitter_editor_input(class_data* data) {
|
||||
bool glitter_editor_dispose(class_data* data) {
|
||||
GPM_VAL.FreeScenes();
|
||||
|
||||
lock_data_free(&glitter_data_lock, (void(*)(void*))glitter_editor_dispose);
|
||||
|
||||
glitter_editor_struct* glt_edt = (glitter_editor_struct*)data->data;
|
||||
if (glt_edt) {
|
||||
glitter_editor_gl_free(glt_edt);
|
||||
@@ -1799,7 +1792,7 @@ static void glitter_editor_save_file(glitter_editor_struct* glt_edt, char* path,
|
||||
|
||||
farc f;
|
||||
if (glitter_diva_effect_unparse_file(glt_type, glt_edt->effect_group, &st)) {
|
||||
f2_struct_mwrite(&st, &ff_dve.data, &ff_dve.size, true, false);
|
||||
f2_struct_write(&st, &ff_dve.data, &ff_dve.size, true, false);
|
||||
ff_dve.name = std::string(file);
|
||||
ff_dve.name += ".dve";
|
||||
f2_struct_free(&st);
|
||||
@@ -1808,7 +1801,7 @@ static void glitter_editor_save_file(glitter_editor_struct* glt_edt, char* path,
|
||||
goto End;
|
||||
|
||||
if (glitter_diva_resource_unparse_file(glt_edt->effect_group, &st)) {
|
||||
f2_struct_mwrite(&st, &ff_drs.data, &ff_drs.size, true, false);
|
||||
f2_struct_write(&st, &ff_drs.data, &ff_drs.size, true, false);
|
||||
ff_drs.name = std::string(file);
|
||||
ff_drs.name += ".drs";
|
||||
}
|
||||
@@ -1816,7 +1809,7 @@ static void glitter_editor_save_file(glitter_editor_struct* glt_edt, char* path,
|
||||
|
||||
if (glt_type == GLITTER_FT)
|
||||
if (glitter_diva_list_unparse_file(glt_edt->effect_group, &st)) {
|
||||
f2_struct_mwrite(&st, &ff_lst.data, &ff_lst.size, true, false);
|
||||
f2_struct_write(&st, &ff_lst.data, &ff_lst.size, true, false);
|
||||
ff_lst.name = std::string(file);
|
||||
ff_lst.name += ".lst";
|
||||
}
|
||||
@@ -1881,7 +1874,7 @@ static bool glitter_editor_list_open_window(glitter_effect_group* eg) {
|
||||
ofn.lpstrTitle = L"File to Open";
|
||||
if (GetOpenFileNameW(&ofn)) {
|
||||
stream s;
|
||||
io_wopen(&s, file, L"rb");
|
||||
io_open(&s, file, L"rb");
|
||||
size_t length = s.length;
|
||||
uint8_t* data = force_malloc_s(uint8_t, length);
|
||||
io_read(&s, data, length);
|
||||
@@ -1983,13 +1976,13 @@ static bool glitter_editor_resource_import(glitter_editor_struct* glt_edt) {
|
||||
if (d->width == 0 || d->height == 0 || d->mipmaps_count == 0 || vector_old_length(d->data) < 1)
|
||||
goto DDSEnd;
|
||||
|
||||
tex = vector_old_txp_reserve_back(&eg->resources_tex);
|
||||
eg->resources_tex.textures.push_back({});
|
||||
tex = &eg->resources_tex.textures.end()[-1];
|
||||
tex->array_size = d->has_cube_map ? 6 : 1;
|
||||
tex->has_cube_map = d->has_cube_map;
|
||||
tex->mipmaps_count = d->mipmaps_count;
|
||||
|
||||
vector_old_txp_mipmap_reserve(&tex->data,
|
||||
(tex->has_cube_map ? 6LL : 1LL) * tex->mipmaps_count);
|
||||
tex->mipmaps.reserve((tex->has_cube_map ? 6LL : 1LL) * tex->mipmaps_count);
|
||||
index = 0;
|
||||
do
|
||||
for (uint32_t i = 0; i < tex->mipmaps_count; i++) {
|
||||
@@ -1999,12 +1992,11 @@ static bool glitter_editor_resource_import(glitter_editor_struct* glt_edt) {
|
||||
tex_mip.height = max(d->height >> i, 1);
|
||||
tex_mip.format = d->format;
|
||||
|
||||
uint32_t size = txp_get_size(tex_mip.format,
|
||||
tex_mip.width, tex_mip.height);
|
||||
uint32_t size = txp::get_size(tex_mip.format, tex_mip.width, tex_mip.height);
|
||||
tex_mip.size = size;
|
||||
tex_mip.data = force_malloc(size);
|
||||
memcpy(tex_mip.data, d->data.begin[index], size);
|
||||
vector_old_txp_mipmap_push_back(&tex->data, &tex_mip);
|
||||
tex_mip.data.resize(size);
|
||||
memcpy(tex_mip.data.data(), d->data.begin[index], size);
|
||||
tex->mipmaps.push_back(tex_mip);
|
||||
index++;
|
||||
}
|
||||
while (index / tex->mipmaps_count < tex->array_size);
|
||||
@@ -2048,11 +2040,11 @@ static bool glitter_editor_resource_export(glitter_editor_struct* glt_edt) {
|
||||
dds* d = dds_init();
|
||||
|
||||
glitter_effect_group* eg = glt_edt->effect_group;
|
||||
txp tex = eg->resources_tex.begin[sel_rsrc];
|
||||
txp& tex = eg->resources_tex.textures[sel_rsrc];
|
||||
|
||||
txp_format format = tex.data.begin[0].format;
|
||||
uint32_t width = tex.data.begin[0].width;
|
||||
uint32_t height = tex.data.begin[0].height;
|
||||
txp_format format = tex.mipmaps[0].format;
|
||||
uint32_t width = tex.mipmaps[0].width;
|
||||
uint32_t height = tex.mipmaps[0].height;
|
||||
|
||||
d->format = format;
|
||||
d->width = width;
|
||||
@@ -2065,9 +2057,9 @@ static bool glitter_editor_resource_export(glitter_editor_struct* glt_edt) {
|
||||
uint32_t index = 0;
|
||||
do
|
||||
for (uint32_t i = 0; i < tex.mipmaps_count; i++) {
|
||||
uint32_t size = txp_get_size(format, max(width >> i, 1), max(height >> i, 1));
|
||||
uint32_t size = txp::get_size(format, max(width >> i, 1), max(height >> i, 1));
|
||||
void* data = force_malloc(size);
|
||||
memcpy(data, tex.data.begin[index].data, size);
|
||||
memcpy(data, tex.mipmaps[index].data.data(), size);
|
||||
vector_old_ptr_void_push_back(&d->data, &data);
|
||||
index++;
|
||||
}
|
||||
@@ -2090,10 +2082,8 @@ static void glitter_editor_test_window(glitter_editor_struct* glt_edt, class_dat
|
||||
float_t x;
|
||||
float_t y;
|
||||
|
||||
float_t w = min((float_t)width, 360.0f);
|
||||
float_t h = min((float_t)height, 326.0f);
|
||||
|
||||
float_t frame_counter;
|
||||
float_t w = 280.0f;
|
||||
float_t h = 326.0f;
|
||||
|
||||
igSetNextWindowPos(ImVec2_Empty, ImGuiCond_FirstUseEver, ImVec2_Empty);
|
||||
igSetNextWindowSize({ w, h }, ImGuiCond_Always);
|
||||
@@ -2138,13 +2128,12 @@ static void glitter_editor_test_window(glitter_editor_struct* glt_edt, class_dat
|
||||
|
||||
igSeparator();
|
||||
|
||||
frame_counter = glt_edt->frame_counter;
|
||||
glt_edt->old_frame_counter = glt_edt->frame_counter;
|
||||
imguiColumnSliderFloat("Frame", &glt_edt->frame_counter, 1.0f,
|
||||
(float_t)glt_edt->start_frame, (float_t)glt_edt->end_frame, "%.0f", 0, true);
|
||||
glt_edt->input_pause_temp = imgui_is_item_activated;
|
||||
|
||||
igText("Start/End Frame: %d/%d %d", glt_edt->start_frame, glt_edt->end_frame, (int32_t)glt_edt->input_pause_temp);
|
||||
igText("Start/End Frame: %d/%d", glt_edt->start_frame, glt_edt->end_frame);
|
||||
|
||||
imguiColumnSliderFloat("Emission", &GPM_VAL.emission, 0.01f, 1.0f, 2.0f, "%.2f", 0, true);
|
||||
|
||||
@@ -2638,7 +2627,7 @@ static void glitter_editor_resources(glitter_editor_struct* glt_edt) {
|
||||
texture** r = eg->resources;
|
||||
int32_t rc = eg->resources_count;
|
||||
uint64_t* rh = eg->resource_hashes.data();
|
||||
txp* rt = eg->resources_tex.begin;
|
||||
txp* rt = eg->resources_tex.textures.data();
|
||||
igPushID_Ptr(eg);
|
||||
ssize_t i_idx = 1;
|
||||
for (int32_t i = 0; i < rc; i++, i_idx++) {
|
||||
@@ -2646,7 +2635,7 @@ static void glitter_editor_resources(glitter_editor_struct* glt_edt) {
|
||||
igPushID_Int(i);
|
||||
igSelectable_Bool(buf, i == sel_rsrc, 0, { 0.0f, 0.0f });
|
||||
if (igIsItemHovered(0)) {
|
||||
txp_mipmap* rtm = rt[i].data.begin;
|
||||
txp_mipmap* rtm = rt[i].mipmaps.data();
|
||||
float_t aspect = (float_t)rtm->width / (float_t)rtm->height;
|
||||
|
||||
ImVec2 size = { 192.0f, 192.0f };
|
||||
@@ -2787,8 +2776,9 @@ static void glitter_editor_play_manager(glitter_editor_struct* glt_edt) {
|
||||
igSeparator();
|
||||
|
||||
glt_edt->old_frame_counter = glt_edt->frame_counter;
|
||||
glt_edt->input_pause_temp = imguiColumnSliderFloat("Frame", &glt_edt->frame_counter, 1.0f,
|
||||
imguiColumnSliderFloat("Frame", &glt_edt->frame_counter, 1.0f,
|
||||
(float_t)glt_edt->start_frame, (float_t)glt_edt->end_frame, "%.0f", 0, true);
|
||||
glt_edt->input_pause_temp = imgui_is_item_activated;
|
||||
|
||||
igText("Start/End Frame: %d/%d", glt_edt->start_frame, glt_edt->end_frame);
|
||||
|
||||
@@ -4250,7 +4240,7 @@ static bool glitter_editor_property_particle_texture(glitter_editor_struct* glt_
|
||||
size_t rc = eg->resources_count;
|
||||
texture** r = eg->resources;
|
||||
uint64_t* rh = eg->resource_hashes.data();
|
||||
txp* rt = eg->resources_tex.begin;
|
||||
txp* rt = eg->resources_tex.textures.data();
|
||||
|
||||
const uint64_t empty_hash = eg->type != GLITTER_FT
|
||||
? hash_murmurhash_empty : hash_fnv1a64m_empty;
|
||||
@@ -4362,7 +4352,7 @@ static bool glitter_editor_property_particle_texture(glitter_editor_struct* glt_
|
||||
}
|
||||
|
||||
|
||||
txp_mipmap* rtm = rt[n - 1].data.begin;
|
||||
txp_mipmap* rtm = rt[n - 1].mipmaps.data();
|
||||
float_t aspect1 = (float_t)rtm->width / (float_t)rtm->height;
|
||||
float_t aspect2 = aspect1;
|
||||
if (particle->data.split_u * particle->data.split_v > 1)
|
||||
|
||||
@@ -198,8 +198,12 @@ void graphics_post_process_imgui(class_data* data) {
|
||||
}
|
||||
imguiColumnSliderFloat("distance to focus[m]",
|
||||
&dof->data.debug.distance_to_focus, 0.01f, 0.01f, 30.0f, "%.2f", 0, true);
|
||||
|
||||
float_t focal_length = dof->data.debug.focal_length * 1000.0f;
|
||||
imguiColumnSliderFloat("focal length[mm]",
|
||||
&dof->data.debug.focal_length, 0.01f, 0.1f, 100.0f, "%.2f", 0, true);
|
||||
&focal_length, 0.01f, 0.1f, 100.0f, "%.2f", 0, true);
|
||||
dof->data.debug.focal_length = focal_length / 1000.0f;
|
||||
|
||||
imguiColumnSliderFloat("F-Number",
|
||||
&dof->data.debug.f_number, 0.01f, 0.1f, 40.0f, "%.2f", 0, true);
|
||||
if (!phys) {
|
||||
@@ -227,12 +231,9 @@ void graphics_post_process_imgui(class_data* data) {
|
||||
igTreePop();
|
||||
}
|
||||
|
||||
if (imguiButton("Reset Post Process", ImVec2_Empty) && rctx->stage) {
|
||||
stage* stg = (stage*)rctx->stage;
|
||||
//light_param_data* light_param = light_param_storage_get_light_param_data(stg->light_param_name);
|
||||
post_process_reset(pp);
|
||||
//if (light_param->glow.ready)
|
||||
//render_context_light_param_data_glow_set(rctx, &light_param->glow);
|
||||
if (imguiButton("Reset Post Process", ImVec2_Empty)) {
|
||||
stage* stg = task_stage_get_current_stage();
|
||||
light_param_storage_data_set_stage(stg->index);
|
||||
}
|
||||
|
||||
data->imgui_focus |= igIsWindowFocused(0);
|
||||
|
||||
@@ -16,6 +16,7 @@ extern timer render_timer;
|
||||
extern timer sound_timer;
|
||||
extern timer input_timer;
|
||||
|
||||
extern size_t render_scale_table_count;
|
||||
extern double_t render_get_scale();
|
||||
extern void render_set_scale(double_t value);
|
||||
extern int32_t render_get_scale_index();
|
||||
@@ -43,11 +44,11 @@ void graphics_render_settings_imgui(class_data* data) {
|
||||
ImGuiStyle* style = igGetStyle();
|
||||
ImFont* font = igGetFont();
|
||||
|
||||
float_t w = min((float_t)width / 4.0f, 280.0f);
|
||||
float_t w = 280.0f;
|
||||
#if defined(CLOUD_DEV)
|
||||
float_t h = min((float_t)height, 196.0f);
|
||||
float_t h = 196.0f;
|
||||
#else
|
||||
float_t h = min((float_t)height, 86.0f);
|
||||
float_t h = 86.0f;
|
||||
#endif
|
||||
|
||||
igSetNextWindowPos(ImVec2_Empty, ImGuiCond_Appearing, ImVec2_Empty);
|
||||
@@ -73,7 +74,7 @@ void graphics_render_settings_imgui(class_data* data) {
|
||||
int32_t scale_index = render_get_scale_index();
|
||||
char buf[0x80];
|
||||
snprintf(buf, sizeof(buf), "%g%%%%", scale);
|
||||
if (imguiColumnSliderInt("Scale", &scale_index, 0, 7, buf, ImGuiSliderFlags_NoInput, true))
|
||||
if (imguiColumnSliderInt("Scale", &scale_index, 0, (int32_t)render_scale_table_count, buf, ImGuiSliderFlags_NoInput, true))
|
||||
render_set_scale_index(scale_index);
|
||||
|
||||
#if defined(CLOUD_DEV)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "information.h"
|
||||
#include "information/frame_speed.h"
|
||||
#include "information/task.h"
|
||||
|
||||
classes_data information_classes[] = {
|
||||
{
|
||||
@@ -29,4 +30,26 @@ classes_data information_classes[] = {
|
||||
0,
|
||||
0,
|
||||
},
|
||||
{
|
||||
"Task##Information",
|
||||
CLASSES_IN_CONTEXT_MENU,
|
||||
information_task_init,
|
||||
CLASSES_DATA_NO_FUNC,
|
||||
CLASSES_DATA_NO_FUNC,
|
||||
CLASSES_DATA_NO_FUNC,
|
||||
CLASSES_DATA_NO_FUNC,
|
||||
information_task_imgui,
|
||||
CLASSES_DATA_NO_FUNC,
|
||||
CLASSES_DATA_NO_FUNC,
|
||||
CLASSES_DATA_NO_FUNC,
|
||||
information_task_dispose,
|
||||
{
|
||||
{},
|
||||
(class_flags)(CLASS_DISPOSED | CLASS_HIDDEN),
|
||||
false,
|
||||
CLASS_DATA_NO_DATA,
|
||||
},
|
||||
0,
|
||||
0,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
|
||||
#include "frame_speed.h"
|
||||
#include "../../../KKdLib/vec.h"
|
||||
#include "../imgui_helper.h"
|
||||
|
||||
extern int32_t width;
|
||||
@@ -45,11 +44,6 @@ void information_frame_speed_imgui(class_data* data) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImGuiColorEditFlags color_edit_flags = 0;
|
||||
color_edit_flags |= ImGuiColorEditFlags_NoLabel;
|
||||
color_edit_flags |= ImGuiColorEditFlags_NoSidePreview;
|
||||
color_edit_flags |= ImGuiColorEditFlags_NoDragDrop;
|
||||
|
||||
imguiGetContentRegionAvailSetNextItemWidth();
|
||||
imguiColumnSliderFloat("frame speed", &frame_speed, 0.01f, 0.0f, 3.0f, "%.2f", 0, true);
|
||||
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "task.h"
|
||||
#include "../../../KKdLib/sort.h"
|
||||
#include "../../../KKdLib/str_utils.h"
|
||||
#include "../../../CRE/task.h"
|
||||
#include "../imgui_helper.h"
|
||||
|
||||
extern int32_t width;
|
||||
extern int32_t height;
|
||||
extern float_t task;
|
||||
|
||||
static const char* information_task_window_title = "Task##Information";
|
||||
|
||||
static int32_t task_sort_by_calc(void const* src1, void const* src2);
|
||||
static int32_t task_sort_by_disp(void const* src1, void const* src2);
|
||||
static int32_t task_sort_by_name(void const* src1, void const* src2);
|
||||
|
||||
bool information_task_init(class_data* data, render_context* rctx) {
|
||||
data->data = force_malloc_s(int32_t, 1);
|
||||
information_task_dispose(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
void information_task_imgui(class_data* data) {
|
||||
int32_t& task_sort = *(int32_t*)data->data;
|
||||
if (!data->data)
|
||||
return;
|
||||
|
||||
ImGuiIO* io = igGetIO();
|
||||
ImGuiStyle* style = igGetStyle();
|
||||
ImFont* font = igGetFont();
|
||||
|
||||
float_t w = 496.0f;
|
||||
float_t h = 240.0f;
|
||||
|
||||
igSetNextWindowPos(ImVec2_Empty, ImGuiCond_Appearing, ImVec2_Empty);
|
||||
igSetNextWindowSize({ w, h }, ImGuiCond_Always);
|
||||
|
||||
ImGuiWindowFlags window_flags = 0;
|
||||
window_flags |= ImGuiWindowFlags_NoResize;
|
||||
|
||||
data->imgui_focus = false;
|
||||
bool open = data->flags & CLASS_HIDDEN ? false : true;
|
||||
bool collapsed = !igBegin(information_task_window_title, &open, window_flags);
|
||||
if (!open) {
|
||||
enum_or(data->flags, CLASS_HIDE);
|
||||
igEnd();
|
||||
return;
|
||||
}
|
||||
else if (collapsed) {
|
||||
igEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<Task*> vec;
|
||||
for (int32_t i = 0; ; i++) {
|
||||
Task* t = TaskWork::GetTaskByIndex(i);
|
||||
if (!t)
|
||||
break;
|
||||
|
||||
vec.push_back(t);
|
||||
}
|
||||
|
||||
switch (task_sort) {
|
||||
case 2:
|
||||
quicksort_custom(vec.data(), vec.size(), sizeof(Task*), task_sort_by_name);
|
||||
break;
|
||||
case 3:
|
||||
quicksort_custom(vec.data(), vec.size(), sizeof(Task*), task_sort_by_calc);
|
||||
break;
|
||||
case 4:
|
||||
quicksort_custom(vec.data(), vec.size(), sizeof(Task*), task_sort_by_disp);
|
||||
break;
|
||||
}
|
||||
|
||||
ImVec2 size;
|
||||
igGetContentRegionAvail(&size);
|
||||
size.y -= font->FontSize + style->ItemSpacing.y;
|
||||
igBeginListBox("#Tasks", size);
|
||||
for (Task*& i : vec) {
|
||||
char buf[0x100];
|
||||
sprintf_s(buf, sizeof(buf), "%-32s % 7d(% 7d) % 7d(% 7d)",
|
||||
i->GetName(), i->GetCalcTime(), i->GetCalcTimeMax(), i->GetDispTime(), i->GetDispTimeMax());
|
||||
igSelectable_Bool((const char*)buf, false, 0, ImVec2_Empty);
|
||||
}
|
||||
igEndListBox();
|
||||
vec.clear();
|
||||
|
||||
int32_t task_sort_new = task_sort;
|
||||
igText("(%c)exec", task_sort == 0 ? '*' : ' ');
|
||||
if (igIsItemClicked(ImGuiMouseButton_Left))
|
||||
task_sort_new = 0;
|
||||
|
||||
igSameLine(0.0f, -1.0f);
|
||||
|
||||
igText("(%c)tree", task_sort == 1 ? '*' : ' ');
|
||||
if (igIsItemClicked(ImGuiMouseButton_Left))
|
||||
task_sort_new = 1;
|
||||
|
||||
igSameLine(0.0f, -1.0f);
|
||||
|
||||
igText("(%c)name", task_sort == 2 ? '*' : ' ');
|
||||
if (igIsItemClicked(ImGuiMouseButton_Left))
|
||||
task_sort_new = 2;
|
||||
|
||||
igSameLine(0.0f, -1.0f);
|
||||
|
||||
igText("(%c)calc", task_sort == 3 ? '*' : ' ');
|
||||
if (igIsItemClicked(ImGuiMouseButton_Left))
|
||||
task_sort_new = 3;
|
||||
|
||||
igSameLine(0.0f, -1.0f);
|
||||
|
||||
igText("(%c)disp", task_sort == 4 ? '*' : ' ');
|
||||
if (igIsItemClicked(ImGuiMouseButton_Left))
|
||||
task_sort_new = 4;
|
||||
|
||||
task_sort = task_sort_new;
|
||||
|
||||
data->imgui_focus |= igIsWindowFocused(0);
|
||||
igEnd();
|
||||
}
|
||||
|
||||
bool information_task_dispose(class_data* data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static int32_t task_sort_by_calc(void const* src1, void const* src2) {
|
||||
Task* t1 = *(Task**)src1;
|
||||
Task* t2 = *(Task**)src2;
|
||||
return t2->calc_time - t1->calc_time;
|
||||
}
|
||||
|
||||
static int32_t task_sort_by_disp(void const* src1, void const* src2) {
|
||||
Task* t1 = *(Task**)src1;
|
||||
Task* t2 = *(Task**)src2;
|
||||
return t2->disp_time - t1->disp_time;
|
||||
}
|
||||
|
||||
static int32_t task_sort_by_name(void const* src1, void const* src2) {
|
||||
Task* t1 = *(Task**)src1;
|
||||
Task* t2 = *(Task**)src2;
|
||||
return str_utils_compare(t1->name, t2->name);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.h"
|
||||
#include "../../classes.h"
|
||||
|
||||
extern bool information_task_init(class_data* data, render_context* rctx);
|
||||
extern void information_task_imgui(class_data* data);
|
||||
extern bool information_task_dispose(class_data* data);
|
||||
@@ -141,6 +141,13 @@ static void input_poll() {
|
||||
if (input_is_down('D'))
|
||||
input_move.y += speed;
|
||||
|
||||
if (input_is_down(VK_SHIFT))
|
||||
speed = input_movement_speed * 2.0;
|
||||
else if (input_is_down(VK_CONTROL))
|
||||
speed = input_movement_speed / 2.0;
|
||||
else
|
||||
speed = input_movement_speed;
|
||||
speed *= freq / freq_hist;
|
||||
speed *= 10.0;
|
||||
|
||||
if (input_is_down(VK_UP))
|
||||
|
||||
+2
-2
@@ -132,7 +132,7 @@ static void a3da_to_dft_dsc(const char* a3da_path, int32_t pv_id) {
|
||||
io_free(&s_dsc);
|
||||
|
||||
stream s_dft;
|
||||
io_mopen(&s_dft, 0, 0);
|
||||
io_open(&s_dft);
|
||||
uint32_t off;
|
||||
vector_old_enrs_entry e = vector_old_empty(enrs_entry);
|
||||
enrs_entry ee;
|
||||
@@ -159,7 +159,7 @@ static void a3da_to_dft_dsc(const char* a3da_path, int32_t pv_id) {
|
||||
memset(&st, 0, sizeof(f2_struct));
|
||||
|
||||
io_align_write(&s_dft, 0x10);
|
||||
io_mcopy(&s_dft, &st.data, &st.length);
|
||||
io_copy(&s_dft, &st.data, &st.length);
|
||||
io_free(&s_dft);
|
||||
|
||||
st.enrs = e;
|
||||
|
||||
+234
-200
@@ -33,6 +33,7 @@
|
||||
#include "../CRE/timer.h"
|
||||
#include "../CRE/post_process.h"
|
||||
#include "../KKdLib/io/path.h"
|
||||
#include "../KKdLib/database/item_table.h"
|
||||
#include"classes/imgui_helper.h"
|
||||
#include <timeapi.h>
|
||||
|
||||
@@ -40,6 +41,9 @@
|
||||
#define OPENGL_DEBUG 0
|
||||
#endif
|
||||
|
||||
#define CUBE_LINE_SIZE (0.0025f)
|
||||
#define CUBE_LINE_POINT_SIZE (CUBE_LINE_SIZE * 1.5f)
|
||||
|
||||
shader_glsl cube_line_shader;
|
||||
shader_glsl cube_line_point_shader;
|
||||
shader_glsl grid_shader;
|
||||
@@ -52,10 +56,10 @@ size_t grid_vertex_count = ((size_t)(grid_size / grid_spacing) * 2 + 1) * 4;
|
||||
|
||||
GLuint cube_line_vao;
|
||||
GLuint cube_line_vbo;
|
||||
GLuint cube_line_point_vao;
|
||||
GLuint cube_line_point_instance_vbo;
|
||||
GLuint grid_vbo;
|
||||
static GLuint common_data_ubo = 0;
|
||||
stage stage_stgtst;
|
||||
stage stage_test_data;
|
||||
|
||||
#define COMMON_DATA_SIZE (int32_t)(sizeof(vec4) + sizeof(mat4) * 3 + sizeof(vec4))
|
||||
|
||||
@@ -64,15 +68,24 @@ bool draw_grid_3d = false;
|
||||
|
||||
const double_t render_scale_table[] = {
|
||||
1.0 / 4.0, // 25%
|
||||
2.0 / 6.0, // 33.3%
|
||||
2.0 / 4.0, // 50%
|
||||
4.0 / 6.0, // 66.6%
|
||||
3.0 / 4.0, // 75%
|
||||
5.0 / 6.0, // 83.3%
|
||||
4.0 / 4.0, // 100%
|
||||
7.0 / 6.0, // 116.6%
|
||||
5.0 / 4.0, // 125%
|
||||
8.0 / 6.0, // 133.3%
|
||||
6.0 / 4.0, // 150%
|
||||
10.0 / 6.0, // 166.6%
|
||||
7.0 / 4.0, // 175%
|
||||
11.0 / 6.0, // 183.3%
|
||||
8.0 / 4.0, // 200%
|
||||
};
|
||||
|
||||
size_t render_scale_table_count = sizeof(render_scale_table) / sizeof(double_t);
|
||||
|
||||
static float_t old_scale, scale;
|
||||
|
||||
static vec2i old_internal_2d_res;
|
||||
@@ -96,7 +109,7 @@ static void render_ctrl(render_context* rctx);
|
||||
static void render_draw(render_context* rctx);
|
||||
static void render_dispose(render_context* rctx);
|
||||
|
||||
static bool render_load_shaders(void* data, char* path, char* file, uint32_t hash);
|
||||
static bool render_load_shaders(void* data, const char* path, const char* file, uint32_t hash);
|
||||
|
||||
static void render_imgui(render_context* rctx);
|
||||
|
||||
@@ -123,7 +136,6 @@ ImGuiContext* imgui_context;
|
||||
lock imgui_context_lock;
|
||||
bool global_context_menu;
|
||||
extern size_t frame_counter;
|
||||
wind* wind_ptr;
|
||||
object_database* obj_db_ptr;
|
||||
render_context* rctx_ptr;
|
||||
int32_t stage_index = -1;
|
||||
@@ -160,8 +172,8 @@ int32_t render_main(void* arg) {
|
||||
width = ris->res.x > 0 && ris->res.x < 8192 ? ris->res.x : mode->width;
|
||||
height = ris->res.y > 0 && ris->res.y < 8192 ? ris->res.y : mode->height;
|
||||
|
||||
width = (int32_t)(width / 1.5f);
|
||||
height = (int32_t)(height / 1.5f);
|
||||
width = (int32_t)(width / 2.0f);
|
||||
height = (int32_t)(height / 2.0f);
|
||||
|
||||
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
|
||||
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
|
||||
@@ -228,8 +240,6 @@ int32_t render_main(void* arg) {
|
||||
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &sv_max_texture_max_anisotropy);
|
||||
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
|
||||
|
||||
lock_init(&pv_lock);
|
||||
|
||||
lock_lock(&state_lock);
|
||||
state = RENDER_INITIALIZING;
|
||||
lock_unlock(&state_lock);
|
||||
@@ -290,8 +300,6 @@ int32_t render_main(void* arg) {
|
||||
state = RENDER_DISPOSED;
|
||||
lock_unlock(&state_lock);
|
||||
|
||||
lock_free(&pv_lock);
|
||||
|
||||
#pragma region GLFW Dispose
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
@@ -307,41 +315,40 @@ double_t render_get_scale() {
|
||||
|
||||
void render_set_scale(double_t value) {
|
||||
size_t i;
|
||||
const size_t c = sizeof(render_scale_table) / sizeof(double_t);
|
||||
for (i = 0; i < c; i++)
|
||||
for (i = 0; i < render_scale_table_count; i++)
|
||||
if (value <= render_scale_table[i]) break;
|
||||
|
||||
if (i < c)
|
||||
if (i < render_scale_table_count)
|
||||
value = render_scale_table[i];
|
||||
else if (render_scale_table_count - 1 > -1)
|
||||
value = render_scale_table[render_scale_table_count - 1];
|
||||
else
|
||||
value = render_scale_table[c - 1];
|
||||
value = 1.0;
|
||||
|
||||
scale = (float_t)value;
|
||||
}
|
||||
|
||||
int32_t render_get_scale_index() {
|
||||
size_t i;
|
||||
const size_t c = sizeof(render_scale_table) / sizeof(double_t);
|
||||
for (i = 0; i < c; i++)
|
||||
for (i = 0; i < render_scale_table_count; i++)
|
||||
if (scale <= render_scale_table[i]) break;
|
||||
|
||||
int32_t index;
|
||||
if (i < c)
|
||||
if (i < render_scale_table_count)
|
||||
index = (int32_t)i;
|
||||
else
|
||||
index = (int32_t)(c - 1);
|
||||
index = (int32_t)(render_scale_table_count - 1);
|
||||
return index;
|
||||
}
|
||||
|
||||
void render_set_scale_index(int32_t index) {
|
||||
const size_t c = sizeof(render_scale_table) / sizeof(double_t);
|
||||
double_t value;
|
||||
if (index < 0)
|
||||
value = render_scale_table[0];
|
||||
else if (index < c)
|
||||
else if (index < render_scale_table_count)
|
||||
value = render_scale_table[index];
|
||||
else
|
||||
value = render_scale_table[c - 1];
|
||||
value = render_scale_table[render_scale_table_count - 1];
|
||||
|
||||
scale = (float_t)value;
|
||||
}
|
||||
@@ -390,15 +397,10 @@ static render_context* render_load() {
|
||||
"} result;\n"
|
||||
"\n"
|
||||
"uniform mat4 vp;\n"
|
||||
"uniform vec3 trans[4];\n"
|
||||
"uniform float scale;\n"
|
||||
"uniform vec4 color;\n"
|
||||
"\n"
|
||||
"void main() {\n"
|
||||
" vec4 pos;\n"
|
||||
" pos.xyz = trans[gl_VertexID];\n"
|
||||
" pos.w = 1.0;\n"
|
||||
" gl_Position = vp * pos;\n"
|
||||
" gl_Position = vp * a_position;\n"
|
||||
" result.color = color;\n"
|
||||
"}\n";
|
||||
|
||||
@@ -416,20 +418,24 @@ static render_context* render_load() {
|
||||
|
||||
const char* cube_line_point_vert_shader =
|
||||
"#version 430 core\n"
|
||||
"layout(location = 0) in vec4 a_position;\n"
|
||||
"layout(location = 0) in vec3 i_trans;\n"
|
||||
"\n"
|
||||
"out VertexData {\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"} result;\n"
|
||||
"\n"
|
||||
"uniform mat4 vp;\n"
|
||||
"uniform mat4 mat;\n"
|
||||
"uniform vec4 color;\n"
|
||||
"uniform vec3 trans[4];\n"
|
||||
"\n"
|
||||
"void main() {\n"
|
||||
" vec4 pos = mat * a_position;\n"
|
||||
" vec4 pos;\n"
|
||||
" pos.xyz = trans[gl_VertexID] + i_trans;\n"
|
||||
" pos.w = 1.0;\n"
|
||||
" gl_Position = vp * pos;\n"
|
||||
" result.color = color;\n"
|
||||
" vec2 uv;\n"
|
||||
" uv.x = float(gl_VertexID / 2);\n"
|
||||
" uv.y = float(gl_VertexID % 2);\n"
|
||||
" result.uv = uv;\n"
|
||||
"}\n";
|
||||
|
||||
const char* cube_line_point_frag_shader =
|
||||
@@ -437,11 +443,16 @@ static render_context* render_load() {
|
||||
"layout(location = 0) out vec4 result;\n"
|
||||
"\n"
|
||||
"in VertexData {\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"} frg;\n"
|
||||
"\n"
|
||||
"uniform float dark_border_end;\n"
|
||||
"uniform float dark_border_start;\n"
|
||||
"\n"
|
||||
"void main() {\n"
|
||||
" result = frg.color;\n"
|
||||
" float blend = step(dark_border_end, frg.uv.x) * (1.0 - step(dark_border_start, frg.uv.x))"
|
||||
" * step(dark_border_end, frg.uv.y) * (1.0 - step(dark_border_start, frg.uv.y));\n"
|
||||
" result = vec4(blend, blend, blend, 1.0);\n"
|
||||
"}\n";
|
||||
|
||||
const char* grid_vert_shader =
|
||||
@@ -532,8 +543,9 @@ static render_context* render_load() {
|
||||
|
||||
render_resize_fb(rctx, true);
|
||||
|
||||
rob_chara_array_init();
|
||||
rob_chara_pv_data_array_init();
|
||||
task_auth_3d_append_task();
|
||||
TaskWork::AppendTask(&glt_particle_manager, "GLITTER_TASK", 2);
|
||||
task_rob_manager_append_task();
|
||||
|
||||
data_struct* aft_data = &data_list[DATA_AFT];
|
||||
auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db;
|
||||
@@ -545,18 +557,25 @@ static render_context* render_load() {
|
||||
|
||||
rctx->data = aft_data;
|
||||
|
||||
{
|
||||
farc chritm_prop;
|
||||
aft_data->load_file(&chritm_prop, "rom/", "chritm_prop.farc", farc::load_file);
|
||||
|
||||
farc_file* ff = chritm_prop.read_file("mikitm_tbl.txt");
|
||||
if (ff && ff->size) {
|
||||
itm_table itm;
|
||||
itm.read(ff->data, ff->size);
|
||||
itm.write("mikitm_tbl.tst");
|
||||
}
|
||||
}
|
||||
|
||||
rob_mot_tbl_init();
|
||||
rob_thread_handler_init();
|
||||
pv_osage_manager_array_ptr_init();
|
||||
|
||||
light_param_data_storage::load(aft_data);
|
||||
auth_3d_data_load_auth_3d_db(aft_auth_3d_db);
|
||||
|
||||
stage_init(&stage_stgtst);
|
||||
stage_load(&stage_stgtst, aft_data, aft_auth_3d_db,
|
||||
aft_obj_db, aft_tex_db, aft_stage_data, "STGTST", rctx);
|
||||
stage_set(&stage_stgtst, rctx);
|
||||
|
||||
stage_init(&stage_test_data);
|
||||
stage_test_data.set_id = -1;
|
||||
stage_test_data.stage_set_id = -1;
|
||||
|
||||
object_set_info* set_info;
|
||||
object_set_load_db_entry(&set_info, aft_data, aft_obj_db, "MIKITM000");
|
||||
object_set_load_db_entry(&set_info, aft_data, aft_obj_db, "MIKITM001");
|
||||
@@ -571,33 +590,44 @@ static render_context* render_load() {
|
||||
motion_set_load_motion(aft_mot_db->get_motion_set_id("PV824"), 0, aft_mot_db);
|
||||
|
||||
rob_chara_pv_data pv_data;
|
||||
rob_chara_pv_data_init(&pv_data);
|
||||
pv_data.field_0 = 2;
|
||||
int32_t chara_id = rob_chara_array_init_chara_index(CHARA_MIKU, &pv_data, 0, false);
|
||||
rob_chara_id_array[0] = chara_id;
|
||||
if (chara_id >= 0 && chara_id < ROB_CHARA_COUNT) {
|
||||
rob_chara_reset_data(&rob_chara_array[chara_id], &rob_chara_array[chara_id].pv_data, aft_bone_data, aft_mot_db);
|
||||
rob_chara_reset(&rob_chara_array[chara_id], aft_bone_data, aft_data, aft_obj_db);
|
||||
rob_chara_load_motion(&rob_chara_array[chara_id],
|
||||
aft_mot_db->get_motion_id("PV824_STF_P1_00"), 2, aft_bone_data, aft_mot_db);
|
||||
rob_chara_set_visibility(&rob_chara_array[chara_id], true);
|
||||
//rob_chara_set_frame(&rob_chara_array[chara_id], 1000.0f);
|
||||
}
|
||||
for (int32_t i = 0; i < 120; i++)
|
||||
TaskWork::Ctrl();
|
||||
|
||||
float_t cube_line_verts[] = {
|
||||
-1.0, 1.0,
|
||||
1.0, 1.0,
|
||||
-1.0, -1.0,
|
||||
1.0, -1.0,
|
||||
};
|
||||
int32_t motion_id = aft_mot_db->get_motion_id("PV824_STF_P1_00");
|
||||
rob_chara_set_motion_id(&rob_chara_array[chara_id], motion_id, 0.0f,
|
||||
motion_storage_get_mot_data_frame_count(motion_id, aft_mot_db),
|
||||
false, true, MOTION_BLEND_CROSS, aft_bone_data, aft_mot_db);
|
||||
rob_chara_set_visibility(&rob_chara_array[chara_id], true);
|
||||
rob_chara_set_frame(&rob_chara_array[chara_id], 0.0f);
|
||||
rob_chara_item_equip* rob_item_equip = rob_chara_array[chara_id].item_equip;
|
||||
for (int32_t j = rob_item_equip->first_item_equip_object;
|
||||
j < rob_item_equip->max_item_equip_object; j++) {
|
||||
rob_chara_item_equip_object* itm_eq_obj = &rob_item_equip->item_equip_object[j];
|
||||
for (ExOsageBlock*& i : itm_eq_obj->osage_blocks)
|
||||
if (i)
|
||||
i->rob.osage_reset = true;
|
||||
}
|
||||
}
|
||||
|
||||
glGenVertexArrays(1, &cube_line_vao);
|
||||
glGenBuffers(1, &cube_line_vbo);
|
||||
gl_state_bind_vertex_array(cube_line_vao);
|
||||
gl_state_bind_array_buffer(cube_line_vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(cube_line_verts), (void*)cube_line_verts, GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vec3) * 4, 0, GL_STREAM_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float_t) * 2, 0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(vec3), 0);
|
||||
gl_state_bind_array_buffer(0);
|
||||
|
||||
glGenVertexArrays(1, &cube_line_point_vao);
|
||||
glGenBuffers(1, &cube_line_point_instance_vbo);
|
||||
gl_state_bind_vertex_array(cube_line_point_vao);
|
||||
gl_state_bind_array_buffer(cube_line_point_instance_vbo);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(std::pair<vec3, float_t>), 0);
|
||||
glVertexAttribDivisor(0, 1);
|
||||
gl_state_bind_array_buffer(0);
|
||||
gl_state_bind_vertex_array(0);
|
||||
|
||||
@@ -674,9 +704,6 @@ static render_context* render_load() {
|
||||
shader_env_vert_set_ptr(&shaders_ft, 3, (vec4*)&vec4_identity);
|
||||
shader_env_vert_set_ptr(&shaders_ft, 4, (vec4*)&vec4_null);
|
||||
classes_process_init(classes, classes_count, rctx);
|
||||
|
||||
TaskWork::AppendTask(&task_auth_3d, "AUTH_3D");
|
||||
TaskWork::AppendTask(&glt_particle_manager, "GLITTER_TASK", 2);
|
||||
return rctx;
|
||||
}
|
||||
|
||||
@@ -789,20 +816,22 @@ static void cube_line_draw(shader_glsl* shader, camera* cam, vec3* trans, float_
|
||||
mat4 mat[2];
|
||||
mat4_translate(trans[0].x, trans[0].y, trans[0].z, &mat[0]);
|
||||
mat4_translate(trans[1].x, trans[1].y, trans[1].z, &mat[1]);
|
||||
mat4_mult(&cam->inv_view_rot, &mat[0], &mat[0]);
|
||||
mat4_mult(&cam->inv_view_rot, &mat[1], &mat[1]);
|
||||
mat4_get_translation(&mat[0], &trans[0]);
|
||||
mat4_get_translation(&mat[1], &trans[1]);
|
||||
mat4_mult(&cam->view, &mat[0], &mat[0]);
|
||||
mat4_mult(&cam->view, &mat[1], &mat[1]);
|
||||
|
||||
vec3 t[2];
|
||||
mat4_get_translation(&mat[0], &t[0]);
|
||||
mat4_get_translation(&mat[1], &t[1]);
|
||||
|
||||
vec3 d;
|
||||
vec2_sub(*(vec2*)&t[1], *(vec2*)&t[0], *(vec2*)&d);
|
||||
vec2_normalize(*(vec2*)&d, *(vec2*)&d);
|
||||
vec2_mult_scalar(*(vec2*)&d, line_size, *(vec2*)&d);
|
||||
d.z = 0.0f;
|
||||
|
||||
float_t dx = trans[1].x - trans[0].x;
|
||||
float_t dy = trans[1].y - trans[0].y;
|
||||
vec3 norm[2];
|
||||
norm[0] = { -dy, dx, 0.0f };
|
||||
norm[1] = { dy, -dx, 0.0f };
|
||||
vec3_normalize(norm[0], norm[0]);
|
||||
vec3_normalize(norm[1], norm[1]);
|
||||
vec3_mult_scalar(norm[0], line_size, norm[0]);
|
||||
vec3_mult_scalar(norm[1], line_size, norm[1]);
|
||||
norm[0] = { -d.y, d.x, 0.0f };
|
||||
norm[1] = { d.y, -d.x, 0.0f };
|
||||
mat4_mult_vec3(&cam->inv_view_rot, &norm[0], &norm[0]);
|
||||
mat4_mult_vec3(&cam->inv_view_rot, &norm[1], &norm[1]);
|
||||
|
||||
@@ -811,27 +840,21 @@ static void cube_line_draw(shader_glsl* shader, camera* cam, vec3* trans, float_
|
||||
vec3_add(trans[0], norm[1], vert_trans[1]);
|
||||
vec3_add(trans[1], norm[0], vert_trans[2]);
|
||||
vec3_add(trans[1], norm[1], vert_trans[3]);
|
||||
shader_glsl_set_vec3_array(shader, "trans", 4, vert_trans);
|
||||
|
||||
shader_glsl_set_vec4(shader, "color", *color);
|
||||
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vert_trans), vert_trans);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
static void cube_line_point_draw(shader_glsl* shader, camera* cam, vec3* trans,
|
||||
float_t size, float_t dark_size, vec4* color, vec4* dark_color) {
|
||||
mat4 mat;
|
||||
mat4_scale(dark_size, dark_size, dark_size, &mat);
|
||||
mat4_set_translation(&mat, trans);
|
||||
mat4_mult(&cam->inv_view_rot, &mat, &mat);
|
||||
shader_glsl_set_mat4(&cube_line_point_shader, "mat", false, mat);
|
||||
shader_glsl_set_vec4(&cube_line_point_shader, "color", *dark_color);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
#include "../KKdLib/sort.h"
|
||||
#include "../KKdLib/str_utils.h"
|
||||
|
||||
mat4_scale(size, size, size, &mat);
|
||||
mat4_set_translation(&mat, trans);
|
||||
mat4_mult(&cam->inv_view_rot, &mat, &mat);
|
||||
shader_glsl_set_mat4(&cube_line_point_shader, "mat", false, mat);
|
||||
shader_glsl_set_vec4(&cube_line_point_shader, "color", *color);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
static int cube_line_points_sort(void const* src1, void const* src2) {
|
||||
std::pair<vec3, float_t>* t2 = (std::pair<vec3, float_t>*)src2;
|
||||
float_t d1 = ((std::pair<vec3, float_t>*)src1)->second;
|
||||
float_t d2 = ((std::pair<vec3, float_t>*)src2)->second;
|
||||
return d1 > d2 ? -1 : (d1 < d2 ? 1 : 0);
|
||||
}
|
||||
|
||||
static void render_draw(render_context* rctx) {
|
||||
@@ -886,40 +909,33 @@ static void render_draw(render_context* rctx) {
|
||||
static bool rob_draw = false;
|
||||
|
||||
gl_state_disable_cull_face();
|
||||
gl_state_bind_vertex_array(cube_line_vao);
|
||||
const float_t line_size = 0.0025f;
|
||||
const float_t line_point_size = line_size * 1.125f;
|
||||
const float_t line_point_dark_size = line_size * 1.5f;
|
||||
vec4 bone_color = { 1.0f, 0.0f, 0.0f, 1.0f };
|
||||
vec4 cns_color = { 1.0f, 1.0f, 0.0f, 1.0f };
|
||||
vec4 exp_color = { 0.0f, 1.0f, 0.0f, 1.0f };
|
||||
vec4 osg_color = { 0.0f, 0.0f, 1.0f, 1.0f };
|
||||
vec4 osg_node_color = { 1.0f, 0.0f, 1.0f, 1.0f };
|
||||
vec4 point_color = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
vec4 point_dark_color = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
for (int32_t i = 0; i < ROB_CHARA_COUNT && rob_draw; i++) {
|
||||
if (rob_chara_pv_data_array[i].field_0 == -1)
|
||||
if (rob_chara_pv_data_array[i].type == ROB_CHARA_TYPE_NONE)
|
||||
continue;
|
||||
|
||||
gl_state_bind_vertex_array(cube_line_vao);
|
||||
gl_state_bind_array_buffer(cube_line_vbo);
|
||||
rob_chara* rob_chr = &rob_chara_array[i];
|
||||
rob_chara_bone_data* rob_bone_data = rob_chr->bone_data;
|
||||
size_t object_bone_count = rob_bone_data->object_bone_count;
|
||||
size_t total_bone_count = rob_bone_data->total_bone_count;
|
||||
size_t ik_bone_count = rob_bone_data->ik_bone_count;
|
||||
vector_old_bone_node* nodes = &rob_bone_data->nodes;
|
||||
shader_glsl_use(&cube_line_shader);
|
||||
for (bone_node* j = nodes->begin; j != nodes->end; j++) {
|
||||
if (!j->parent)
|
||||
for (bone_node& j : rob_bone_data->nodes) {
|
||||
if (!j.parent)
|
||||
continue;
|
||||
|
||||
vec3 trans[2];
|
||||
mat4_get_translation(j->parent->mat, &trans[0]);
|
||||
mat4_get_translation(j->mat, &trans[1]);
|
||||
mat4_get_translation(j.parent->mat, &trans[0]);
|
||||
mat4_get_translation(j.mat, &trans[1]);
|
||||
|
||||
if (!memcmp(&trans[0], &trans[1], sizeof(vec3)))
|
||||
continue;
|
||||
|
||||
cube_line_draw(&cube_line_shader, cam, trans, line_size, &bone_color);
|
||||
if (memcmp(&trans[0], &trans[1], sizeof(vec3)))
|
||||
cube_line_draw(&cube_line_shader, cam, trans, CUBE_LINE_SIZE, &bone_color);
|
||||
}
|
||||
|
||||
rob_chara_item_equip* rob_item_equip = rob_chr->item_equip;
|
||||
@@ -927,156 +943,171 @@ static void render_draw(render_context* rctx) {
|
||||
j < rob_item_equip->max_item_equip_object; j++) {
|
||||
rob_chara_item_equip_object* itm_eq_obj = &rob_item_equip->item_equip_object[j];
|
||||
|
||||
vector_old_ptr_ExExpressionBlock* expression_blocks = &itm_eq_obj->expression_blocks;
|
||||
for (ExExpressionBlock** k = expression_blocks->begin; k != expression_blocks->end; k++) {
|
||||
if (!*k)
|
||||
continue;
|
||||
|
||||
ExExpressionBlock* exp = *k;
|
||||
|
||||
if (!exp->bone_node_ptr || !exp->parent_bone_node)
|
||||
for (ExExpressionBlock*& k : itm_eq_obj->expression_blocks) {
|
||||
ExExpressionBlock* exp = k;
|
||||
if (!exp || !exp->bone_node_ptr || !exp->parent_bone_node)
|
||||
continue;
|
||||
|
||||
vec3 trans[2];
|
||||
mat4_get_translation(exp->parent_bone_node->mat, &trans[0]);
|
||||
mat4_get_translation(exp->bone_node_ptr->mat, &trans[1]);
|
||||
|
||||
if (!memcmp(&trans[0], &trans[1], sizeof(vec3)))
|
||||
continue;
|
||||
|
||||
cube_line_draw(&cube_line_shader, cam, trans, line_size, &cns_color);
|
||||
if (memcmp(&trans[0], &trans[1], sizeof(vec3)))
|
||||
cube_line_draw(&cube_line_shader, cam, trans, CUBE_LINE_SIZE, &cns_color);
|
||||
}
|
||||
|
||||
vector_old_ptr_ExConstraintBlock* constraint_blocks = &itm_eq_obj->constraint_blocks;
|
||||
for (ExConstraintBlock** k = constraint_blocks->begin; k != constraint_blocks->end; k++) {
|
||||
if (!*k)
|
||||
continue;
|
||||
|
||||
ExConstraintBlock* cns = *k;
|
||||
|
||||
if (!cns->bone_node_ptr || !cns->parent_bone_node)
|
||||
for (ExConstraintBlock*& k : itm_eq_obj->constraint_blocks) {
|
||||
ExConstraintBlock* cns = k;
|
||||
if (!cns || !cns->bone_node_ptr || !cns->parent_bone_node)
|
||||
continue;
|
||||
|
||||
vec3 trans[2];
|
||||
mat4_get_translation(cns->parent_bone_node->mat, &trans[0]);
|
||||
mat4_get_translation(cns->bone_node_ptr->mat, &trans[1]);
|
||||
|
||||
if (!memcmp(&trans[0], &trans[1], sizeof(vec3)))
|
||||
continue;
|
||||
|
||||
cube_line_draw(&cube_line_shader, cam, trans, line_size, &exp_color);
|
||||
if (memcmp(&trans[0], &trans[1], sizeof(vec3)))
|
||||
cube_line_draw(&cube_line_shader, cam, trans, CUBE_LINE_SIZE, &exp_color);
|
||||
}
|
||||
|
||||
vector_old_ptr_ExOsageBlock* osage_blocks = &itm_eq_obj->osage_blocks;
|
||||
for (ExOsageBlock** k = osage_blocks->begin; k != osage_blocks->end; k++) {
|
||||
if (!*k)
|
||||
continue;
|
||||
|
||||
ExOsageBlock* osg = *k;
|
||||
|
||||
if (!osg->bone_node_ptr || !osg->parent_bone_node)
|
||||
for (ExOsageBlock*& k : itm_eq_obj->osage_blocks) {
|
||||
ExOsageBlock* osg = k;
|
||||
if (!osg || !osg->bone_node_ptr || !osg->parent_bone_node)
|
||||
continue;
|
||||
|
||||
vec3 trans[2];
|
||||
mat4_get_translation(osg->parent_bone_node->mat, &trans[0]);
|
||||
mat4_get_translation(osg->bone_node_ptr->mat, &trans[1]);
|
||||
|
||||
if (!memcmp(&trans[0], &trans[1], sizeof(vec3)))
|
||||
continue;
|
||||
if (!memcmp(&trans[0], &trans[1], sizeof(vec3))) {
|
||||
mat4_get_translation(osg->parent_bone_node->parent->mat, &trans[0]);
|
||||
if (!memcmp(&trans[0], &trans[1], sizeof(vec3)))
|
||||
continue;
|
||||
}
|
||||
|
||||
cube_line_draw(&cube_line_shader, cam, trans, line_size, &osg_color);
|
||||
cube_line_draw(&cube_line_shader, cam, trans, CUBE_LINE_SIZE, &osg_color);
|
||||
|
||||
rob_osage* rob_osg = &osg->rob;
|
||||
vector_old_rob_osage_node* nodes = &osg->rob.nodes;
|
||||
rob_osage_node* parent_node = &osg->rob.node;
|
||||
for (rob_osage_node* l = nodes->begin; l != nodes->end; parent_node = l++) {
|
||||
if (!l->bone_node_ptr || !parent_node->bone_node_ptr)
|
||||
for (rob_osage_node& l : osg->rob.nodes) {
|
||||
if (!l.bone_node_ptr || !parent_node->bone_node_ptr) {
|
||||
parent_node = &l;
|
||||
continue;
|
||||
}
|
||||
|
||||
vec3 trans[2];
|
||||
mat4_get_translation(parent_node->bone_node_ptr->mat, &trans[0]);
|
||||
mat4_get_translation(l->bone_node_ptr->mat, &trans[1]);
|
||||
mat4_get_translation(l.bone_node_ptr->mat, &trans[1]);
|
||||
|
||||
if (!memcmp(&trans[0], &trans[1], sizeof(vec3)))
|
||||
continue;
|
||||
|
||||
cube_line_draw(&cube_line_shader, cam, trans, line_size, &osg_node_color);
|
||||
if (memcmp(&trans[0], &trans[1], sizeof(vec3)))
|
||||
cube_line_draw(&cube_line_shader, cam, trans, CUBE_LINE_SIZE, &osg_node_color);
|
||||
else {
|
||||
mat4_get_translation(parent_node->bone_node_ptr->parent->mat, &trans[0]);
|
||||
if (!memcmp(&trans[0], &trans[1], sizeof(vec3)))
|
||||
continue;
|
||||
cube_line_draw(&cube_line_shader, cam, trans, CUBE_LINE_SIZE, &osg_node_color);
|
||||
}
|
||||
parent_node = &l;
|
||||
}
|
||||
}
|
||||
}
|
||||
gl_state_bind_array_buffer(0);
|
||||
|
||||
shader_glsl_use(&cube_line_point_shader);
|
||||
for (bone_node* j = nodes->begin; j != nodes->end; j++) {
|
||||
std::vector<std::pair<vec3, float_t>> cube_line_points;
|
||||
for (bone_node& j : rob_bone_data->nodes) {
|
||||
vec3 trans;
|
||||
mat4_get_translation(j->mat, &trans);
|
||||
cube_line_point_draw(&cube_line_point_shader, cam, &trans,
|
||||
line_point_size, line_point_dark_size, &point_color, &point_dark_color);
|
||||
mat4_get_translation(j.mat, &trans);
|
||||
cube_line_points.push_back({ trans, 0.0f });
|
||||
}
|
||||
|
||||
for (int32_t j = rob_item_equip->first_item_equip_object;
|
||||
j < rob_item_equip->max_item_equip_object; j++) {
|
||||
rob_chara_item_equip_object* itm_eq_obj = &rob_item_equip->item_equip_object[j];
|
||||
|
||||
vector_old_ptr_ExExpressionBlock* expression_blocks = &itm_eq_obj->expression_blocks;
|
||||
for (ExExpressionBlock** k = expression_blocks->begin; k != expression_blocks->end; k++) {
|
||||
if (!*k)
|
||||
continue;
|
||||
|
||||
ExExpressionBlock* exp = *k;
|
||||
|
||||
if (!exp->bone_node_ptr)
|
||||
for (ExExpressionBlock*& k : itm_eq_obj->expression_blocks) {
|
||||
ExExpressionBlock* exp = k;
|
||||
if (!exp || !exp->bone_node_ptr)
|
||||
continue;
|
||||
|
||||
vec3 trans;
|
||||
mat4_get_translation(exp->bone_node_ptr->mat, &trans);
|
||||
cube_line_point_draw(&cube_line_point_shader, cam, &trans,
|
||||
line_point_size, line_point_dark_size, &point_color, &point_dark_color);
|
||||
cube_line_points.push_back({ trans, 0.0f });
|
||||
}
|
||||
|
||||
vector_old_ptr_ExConstraintBlock* constraint_blocks = &itm_eq_obj->constraint_blocks;
|
||||
for (ExConstraintBlock** k = constraint_blocks->begin; k != constraint_blocks->end; k++) {
|
||||
if (!*k)
|
||||
continue;
|
||||
|
||||
ExConstraintBlock* cns = *k;
|
||||
|
||||
if (!cns->bone_node_ptr)
|
||||
for (ExConstraintBlock*& k : itm_eq_obj->constraint_blocks) {
|
||||
ExConstraintBlock* cns = k;
|
||||
if (!cns || !cns->bone_node_ptr)
|
||||
continue;
|
||||
|
||||
vec3 trans;
|
||||
mat4_get_translation(cns->bone_node_ptr->mat, &trans);
|
||||
cube_line_point_draw(&cube_line_point_shader, cam, &trans,
|
||||
line_point_size, line_point_dark_size, &point_color, &point_dark_color);
|
||||
cube_line_points.push_back({ trans, 0.0f });
|
||||
}
|
||||
|
||||
vector_old_ptr_ExOsageBlock* osage_blocks = &itm_eq_obj->osage_blocks;
|
||||
for (ExOsageBlock** k = osage_blocks->begin; k != osage_blocks->end; k++) {
|
||||
if (!*k)
|
||||
continue;
|
||||
|
||||
ExOsageBlock* osg = *k;
|
||||
|
||||
if (!osg->bone_node_ptr)
|
||||
for (ExOsageBlock*& k : itm_eq_obj->osage_blocks) {
|
||||
ExOsageBlock* osg = k;
|
||||
if (!osg || !osg->bone_node_ptr)
|
||||
continue;
|
||||
|
||||
vec3 trans;
|
||||
mat4_get_translation(osg->bone_node_ptr->mat, &trans);
|
||||
cube_line_point_draw(&cube_line_point_shader, cam, &trans,
|
||||
line_point_size, line_point_dark_size, &point_color, &point_dark_color);
|
||||
cube_line_points.push_back({ trans, 0.0f });
|
||||
|
||||
rob_osage* rob_osg = &osg->rob;
|
||||
vector_old_rob_osage_node* nodes = &osg->rob.nodes;
|
||||
for (rob_osage_node* l = nodes->begin; l != nodes->end; l++) {
|
||||
if (!l->bone_node_ptr)
|
||||
rob_osage_node* parent_node = &osg->rob.node;
|
||||
for (rob_osage_node& l : osg->rob.nodes) {
|
||||
if (!l.bone_node_ptr) {
|
||||
parent_node = &l;
|
||||
continue;
|
||||
}
|
||||
|
||||
vec3 trans;
|
||||
mat4_get_translation(l->bone_node_ptr->mat, &trans);
|
||||
cube_line_point_draw(&cube_line_point_shader, cam, &trans,
|
||||
line_point_size, line_point_dark_size, &point_color, &point_dark_color);
|
||||
mat4_get_translation(l.bone_node_ptr->mat, &trans);
|
||||
cube_line_points.push_back({ trans, 0.0f });
|
||||
parent_node = &l;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (std::pair<vec3, float_t>& i : cube_line_points) {
|
||||
vec3 trans;
|
||||
mat4_mult_vec3(&cam->view_projection, &i.first, &trans);
|
||||
i.second = trans.z;
|
||||
}
|
||||
|
||||
quicksort_custom(cube_line_points.data(), cube_line_points.size(),
|
||||
sizeof(std::pair<vec3, float_t>), cube_line_points_sort);
|
||||
|
||||
gl_state_bind_array_buffer(cube_line_point_instance_vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(sizeof(std::pair<vec3, float_t>)
|
||||
* cube_line_points.size()), cube_line_points.data(), GL_STREAM_DRAW);
|
||||
gl_state_bind_array_buffer(0);
|
||||
|
||||
vec3 trans[4];
|
||||
trans[0] = { -1.0, 1.0, 0.0 };
|
||||
trans[1] = { 1.0, 1.0, 0.0 };
|
||||
trans[2] = { -1.0, -1.0, 0.0 };
|
||||
trans[3] = { 1.0, -1.0, 0.0 };
|
||||
|
||||
vec3_mult_scalar(trans[0], CUBE_LINE_POINT_SIZE, trans[0]);
|
||||
vec3_mult_scalar(trans[1], CUBE_LINE_POINT_SIZE, trans[1]);
|
||||
vec3_mult_scalar(trans[2], CUBE_LINE_POINT_SIZE, trans[2]);
|
||||
vec3_mult_scalar(trans[3], CUBE_LINE_POINT_SIZE, trans[3]);
|
||||
|
||||
mat4_mult_vec3(&cam->inv_view_rot, &trans[0], &trans[0]);
|
||||
mat4_mult_vec3(&cam->inv_view_rot, &trans[1], &trans[1]);
|
||||
mat4_mult_vec3(&cam->inv_view_rot, &trans[2], &trans[2]);
|
||||
mat4_mult_vec3(&cam->inv_view_rot, &trans[3], &trans[3]);
|
||||
|
||||
gl_state_bind_vertex_array(cube_line_point_vao);
|
||||
shader_glsl_use(&cube_line_point_shader);
|
||||
shader_glsl_set_vec3_array(&cube_line_point_shader, "trans", 4, trans);
|
||||
shader_glsl_set_float(&cube_line_point_shader, "dark_border_end",
|
||||
((CUBE_LINE_POINT_SIZE - (CUBE_LINE_SIZE * 1.125f)) / (2.0f * CUBE_LINE_POINT_SIZE)));
|
||||
shader_glsl_set_float(&cube_line_point_shader, "dark_border_start",
|
||||
(1.0f - ((CUBE_LINE_POINT_SIZE - (CUBE_LINE_SIZE * 1.125f)) / (2.0f * CUBE_LINE_POINT_SIZE))));
|
||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, (GLsizei)cube_line_points.size());
|
||||
cube_line_points.clear();
|
||||
cube_line_points.shrink_to_fit();
|
||||
}
|
||||
gl_state_bind_vertex_array(0);
|
||||
gl_state_enable_cull_face();
|
||||
@@ -1099,9 +1130,6 @@ static void render_dispose(render_context* rctx) {
|
||||
igDestroyContext(imgui_context);
|
||||
lock_free(&imgui_context_lock);
|
||||
|
||||
stage_free(&stage_test_data, rctx);
|
||||
stage_free(&stage_stgtst, rctx);
|
||||
|
||||
data_struct_free();
|
||||
|
||||
render_shaders_free();
|
||||
@@ -1112,10 +1140,14 @@ static void render_dispose(render_context* rctx) {
|
||||
|
||||
glDeleteBuffers(1, &common_data_ubo);
|
||||
glDeleteBuffers(1, &grid_vbo);
|
||||
glDeleteBuffers(1, &cube_line_point_instance_vbo);
|
||||
glDeleteVertexArrays(1, &cube_line_point_vao);
|
||||
glDeleteBuffers(1, &cube_line_vbo);
|
||||
glDeleteVertexArrays(1, &cube_line_vao);
|
||||
|
||||
rob_chara_array_free();
|
||||
pv_osage_manager_array_ptr_free();
|
||||
rob_thread_handler_free();
|
||||
rob_mot_tbl_free();
|
||||
|
||||
motion_storage_free();
|
||||
|
||||
@@ -1124,6 +1156,8 @@ static void render_dispose(render_context* rctx) {
|
||||
render_texture_data_free();
|
||||
render_context_free(rctx);
|
||||
|
||||
file_handler_storage_free_thread();
|
||||
|
||||
object_storage_free();
|
||||
texture_storage_free();
|
||||
}
|
||||
@@ -1135,7 +1169,7 @@ static void render_imgui(render_context* rctx) {
|
||||
lock_unlock(&imgui_context_lock);
|
||||
}
|
||||
|
||||
static bool render_load_shaders(void* data, char* path, char* file, uint32_t hash) {
|
||||
static bool render_load_shaders(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
string s;
|
||||
string_init(&s, path);
|
||||
string_add(&s, file);
|
||||
@@ -1252,7 +1286,7 @@ static void render_imgui_context_menu(classes_data* classes,
|
||||
}
|
||||
|
||||
inline static void render_shaders_load() {
|
||||
data_struct_load_file(&data_list[DATA_AFT], &shaders_ft,
|
||||
data_list[DATA_AFT].load_file(&shaders_ft,
|
||||
"rom/", "ft_shaders.farc", render_load_shaders);
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -97,7 +97,7 @@ classes_data classes[] = {
|
||||
CLASS_DATA_NO_DATA,
|
||||
},
|
||||
information_classes,
|
||||
1,
|
||||
2,
|
||||
},
|
||||
#if defined(CLOUD_DEV)
|
||||
{
|
||||
@@ -130,6 +130,5 @@ const size_t classes_count = sizeof(classes) / sizeof(classes_data);
|
||||
render_state state;
|
||||
lock state_lock;
|
||||
|
||||
lock_data glitter_data_lock;
|
||||
lock_data stage_data_lock;
|
||||
lock pv_lock;
|
||||
bool stage_control;
|
||||
lock stage_control_lock;
|
||||
|
||||
@@ -21,6 +21,3 @@ extern classes_data classes[];
|
||||
extern const size_t classes_count;
|
||||
extern render_state state;
|
||||
extern lock state_lock;
|
||||
extern lock_data glitter_data_lock;
|
||||
extern lock_data stage_data_lock;
|
||||
extern lock pv_lock;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
Some code is from LearnOpenGL
|
||||
*/
|
||||
|
||||
#if defined(CLOUD_DEV)
|
||||
#include "x_pv_player.h"
|
||||
#include "../KKdLib/dsc.h"
|
||||
#include "../KKdLib/farc.h"
|
||||
@@ -40,11 +41,11 @@ void x_pv_player::Load(int32_t pv_id, int32_t stage_id) {
|
||||
|
||||
sprintf_s(file_buf, sizeof(file_buf), "pv%03d.pvpp", pv_id);
|
||||
pp = new pvpp;
|
||||
data_struct_load_file(x_data, pp, "rom/pv/", file_buf, pvpp_load_file);
|
||||
x_data->load_file(pp, "rom/pv/", file_buf, pvpp::load_file);
|
||||
|
||||
sprintf_s(file_buf, sizeof(file_buf), "stgpv%03d_param.pvsr", stage_id);
|
||||
pvsr_init(&sr);
|
||||
data_struct_load_file(x_data, &sr, "rom/pv_stage_rsrc/", file_buf, pvsr_load_file);
|
||||
x_data->load_file(&sr, "rom/pv_stage_rsrc/", file_buf, pvsr_load_file);
|
||||
|
||||
glt_particle_manager.data = x_data;
|
||||
|
||||
@@ -64,7 +65,7 @@ void x_pv_player::Load(int32_t pv_id, int32_t stage_id) {
|
||||
farc dsc_common_farc;
|
||||
sprintf_s(path_buf, sizeof(path_buf), "rom/pv_script/pv%03d/", pv_id);
|
||||
sprintf_s(file_buf, sizeof(file_buf), "pv_%03d_common.farc", pv_id);
|
||||
data_struct_load_file(x_data, &dsc_common_farc, path_buf, file_buf, farc::load_file);
|
||||
x_data->load_file(&dsc_common_farc, path_buf, file_buf, farc::load_file);
|
||||
|
||||
sprintf_s(file_buf, sizeof(file_buf), "pv_%03d_scene.dsc", pv_id);
|
||||
farc_file* dsc_scene_ff = dsc_common_farc.read_file(file_buf);
|
||||
@@ -78,7 +79,7 @@ void x_pv_player::Load(int32_t pv_id, int32_t stage_id) {
|
||||
|
||||
sprintf_s(file_buf, sizeof(file_buf), "pv_%03d_easy.dsc", pv_id);
|
||||
dsc_easy.type = DSC_X;
|
||||
data_struct_load_file(x_data, &dsc_easy, path_buf, file_buf, dsc_load_file);
|
||||
x_data->load_file(&dsc_easy, path_buf, file_buf, dsc_load_file);
|
||||
|
||||
dsc dsc_m;
|
||||
dsc_merge(&dsc_m, 3, &dsc_scene, &dsc_system, &dsc_easy);
|
||||
@@ -87,7 +88,8 @@ void x_pv_player::Load(int32_t pv_id, int32_t stage_id) {
|
||||
dsc_free(&dsc_system);
|
||||
dsc_free(&dsc_easy);
|
||||
|
||||
this->frame_data = {};
|
||||
this->frame_data.clear();
|
||||
this->frame_data.shrink_to_fit();
|
||||
|
||||
int32_t end_func_id = dsc_x_get_func_id("END");
|
||||
int32_t time_func_id = dsc_x_get_func_id("TIME");
|
||||
@@ -174,3 +176,4 @@ x_pv_player_glitter::x_pv_player_glitter(char* name) {
|
||||
x_pv_player_glitter::~x_pv_player_glitter() {
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#if defined(CLOUD_DEV)
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
@@ -60,3 +61,4 @@ public:
|
||||
|
||||
void Load(int32_t pv_id, int32_t stage_id);
|
||||
} x_pv_player;
|
||||
#endif
|
||||
|
||||
@@ -111,13 +111,12 @@ void glitter_effect_dispose(glitter_effect* e) {
|
||||
}
|
||||
|
||||
object_info glitter_effect_ext_anim_get_object_info(uint64_t hash) {
|
||||
vector_old_object_set_info* object_set = &obj_db_ptr->object_set;
|
||||
for (object_set_info* i = object_set->begin; i != object_set->end; i++) {
|
||||
for (object_info_data* j = i->object.begin; j != i->object.end; j++)
|
||||
if (hash == j->name_hash_murmurhash || hash == j->name_hash_fnv1a64m_upper)
|
||||
return { j->id, i->id };
|
||||
for (object_set_info& i : obj_db_ptr->object_set) {
|
||||
for (object_info_data& j : i.object)
|
||||
if (hash == j.name_hash_murmurhash || hash == j.name_hash_fnv1a64m_upper)
|
||||
return { j.id, i.id };
|
||||
}
|
||||
return object_info_null;
|
||||
return object_info();
|
||||
}
|
||||
|
||||
static bool glitter_effect_pack_file(GLT, f2_struct* st, glitter_effect* a2) {
|
||||
|
||||
@@ -29,7 +29,6 @@ resources_count(), resources_tex(), resources(), field_3C(), scene_init(), buffe
|
||||
glitter_effect_group::~glitter_effect_group() {
|
||||
vector_old_ptr_glitter_effect_free(&this->effects, glitter_effect_dispose);
|
||||
glitter_texture_unload(this);
|
||||
txp_set_free(&resources_tex);
|
||||
#if defined(CRE_DEV)
|
||||
glitter_effect_group_free_model(this);
|
||||
#endif
|
||||
@@ -125,15 +124,14 @@ void glitter_effect_group_load_model(glitter_effect_group* eg, void* ds) {
|
||||
for (uint32_t& i : eg->object_set_ids) {
|
||||
object_database obj_db;
|
||||
texture_database tex_db;
|
||||
object_database_init(&obj_db);
|
||||
object_set_load_by_hash(ds, &obj_db, &tex_db, i);
|
||||
object_database_free(&obj_db);
|
||||
}
|
||||
}
|
||||
|
||||
void glitter_effect_group_free_model(glitter_effect_group* eg) {
|
||||
for (uint32_t& i : eg->object_set_ids)
|
||||
object_storage_delete_object_set(i);
|
||||
eg->object_set_ids = {};
|
||||
eg->object_set_ids.clear();
|
||||
eg->object_set_ids.shrink_to_fit();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -48,7 +48,7 @@ glitter_effect_inst* glitter_effect_inst_init(GPM, GLT,
|
||||
inst_ext_anim->mesh_index = -1;
|
||||
inst_ext_anim->a3da_id = -1;
|
||||
inst_ext_anim->object_is_hrc = false;
|
||||
inst_ext_anim->object = object_info_null;
|
||||
inst_ext_anim->object = object_info();
|
||||
inst_ext_anim->mesh_name = 0;
|
||||
|
||||
inst_ext_anim->mat = mat4_identity;
|
||||
@@ -421,9 +421,9 @@ static int32_t glitter_effect_inst_get_ext_anim_bone_index(
|
||||
return -1;
|
||||
|
||||
bone_database* bone_data = (bone_database*)GPM_VAL.bone_data;
|
||||
vector_old_string* motion_bone_names = 0;
|
||||
if (!bone_data || vector_old_length(bone_data->skeleton) < 1
|
||||
|| !bone_database_get_skeleton_motion_bones(bone_data,
|
||||
std::vector<std::string>* motion_bone_names = 0;
|
||||
if (!bone_data || bone_data->skeleton.size() < 1
|
||||
|| !bone_data->get_skeleton_motion_bones(
|
||||
(char*)bone_database_skeleton_type_to_string(BONE_DATABASE_SKELETON_COMMON), &motion_bone_names))
|
||||
return -1;
|
||||
|
||||
@@ -449,9 +449,9 @@ static int32_t glitter_effect_inst_get_ext_anim_bone_index(
|
||||
};
|
||||
|
||||
char* bone_name = (char*)bone_names[node];
|
||||
for (string* i = motion_bone_names->begin; i != motion_bone_names->end; i++)
|
||||
if (!str_utils_compare(bone_name, string_data(i)))
|
||||
return (int32_t)(i - motion_bone_names->begin);
|
||||
for (std::string& i : *motion_bone_names)
|
||||
if (!str_utils_compare(bone_name, i.c_str()))
|
||||
return (int32_t)(&i - motion_bone_names->data());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ glitter_file_reader::~glitter_file_reader() {
|
||||
bool glitter_file_reader::Read(GPM, float_t emission) {
|
||||
::farc f;
|
||||
char* farc_file_temp = str_utils_add(this->file.c_str(), ".farc");
|
||||
bool ret = data_struct_load_file((data_struct*)GPM_VAL->data,
|
||||
bool ret = ((data_struct*)GPM_VAL->data)->load_file(
|
||||
&f, this->path.c_str(), farc_file_temp, farc::load_file);
|
||||
free(farc_file_temp);
|
||||
|
||||
@@ -70,7 +70,7 @@ bool glitter_file_reader::Read(GPM, float_t emission) {
|
||||
return false;
|
||||
|
||||
f2_struct st;
|
||||
f2_struct_mread(&st, dve_ff->data, dve_ff->size);
|
||||
f2_struct_read(&st, dve_ff->data, dve_ff->size);
|
||||
if (st.header.signature == reverse_endianness_uint32_t('DVEF'))
|
||||
ret = glitter_diva_effect_parse_file(GPM_VAL, this, &st, emission);
|
||||
else
|
||||
@@ -86,7 +86,7 @@ bool glitter_file_reader::Read(GPM, float_t emission) {
|
||||
|
||||
if (drs_ff) {
|
||||
f2_struct st;
|
||||
f2_struct_mread(&st, drs_ff->data, drs_ff->size);
|
||||
f2_struct_read(&st, drs_ff->data, drs_ff->size);
|
||||
if (st.header.signature == reverse_endianness_uint32_t('DVRS'))
|
||||
glitter_diva_resource_parse_file(GPM_VAL, this->effect_group, &st);
|
||||
f2_struct_free(&st);
|
||||
@@ -98,7 +98,7 @@ bool glitter_file_reader::Read(GPM, float_t emission) {
|
||||
|
||||
if (lst_ff) {
|
||||
f2_struct st;
|
||||
f2_struct_mread(&st, lst_ff->data, lst_ff->size);
|
||||
f2_struct_read(&st, lst_ff->data, lst_ff->size);
|
||||
if (st.header.signature == reverse_endianness_uint32_t('LIST'))
|
||||
glitter_diva_list_parse_file(this->effect_group, &st);
|
||||
f2_struct_free(&st);
|
||||
@@ -127,7 +127,7 @@ bool glitter_file_reader_load_farc(glitter_file_reader* fr,
|
||||
|
||||
std::string file_temp = fr->file + ".farc";
|
||||
|
||||
if (data_struct_load_file((data_struct*)(GPM_VAL.data),
|
||||
if (((data_struct*)(GPM_VAL.data))->load_file(
|
||||
fr->farc, path, file_temp.c_str(), farc::load_file)) {
|
||||
fr->hash = hash;
|
||||
fr->load_count = 1;
|
||||
|
||||
@@ -533,7 +533,7 @@ public:
|
||||
float_t emission;
|
||||
uint32_t resources_count;
|
||||
std::vector<uint64_t> resource_hashes;
|
||||
vector_old_txp resources_tex;
|
||||
txp_set resources_tex;
|
||||
texture** resources;
|
||||
#if defined(CRE_DEV) || defined(CLOUD_DEV)
|
||||
std::vector<uint32_t> object_set_ids;
|
||||
|
||||
@@ -11,21 +11,12 @@
|
||||
#include "render_group.h"
|
||||
#include "scene.h"
|
||||
|
||||
GltParticleManager::GltParticleManager() {
|
||||
scenes = {};
|
||||
file_readers = {};
|
||||
sys_frame_rate = 0;
|
||||
flags = (glitter_particle_manager_flag)0;
|
||||
scene_counter = 0;
|
||||
emission = 1.5;
|
||||
delta_frame = 2.0;
|
||||
texture_counter = 0;
|
||||
scenes = {};
|
||||
GltParticleManager::GltParticleManager() :scene(), effect(), emitter(), particle(), rctx(),
|
||||
data(), bone_data(), sys_frame_rate(), flags(), scene_counter(), emission(1.5f), delta_frame(2.0f),
|
||||
texture_counter(), random(), counter(), cam_projection(), cam_view(), cam_inv_view(), cam_inv_view_mat3(),
|
||||
cam_view_point(), cam_rotation_y(), draw_all(true), draw_all_mesh(true), draw_selected() {
|
||||
scenes.reserve(0x100);
|
||||
file_readers = {};
|
||||
file_readers.reserve(0x100);
|
||||
draw_all = true;
|
||||
draw_all_mesh = true;
|
||||
}
|
||||
|
||||
GltParticleManager::~GltParticleManager() {
|
||||
@@ -40,10 +31,10 @@ bool GltParticleManager::Init() {
|
||||
bool GltParticleManager::Ctrl() {
|
||||
if (flags & GLITTER_PARTICLE_MANAGER_READ_FILES) {
|
||||
for (glitter_file_reader** i = file_readers.begin()._Ptr; i != file_readers.end()._Ptr;)
|
||||
if (!*i || (*i)->ReadFarc(this, this->emission)) {
|
||||
if (!*i || (*i)->ReadFarc(this, emission)) {
|
||||
delete* i;
|
||||
*i = 0;
|
||||
file_readers.erase(file_readers.begin() + (i - file_readers.begin()._Ptr));
|
||||
file_readers.erase(file_readers.begin() + (i - file_readers.data()));
|
||||
}
|
||||
else
|
||||
i++;
|
||||
@@ -52,33 +43,8 @@ bool GltParticleManager::Ctrl() {
|
||||
enum_and(flags, ~GLITTER_PARTICLE_MANAGER_READ_FILES);
|
||||
}
|
||||
|
||||
if (flags & GLITTER_PARTICLE_MANAGER_PAUSE)
|
||||
return false;
|
||||
|
||||
delta_frame = get_delta_frame();
|
||||
if (sys_frame_rate)
|
||||
delta_frame *= sys_frame_rate->frame_speed;
|
||||
|
||||
for (glitter_scene** i = scenes.begin()._Ptr; i != scenes.end()._Ptr;) {
|
||||
if (!*i || glitter_scene_has_ended(*i, 1)) {
|
||||
delete* i;
|
||||
*i = 0;
|
||||
scenes.erase(scenes.begin() + (i - scenes.begin()._Ptr));
|
||||
}
|
||||
#if defined(CRE_DEV)
|
||||
else if (~(*i)->flags & GLITTER_SCENE_EDITOR) {
|
||||
glitter_scene_ctrl(this, *i, delta_frame);
|
||||
i++;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
#else
|
||||
else {
|
||||
glitter_scene_ctrl(this, *i, delta_frame);
|
||||
i++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (~flags & GLITTER_PARTICLE_MANAGER_PAUSE)
|
||||
CtrlScenes();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -131,7 +97,7 @@ void GltParticleManager::BasicEffectGroups() {
|
||||
|
||||
delete* j;
|
||||
*j = 0;
|
||||
scenes.erase(scenes.begin() + (j - scenes.begin()._Ptr));
|
||||
scenes.erase(scenes.begin() + (j - scenes.data()));
|
||||
}
|
||||
i = effect_groups.erase(i);
|
||||
}
|
||||
@@ -155,6 +121,33 @@ bool GltParticleManager::CheckNoFileReaders(uint64_t hash) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void GltParticleManager::CtrlScenes() {
|
||||
delta_frame = get_delta_frame();
|
||||
if (sys_frame_rate)
|
||||
delta_frame *= sys_frame_rate->frame_speed;
|
||||
|
||||
for (glitter_scene** i = scenes.begin()._Ptr; i != scenes.end()._Ptr;) {
|
||||
if (!*i || glitter_scene_has_ended(*i, 1)) {
|
||||
delete* i;
|
||||
*i = 0;
|
||||
scenes.erase(scenes.begin() + (i - scenes.data()));
|
||||
}
|
||||
#if defined(CRE_DEV)
|
||||
else if (~(*i)->flags & GLITTER_SCENE_EDITOR) {
|
||||
glitter_scene_ctrl(this, *i, delta_frame);
|
||||
i++;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
#else
|
||||
else {
|
||||
glitter_scene_ctrl(this, *i, delta_frame);
|
||||
i++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void GltParticleManager::Disp(draw_pass_3d_type draw_pass_type) {
|
||||
if (flags & GLITTER_PARTICLE_MANAGER_NOT_DISP)
|
||||
return;
|
||||
@@ -188,7 +181,7 @@ void GltParticleManager::FreeSceneEffect(glitter_scene_counter scene_counter, ui
|
||||
&& (glitter_scene_free_effect(this, *i, scene_counter.index, true), glitter_scene_has_ended(*i, 0))) {
|
||||
delete *i;
|
||||
*i = 0;
|
||||
scenes.erase(scenes.begin() + (i - scenes.begin()._Ptr));
|
||||
scenes.erase(scenes.begin() + (i - scenes.data()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -621,7 +614,7 @@ void GltParticleManager::SetFrame(glitter_effect_group* effect_group,
|
||||
continue;
|
||||
}
|
||||
|
||||
scenes.erase(scenes.begin() + (i - scenes.begin()._Ptr));
|
||||
scenes.erase(scenes.begin() + (i - scenes.data()));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -664,7 +657,7 @@ void GltParticleManager::UnloadEffectGroup(uint64_t hash) {
|
||||
if (!*i || (*i)->hash == hash) {
|
||||
delete* i;
|
||||
*i = 0;
|
||||
file_readers.erase(file_readers.begin() + (i - file_readers.begin()._Ptr));
|
||||
file_readers.erase(file_readers.begin() + (i - file_readers.data()));
|
||||
}
|
||||
else
|
||||
i++;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "effect_inst.h"
|
||||
|
||||
glitter_scene::glitter_scene(glitter_scene_counter counter, uint64_t hash, glitter_effect_group* a4, bool a5) : counter(0) {
|
||||
effects = {};
|
||||
this->counter = counter;
|
||||
this->hash = hash;
|
||||
flags = GLITTER_SCENE_NONE;
|
||||
@@ -17,6 +16,7 @@ glitter_scene::glitter_scene(glitter_scene_counter counter, uint64_t hash, glitt
|
||||
effect_group = a4;
|
||||
delta_frame_history = 0.0f;
|
||||
skip = false;
|
||||
effects = {};
|
||||
if (a4) {
|
||||
vector_old_glitter_scene_effect_reserve(&effects, vector_old_length(a4->effects));
|
||||
emission = a4->emission;
|
||||
|
||||
@@ -87,15 +87,15 @@ bool glitter_texture_hashes_unpack_file(glitter_effect_group* a1, f2_struct* st)
|
||||
}
|
||||
|
||||
bool glitter_texture_resource_pack_file(glitter_effect_group* a1, f2_struct* st) {
|
||||
if (vector_old_length(a1->resources_tex) < 1)
|
||||
if (a1->resources_tex.textures.size() < 1)
|
||||
return false;
|
||||
|
||||
memset(st, 0, sizeof(f2_struct));
|
||||
|
||||
if (!txp_set_produce_enrs(&a1->resources_tex, &st->enrs))
|
||||
if (!a1->resources_tex.produce_enrs(&st->enrs))
|
||||
return false;
|
||||
|
||||
txp_set_pack_file(&a1->resources_tex, &st->data, &st->length, false);
|
||||
a1->resources_tex.pack_file(&st->data, &st->length, false);
|
||||
|
||||
st->header.signature = reverse_endianness_uint32_t('TXPC');
|
||||
st->header.length = 0x20;
|
||||
@@ -108,7 +108,7 @@ bool glitter_texture_resource_unpack_file(GPM, glitter_effect_group* a1, f2_stru
|
||||
if (!st || !st->header.data_size)
|
||||
return false;
|
||||
|
||||
txp_set_unpack_file(&a1->resources_tex, st->data, st->header.use_big_endian);
|
||||
a1->resources_tex.unpack_file(st->data, st->header.use_big_endian);
|
||||
return glitter_texture_load(GPM_VAL, a1);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ bool glitter_texture_load(GPM, glitter_effect_group* a1) {
|
||||
if (!a1->resources_count)
|
||||
return false;
|
||||
|
||||
size_t count = vector_old_length(a1->resources_tex);
|
||||
size_t count = a1->resources_tex.textures.size();
|
||||
|
||||
if (count < 1 || a1->resources_count < 1 || a1->resources_count != count)
|
||||
return false;
|
||||
|
||||
@@ -306,9 +306,9 @@ static int32_t glitter_x_effect_inst_get_ext_anim_bone_index(GPM,
|
||||
return -1;
|
||||
|
||||
bone_database* bone_data = (bone_database*)GPM_VAL->bone_data;
|
||||
vector_old_string* motion_bone_names = 0;
|
||||
if (!bone_data || vector_old_length(bone_data->skeleton) < 1
|
||||
|| !bone_database_get_skeleton_motion_bones(bone_data,
|
||||
std::vector<std::string>* motion_bone_names = 0;
|
||||
if (!bone_data || bone_data->skeleton.size() < 1
|
||||
|| !bone_data->get_skeleton_motion_bones(
|
||||
(char*)bone_database_skeleton_type_to_string(BONE_DATABASE_SKELETON_COMMON), &motion_bone_names))
|
||||
return -1;
|
||||
|
||||
@@ -334,9 +334,9 @@ static int32_t glitter_x_effect_inst_get_ext_anim_bone_index(GPM,
|
||||
};
|
||||
|
||||
char* bone_name = (char*)bone_names[node];
|
||||
for (string* i = motion_bone_names->begin; i != motion_bone_names->end; i++)
|
||||
if (!str_utils_compare(bone_name, string_data(i)))
|
||||
return (int32_t)(i - motion_bone_names->begin);
|
||||
for (std::string& i : *motion_bone_names)
|
||||
if (!str_utils_compare(bone_name, i.c_str()))
|
||||
return (int32_t)(&i - motion_bone_names->data());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
+178
-90
@@ -10,6 +10,17 @@
|
||||
#include "draw_task.h"
|
||||
#include "object.h"
|
||||
|
||||
namespace auth_3d_detail {
|
||||
class TaskAuth3d : public Task {
|
||||
public:
|
||||
TaskAuth3d();
|
||||
virtual ~TaskAuth3d() override;
|
||||
virtual bool Init() override;
|
||||
virtual bool Ctrl() override;
|
||||
virtual void Disp() override;
|
||||
};
|
||||
}
|
||||
|
||||
typedef a3da_ambient auth_3d_ambient_file;
|
||||
typedef a3da_camera_auxiliary auth_3d_camera_auxiliary_file;
|
||||
typedef a3da_camera_root auth_3d_camera_root_file;
|
||||
@@ -140,6 +151,7 @@ static void auth_3d_post_process_restore_prev_value(auth_3d_post_process* pp, re
|
||||
static void auth_3d_post_process_set(auth_3d_post_process* pp, render_context* rctx);
|
||||
|
||||
static bool auth_3d_data_struct_init(auth_3d_data_struct* auth_3d_data, render_context* rctx);
|
||||
static bool auth_3d_data_struct_check_category_loaded(auth_3d_data_struct* auth_3d_data, char* category_name);
|
||||
static bool auth_3d_data_struct_ctrl(auth_3d_data_struct* auth_3d_data, render_context* rctx);
|
||||
static void auth_3d_data_struct_disp(auth_3d_data_struct* auth_3d_data, render_context* rctx);
|
||||
static auth_3d_farc* auth_3d_data_struct_get_farc(auth_3d_data_struct* auth_3d_data, const char* category_name);
|
||||
@@ -150,7 +162,7 @@ static void auth_3d_data_struct_unload_category(auth_3d_data_struct* auth_3d_dat
|
||||
static void auth_3d_farc_free_data(auth_3d_farc* a3da_farc);
|
||||
static void auth_3d_farc_load(auth_3d_farc* a3da_farc, char* mdata_dir);
|
||||
static void auth_3d_farc_read_file(auth_3d_farc* a3da_farc, char* mdata_dir);
|
||||
static bool auth_3d_farc_read_func(auth_3d_farc* a3da_farc, void* data);
|
||||
static bool auth_3d_farc_read_func(auth_3d_farc* a3da_farc, void* data, size_t size);
|
||||
static void auth_3d_farc_unload(auth_3d_farc* a3da_farc);
|
||||
|
||||
static void auth_3d_uid_file_load(auth_3d_uid_file* uid_file);
|
||||
@@ -159,7 +171,7 @@ static void auth_3d_uid_file_unload(auth_3d_uid_file* uid_file);
|
||||
static void auth_3d_uid_file_unload_file(auth_3d_uid_file* uid_file);
|
||||
|
||||
auth_3d_data_struct auth_3d_data;
|
||||
TaskAuth3d task_auth_3d;
|
||||
auth_3d_detail::TaskAuth3d task_auth_3d;
|
||||
static int16_t auth_3d_load_counter;
|
||||
|
||||
extern render_context* rctx_ptr;
|
||||
@@ -509,7 +521,7 @@ void auth_3d::load(a3da* auth_file,
|
||||
if (i.parent_node != k.name)
|
||||
continue;
|
||||
|
||||
int32_t node_index = (int32_t)(&k - j.node.begin()._Ptr);
|
||||
int32_t node_index = (int32_t)(&k - j.node.data());
|
||||
j.childer_object_parent_node.push_back(node_index);
|
||||
j.children_object.push_back(&i);
|
||||
break;
|
||||
@@ -541,7 +553,7 @@ void auth_3d::load(a3da* auth_file,
|
||||
if (i.parent_node != k.name)
|
||||
continue;
|
||||
|
||||
int32_t node_index = (int32_t)(&k - j.node.begin()._Ptr);
|
||||
int32_t node_index = (int32_t)(&k - j.node.data());
|
||||
j.childer_object_hrc_parent_node.push_back(node_index);
|
||||
j.children_object_hrc.push_back(&i);
|
||||
break;
|
||||
@@ -605,26 +617,43 @@ void auth_3d::reset() {
|
||||
frame_offset = 0.0f;
|
||||
last_frame = 0.0f;
|
||||
paused = true;
|
||||
ambient = {};
|
||||
auth_2d = {};
|
||||
ambient.clear();
|
||||
ambient.shrink_to_fit();
|
||||
auth_2d.clear();
|
||||
auth_2d.shrink_to_fit();
|
||||
camera_auxiliary.reset();
|
||||
camera_root = {};
|
||||
chara = {};
|
||||
curve = {};
|
||||
camera_root.clear();
|
||||
camera_root.shrink_to_fit();
|
||||
chara.clear();
|
||||
chara.shrink_to_fit();
|
||||
curve.clear();
|
||||
curve.shrink_to_fit();
|
||||
dof.reset();
|
||||
event = {};
|
||||
fog = {};
|
||||
light = {};
|
||||
m_object_hrc = {};
|
||||
m_object_hrc_list = {};
|
||||
material_list = {};
|
||||
motion = {};
|
||||
object = {};
|
||||
object_hrc = {};
|
||||
object_hrc_list = {};
|
||||
object_list = {};
|
||||
event.clear();
|
||||
event.shrink_to_fit();
|
||||
fog.clear();
|
||||
fog.shrink_to_fit();
|
||||
light.clear();
|
||||
light.shrink_to_fit();
|
||||
m_object_hrc.clear();
|
||||
m_object_hrc.shrink_to_fit();
|
||||
m_object_hrc_list.clear();
|
||||
m_object_hrc_list.shrink_to_fit();
|
||||
material_list.clear();
|
||||
material_list.shrink_to_fit();
|
||||
motion.clear();
|
||||
motion.shrink_to_fit();
|
||||
object.clear();
|
||||
object.shrink_to_fit();
|
||||
object_hrc.clear();
|
||||
object_hrc.shrink_to_fit();
|
||||
object_hrc_list.clear();
|
||||
object_hrc_list.shrink_to_fit();
|
||||
object_list.clear();
|
||||
object_list.shrink_to_fit();
|
||||
play_control.reset();
|
||||
point = {};
|
||||
point.clear();
|
||||
point.shrink_to_fit();
|
||||
post_process.reset();
|
||||
}
|
||||
|
||||
@@ -667,7 +696,8 @@ inline void auth_3d_key::reset() {
|
||||
ep_type_post = (auth_3d_ep_type)0;
|
||||
frame_delta = 0.0f;
|
||||
value_delta = 0.0f;
|
||||
keys_vec = {};
|
||||
keys_vec.clear();
|
||||
keys_vec.shrink_to_fit();
|
||||
length = 0;
|
||||
keys = 0;
|
||||
frame = 0.0f;
|
||||
@@ -738,7 +768,8 @@ auth_3d_ambient::auth_3d_ambient() : flags() {
|
||||
void auth_3d_ambient::reset() {
|
||||
flags = (auth_3d_ambient_flags)0;
|
||||
light_diffuse.reset();
|
||||
name = {};
|
||||
name.clear();
|
||||
name.shrink_to_fit();
|
||||
rim_light_diffuse.reset();
|
||||
}
|
||||
|
||||
@@ -817,7 +848,8 @@ auth_3d_chara::auth_3d_chara() {
|
||||
|
||||
void auth_3d_chara::reset() {
|
||||
model_transform.reset();
|
||||
name = {};
|
||||
name.clear();
|
||||
name.shrink_to_fit();
|
||||
}
|
||||
|
||||
auth_3d_chara::~auth_3d_chara() {
|
||||
@@ -830,7 +862,8 @@ auth_3d_curve::auth_3d_curve() : value() {
|
||||
|
||||
void auth_3d_curve::reset() {
|
||||
curve.reset();
|
||||
name = {};
|
||||
name.clear();
|
||||
name.shrink_to_fit();
|
||||
value = 0.0f;
|
||||
}
|
||||
|
||||
@@ -861,9 +894,12 @@ void auth_3d_event::reset() {
|
||||
clip_begin = 0.0f;
|
||||
clip_end = 0.0f;
|
||||
end = 0.0f;
|
||||
name = {};
|
||||
param_1 = {};
|
||||
ref = {};
|
||||
name.clear();
|
||||
name.shrink_to_fit();
|
||||
param_1.clear();
|
||||
param_1.shrink_to_fit();
|
||||
ref.clear();
|
||||
ref.shrink_to_fit();
|
||||
time_ref_scale = 0.0f;
|
||||
type = (auth_3d_event_type)0;
|
||||
}
|
||||
@@ -924,7 +960,8 @@ void auth_3d_light::reset() {
|
||||
specular.reset();
|
||||
spot_direction.reset();
|
||||
tone_curve.reset();
|
||||
type = {};
|
||||
type.clear();
|
||||
type.shrink_to_fit();
|
||||
cone_angle_value = 0.0f;
|
||||
constant_value = 0.0f;
|
||||
drop_off_value = 0.0f;
|
||||
@@ -956,12 +993,15 @@ auth_3d_m_object_hrc::auth_3d_m_object_hrc() {
|
||||
void auth_3d_m_object_hrc::reset() {
|
||||
for (auth_3d_object_instance& i : instance)
|
||||
i.reset();
|
||||
instance = {};
|
||||
instance.clear();
|
||||
instance.shrink_to_fit();
|
||||
model_transform.reset();
|
||||
name = {};
|
||||
name.clear();
|
||||
name.shrink_to_fit();
|
||||
for (auth_3d_object_node& i : node)
|
||||
i.reset();
|
||||
node = {};
|
||||
node.clear();
|
||||
node.shrink_to_fit();
|
||||
}
|
||||
|
||||
auth_3d_m_object_hrc::~auth_3d_m_object_hrc() {
|
||||
@@ -977,7 +1017,8 @@ void auth_3d_material_list::reset() {
|
||||
blend_color.reset();
|
||||
glow_intensity.reset();
|
||||
incandescence.reset();
|
||||
name = {};
|
||||
name.clear();
|
||||
name.shrink_to_fit();
|
||||
glow_intensity_value = 0.0f;
|
||||
}
|
||||
|
||||
@@ -992,27 +1033,35 @@ auth_3d_object::auth_3d_object() : object_info(), object_hash(), reflect(), refr
|
||||
void auth_3d_object::reset() {
|
||||
for (auth_3d_object*& i : children_object)
|
||||
i = 0;
|
||||
children_object = {};
|
||||
children_object.clear();
|
||||
children_object.shrink_to_fit();
|
||||
for (auth_3d_object_hrc*& i : children_object_hrc)
|
||||
i = 0;
|
||||
children_object_hrc = {};
|
||||
children_object_hrc.clear();
|
||||
children_object_hrc.shrink_to_fit();
|
||||
model_transform.reset();
|
||||
morph.reset();
|
||||
object_info = object_info_null;
|
||||
object_info = ::object_info();
|
||||
object_hash = (uint32_t)-1;
|
||||
name = {};
|
||||
parent_name = {};
|
||||
parent_node = {};
|
||||
name.clear();
|
||||
name.shrink_to_fit();
|
||||
parent_name.clear();
|
||||
parent_name.shrink_to_fit();
|
||||
parent_node.clear();
|
||||
parent_node.shrink_to_fit();
|
||||
pattern.reset();
|
||||
reflect = false;
|
||||
refract = false;
|
||||
for (auth_3d_object_texture_pattern& i : texture_pattern)
|
||||
i.reset();
|
||||
texture_pattern = {};
|
||||
texture_pattern.clear();
|
||||
texture_pattern.shrink_to_fit();
|
||||
for (auth_3d_object_texture_transform& i : texture_transform)
|
||||
i.reset();
|
||||
texture_transform = {};
|
||||
uid_name = {};
|
||||
texture_transform.clear();
|
||||
texture_transform.shrink_to_fit();
|
||||
uid_name.clear();
|
||||
uid_name.shrink_to_fit();
|
||||
}
|
||||
|
||||
auth_3d_object::~auth_3d_object() {
|
||||
@@ -1025,7 +1074,8 @@ auth_3d_object_curve::auth_3d_object_curve() : curve(), frame_offset(), value()
|
||||
|
||||
void auth_3d_object_curve::reset() {
|
||||
curve = 0;
|
||||
name = {};
|
||||
name.clear();
|
||||
name.shrink_to_fit();
|
||||
frame_offset = 0.0f;
|
||||
value = 0.0f;
|
||||
}
|
||||
@@ -1042,25 +1092,35 @@ object_hash(), reflect(), refract(), shadow() {
|
||||
void auth_3d_object_hrc::reset() {
|
||||
for (auth_3d_object*& i : children_object)
|
||||
i = 0;
|
||||
children_object = {};
|
||||
children_object.clear();
|
||||
children_object.shrink_to_fit();
|
||||
for (auth_3d_object_hrc*& i : children_object_hrc)
|
||||
i = 0;
|
||||
children_object_hrc = {};
|
||||
childer_object_hrc_parent_node = {};
|
||||
childer_object_parent_node = {};
|
||||
mats = {};
|
||||
name = {};
|
||||
children_object_hrc.clear();
|
||||
children_object_hrc.shrink_to_fit();
|
||||
childer_object_hrc_parent_node.clear();
|
||||
childer_object_hrc_parent_node.shrink_to_fit();
|
||||
childer_object_parent_node.clear();
|
||||
childer_object_parent_node .shrink_to_fit();
|
||||
mats.clear();
|
||||
mats.shrink_to_fit();
|
||||
name.clear();
|
||||
name.shrink_to_fit();
|
||||
for (auth_3d_object_node& i : node)
|
||||
i.reset();
|
||||
node = {};
|
||||
object_info = object_info_null;
|
||||
node.clear();
|
||||
node.shrink_to_fit();
|
||||
object_info = ::object_info();
|
||||
object_hash = (uint32_t)-1;
|
||||
parent_name = {};
|
||||
parent_node = {};
|
||||
parent_name.clear();
|
||||
parent_name.shrink_to_fit();
|
||||
parent_node.clear();
|
||||
parent_node.shrink_to_fit();
|
||||
reflect = false;
|
||||
refract = false;
|
||||
shadow = false;
|
||||
uid_name = {};
|
||||
uid_name.clear();
|
||||
uid_name.shrink_to_fit();
|
||||
}
|
||||
|
||||
auth_3d_object_hrc::~auth_3d_object_hrc() {
|
||||
@@ -1072,14 +1132,18 @@ auth_3d_object_instance::auth_3d_object_instance() : object_info(), object_hash(
|
||||
}
|
||||
|
||||
void auth_3d_object_instance::reset() {
|
||||
mats = {};
|
||||
mats.clear();
|
||||
mats.shrink_to_fit();
|
||||
model_transform.reset();
|
||||
name = {};
|
||||
object_bone_indices = {};
|
||||
object_info = object_info_null;
|
||||
name.clear();
|
||||
name.shrink_to_fit();
|
||||
object_bone_indices.clear();
|
||||
object_bone_indices.shrink_to_fit();
|
||||
object_info = ::object_info();
|
||||
object_hash = (uint32_t)-1;
|
||||
shadow = false;
|
||||
uid_name = {};
|
||||
uid_name.clear();
|
||||
uid_name.shrink_to_fit();
|
||||
}
|
||||
|
||||
auth_3d_object_instance::~auth_3d_object_instance() {
|
||||
@@ -1127,7 +1191,8 @@ void auth_3d_object_node::reset() {
|
||||
joint_orient_mat = mat4u_identity;
|
||||
mat = 0;
|
||||
model_transform.reset();
|
||||
name = {};
|
||||
name.clear();
|
||||
name.shrink_to_fit();
|
||||
parent = -1;
|
||||
}
|
||||
|
||||
@@ -1140,7 +1205,8 @@ auth_3d_object_texture_pattern::auth_3d_object_texture_pattern() : texture_id()
|
||||
}
|
||||
|
||||
void auth_3d_object_texture_pattern::reset() {
|
||||
name = {};
|
||||
name.clear();
|
||||
name.shrink_to_fit();
|
||||
pattern.reset();
|
||||
texture_id = -1;
|
||||
}
|
||||
@@ -1158,7 +1224,8 @@ void auth_3d_object_texture_transform::reset() {
|
||||
coverage_u.reset();
|
||||
coverage_v.reset();
|
||||
mat = mat4u_identity;
|
||||
name = {};
|
||||
name.clear();
|
||||
name.shrink_to_fit();
|
||||
offset_u.reset();
|
||||
offset_v.reset();
|
||||
repeat_u.reset();
|
||||
@@ -1198,7 +1265,8 @@ auth_3d_point::auth_3d_point() {
|
||||
|
||||
void auth_3d_point::reset() {
|
||||
model_transform.reset();
|
||||
name = {};
|
||||
name.clear();
|
||||
name.shrink_to_fit();
|
||||
}
|
||||
|
||||
auth_3d_point::~auth_3d_point() {
|
||||
@@ -1601,6 +1669,10 @@ bool auth_3d_data_check_id_not_empty(int32_t* id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool auth_3d_data_check_category_loaded(char* category_name) {
|
||||
return auth_3d_data_struct_check_category_loaded(&auth_3d_data, category_name);
|
||||
}
|
||||
|
||||
auth_3d* auth_3d_data_get_auth_3d(int32_t id) {
|
||||
int32_t index = 0;
|
||||
while (auth_3d_data.data[index].id != id)
|
||||
@@ -1708,14 +1780,14 @@ float_t auth_3d_data_get_play_control_size(int32_t* id) {
|
||||
}
|
||||
|
||||
void auth_3d_data_load_auth_3d_db(auth_3d_database* auth_3d_db) {
|
||||
auth_3d_data.farcs = {};
|
||||
auth_3d_data.farcs.clear();
|
||||
auth_3d_data.farcs.resize(auth_3d_db->category.size());
|
||||
|
||||
size_t cat_index = 0;
|
||||
for (auth_3d_farc& i : auth_3d_data.farcs)
|
||||
i.name = auth_3d_db->category[cat_index++].name.c_str();
|
||||
|
||||
auth_3d_data.uid_files = {};
|
||||
auth_3d_data.uid_files.clear();
|
||||
auth_3d_data.uid_files.resize(auth_3d_db->uid.size());
|
||||
|
||||
size_t uid_index = 0;
|
||||
@@ -1945,6 +2017,10 @@ void auth_3d_data_unload_category(char* category_name) {
|
||||
auth_3d_data_struct_unload_category(&auth_3d_data, category_name);
|
||||
}
|
||||
|
||||
void task_auth_3d_append_task() {
|
||||
TaskWork::AppendTask(&task_auth_3d, "AUTH_3D");
|
||||
}
|
||||
|
||||
void auth_3d_data_unload_id(int32_t id, render_context* rctx) {
|
||||
if (id < 0 || (id & 0x7FFF) >= AUTH_3D_DATA_COUNT)
|
||||
return;
|
||||
@@ -1959,29 +2035,29 @@ void auth_3d_data_unload_id(int32_t id, render_context* rctx) {
|
||||
continue;
|
||||
|
||||
auth_3d_data.loaded_ids.erase(auth_3d_data.loaded_ids.begin()
|
||||
+ (&i - auth_3d_data.loaded_ids.begin()._Ptr));
|
||||
+ (&i - auth_3d_data.loaded_ids.data()));
|
||||
auth->unload(rctx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TaskAuth3d::TaskAuth3d() {
|
||||
auth_3d_detail::TaskAuth3d::TaskAuth3d() {
|
||||
|
||||
}
|
||||
|
||||
TaskAuth3d:: ~TaskAuth3d() {
|
||||
auth_3d_detail::TaskAuth3d:: ~TaskAuth3d() {
|
||||
|
||||
}
|
||||
|
||||
bool TaskAuth3d::Init() {
|
||||
bool auth_3d_detail::TaskAuth3d::Init() {
|
||||
return auth_3d_data_struct_init(&auth_3d_data, rctx_ptr);
|
||||
}
|
||||
|
||||
bool TaskAuth3d::Ctrl() {
|
||||
bool auth_3d_detail::TaskAuth3d::Ctrl() {
|
||||
return auth_3d_data_struct_ctrl(&auth_3d_data, rctx_ptr);
|
||||
}
|
||||
|
||||
void TaskAuth3d::Disp() {
|
||||
void auth_3d_detail::TaskAuth3d::Disp() {
|
||||
auth_3d_data_struct_disp(&auth_3d_data, rctx_ptr);
|
||||
}
|
||||
|
||||
@@ -2313,7 +2389,7 @@ static int32_t auth_3d_get_auth_3d_object_index_by_object_info(auth_3d* auth,
|
||||
for (auth_3d_object& i : auth->object)
|
||||
if (obj_info == i.object_info) {
|
||||
if (obj_instance == instance)
|
||||
return (int32_t)(&i - auth->object.begin()._Ptr);
|
||||
return (int32_t)(&i - auth->object.data());
|
||||
obj_instance++;
|
||||
}
|
||||
return -1;
|
||||
@@ -2325,7 +2401,7 @@ static int32_t auth_3d_get_auth_3d_object_index_by_hash(auth_3d* auth,
|
||||
for (auth_3d_object& i : auth->object)
|
||||
if (object_hash == i.object_hash) {
|
||||
if (obj_instance == instance)
|
||||
return (int32_t)(&i - auth->object.begin()._Ptr);
|
||||
return (int32_t)(&i - auth->object.data());
|
||||
obj_instance++;
|
||||
}
|
||||
return -1;
|
||||
@@ -2343,7 +2419,7 @@ static int32_t auth_3d_get_auth_3d_object_hrc_index_by_object_info(auth_3d* auth
|
||||
for (auth_3d_object_hrc& i : auth->object_hrc)
|
||||
if (obj_info == i.object_info) {
|
||||
if (obj_instance == instance)
|
||||
return (int32_t)(&i - auth->object_hrc.begin()._Ptr);
|
||||
return (int32_t)(&i - auth->object_hrc.data());
|
||||
obj_instance++;
|
||||
}
|
||||
return -1;
|
||||
@@ -2355,7 +2431,7 @@ static int32_t auth_3d_get_auth_3d_object_hrc_index_by_hash(auth_3d* auth,
|
||||
for (auth_3d_object_hrc& i : auth->object_hrc)
|
||||
if (object_hash == i.object_hash) {
|
||||
if (obj_instance == instance)
|
||||
return (int32_t)(&i - auth->object_hrc.begin()._Ptr);
|
||||
return (int32_t)(&i - auth->object_hrc.data());
|
||||
obj_instance++;
|
||||
}
|
||||
return -1;
|
||||
@@ -3134,7 +3210,7 @@ static void auth_3d_object_load(auth_3d* auth, auth_3d_object* o,
|
||||
o->reflect = strstr(o->uid_name.c_str(), "_REFLECT") ? true : false;
|
||||
o->refract = strstr(o->uid_name.c_str(), "_REFRACT") ? true : false;
|
||||
|
||||
o->object_info = object_database_get_object_info(obj_db, o->uid_name.c_str());
|
||||
o->object_info = obj_db->get_object_info(o->uid_name.c_str());
|
||||
o->object_hash = hash_string_murmurhash(&o->uid_name, 0, false);
|
||||
}
|
||||
|
||||
@@ -3239,22 +3315,22 @@ static void auth_3d_object_disp(auth_3d_object* o, auth_3d* auth, render_context
|
||||
morph = fmodf(morph, 1.0f);
|
||||
if (morph > 0.0f && morph < 1.0f) {
|
||||
sprintf_s(buf, sizeof(buf), "%.*s%03d", uid_name_length - 3, uid_name, morph_int + 1);
|
||||
object_info morph_obj_info = object_database_get_object_info(obj_db, buf);
|
||||
object_info morph_obj_info = obj_db->get_object_info(buf);
|
||||
if (morph_obj_info.is_null())
|
||||
morph_obj_info = o->object_info;
|
||||
object_data_set_morph(object_data, morph_obj_info, morph);
|
||||
|
||||
sprintf_s(buf, sizeof(buf), "%.*s%03d", uid_name_length - 3, uid_name, morph_int);
|
||||
object_info obj_info = object_database_get_object_info(obj_db, buf);
|
||||
object_info obj_info = obj_db->get_object_info(buf);
|
||||
draw_task_add_draw_object_by_object_info_opaque(rctx, &mat, obj_info);
|
||||
object_data_set_morph(object_data, object_info_null, 0.0f);
|
||||
object_data_set_morph(object_data, object_info(), 0.0f);
|
||||
}
|
||||
else {
|
||||
if (morph >= 1.0f)
|
||||
morph_int++;
|
||||
|
||||
sprintf_s(buf, sizeof(buf), "%.*s%03d", uid_name_length - 3, uid_name, morph_int);
|
||||
object_info obj_info = object_database_get_object_info(obj_db, buf);
|
||||
object_info obj_info = obj_db->get_object_info(buf);
|
||||
if (obj_info.is_null())
|
||||
obj_info = o->object_info;
|
||||
draw_task_add_draw_object_by_object_info_opaque(rctx, &mat, obj_info);
|
||||
@@ -3268,7 +3344,7 @@ static void auth_3d_object_disp(auth_3d_object* o, auth_3d* auth, render_context
|
||||
pat = (float_t)(int32_t)(pat - 0.5f);
|
||||
|
||||
sprintf_s(buf, sizeof(buf), "%.*s%03d", uid_name_length - 3, uid_name, (int32_t)pat);
|
||||
object_info obj_info = object_database_get_object_info(obj_db, buf);
|
||||
object_info obj_info = obj_db->get_object_info(buf);
|
||||
draw_task_add_draw_object_by_object_info_opaque(rctx, &mat, obj_info);
|
||||
}
|
||||
else
|
||||
@@ -3321,7 +3397,7 @@ static void auth_3d_object_hrc_load(auth_3d* auth, auth_3d_object_hrc* oh,
|
||||
oh->reflect = strstr(oh->uid_name.c_str(), "_REFLECT") ? true : false;
|
||||
oh->refract = strstr(oh->uid_name.c_str(), "_REFRACT") ? true : false;
|
||||
|
||||
oh->object_info = object_database_get_object_info(obj_db, oh->uid_name.c_str());
|
||||
oh->object_info = obj_db->get_object_info(oh->uid_name.c_str());
|
||||
oh->object_hash = hash_string_murmurhash(&oh->uid_name, 0, false);
|
||||
|
||||
object* obj = object_storage_get_object(oh->object_info);
|
||||
@@ -3446,7 +3522,7 @@ static void auth_3d_object_instance_load(auth_3d* auth, auth_3d_object_instance*
|
||||
oi->shadow = oif->shadow;
|
||||
oi->uid_name = oif->uid_name;
|
||||
|
||||
oi->object_info = object_database_get_object_info(obj_db, oi->uid_name.c_str());
|
||||
oi->object_info = obj_db->get_object_info(oi->uid_name.c_str());
|
||||
oi->object_hash = hash_string_murmurhash(&oi->uid_name, 0, false);
|
||||
|
||||
object* obj = object_storage_get_object(oi->object_info);
|
||||
@@ -3466,7 +3542,7 @@ static void auth_3d_object_instance_load(auth_3d* auth, auth_3d_object_instance*
|
||||
if (!str_utils_compare(j.name.c_str(), string_data(&skin->bones[i].name))) {
|
||||
int32_t bone_id = skin->bones[i].id;
|
||||
if (!(bone_id & 0x8000))
|
||||
object_bone_indices[bone_id] = (int32_t)(&j - moh->node.begin()._Ptr);
|
||||
object_bone_indices[bone_id] = (int32_t)(&j - moh->node.data());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3892,12 +3968,22 @@ static void auth_3d_post_process_set(auth_3d_post_process* pp, render_context* r
|
||||
}
|
||||
|
||||
static bool auth_3d_data_struct_init(auth_3d_data_struct* auth_3d_data, render_context* rctx) {
|
||||
auth_3d_data->loaded_ids = {};
|
||||
auth_3d_data->loaded_ids.clear();
|
||||
auth_3d_data->loaded_ids.shrink_to_fit();
|
||||
for (int32_t i = 0; i < AUTH_3D_DATA_COUNT; i++)
|
||||
auth_3d_data->data[i].reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool auth_3d_data_struct_check_category_loaded(auth_3d_data_struct* auth_3d_data, char* category_name) {
|
||||
if (category_name) {
|
||||
auth_3d_farc* a3da_farc = auth_3d_data_struct_get_farc(auth_3d_data, category_name);
|
||||
if (a3da_farc)
|
||||
return a3da_farc->state == 2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool auth_3d_data_struct_ctrl(auth_3d_data_struct* auth_3d_data, render_context* rctx) {
|
||||
for (int32_t& i : auth_3d_data->loaded_ids)
|
||||
if (i >= 0 && (i & 0x7FFF) < AUTH_3D_DATA_COUNT) {
|
||||
@@ -3955,8 +4041,10 @@ static void auth_3d_farc_free_data(auth_3d_farc* a3da_farc) {
|
||||
a3da_farc->file_handler.free_data();
|
||||
}
|
||||
|
||||
a3da_farc->path = {};
|
||||
a3da_farc->file = {};
|
||||
a3da_farc->path.clear();
|
||||
a3da_farc->path.shrink_to_fit();
|
||||
a3da_farc->file.clear();
|
||||
a3da_farc->file.shrink_to_fit();
|
||||
a3da_farc->data = 0;
|
||||
a3da_farc->size = 0;
|
||||
a3da_farc->state = 0;
|
||||
@@ -3988,16 +4076,16 @@ static void auth_3d_farc_read_file(auth_3d_farc* a3da_farc, char* mdata_dir) {
|
||||
if (a3da_farc->file_handler.read_file_path((char*)a3da_farc->path.c_str(),
|
||||
(char*)a3da_farc->file.c_str()))
|
||||
a3da_farc->file_handler.set_read_free_func_data(0,
|
||||
(void(*)(void*, void*))auth_3d_farc_read_func, a3da_farc);
|
||||
(void(*)(void*, void*, size_t))auth_3d_farc_read_func, a3da_farc);
|
||||
else
|
||||
a3da_farc->state = 2;
|
||||
}
|
||||
|
||||
static bool auth_3d_farc_read_func(auth_3d_farc* a3da_farc, void* data) {
|
||||
static bool auth_3d_farc_read_func(auth_3d_farc* a3da_farc, void* data, size_t size) {
|
||||
if (a3da_farc->state == 1) {
|
||||
a3da_farc->state = 2;
|
||||
a3da_farc->data = data;
|
||||
a3da_farc->size = a3da_farc->file_handler.get_size();
|
||||
a3da_farc->size = size;
|
||||
}
|
||||
|
||||
a3da_farc->farc = new farc;
|
||||
|
||||
+4
-11
@@ -661,7 +661,6 @@ class auth_3d {
|
||||
public:
|
||||
int32_t uid;
|
||||
int32_t id;
|
||||
mat4u mat;
|
||||
bool enable;
|
||||
bool camera_root_update;
|
||||
bool visible;
|
||||
@@ -669,6 +668,7 @@ public:
|
||||
bool ended;
|
||||
bool left_right_reverse;
|
||||
bool once;
|
||||
mat4u mat;
|
||||
float_t alpha;
|
||||
draw_task_flags draw_task_flags;
|
||||
int32_t chara_id;
|
||||
@@ -763,19 +763,10 @@ public:
|
||||
~auth_3d_data_struct();
|
||||
};
|
||||
|
||||
class TaskAuth3d : public Task {
|
||||
public:
|
||||
TaskAuth3d();
|
||||
virtual ~TaskAuth3d() override;
|
||||
virtual bool Init() override;
|
||||
virtual bool Ctrl() override;
|
||||
virtual void Disp() override;
|
||||
};
|
||||
|
||||
extern auth_3d_data_struct auth_3d_data;
|
||||
extern TaskAuth3d task_auth_3d;
|
||||
|
||||
extern bool auth_3d_data_check_id_not_empty(int32_t* id);
|
||||
extern bool auth_3d_data_check_category_loaded(char* category_name);
|
||||
extern auth_3d* auth_3d_data_get_auth_3d(int32_t id);
|
||||
extern int32_t auth_3d_data_get_chara_id(int32_t id);
|
||||
extern int32_t auth_3d_data_get_auth_3d_id_by_object_info(object_info obj_info,
|
||||
@@ -811,3 +802,5 @@ extern void auth_3d_data_set_shadow(int32_t* id, bool value);
|
||||
extern void auth_3d_data_set_visibility(int32_t* id, bool value);
|
||||
extern void auth_3d_data_unload_category(char* category_name);
|
||||
extern void auth_3d_data_unload_id(int32_t id, render_context* rctx);
|
||||
|
||||
extern void task_auth_3d_append_task();
|
||||
|
||||
+222
-204
@@ -9,57 +9,171 @@
|
||||
#include "../KKdLib/hash.h"
|
||||
#include "../KKdLib/str_utils.h"
|
||||
|
||||
data_struct data_list[DATA_MAX];
|
||||
data_struct* data_list;
|
||||
|
||||
static char default_config[] = "#AFT\n\n\n";
|
||||
|
||||
static void data_free_inner(data_struct* ds);
|
||||
static void data_load_inner(stream* s);
|
||||
#if defined(CRE_DEV)
|
||||
static void data_load_glitter_list(data_struct* ds, char* path);
|
||||
static void data_load_glitter_list(data_struct* ds, const char* path);
|
||||
#endif
|
||||
|
||||
void data_struct_init() {
|
||||
data_list = new data_struct[8];
|
||||
for (int32_t i = DATA_AFT; i < DATA_MAX; i++)
|
||||
data_list[i].type = (data_type)i;
|
||||
}
|
||||
|
||||
void data_struct_load(char* path) {
|
||||
void data_struct_load(const char* path) {
|
||||
stream s;
|
||||
io_open(&s, path, "rb");
|
||||
if (s.io.stream)
|
||||
data_load_inner(&s);
|
||||
else {
|
||||
io_free(&s);
|
||||
io_mopen(&s, default_config, 7);
|
||||
io_open(&s, default_config, 7);
|
||||
data_load_inner(&s);
|
||||
}
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
inline void data_struct_load(const char* path) {
|
||||
data_struct_load((char*)path);
|
||||
}
|
||||
|
||||
void data_struct_load(wchar_t* path) {
|
||||
void data_struct_load(const wchar_t* path) {
|
||||
stream s;
|
||||
io_wopen(&s, path, L"rb");
|
||||
io_open(&s, path, L"rb");
|
||||
if (s.io.stream)
|
||||
data_load_inner(&s);
|
||||
else {
|
||||
io_free(&s);
|
||||
io_mopen(&s, default_config, 7);
|
||||
io_open(&s, default_config, 7);
|
||||
data_load_inner(&s);
|
||||
}
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
inline void data_struct_load(const wchar_t* path) {
|
||||
data_struct_load((wchar_t*)path);
|
||||
void data_struct_free() {
|
||||
if (data_list[DATA_AFT].ready) {
|
||||
data_struct* ds = &data_list[DATA_AFT];
|
||||
data_ft* d = &ds->data_ft;
|
||||
|
||||
stage_database_free(&d->stage_data);
|
||||
|
||||
stage_database_free(&d->base_stage_data);
|
||||
}
|
||||
#if defined(CRE_DEV)
|
||||
if (data_list[DATA_F2BE].ready) {
|
||||
data_struct* ds = &data_list[DATA_F2BE];
|
||||
data_f2* d = &ds->data_f2;
|
||||
}
|
||||
|
||||
if (data_list[DATA_F2LE].ready) {
|
||||
data_struct* ds = &data_list[DATA_F2LE];
|
||||
data_f2* d = &ds->data_f2;
|
||||
}
|
||||
|
||||
if (data_list[DATA_FT].ready) {
|
||||
data_struct* ds = &data_list[DATA_FT];
|
||||
data_ft* d = &ds->data_ft;
|
||||
}
|
||||
|
||||
if (data_list[DATA_M39].ready) {
|
||||
data_struct* ds = &data_list[DATA_M39];
|
||||
data_ft* d = &ds->data_ft;
|
||||
}
|
||||
|
||||
if (data_list[DATA_VRFL].ready) {
|
||||
data_struct* ds = &data_list[DATA_VRFL];
|
||||
data_x* d = &ds->data_x;
|
||||
}
|
||||
|
||||
if (data_list[DATA_X].ready) {
|
||||
data_struct* ds = &data_list[DATA_X];
|
||||
data_x* d = &ds->data_x;
|
||||
}
|
||||
|
||||
if (data_list[DATA_XHD].ready) {
|
||||
data_struct* ds = &data_list[DATA_XHD];
|
||||
data_x* d = &ds->data_x;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int32_t i = DATA_AFT; i < DATA_MAX; i++)
|
||||
data_free_inner(&data_list[i]);
|
||||
delete[] data_list;
|
||||
}
|
||||
|
||||
void data_struct_get_directory_files(data_struct* ds, char* dir, std::vector<data_struct_file>* data_files) {
|
||||
*data_files = {};
|
||||
bool data_struct::check_file_exists(const char* dir, const char* file) {
|
||||
if (path_check_directory_exists(dir)) {
|
||||
const char* t = strrchr(file, '.');
|
||||
size_t t_len;
|
||||
if (t)
|
||||
t_len = t - file;
|
||||
else
|
||||
t_len = utf8_length(file);
|
||||
|
||||
uint32_t h = hash_murmurhash(file, t_len, 0, false, false);
|
||||
std::string path = std::string(dir) + file;
|
||||
if (path_check_file_exists(path.c_str()))
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t dir_len = utf8_length(dir);
|
||||
if (dir_len >= 2 && !memcmp(dir, "./", 2)) {
|
||||
dir += 2;
|
||||
dir_len -= 2;
|
||||
}
|
||||
|
||||
if (dir_len < 3 || memcmp(dir, "rom", 3))
|
||||
return false;
|
||||
|
||||
dir += 3;
|
||||
dir_len -= 3;
|
||||
|
||||
while (*dir == '/' || *dir == '\\') {
|
||||
dir++;
|
||||
dir_len--;
|
||||
}
|
||||
|
||||
size_t max_len = 0;
|
||||
for (data_struct_path& i : data_paths)
|
||||
for (data_struct_directory& j : i.data)
|
||||
if (max_len < j.path.size())
|
||||
max_len = j.path.size();
|
||||
|
||||
char* dir_temp = force_malloc_s(char, dir_len + 1);
|
||||
memcpy(dir_temp, dir, dir_len + 1);
|
||||
|
||||
char* t = dir_temp;
|
||||
while (t = strchr(t, '/'))
|
||||
*t = '\\';
|
||||
|
||||
char* temp = force_malloc_s(char, max_len + dir_len + 2);
|
||||
for (data_struct_path& i : data_paths)
|
||||
for (data_struct_directory& j : i.data) {
|
||||
const char* path = j.path.c_str();
|
||||
size_t path_len = j.path.size();
|
||||
|
||||
memcpy(temp, path, path_len);
|
||||
memcpy(&temp[path_len], "\\", 2);
|
||||
if (dir_len)
|
||||
memcpy(&temp[path_len + 1], dir_temp, dir_len + 1);
|
||||
|
||||
std::string path_temp = std::string(temp) + file;
|
||||
if (path_check_file_exists(path_temp.c_str())) {
|
||||
free(dir_temp);
|
||||
free(temp);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
free(dir_temp);
|
||||
free(temp);
|
||||
return false;
|
||||
}
|
||||
|
||||
void data_struct::get_directory_files(const char* dir, std::vector<data_struct_file>* data_files) {
|
||||
data_files->clear();
|
||||
data_files->shrink_to_fit();
|
||||
|
||||
size_t dir_len = utf8_length(dir);
|
||||
if (dir_len >= 2 && !memcmp(dir, "./", 2)) {
|
||||
@@ -79,7 +193,7 @@ void data_struct_get_directory_files(data_struct* ds, char* dir, std::vector<dat
|
||||
}
|
||||
|
||||
size_t max_len = 0;
|
||||
for (data_struct_path& i : ds->data_paths)
|
||||
for (data_struct_path& i : data_paths)
|
||||
for (data_struct_directory& j : i.data)
|
||||
if (max_len < j.path.size())
|
||||
max_len = j.path.size();
|
||||
@@ -92,7 +206,7 @@ void data_struct_get_directory_files(data_struct* ds, char* dir, std::vector<dat
|
||||
*t = '\\';
|
||||
|
||||
char* temp = force_malloc_s(char, max_len + dir_len + 2);
|
||||
for (data_struct_path& i : ds->data_paths)
|
||||
for (data_struct_path& i : data_paths)
|
||||
for (data_struct_directory& j : i.data) {
|
||||
const char* path = j.path.c_str();
|
||||
size_t path_len = j.path.size();
|
||||
@@ -102,14 +216,12 @@ void data_struct_get_directory_files(data_struct* ds, char* dir, std::vector<dat
|
||||
if (dir_len)
|
||||
memcpy(&temp[path_len + 1], dir_temp, dir_len + 1);
|
||||
|
||||
vector_old_string files = vector_old_empty(string);
|
||||
std::vector<std::string> files;
|
||||
path_get_files(&files, temp);
|
||||
for (string* k = files.begin; k != files.end; k++) {
|
||||
char* k_str = string_data(k);
|
||||
size_t len = k->length;
|
||||
for (std::string& k : files) {
|
||||
bool found = false;
|
||||
for (data_struct_file& l : *data_files)
|
||||
if (!memcmp(k_str, l.name.c_str(), min(len, l.name.size()) + 1)) {
|
||||
if (k == l.name) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -119,25 +231,19 @@ void data_struct_get_directory_files(data_struct* ds, char* dir, std::vector<dat
|
||||
|
||||
data_struct_file f;
|
||||
f.path = std::string(temp);
|
||||
f.name = std::string(string_data(k), k->length);
|
||||
*k = string_empty;
|
||||
f.name = k;
|
||||
data_files->push_back(f);
|
||||
}
|
||||
vector_old_string_free(&files, string_free);
|
||||
}
|
||||
|
||||
free(dir_temp);
|
||||
free(temp);
|
||||
}
|
||||
|
||||
inline void data_struct_get_directory_files(data_struct* ds, const char* dir, std::vector<data_struct_file>* data_files) {
|
||||
data_struct_get_directory_files(ds, (char*)dir, data_files);
|
||||
}
|
||||
|
||||
bool data_struct_load_file(data_struct* ds, void* data, char* dir, char* file,
|
||||
bool (*load_func)(void* data, char* path, char* file, uint32_t hash)) {
|
||||
bool data_struct::load_file(void* data, const char* dir, const char* file,
|
||||
bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash)) {
|
||||
if (path_check_directory_exists(dir)) {
|
||||
char* t = strrchr(file, '.');
|
||||
const char* t = strrchr(file, '.');
|
||||
size_t t_len;
|
||||
if (t)
|
||||
t_len = t - file;
|
||||
@@ -168,7 +274,7 @@ bool data_struct_load_file(data_struct* ds, void* data, char* dir, char* file,
|
||||
}
|
||||
|
||||
size_t max_len = 0;
|
||||
for (data_struct_path& i : ds->data_paths)
|
||||
for (data_struct_path& i : data_paths)
|
||||
for (data_struct_directory& j : i.data)
|
||||
if (max_len < j.path.size())
|
||||
max_len = j.path.size();
|
||||
@@ -181,7 +287,7 @@ bool data_struct_load_file(data_struct* ds, void* data, char* dir, char* file,
|
||||
*t = '\\';
|
||||
|
||||
char* temp = force_malloc_s(char, max_len + dir_len + 2);
|
||||
for (data_struct_path& i : ds->data_paths)
|
||||
for (data_struct_path& i : data_paths)
|
||||
for (data_struct_directory& j : i.data) {
|
||||
const char* path = j.path.c_str();
|
||||
size_t path_len = j.path.size();
|
||||
@@ -191,25 +297,18 @@ bool data_struct_load_file(data_struct* ds, void* data, char* dir, char* file,
|
||||
if (dir_len)
|
||||
memcpy(&temp[path_len + 1], dir_temp, dir_len + 1);
|
||||
|
||||
vector_old_string files = vector_old_empty(string);
|
||||
path_get_files(&files, temp);
|
||||
|
||||
std::string path_temp = std::string(temp) + file;
|
||||
bool ret = false;
|
||||
for (string* l = files.begin; l != files.end; l++) {
|
||||
if (str_utils_compare(string_data(l), file))
|
||||
continue;
|
||||
|
||||
char* l_str = string_data(l);
|
||||
char* t = strrchr(l_str, '.');
|
||||
size_t l_len = l->length;
|
||||
if (path_check_file_exists(path_temp.c_str())) {
|
||||
const char* l_str = file;
|
||||
const char* t = strrchr(l_str, '.');
|
||||
size_t l_len = utf8_length(file);
|
||||
if (t)
|
||||
l_len = t - l_str;
|
||||
|
||||
uint32_t h = hash_murmurhash(l_str, l_len, 0, false, false);
|
||||
ret = load_func(data, temp, l_str, h);
|
||||
break;
|
||||
}
|
||||
vector_old_string_free(&files, string_free);
|
||||
|
||||
if (ret) {
|
||||
free(dir_temp);
|
||||
@@ -223,23 +322,8 @@ bool data_struct_load_file(data_struct* ds, void* data, char* dir, char* file,
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool data_struct_load_file(data_struct* c, void* data, char* dir, const char* file,
|
||||
bool (*load_func)(void* data, char* path, char* file, uint32_t hash)) {
|
||||
return data_struct_load_file(c, data, dir, (char*)file, load_func);
|
||||
}
|
||||
|
||||
inline bool data_struct_load_file(data_struct* c, void* data, const char* dir, char* file,
|
||||
bool (*load_func)(void* data, char* path, char* file, uint32_t hash)) {
|
||||
return data_struct_load_file(c, data, (char*)dir, file, load_func);
|
||||
}
|
||||
|
||||
inline bool data_struct_load_file(data_struct* c, void* data, const char* dir, const char* file,
|
||||
bool (*load_func)(void* data, char* path, char* file, uint32_t hash)) {
|
||||
return data_struct_load_file(c, data, (char*)dir, (char*)file, load_func);
|
||||
}
|
||||
|
||||
bool data_struct_load_file_by_hash(data_struct* ds, void* data, char* dir, uint32_t hash,
|
||||
bool (*load_func)(void* data, char* path, char* file, uint32_t hash)) {
|
||||
bool data_struct::load_file_by_hash(void* data, const char* dir, uint32_t hash,
|
||||
bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash)) {
|
||||
size_t dir_len = utf8_length(dir);
|
||||
if (dir_len >= 2 && !memcmp(dir, "./", 2)) {
|
||||
dir += 2;
|
||||
@@ -258,7 +342,7 @@ bool data_struct_load_file_by_hash(data_struct* ds, void* data, char* dir, uint3
|
||||
}
|
||||
|
||||
size_t max_len = 0;
|
||||
for (data_struct_path& i : ds->data_paths)
|
||||
for (data_struct_path& i : data_paths)
|
||||
for (data_struct_directory& j : i.data)
|
||||
if (max_len < j.path.size())
|
||||
max_len = j.path.size();
|
||||
@@ -271,7 +355,7 @@ bool data_struct_load_file_by_hash(data_struct* ds, void* data, char* dir, uint3
|
||||
*t = '\\';
|
||||
|
||||
char* temp = force_malloc_s(char, max_len + dir_len + 2);
|
||||
for (data_struct_path& i : ds->data_paths)
|
||||
for (data_struct_path& i : data_paths)
|
||||
for (data_struct_directory& j : i.data) {
|
||||
const char* path = j.path.c_str();
|
||||
size_t path_len = j.path.size();
|
||||
@@ -281,31 +365,28 @@ bool data_struct_load_file_by_hash(data_struct* ds, void* data, char* dir, uint3
|
||||
if (dir_len)
|
||||
memcpy(&temp[path_len + 1], dir_temp, dir_len + 1);
|
||||
|
||||
vector_old_string files = vector_old_empty(string);
|
||||
std::vector<std::string> files;
|
||||
path_get_files(&files, temp);
|
||||
|
||||
vector_old_uint32_t files_murmurhash = vector_old_empty(uint32_t);
|
||||
vector_old_uint32_t_reserve(&files_murmurhash, vector_old_length(files));
|
||||
for (string* l = files.begin; l != files.end; l++) {
|
||||
char* t = strrchr(string_data(l), '.');
|
||||
size_t t_len = l->length;
|
||||
std::vector<uint32_t> files_murmurhash;
|
||||
files_murmurhash.reserve(files.size());
|
||||
for (std::string& l : files) {
|
||||
const char* t = strrchr(l.c_str(), '.');
|
||||
size_t t_len = l.size();
|
||||
if (t)
|
||||
t_len = t - string_data(l);
|
||||
t = string_data(l);
|
||||
t_len = t - l.c_str();
|
||||
t = l.c_str();
|
||||
|
||||
uint32_t h = hash_murmurhash(t, t_len, 0, false, false);
|
||||
vector_old_uint32_t_push_back(&files_murmurhash, &h);
|
||||
files_murmurhash.push_back(hash_murmurhash(t, t_len, 0, false, false));
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
for (uint32_t* l = files_murmurhash.begin; l != files_murmurhash.end; l++)
|
||||
if (*l == hash) {
|
||||
string* file = &files.begin[l - files_murmurhash.begin];
|
||||
ret = load_func(data, temp, string_data(file), hash);
|
||||
for (uint32_t& l : files_murmurhash)
|
||||
if (l == hash) {
|
||||
std::string& file = files[&l - files_murmurhash.data()];
|
||||
ret = load_func(data, temp, (char*)file.c_str(), hash);
|
||||
break;
|
||||
}
|
||||
vector_old_string_free(&files, string_free);
|
||||
vector_old_uint32_t_free(&files_murmurhash, 0);
|
||||
|
||||
if (ret) {
|
||||
free(dir_temp);
|
||||
@@ -319,70 +400,6 @@ bool data_struct_load_file_by_hash(data_struct* ds, void* data, char* dir, uint3
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool data_struct_load_file_by_hash(data_struct* c, void* data, const char* dir, uint32_t hash,
|
||||
bool (*load_func)(void* data, char* path, char* file, uint32_t hash)) {
|
||||
return data_struct_load_file_by_hash(c, data, (char*)dir, hash, load_func);
|
||||
}
|
||||
|
||||
void data_struct_free() {
|
||||
if (data_list[DATA_AFT].ready) {
|
||||
data_struct* ds = &data_list[DATA_AFT];
|
||||
data_ft* d = &ds->data_ft;
|
||||
|
||||
bone_database_free(&d->bone_data);
|
||||
object_database_free(&d->obj_db);
|
||||
stage_database_free(&d->stage_data);
|
||||
|
||||
object_database_free(&d->base_obj_db);
|
||||
stage_database_free(&d->base_stage_data);
|
||||
}
|
||||
#if defined(CRE_DEV)
|
||||
if (data_list[DATA_F2BE].ready) {
|
||||
data_struct* ds = &data_list[DATA_F2BE];
|
||||
data_f2* d = &ds->data_f2;
|
||||
}
|
||||
|
||||
if (data_list[DATA_F2LE].ready) {
|
||||
data_struct* ds = &data_list[DATA_F2LE];
|
||||
data_f2* d = &ds->data_f2;
|
||||
}
|
||||
|
||||
if (data_list[DATA_FT].ready) {
|
||||
data_struct* ds = &data_list[DATA_FT];
|
||||
data_ft* d = &ds->data_ft;
|
||||
}
|
||||
|
||||
if (data_list[DATA_M39].ready) {
|
||||
data_struct* ds = &data_list[DATA_M39];
|
||||
data_ft* d = &ds->data_ft;
|
||||
}
|
||||
|
||||
if (data_list[DATA_VRFL].ready) {
|
||||
data_struct* ds = &data_list[DATA_VRFL];
|
||||
data_x* d = &ds->data_x;
|
||||
|
||||
bone_database_free(&d->bone_data);
|
||||
}
|
||||
|
||||
if (data_list[DATA_X].ready) {
|
||||
data_struct* ds = &data_list[DATA_X];
|
||||
data_x* d = &ds->data_x;
|
||||
|
||||
bone_database_free(&d->bone_data);
|
||||
}
|
||||
|
||||
if (data_list[DATA_XHD].ready) {
|
||||
data_struct* ds = &data_list[DATA_XHD];
|
||||
data_x* d = &ds->data_x;
|
||||
|
||||
bone_database_free(&d->bone_data);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int32_t i = DATA_AFT; i < DATA_MAX; i++)
|
||||
data_free_inner(&data_list[i]);
|
||||
}
|
||||
|
||||
data_struct::data_struct() : type(), ready() {
|
||||
|
||||
}
|
||||
@@ -415,51 +432,56 @@ data_struct_path::~data_struct_path() {
|
||||
|
||||
}
|
||||
|
||||
data_f2::data_f2() : bone_data() {
|
||||
#if defined(CRE_DEV)
|
||||
data_f2::data_f2() {
|
||||
|
||||
}
|
||||
|
||||
data_f2::~data_f2() {
|
||||
bone_database_free(&bone_data);
|
||||
}
|
||||
|
||||
data_ft::data_ft() : bone_data(), obj_db(), stage_data(), base_obj_db(), base_stage_data() {
|
||||
}
|
||||
#endif
|
||||
|
||||
data_ft::data_ft() : obj_db(), stage_data(), base_obj_db(), base_stage_data() {
|
||||
|
||||
}
|
||||
|
||||
data_ft::~data_ft() {
|
||||
bone_database_free(&bone_data);
|
||||
object_database_free(&obj_db);
|
||||
stage_database_free(&stage_data);
|
||||
object_database_free(&base_obj_db);
|
||||
stage_database_free(&base_stage_data);
|
||||
}
|
||||
|
||||
data_x::data_x() : bone_data() {
|
||||
#if defined(CRE_DEV)
|
||||
data_x::data_x() {
|
||||
|
||||
}
|
||||
|
||||
data_x::~data_x() {
|
||||
bone_database_free(&bone_data);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
static void data_free_inner(data_struct* ds) {
|
||||
ds->data_paths = {};
|
||||
ds->data_paths.clear();
|
||||
ds->data_paths.shrink_to_fit();
|
||||
|
||||
#if defined(CRE_DEV)
|
||||
ds->glitter_list_names = {};
|
||||
ds->glitter_list_names.clear();
|
||||
ds->glitter_list_names.shrink_to_fit();
|
||||
switch (ds->type) {
|
||||
case DATA_F2LE:
|
||||
case DATA_F2BE:
|
||||
case DATA_VRFL:
|
||||
case DATA_X:
|
||||
case DATA_XHD:
|
||||
ds->glitter_list_murmurhash = {};
|
||||
ds->glitter_list_murmurhash.clear();
|
||||
ds->glitter_list_murmurhash.shrink_to_fit();
|
||||
break;
|
||||
case DATA_AFT:
|
||||
case DATA_FT:
|
||||
case DATA_M39:
|
||||
ds->glitter_list_fnv1a64m = {};
|
||||
ds->glitter_list_fnv1a64m.clear();
|
||||
ds->glitter_list_fnv1a64m.shrink_to_fit();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@@ -641,45 +663,43 @@ static void data_load_inner(stream* s) {
|
||||
add_data_rom_path_len--;
|
||||
}
|
||||
|
||||
vector_old_string data_directories = vector_old_empty(string);
|
||||
std::vector<std::string> data_directories;
|
||||
path_get_directories(&data_directories, add_data_rom_path, &main_rom_path, 1);
|
||||
|
||||
max_len = 0;
|
||||
for (string* k = data_directories.begin; k != data_directories.end; k++) {
|
||||
size_t len = k->length;
|
||||
for (std::string& k : data_directories) {
|
||||
size_t len = k.size();
|
||||
if (max_len < len)
|
||||
max_len = len;
|
||||
}
|
||||
|
||||
char* data_dir_path_temp = force_malloc_s(char, add_data_rom_path_len + max_len + add_data_rom_len + 3);
|
||||
if (data_dir_path_temp) {
|
||||
j.data.reserve(vector_old_length(data_directories) + 1);
|
||||
j.data.reserve(data_directories.size() + 1);
|
||||
memcpy(data_dir_path_temp, add_data_rom_path, add_data_rom_path_len);
|
||||
data_dir_path_temp[add_data_rom_path_len] = '\\';
|
||||
for (string* k = data_directories.end - 1; k != data_directories.begin - 1; k--) {
|
||||
memcpy(&data_dir_path_temp[add_data_rom_path_len + 1], string_data(k), k->length + 1);
|
||||
for (std::vector<std::string>::reverse_iterator k = data_directories.rbegin();
|
||||
k != data_directories.rend(); k++) {
|
||||
memcpy(&data_dir_path_temp[add_data_rom_path_len + 1], k->c_str(), k->size() + 1);
|
||||
if (add_data_rom_len) {
|
||||
data_dir_path_temp[add_data_rom_path_len + 1 + k->length] = '\\';
|
||||
memcpy(&data_dir_path_temp[add_data_rom_path_len + 1 + k->length + 1],
|
||||
data_dir_path_temp[add_data_rom_path_len + 1 + k->size()] = '\\';
|
||||
memcpy(&data_dir_path_temp[add_data_rom_path_len + 1 + k->size() + 1],
|
||||
add_data_rom, add_data_rom_len + 1);
|
||||
}
|
||||
|
||||
data_struct_directory data_dir;
|
||||
data_dir.path = std::string(data_dir_path_temp);
|
||||
data_dir.name = std::string(string_data(k), k->length);
|
||||
data_dir.name = *k;
|
||||
j.data.push_back(data_dir);
|
||||
}
|
||||
vector_old_string_free(&data_directories, 0);
|
||||
}
|
||||
else {
|
||||
else
|
||||
j.data.reserve(1);
|
||||
vector_old_string_free(&data_directories, string_free);
|
||||
}
|
||||
free(data_dir_path_temp);
|
||||
|
||||
data_struct_directory data_dir;
|
||||
data_dir.path = std::string(main_rom_path);
|
||||
data_dir.name = {};
|
||||
data_dir.name = std::string();
|
||||
j.data.push_back(data_dir);
|
||||
free(data_dir_path_temp);
|
||||
}
|
||||
@@ -696,12 +716,12 @@ static void data_load_inner(stream* s) {
|
||||
|
||||
{
|
||||
auth_3d_database_file* base_auth_3d_db = &d->base_auth_3d_db;
|
||||
*base_auth_3d_db = {};
|
||||
data_struct_load_file(ds, base_auth_3d_db, "rom/auth_3d/",
|
||||
*base_auth_3d_db = auth_3d_database_file();
|
||||
ds->load_file(base_auth_3d_db, "rom/auth_3d/",
|
||||
"auth_3d_db.bin", auth_3d_database_file::load_file);
|
||||
|
||||
auth_3d_database_file mdata_auth_3d_db;
|
||||
data_struct_load_file(ds, &mdata_auth_3d_db, "rom/auth_3d/",
|
||||
ds->load_file(&mdata_auth_3d_db, "rom/auth_3d/",
|
||||
"mdata_auth_3d_db.bin", auth_3d_database_file::load_file);
|
||||
|
||||
d->auth_3d_db.merge_mdata(base_auth_3d_db, &mdata_auth_3d_db);
|
||||
@@ -709,19 +729,19 @@ static void data_load_inner(stream* s) {
|
||||
|
||||
{
|
||||
bone_database* bone_data = &d->bone_data;
|
||||
bone_database_init(bone_data);
|
||||
*bone_data = bone_database();
|
||||
bone_data->modern = false;
|
||||
data_struct_load_file(ds, bone_data, "rom/",
|
||||
"bone_data.bin", bone_database_load_file);
|
||||
ds->load_file(bone_data, "rom/",
|
||||
"bone_data.bin", bone_database::load_file);
|
||||
}
|
||||
|
||||
{
|
||||
motion_database* base_mot_db = &d->base_mot_db;
|
||||
data_struct_load_file(ds, base_mot_db, "rom/rob/",
|
||||
ds->load_file(base_mot_db, "rom/rob/",
|
||||
"mot_db.farc", motion_database::load_file);
|
||||
|
||||
motion_database mdata_mot_db;
|
||||
data_struct_load_file(ds, &mdata_mot_db, "rom/rob/",
|
||||
ds->load_file(&mdata_mot_db, "rom/rob/",
|
||||
"mdata_mot_db.farc", motion_database::load_file);
|
||||
|
||||
d->mot_db.merge_mdata(base_mot_db, &mdata_mot_db);
|
||||
@@ -729,34 +749,32 @@ static void data_load_inner(stream* s) {
|
||||
|
||||
{
|
||||
object_database* base_obj_db = &d->base_obj_db;
|
||||
object_database_init(base_obj_db);
|
||||
*base_obj_db = object_database();
|
||||
base_obj_db->modern = false;
|
||||
data_struct_load_file(ds, base_obj_db, "rom/objset/",
|
||||
"obj_db.bin", object_database_load_file);
|
||||
ds->load_file(base_obj_db, "rom/objset/",
|
||||
"obj_db.bin", object_database::load_file);
|
||||
|
||||
object_database mdata_obj_db;
|
||||
object_database_init(&mdata_obj_db);
|
||||
mdata_obj_db.modern = false;
|
||||
data_struct_load_file(ds, &mdata_obj_db, "rom/objset/",
|
||||
"mdata_obj_db.bin", object_database_load_file);
|
||||
ds->load_file(&mdata_obj_db, "rom/objset/",
|
||||
"mdata_obj_db.bin", object_database::load_file);
|
||||
|
||||
object_database* obj_db = &d->obj_db;
|
||||
object_database_init(obj_db);
|
||||
object_database_merge_mdata(obj_db, base_obj_db, &mdata_obj_db);
|
||||
object_database_free(&mdata_obj_db);
|
||||
*obj_db = object_database();
|
||||
obj_db->merge_mdata(base_obj_db, &mdata_obj_db);
|
||||
}
|
||||
|
||||
{
|
||||
stage_database* base_stage_data = &d->base_stage_data;
|
||||
stage_database_init(base_stage_data);
|
||||
base_stage_data->modern = false;
|
||||
data_struct_load_file(ds, base_stage_data, "rom/",
|
||||
ds->load_file(base_stage_data, "rom/",
|
||||
"stage_data.bin", stage_database_load_file);
|
||||
|
||||
stage_database mdata_stage_data;
|
||||
stage_database_init(&mdata_stage_data);
|
||||
mdata_stage_data.modern = false;
|
||||
data_struct_load_file(ds, &mdata_stage_data, "rom/",
|
||||
ds->load_file(&mdata_stage_data, "rom/",
|
||||
"mdata_stage_data.bin", stage_database_load_file);
|
||||
|
||||
stage_database* stage_data = &d->stage_data;
|
||||
@@ -767,14 +785,14 @@ static void data_load_inner(stream* s) {
|
||||
|
||||
{
|
||||
texture_database* base_tex_db = &d->base_tex_db;
|
||||
*base_tex_db = {};
|
||||
*base_tex_db = texture_database();
|
||||
base_tex_db->modern = false;
|
||||
data_struct_load_file(ds, base_tex_db, "rom/objset/",
|
||||
ds->load_file(base_tex_db, "rom/objset/",
|
||||
"tex_db.bin", texture_database::load_file);
|
||||
|
||||
texture_database mdata_tex_db;
|
||||
mdata_tex_db.modern = false;
|
||||
data_struct_load_file(ds, &mdata_tex_db, "rom/objset/",
|
||||
ds->load_file(&mdata_tex_db, "rom/objset/",
|
||||
"mdata_tex_db.bin", texture_database::load_file);
|
||||
|
||||
d->tex_db.merge_mdata(base_tex_db, &mdata_tex_db);
|
||||
@@ -804,10 +822,10 @@ static void data_load_inner(stream* s) {
|
||||
|
||||
{
|
||||
bone_database* bone_data = &d->bone_data;
|
||||
bone_database_init(bone_data);
|
||||
*bone_data = bone_database();
|
||||
bone_data->modern = true;
|
||||
data_struct_load_file(ds, bone_data, "rom/",
|
||||
"bone_data.bon", bone_database_load_file);
|
||||
ds->load_file(bone_data, "rom/",
|
||||
"bone_data.bon", bone_database::load_file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -817,10 +835,10 @@ static void data_load_inner(stream* s) {
|
||||
|
||||
{
|
||||
bone_database* bone_data = &d->bone_data;
|
||||
bone_database_init(bone_data);
|
||||
*bone_data = bone_database();
|
||||
bone_data->modern = true;
|
||||
data_struct_load_file(ds, bone_data, "rom/",
|
||||
"bone_data.bon", bone_database_load_file);
|
||||
ds->load_file(bone_data, "rom/",
|
||||
"bone_data.bon", bone_database::load_file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -830,17 +848,17 @@ static void data_load_inner(stream* s) {
|
||||
|
||||
{
|
||||
bone_database* bone_data = &d->bone_data;
|
||||
bone_database_init(bone_data);
|
||||
*bone_data = bone_database();
|
||||
bone_data->modern = true;
|
||||
data_struct_load_file(ds, bone_data, "rom/",
|
||||
"bone_data.bon", bone_database_load_file);
|
||||
ds->load_file(bone_data, "rom/",
|
||||
"bone_data.bon", bone_database::load_file);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(CRE_DEV)
|
||||
static void data_load_glitter_list(data_struct* ds, char* path) {
|
||||
static void data_load_glitter_list(data_struct* ds, const char* path) {
|
||||
stream s;
|
||||
io_open(&s, path, "rb");
|
||||
size_t length = s.length;
|
||||
|
||||
+8
-17
@@ -116,29 +116,20 @@ public:
|
||||
|
||||
data_struct();
|
||||
~data_struct();
|
||||
|
||||
bool check_file_exists(const char* dir, const char* file);
|
||||
void get_directory_files(const char* dir, std::vector<data_struct_file>* data_files);
|
||||
bool load_file(void* data, const char* dir, const char* file,
|
||||
bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash));
|
||||
bool load_file_by_hash(void* data, const char* dir, uint32_t hash,
|
||||
bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash));
|
||||
};
|
||||
|
||||
extern data_struct data_list[];
|
||||
extern data_struct* data_list;
|
||||
|
||||
#define DATA_LOAD_FILE_FUNC(f)
|
||||
|
||||
extern void data_struct_init();
|
||||
extern void data_struct_load(char* path);
|
||||
extern void data_struct_load(const char* path);
|
||||
extern void data_struct_load(wchar_t* path);
|
||||
extern void data_struct_load(const wchar_t* path);
|
||||
extern void data_struct_get_directory_files(data_struct* c, char* dir, std::vector<data_struct_file>* data_files);
|
||||
extern void data_struct_get_directory_files(data_struct* c, const char* dir, std::vector<data_struct_file>* data_files);
|
||||
extern bool data_struct_load_file(data_struct* c, void* data, char* dir, char* file,
|
||||
bool (*load_func)(void* data, char* path, char* file, uint32_t hash));
|
||||
extern bool data_struct_load_file(data_struct* c, void* data, char* dir, const char* file,
|
||||
bool (*load_func)(void* data, char* path, char* file, uint32_t hash));
|
||||
extern bool data_struct_load_file(data_struct* c, void* data, const char* dir, char* file,
|
||||
bool (*load_func)(void* data, char* path, char* file, uint32_t hash));
|
||||
extern bool data_struct_load_file(data_struct* c, void* data, const char* dir, const char* file,
|
||||
bool (*load_func)(void* data, char* path, char* file, uint32_t hash));
|
||||
extern bool data_struct_load_file_by_hash(data_struct* c, void* data, char* dir, uint32_t hash,
|
||||
bool (*load_func)(void* data, char* path, char* file, uint32_t hash));
|
||||
extern bool data_struct_load_file_by_hash(data_struct* c, void* data, const char* dir, uint32_t hash,
|
||||
bool (*load_func)(void* data, char* path, char* file, uint32_t hash));
|
||||
extern void data_struct_free();
|
||||
|
||||
+191
-190
@@ -11,40 +11,40 @@
|
||||
|
||||
#define enable_vertex_attrib_array(index) \
|
||||
glEnableVertexAttribArray(index); \
|
||||
disp->vertex_attrib_array[index] = true
|
||||
draw->vertex_attrib_array[index] = true
|
||||
|
||||
static bool draw_object_blend_set(render_context* rctx,
|
||||
draw_object* disp, object_material_shader_lighting_type lighting_type);
|
||||
draw_object* draw, object_material_shader_lighting_type lighting_type);
|
||||
static void draw_object_chara_color_fog_set(render_context* rctx,
|
||||
draw_object* disp, bool disable_fog);
|
||||
draw_object* draw, bool disable_fog);
|
||||
static void draw_object_material_reset_default(object_material_data* mat_data);
|
||||
static void draw_object_material_reset_reflect();
|
||||
static void draw_object_material_set_default(render_context* rctx,
|
||||
draw_object* disp, bool use_shader);
|
||||
draw_object* draw, bool use_shader);
|
||||
static void draw_object_material_set_parameter(render_context* rctx,
|
||||
object_material_data* mat_data);
|
||||
static void draw_object_material_set_reflect(render_context* rctx, draw_object* disp);
|
||||
static void draw_object_material_set_reflect(render_context* rctx, draw_object* draw);
|
||||
static void draw_object_material_set_uniform(render_context* rctx,
|
||||
object_material_data* mat_data, bool disable_color_l);
|
||||
static void draw_object_vertex_attrib_reset_default(draw_object* disp);
|
||||
static void draw_object_vertex_attrib_reset_default_compressed(draw_object* disp);
|
||||
static void draw_object_vertex_attrib_reset_reflect(draw_object* disp);
|
||||
static void draw_object_vertex_attrib_reset_reflect_compressed(draw_object* disp);
|
||||
static void draw_object_vertex_attrib_set_default(draw_object* disp);
|
||||
static void draw_object_vertex_attrib_set_default_compressed(draw_object* disp);
|
||||
static void draw_object_vertex_attrib_set_reflect(draw_object* disp);
|
||||
static void draw_object_vertex_attrib_set_reflect_compressed(draw_object* disp);
|
||||
static void draw_object_vertex_attrib_reset_default(draw_object* draw);
|
||||
static void draw_object_vertex_attrib_reset_default_compressed(draw_object* draw);
|
||||
static void draw_object_vertex_attrib_reset_reflect(draw_object* draw);
|
||||
static void draw_object_vertex_attrib_reset_reflect_compressed(draw_object* draw);
|
||||
static void draw_object_vertex_attrib_set_default(draw_object* draw);
|
||||
static void draw_object_vertex_attrib_set_default_compressed(draw_object* draw);
|
||||
static void draw_object_vertex_attrib_set_reflect(draw_object* draw);
|
||||
static void draw_object_vertex_attrib_set_reflect_compressed(draw_object* draw);
|
||||
|
||||
void draw_object_draw(render_context* rctx, draw_object* disp, mat4* model,
|
||||
void(*draw_object_func)(render_context* rctx, draw_object* disp), int32_t show_vector_old) {
|
||||
if (disp->mats) {
|
||||
mat4u* mats = disp->mats;
|
||||
if (disp->mat_count == 2) {
|
||||
void draw_object_draw(render_context* rctx, draw_object* draw, mat4* model,
|
||||
void(*draw_object_func)(render_context* rctx, draw_object* draw), int32_t show_vector_old) {
|
||||
if (draw->mats) {
|
||||
mat4u* mats = draw->mats;
|
||||
if (draw->mat_count == 2) {
|
||||
mat4 mat = *mats;;
|
||||
shader_state_matrix_set_program(&shaders_ft, 7, &mat);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < disp->mat_count; i++, mats++) {
|
||||
for (int32_t i = 0; i < draw->mat_count; i++, mats++) {
|
||||
mat4 mat = *mats;
|
||||
mat4_transpose(&mat, &mat);
|
||||
shader_buffer_set_ptr_array(&shaders_ft, (size_t)i * 3, 3, (vec4*)&mat);
|
||||
@@ -58,60 +58,60 @@ void draw_object_draw(render_context* rctx, draw_object* disp, mat4* model,
|
||||
}
|
||||
|
||||
mat4 mat;
|
||||
if (disp->mesh->flags & OBJECT_MESH_BILLBOARD)
|
||||
if (draw->mesh->flags & OBJECT_MESH_BILLBOARD)
|
||||
model_mat_face_camera_view(&rctx->camera->inv_view_rot, model, &mat);
|
||||
else if (disp->mesh->flags & OBJECT_MESH_BILLBOARD_Y_AXIS)
|
||||
else if (draw->mesh->flags & OBJECT_MESH_BILLBOARD_Y_AXIS)
|
||||
model_mat_face_camera_position(&rctx->camera->view, model, &mat);
|
||||
else
|
||||
mat = *model;
|
||||
draw_object_model_mat_load(rctx, &mat);
|
||||
|
||||
if (!show_vector_old)
|
||||
draw_object_func(rctx, disp);
|
||||
draw_object_func(rctx, draw);
|
||||
uniform_value[U_BONE_MAT] = 0;
|
||||
}
|
||||
|
||||
void draw_object_draw_default(render_context* rctx, draw_object* disp) {
|
||||
if (disp->set_blend_color) {
|
||||
vec4 blend_color = disp->blend_color;
|
||||
void draw_object_draw_default(render_context* rctx, draw_object* draw) {
|
||||
if (draw->set_blend_color) {
|
||||
vec4 blend_color = draw->blend_color;
|
||||
shader_env_vert_set_ptr(&shaders_ft, 3, &blend_color);
|
||||
shader_env_vert_set_ptr(&shaders_ft, 4, (vec4*)&vec4_null);
|
||||
}
|
||||
|
||||
if (!disp->draw_object_func)
|
||||
draw_object_vertex_attrib_set_default(disp);
|
||||
if (!draw->draw_object_func)
|
||||
draw_object_vertex_attrib_set_default(draw);
|
||||
|
||||
draw_object_material_set_default(rctx, disp, rctx->draw_state.shader);
|
||||
if (!disp->instances_count)
|
||||
draw_object_material_set_default(rctx, draw, rctx->draw_state.shader);
|
||||
if (!draw->instances_count)
|
||||
object_sub_mesh_draw(rctx,
|
||||
disp->sub_mesh->primitive_type,
|
||||
disp->sub_mesh->indices_count,
|
||||
disp->sub_mesh->first_index,
|
||||
disp->sub_mesh->last_index,
|
||||
disp->sub_mesh->index_format,
|
||||
disp->sub_mesh->indices_offset);
|
||||
draw->sub_mesh->primitive_type,
|
||||
draw->sub_mesh->indices_count,
|
||||
draw->sub_mesh->first_index,
|
||||
draw->sub_mesh->last_index,
|
||||
draw->sub_mesh->index_format,
|
||||
draw->sub_mesh->indices_offset);
|
||||
else
|
||||
for (int32_t i = 0; i < disp->instances_count; i++) {
|
||||
for (int32_t i = 0; i < draw->instances_count; i++) {
|
||||
mat4 mat;
|
||||
mat4_transpose(&disp->instances_mat[i], &mat);
|
||||
mat4_transpose(&draw->instances_mat[i], &mat);
|
||||
glVertexAttrib4fv(12, (const GLfloat*)&mat.row0);
|
||||
glVertexAttrib4fv(13, (const GLfloat*)&mat.row1);
|
||||
glVertexAttrib4fv(14, (const GLfloat*)&mat.row2);
|
||||
glVertexAttrib4fv(15, (const GLfloat*)&mat.row3);
|
||||
object_sub_mesh_draw(rctx,
|
||||
disp->sub_mesh->primitive_type,
|
||||
disp->sub_mesh->indices_count,
|
||||
disp->sub_mesh->first_index,
|
||||
disp->sub_mesh->last_index,
|
||||
disp->sub_mesh->index_format,
|
||||
disp->sub_mesh->indices_offset);
|
||||
draw->sub_mesh->primitive_type,
|
||||
draw->sub_mesh->indices_count,
|
||||
draw->sub_mesh->first_index,
|
||||
draw->sub_mesh->last_index,
|
||||
draw->sub_mesh->index_format,
|
||||
draw->sub_mesh->indices_offset);
|
||||
}
|
||||
|
||||
draw_object_material_reset_default(disp->material);
|
||||
if (!disp->draw_object_func)
|
||||
draw_object_vertex_attrib_reset_default(disp);
|
||||
draw_object_material_reset_default(draw->material);
|
||||
if (!draw->draw_object_func)
|
||||
draw_object_vertex_attrib_reset_default(draw);
|
||||
|
||||
if (disp->set_blend_color) {
|
||||
if (draw->set_blend_color) {
|
||||
shader_env_vert_set_ptr(&shaders_ft, 3, (vec4*)&vec4_identity);
|
||||
shader_env_vert_set_ptr(&shaders_ft, 4, (vec4*)&vec4_null);
|
||||
}
|
||||
@@ -119,16 +119,16 @@ void draw_object_draw_default(render_context* rctx, draw_object* disp) {
|
||||
rctx->draw_state.stats.object_draw_count++;
|
||||
}
|
||||
|
||||
void draw_object_draw_sss(render_context* rctx, draw_object* disp) {
|
||||
object_material_blend_flags blend_flags = disp->material->material.blend_flags;
|
||||
uniform_value[U_ALPHA_TEST] = (!blend_flags.flag_28 && (disp->blend_color.w < 1.0f
|
||||
void draw_object_draw_sss(render_context* rctx, draw_object* draw) {
|
||||
object_material_blend_flags blend_flags = draw->material->material.blend_flags;
|
||||
uniform_value[U_ALPHA_TEST] = (!blend_flags.flag_28 && (draw->blend_color.w < 1.0f
|
||||
|| (blend_flags.alpha_texture || blend_flags.alpha_material) && !blend_flags.punch_through
|
||||
|| disp->sub_mesh->flags & OBJECT_SUB_MESH_TRANSPARENT)
|
||||
|| draw->sub_mesh->flags & OBJECT_SUB_MESH_TRANSPARENT)
|
||||
|| blend_flags.punch_through) ? 1 : 0;
|
||||
|
||||
uniform_value[U26] = 1;
|
||||
bool aniso = false;
|
||||
object_material_data* material = disp->material;
|
||||
object_material_data* material = draw->material;
|
||||
switch (material->material.shader_index) {
|
||||
case SHADER_FT_CLOTH:
|
||||
if (!rctx->draw_pass.npr_param && material->material.ambient.w < 1.0f
|
||||
@@ -157,19 +157,19 @@ void draw_object_draw_sss(render_context* rctx, draw_object* disp) {
|
||||
shader_env_frag_set(&shaders_ft, 25, sss_param.x, sss_param.y, sss_param.z, 0.5f);
|
||||
uniform_value[U37] = 0;
|
||||
}
|
||||
draw_object_draw_default(rctx, disp);
|
||||
draw_object_draw_default(rctx, draw);
|
||||
}
|
||||
|
||||
void draw_object_draw_reflect(render_context* rctx, draw_object* disp) {
|
||||
object_material_data* material = disp->material;
|
||||
draw_object_vertex_attrib_set_reflect(disp);
|
||||
void draw_object_draw_reflect(render_context* rctx, draw_object* draw) {
|
||||
object_material_data* material = draw->material;
|
||||
draw_object_vertex_attrib_set_reflect(draw);
|
||||
object_material_shader_lighting_type lighting_type =
|
||||
object_material_shader_get_lighting_type(&material->material.shader_flags);
|
||||
bool disable_fog = draw_object_blend_set(rctx, disp, lighting_type);
|
||||
draw_object_chara_color_fog_set(rctx, disp, disable_fog);
|
||||
draw_object_material_set_reflect(rctx, disp);
|
||||
bool disable_fog = draw_object_blend_set(rctx, draw, lighting_type);
|
||||
draw_object_chara_color_fog_set(rctx, draw, disable_fog);
|
||||
draw_object_material_set_reflect(rctx, draw);
|
||||
|
||||
object_sub_mesh* sub_mesh = disp->sub_mesh;
|
||||
object_sub_mesh* sub_mesh = draw->sub_mesh;
|
||||
if (sub_mesh->index_format != OBJECT_INDEX_U8)
|
||||
object_sub_mesh_draw(rctx,
|
||||
sub_mesh->primitive_type,
|
||||
@@ -180,17 +180,17 @@ void draw_object_draw_reflect(render_context* rctx, draw_object* disp) {
|
||||
sub_mesh->indices_offset);
|
||||
|
||||
draw_object_material_reset_reflect();
|
||||
draw_object_vertex_attrib_reset_reflect(disp);
|
||||
draw_object_vertex_attrib_reset_reflect(draw);
|
||||
uniform_value_reset();
|
||||
|
||||
rctx->draw_state.stats.object_reflect_draw_count++;
|
||||
}
|
||||
|
||||
void draw_object_draw_reflect_reflect_map(render_context* rctx, draw_object* disp) {
|
||||
draw_object_vertex_attrib_set_reflect(disp);
|
||||
draw_object_material_set_reflect(rctx, disp);
|
||||
void draw_object_draw_reflect_reflect_map(render_context* rctx, draw_object* draw) {
|
||||
draw_object_vertex_attrib_set_reflect(draw);
|
||||
draw_object_material_set_reflect(rctx, draw);
|
||||
|
||||
object_sub_mesh* sub_mesh = disp->sub_mesh;
|
||||
object_sub_mesh* sub_mesh = draw->sub_mesh;
|
||||
if (sub_mesh->index_format != OBJECT_INDEX_U8)
|
||||
object_sub_mesh_draw(rctx,
|
||||
sub_mesh->primitive_type,
|
||||
@@ -201,29 +201,29 @@ void draw_object_draw_reflect_reflect_map(render_context* rctx, draw_object* dis
|
||||
sub_mesh->indices_offset);
|
||||
|
||||
draw_object_material_reset_reflect();
|
||||
draw_object_vertex_attrib_reset_reflect(disp);
|
||||
draw_object_vertex_attrib_reset_reflect(draw);
|
||||
|
||||
rctx->draw_state.stats.object_reflect_draw_count++;
|
||||
}
|
||||
|
||||
void draw_object_draw_shadow(render_context* rctx, draw_object* disp) {
|
||||
object_material_blend_flags blend_flags = disp->material->material.blend_flags;
|
||||
if (!blend_flags.flag_28 && (disp->blend_color.w < 1.0f
|
||||
void draw_object_draw_shadow(render_context* rctx, draw_object* draw) {
|
||||
object_material_blend_flags blend_flags = draw->material->material.blend_flags;
|
||||
if (!blend_flags.flag_28 && (draw->blend_color.w < 1.0f
|
||||
|| (blend_flags.alpha_texture || blend_flags.alpha_material) && !blend_flags.punch_through
|
||||
|| disp->sub_mesh->flags & OBJECT_SUB_MESH_TRANSPARENT)
|
||||
|| draw->sub_mesh->flags & OBJECT_SUB_MESH_TRANSPARENT)
|
||||
|| blend_flags.punch_through) {
|
||||
uniform_value[U_ALPHA_TEST] = 1;
|
||||
draw_object_draw_translucent(rctx, disp);
|
||||
draw_object_draw_translucent(rctx, draw);
|
||||
}
|
||||
else {
|
||||
uniform_value[U_ALPHA_TEST] = 0;
|
||||
draw_object_draw_translucent(rctx, disp);
|
||||
draw_object_draw_translucent(rctx, draw);
|
||||
}
|
||||
}
|
||||
|
||||
void draw_object_draw_translucent(render_context* rctx, draw_object* disp) {
|
||||
object_material_data* material = disp->material;
|
||||
GLuint* textures = disp->textures;
|
||||
void draw_object_draw_translucent(render_context* rctx, draw_object* draw) {
|
||||
object_material_data* material = draw->material;
|
||||
GLuint* textures = draw->textures;
|
||||
if (rctx->draw_state.shader_index != -1) {
|
||||
vec4 emission = material->material.emission;
|
||||
shader_state_material_set_emission_ptr(&shaders_ft, false, &emission);
|
||||
@@ -233,8 +233,8 @@ void draw_object_draw_translucent(render_context* rctx, draw_object* disp) {
|
||||
shader_set(&shaders_ft, rctx->draw_state.shader_index);
|
||||
}
|
||||
|
||||
draw_object_vertex_attrib_set_default(disp);
|
||||
if (disp->material->material.blend_flags.double_sided)
|
||||
draw_object_vertex_attrib_set_default(draw);
|
||||
if (draw->material->material.blend_flags.double_sided)
|
||||
gl_state_disable_cull_face();
|
||||
|
||||
GLuint tex_id = -1;
|
||||
@@ -265,9 +265,9 @@ void draw_object_draw_translucent(render_context* rctx, draw_object* disp) {
|
||||
}
|
||||
|
||||
if (texture_id != -1) {
|
||||
for (int32_t j = 0; j < disp->texture_pattern_count; j++)
|
||||
if (disp->texture_pattern_array[j].src == texture_id) {
|
||||
texture* tex = texture_storage_get_texture(disp->texture_pattern_array[j].dst);
|
||||
for (int32_t j = 0; j < draw->texture_pattern_count; j++)
|
||||
if (draw->texture_pattern_array[j].src == texture_id) {
|
||||
texture* tex = texture_storage_get_texture(draw->texture_pattern_array[j].dst);
|
||||
if (tex)
|
||||
tex_id = tex->texture;
|
||||
break;
|
||||
@@ -283,7 +283,7 @@ void draw_object_draw_translucent(render_context* rctx, draw_object* disp) {
|
||||
}
|
||||
}
|
||||
|
||||
object_sub_mesh* sub_mesh = disp->sub_mesh;
|
||||
object_sub_mesh* sub_mesh = draw->sub_mesh;
|
||||
if (sub_mesh->index_format != OBJECT_INDEX_U8)
|
||||
object_sub_mesh_draw(rctx,
|
||||
sub_mesh->primitive_type,
|
||||
@@ -297,7 +297,7 @@ void draw_object_draw_translucent(render_context* rctx, draw_object* disp) {
|
||||
gl_state_active_bind_texture_2d(tex_index, 0);
|
||||
|
||||
gl_state_enable_cull_face();
|
||||
draw_object_vertex_attrib_reset_default(disp);
|
||||
draw_object_vertex_attrib_reset_default(draw);
|
||||
|
||||
if (rctx->draw_state.shader_index != -1)
|
||||
uniform_value_reset();
|
||||
@@ -381,7 +381,8 @@ void object_sub_mesh_draw(render_context* rctx, object_primitive_type primitive_
|
||||
rctx->draw_state.stats.draw_triangle_count += count - 2;
|
||||
}
|
||||
|
||||
static bool draw_object_blend_set(render_context* rctx, draw_object* disp, object_material_shader_lighting_type lighting_type) {
|
||||
static bool draw_object_blend_set(render_context* rctx,
|
||||
draw_object* draw, object_material_shader_lighting_type lighting_type) {
|
||||
GLenum blend_factor_table[] = {
|
||||
GL_ZERO,
|
||||
GL_ONE,
|
||||
@@ -401,14 +402,14 @@ static bool draw_object_blend_set(render_context* rctx, draw_object* disp, objec
|
||||
GL_ZERO,
|
||||
};
|
||||
|
||||
object_material_data* material = disp->material;
|
||||
object_material_data* material = draw->material;
|
||||
object_material_blend_flags blend_flags = material->material.blend_flags;
|
||||
if ((!blend_flags.alpha_texture && !blend_flags.alpha_material) || blend_flags.punch_through)
|
||||
return false;
|
||||
|
||||
GLenum src_blend_factor = blend_factor_table[blend_flags.src_blend_factor & 0xF];
|
||||
GLenum dst_blend_factor = blend_factor_table[blend_flags.dst_blend_factor & 0xF];
|
||||
if (disp->chara_color) {
|
||||
if (draw->chara_color) {
|
||||
light_set* set = &rctx->light_set_data[LIGHT_SET_MAIN];
|
||||
light_data* chara_color = &set->lights[LIGHT_CHARA_COLOR];
|
||||
vec4 specular;
|
||||
@@ -443,9 +444,9 @@ static bool draw_object_blend_set(render_context* rctx, draw_object* disp, objec
|
||||
return dst_blend_factor == GL_ONE;
|
||||
}
|
||||
|
||||
static void draw_object_chara_color_fog_set(render_context* rctx, draw_object* disp, bool disable_fog) {
|
||||
static void draw_object_chara_color_fog_set(render_context* rctx, draw_object* draw, bool disable_fog) {
|
||||
uniform_value[U_CHARA_COLOR] = 0;
|
||||
if (disp->chara_color) {
|
||||
if (draw->chara_color) {
|
||||
light_set* set = &rctx->light_set_data[LIGHT_SET_MAIN];
|
||||
light_data* chara_color = &set->lights[LIGHT_CHARA_COLOR];
|
||||
vec4 specular;
|
||||
@@ -454,7 +455,7 @@ static void draw_object_chara_color_fog_set(render_context* rctx, draw_object* d
|
||||
uniform_value[U_CHARA_COLOR] = 1;
|
||||
}
|
||||
|
||||
object_material_blend_flags blend_flags = disp->material->material.blend_flags;
|
||||
object_material_blend_flags blend_flags = draw->material->material.blend_flags;
|
||||
if (!blend_flags.no_fog && !disable_fog) {
|
||||
if (blend_flags.has_fog_height)
|
||||
uniform_value[U_FOG_HEIGHT] = 2 + blend_flags.fog_height;
|
||||
@@ -480,33 +481,33 @@ static void draw_object_material_reset_reflect() {
|
||||
uniform_value_reset();
|
||||
}
|
||||
|
||||
static void draw_object_material_set_default(render_context* rctx, draw_object* disp, bool use_shader) {
|
||||
GLuint* textures = disp->textures;
|
||||
object_material_data* material = disp->material;
|
||||
static void draw_object_material_set_default(render_context* rctx, draw_object* draw, bool use_shader) {
|
||||
GLuint* textures = draw->textures;
|
||||
object_material_data* material = draw->material;
|
||||
object_material_shader_lighting_type lighting_type =
|
||||
object_material_shader_get_lighting_type(&material->material.shader_flags);
|
||||
bool disable_fog = draw_object_blend_set(rctx, disp, lighting_type);
|
||||
bool disable_fog = draw_object_blend_set(rctx, draw, lighting_type);
|
||||
draw_object_material_set_uniform(rctx, material, false);
|
||||
if (!rctx->draw_state.light)
|
||||
uniform_value[U_LIGHT_0] = 0;
|
||||
else if (disp->self_shadow)
|
||||
uniform_value[U_LIGHT_0] = disp->self_shadow ? 1 : 1;
|
||||
else if (draw->self_shadow)
|
||||
uniform_value[U_LIGHT_0] = draw->self_shadow ? 1 : 1;
|
||||
else
|
||||
uniform_value[U_LIGHT_0] = disp->sub_mesh->flags & OBJECT_SUB_MESH_RECIEVE_SHADOW ? 1 : 0;
|
||||
uniform_value[U_LIGHT_0] = draw->sub_mesh->flags & OBJECT_SUB_MESH_RECIEVE_SHADOW ? 1 : 0;
|
||||
uniform_value[U_SHADOW] = 0;
|
||||
uniform_value[U_SELF_SHADOW] = rctx->draw_state.self_shadow ? 1 : 0;
|
||||
|
||||
object_material_texture* mat_tex = material->material.textures;
|
||||
uniform_value[U_SHADOW] = disp->shadow > SHADOW_CHARA;
|
||||
uniform_value[U_SHADOW] = draw->shadow > SHADOW_CHARA;
|
||||
for (int32_t i = 0, j = 0; i < 8; i++, mat_tex++) {
|
||||
if (mat_tex->texture_id == -1)
|
||||
continue;
|
||||
|
||||
GLuint tex_id = -1;
|
||||
uint32_t texture_id = mat_tex->texture_id;
|
||||
for (int32_t j = 0; j < disp->texture_pattern_count; j++)
|
||||
if (disp->texture_pattern_array[j].src == texture_id) {
|
||||
texture* tex = texture_storage_get_texture(disp->texture_pattern_array[j].dst);
|
||||
for (int32_t j = 0; j < draw->texture_pattern_count; j++)
|
||||
if (draw->texture_pattern_array[j].src == texture_id) {
|
||||
texture* tex = texture_storage_get_texture(draw->texture_pattern_array[j].dst);
|
||||
if (tex)
|
||||
tex_id = tex->texture;
|
||||
break;
|
||||
@@ -603,7 +604,7 @@ static void draw_object_material_set_default(render_context* rctx, draw_object*
|
||||
|
||||
vec4 diffuse = material->material.diffuse;
|
||||
vec4 emission = material->material.emission;
|
||||
draw_object_chara_color_fog_set(rctx, disp, disable_fog);
|
||||
draw_object_chara_color_fog_set(rctx, draw, disable_fog);
|
||||
shader_state_material_set_ambient_ptr(&shaders_ft, false, &ambient);
|
||||
shader_state_material_set_diffuse_ptr(&shaders_ft, false, &diffuse);
|
||||
shader_state_material_set_emission_ptr(&shaders_ft, false, &emission);
|
||||
@@ -616,7 +617,7 @@ static void draw_object_material_set_default(render_context* rctx, draw_object*
|
||||
float_t luma;
|
||||
vec3 luma_coeff = { 0.30f, 0.59f, 0.11f };
|
||||
vec3_dot(*(vec3*)&specular, luma_coeff, luma);
|
||||
if (luma >= 0.0099999998f || disp->texture_color_coeff.w >= 0.1f)
|
||||
if (luma >= 0.0099999998f || draw->texture_color_coeff.w >= 0.1f)
|
||||
uniform_value[U_SPECULAR_IBL] = 1;
|
||||
else
|
||||
uniform_value[U_SPECULAR_IBL] = 0;
|
||||
@@ -672,10 +673,10 @@ static void draw_object_material_set_default(render_context* rctx, draw_object*
|
||||
|
||||
switch (material->material.shader_index) {
|
||||
case SHADER_FT_SKIN: {
|
||||
vec4 texture_color_coeff = disp->texture_color_coeff;
|
||||
vec4 texture_color_offset = disp->texture_color_offset;
|
||||
vec4 texture_specular_coeff = disp->texture_specular_coeff;
|
||||
vec4 texture_specular_offset = disp->texture_specular_offset;
|
||||
vec4 texture_color_coeff = draw->texture_color_coeff;
|
||||
vec4 texture_color_offset = draw->texture_color_offset;
|
||||
vec4 texture_specular_coeff = draw->texture_specular_coeff;
|
||||
vec4 texture_specular_offset = draw->texture_specular_offset;
|
||||
|
||||
texture_color_coeff.w *= 0.015f;
|
||||
texture_specular_coeff.w *= 0.015f;
|
||||
@@ -688,8 +689,8 @@ static void draw_object_material_set_default(render_context* rctx, draw_object*
|
||||
case SHADER_FT_HAIR:
|
||||
case SHADER_FT_CLOTH:
|
||||
case SHADER_FT_TIGHTS:
|
||||
shader_local_frag_set(&shaders_ft, 5, 1.0f - disp->texture_color_coeff.w * 0.4f,
|
||||
0.0f, 0.0f, disp->texture_color_coeff.w * 0.02f);
|
||||
shader_local_frag_set(&shaders_ft, 5, 1.0f - draw->texture_color_coeff.w * 0.4f,
|
||||
0.0f, 0.0f, draw->texture_color_coeff.w * 0.02f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -737,9 +738,9 @@ static void draw_object_material_set_parameter(render_context* rctx, object_mate
|
||||
shader_env_vert_set_ptr(&shaders_ft, 18, &specular);
|
||||
}
|
||||
|
||||
static void draw_object_material_set_reflect(render_context* rctx, draw_object* disp) {
|
||||
object_material_data* material = disp->material;
|
||||
GLuint* textures = disp->textures;
|
||||
static void draw_object_material_set_reflect(render_context* rctx, draw_object* draw) {
|
||||
object_material_data* material = draw->material;
|
||||
GLuint* textures = draw->textures;
|
||||
if (material->material.blend_flags.double_sided)
|
||||
gl_state_disable_cull_face();
|
||||
|
||||
@@ -750,9 +751,9 @@ static void draw_object_material_set_reflect(render_context* rctx, draw_object*
|
||||
break;
|
||||
|
||||
GLuint tex_id = -1;
|
||||
for (int32_t j = 0; j < disp->texture_pattern_count; j++)
|
||||
if (disp->texture_pattern_array[j].src == texture_id) {
|
||||
texture* tex = texture_storage_get_texture(disp->texture_pattern_array[j].dst);
|
||||
for (int32_t j = 0; j < draw->texture_pattern_count; j++)
|
||||
if (draw->texture_pattern_array[j].src == texture_id) {
|
||||
texture* tex = texture_storage_get_texture(draw->texture_pattern_array[j].dst);
|
||||
if (tex)
|
||||
tex_id = tex->texture;
|
||||
break;
|
||||
@@ -807,7 +808,7 @@ static void draw_object_material_set_reflect(render_context* rctx, draw_object*
|
||||
shader_state_material_set_diffuse_ptr(&shaders_ft, false, &diffuse);
|
||||
shader_state_material_set_emission_ptr(&shaders_ft, false, &emission);
|
||||
shader_state_material_set_specular_ptr(&shaders_ft, false, &specular);
|
||||
draw_object_material_set_parameter(rctx, disp->material);
|
||||
draw_object_material_set_parameter(rctx, draw->material);
|
||||
}
|
||||
|
||||
static void draw_object_material_set_uniform(render_context* rctx, object_material_data* mat_data, bool disable_color_l) {
|
||||
@@ -863,25 +864,25 @@ static void draw_object_material_set_uniform(render_context* rctx, object_materi
|
||||
uniform_value[U45] = 1;
|
||||
}
|
||||
|
||||
static void draw_object_vertex_attrib_reset_default(draw_object* disp) {
|
||||
object_mesh* mesh = disp->mesh;
|
||||
static void draw_object_vertex_attrib_reset_default(draw_object* draw) {
|
||||
object_mesh* mesh = draw->mesh;
|
||||
object_vertex_flags vertex_flags = mesh->vertex_flags;
|
||||
|
||||
if (mesh->compressed) {
|
||||
draw_object_vertex_attrib_reset_default_compressed(disp);
|
||||
draw_object_vertex_attrib_reset_default_compressed(draw);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < 16; i++) {
|
||||
if (disp->vertex_attrib_array[i])
|
||||
if (draw->vertex_attrib_array[i])
|
||||
glDisableVertexAttribArray(i);
|
||||
disp->vertex_attrib_array[i] = false;
|
||||
draw->vertex_attrib_array[i] = false;
|
||||
}
|
||||
|
||||
if (vertex_flags & OBJECT_VERTEX_BONE_DATA)
|
||||
uniform_value[U_BONE_MAT] = 0;
|
||||
|
||||
if (disp->morph_array_buffer) {
|
||||
if (draw->morph_array_buffer) {
|
||||
uniform_value[U_MORPH] = 0;
|
||||
uniform_value[U_MORPH_COLOR] = 0;
|
||||
}
|
||||
@@ -893,20 +894,20 @@ static void draw_object_vertex_attrib_reset_default(draw_object* disp) {
|
||||
gl_state_active_texture(0);
|
||||
}
|
||||
|
||||
static void draw_object_vertex_attrib_reset_default_compressed(draw_object* disp) {
|
||||
object_mesh* mesh = disp->mesh;
|
||||
static void draw_object_vertex_attrib_reset_default_compressed(draw_object* draw) {
|
||||
object_mesh* mesh = draw->mesh;
|
||||
object_vertex_flags vertex_flags = mesh->vertex_flags;
|
||||
|
||||
for (int32_t i = 0; i < 16; i++) {
|
||||
if (disp->vertex_attrib_array[i])
|
||||
if (draw->vertex_attrib_array[i])
|
||||
glDisableVertexAttribArray(i);
|
||||
disp->vertex_attrib_array[i] = false;
|
||||
draw->vertex_attrib_array[i] = false;
|
||||
}
|
||||
|
||||
if (vertex_flags & OBJECT_VERTEX_BONE_DATA)
|
||||
uniform_value[U_BONE_MAT] = 0;
|
||||
|
||||
if (disp->morph_array_buffer) {
|
||||
if (draw->morph_array_buffer) {
|
||||
uniform_value[U_MORPH] = 0;
|
||||
uniform_value[U_MORPH_COLOR] = 0;
|
||||
}
|
||||
@@ -918,25 +919,25 @@ static void draw_object_vertex_attrib_reset_default_compressed(draw_object* disp
|
||||
gl_state_active_texture(0);
|
||||
}
|
||||
|
||||
static void draw_object_vertex_attrib_reset_reflect(draw_object* disp) {
|
||||
object_mesh* mesh = disp->mesh;
|
||||
static void draw_object_vertex_attrib_reset_reflect(draw_object* draw) {
|
||||
object_mesh* mesh = draw->mesh;
|
||||
object_vertex_flags vertex_flags = mesh->vertex_flags;
|
||||
|
||||
if (mesh->compressed) {
|
||||
draw_object_vertex_attrib_reset_reflect_compressed(disp);
|
||||
draw_object_vertex_attrib_reset_reflect_compressed(draw);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < 16; i++) {
|
||||
if (disp->vertex_attrib_array[i])
|
||||
if (draw->vertex_attrib_array[i])
|
||||
glDisableVertexAttribArray(i);
|
||||
disp->vertex_attrib_array[i] = false;
|
||||
draw->vertex_attrib_array[i] = false;
|
||||
}
|
||||
|
||||
if (vertex_flags & OBJECT_VERTEX_BONE_DATA)
|
||||
uniform_value[U_BONE_MAT] = 0;
|
||||
|
||||
if (disp->morph_array_buffer) {
|
||||
if (draw->morph_array_buffer) {
|
||||
uniform_value[U_MORPH] = 0;
|
||||
uniform_value[U_MORPH_COLOR] = 0;
|
||||
}
|
||||
@@ -946,20 +947,20 @@ static void draw_object_vertex_attrib_reset_reflect(draw_object* disp) {
|
||||
gl_state_active_texture(0);
|
||||
}
|
||||
|
||||
inline static void draw_object_vertex_attrib_reset_reflect_compressed(draw_object* disp) {
|
||||
object_mesh* mesh = disp->mesh;
|
||||
inline static void draw_object_vertex_attrib_reset_reflect_compressed(draw_object* draw) {
|
||||
object_mesh* mesh = draw->mesh;
|
||||
object_vertex_flags vertex_flags = mesh->vertex_flags;
|
||||
|
||||
for (int32_t i = 0; i < 16; i++) {
|
||||
if (disp->vertex_attrib_array[i])
|
||||
if (draw->vertex_attrib_array[i])
|
||||
glDisableVertexAttribArray(i);
|
||||
disp->vertex_attrib_array[i] = false;
|
||||
draw->vertex_attrib_array[i] = false;
|
||||
}
|
||||
|
||||
if (vertex_flags & OBJECT_VERTEX_BONE_DATA)
|
||||
uniform_value[U_BONE_MAT] = 0;
|
||||
|
||||
if (disp->morph_array_buffer) {
|
||||
if (draw->morph_array_buffer) {
|
||||
uniform_value[U_MORPH] = 0;
|
||||
uniform_value[U_MORPH_COLOR] = 0;
|
||||
}
|
||||
@@ -969,18 +970,18 @@ inline static void draw_object_vertex_attrib_reset_reflect_compressed(draw_objec
|
||||
gl_state_active_texture(0);
|
||||
}
|
||||
|
||||
static void draw_object_vertex_attrib_set_default(draw_object* disp) {
|
||||
object_mesh* mesh = disp->mesh;
|
||||
object_sub_mesh* sub_mesh = disp->sub_mesh;
|
||||
static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
object_mesh* mesh = draw->mesh;
|
||||
object_sub_mesh* sub_mesh = draw->sub_mesh;
|
||||
GLsizei vertex_size = (GLsizei)mesh->vertex_size;
|
||||
object_vertex_flags vertex_flags = mesh->vertex_flags;
|
||||
|
||||
if (mesh->compressed) {
|
||||
draw_object_vertex_attrib_set_default_compressed(disp);
|
||||
draw_object_vertex_attrib_set_default_compressed(draw);
|
||||
return;
|
||||
}
|
||||
|
||||
gl_state_bind_array_buffer(disp->array_buffer);
|
||||
gl_state_bind_array_buffer(draw->array_buffer);
|
||||
|
||||
size_t offset = 0;
|
||||
if (vertex_flags & OBJECT_VERTEX_POSITION) {
|
||||
@@ -1011,7 +1012,7 @@ static void draw_object_vertex_attrib_set_default(draw_object* disp) {
|
||||
offset += 12;
|
||||
|
||||
bool texcoord_mat_set[4] = { false };
|
||||
object_material_data* material = disp->material;
|
||||
object_material_data* material = draw->material;
|
||||
for (int32_t i = 0, j = 0, l = 0; i < 4; i++) {
|
||||
if (material->material.textures[i].texture_id == -1)
|
||||
continue;
|
||||
@@ -1039,9 +1040,9 @@ static void draw_object_vertex_attrib_set_default(draw_object* disp) {
|
||||
mat4 mat = material->material.textures[i].tex_coord_mat;
|
||||
shader_state_matrix_set_texture(&shaders_ft, texcoord_index, &mat);
|
||||
if (material->material.textures[i].texture_flags.type == OBJECT_MATERIAL_TEXTURE_COLOR)
|
||||
for (int32_t k = 0; k < disp->texture_transform_count; k++)
|
||||
if (disp->texture_transform_array[k].id == texture_id) {
|
||||
mat = disp->texture_transform_array[k].mat;
|
||||
for (int32_t k = 0; k < draw->texture_transform_count; k++)
|
||||
if (draw->texture_transform_array[k].id == texture_id) {
|
||||
mat = draw->texture_transform_array[k].mat;
|
||||
shader_state_matrix_set_texture(&shaders_ft, texcoord_index, &mat);
|
||||
texcoord_mat_set[texcoord_index] = true;
|
||||
break;
|
||||
@@ -1049,7 +1050,7 @@ static void draw_object_vertex_attrib_set_default(draw_object* disp) {
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < 4; i++)
|
||||
if (!disp->vertex_attrib_array[8 + i])
|
||||
if (!draw->vertex_attrib_array[8 + i])
|
||||
glVertexAttrib4f(8 + i, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_flags & OBJECT_VERTEX_TEXCOORD0)
|
||||
@@ -1096,10 +1097,10 @@ static void draw_object_vertex_attrib_set_default(draw_object* disp) {
|
||||
else
|
||||
glVertexAttrib4f(7, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (disp->morph_array_buffer) {
|
||||
if (draw->morph_array_buffer) {
|
||||
uniform_value[U_MORPH] = 1;
|
||||
|
||||
gl_state_bind_array_buffer(disp->morph_array_buffer);
|
||||
gl_state_bind_array_buffer(draw->morph_array_buffer);
|
||||
|
||||
offset = 0;
|
||||
if (vertex_flags & OBJECT_VERTEX_POSITION) {
|
||||
@@ -1169,23 +1170,23 @@ static void draw_object_vertex_attrib_set_default(draw_object* disp) {
|
||||
if (vertex_flags & OBJECT_VERTEX_UNKNOWN)
|
||||
offset += 16;
|
||||
|
||||
shader_env_vert_set(&shaders_ft, 13, disp->morph_value, 1.0f - disp->morph_value, 0.0f, 0.0f);
|
||||
shader_env_vert_set(&shaders_ft, 13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
|
||||
}
|
||||
gl_state_bind_array_buffer(0);
|
||||
|
||||
gl_state_bind_element_array_buffer(disp->element_array_buffer);
|
||||
gl_state_bind_element_array_buffer(draw->element_array_buffer);
|
||||
|
||||
if (disp->instances_count)
|
||||
if (draw->instances_count)
|
||||
uniform_value[U_INSTANCE] = 1;
|
||||
}
|
||||
|
||||
inline static void draw_object_vertex_attrib_set_default_compressed(draw_object* disp) {
|
||||
object_mesh* mesh = disp->mesh;
|
||||
object_sub_mesh* sub_mesh = disp->sub_mesh;
|
||||
inline static void draw_object_vertex_attrib_set_default_compressed(draw_object* draw) {
|
||||
object_mesh* mesh = draw->mesh;
|
||||
object_sub_mesh* sub_mesh = draw->sub_mesh;
|
||||
GLsizei vertex_size = (GLsizei)mesh->vertex_size;
|
||||
object_vertex_flags vertex_flags = mesh->vertex_flags;
|
||||
|
||||
gl_state_bind_array_buffer(disp->array_buffer);
|
||||
gl_state_bind_array_buffer(draw->array_buffer);
|
||||
|
||||
size_t offset = 0;
|
||||
if (vertex_flags & OBJECT_VERTEX_POSITION) {
|
||||
@@ -1213,7 +1214,7 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
glVertexAttrib4f(6, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
bool texcoord_mat_set[4] = { false };
|
||||
object_material_data* material = disp->material;
|
||||
object_material_data* material = draw->material;
|
||||
for (int32_t i = 0, j = 0, l = 0; i < 4; i++) {
|
||||
if (material->material.textures[i].texture_id == -1)
|
||||
continue;
|
||||
@@ -1248,9 +1249,9 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
mat4 mat = material->material.textures[i].tex_coord_mat;
|
||||
shader_state_matrix_set_texture(&shaders_ft, texcoord_index, &mat);
|
||||
if (material->material.textures[i].texture_flags.type == OBJECT_MATERIAL_TEXTURE_COLOR)
|
||||
for (int32_t k = 0; k < disp->texture_transform_count; k++)
|
||||
if (disp->texture_transform_array[k].id == texture_id) {
|
||||
mat = disp->texture_transform_array[k].mat;
|
||||
for (int32_t k = 0; k < draw->texture_transform_count; k++)
|
||||
if (draw->texture_transform_array[k].id == texture_id) {
|
||||
mat = draw->texture_transform_array[k].mat;
|
||||
shader_state_matrix_set_texture(&shaders_ft, texcoord_index, &mat);
|
||||
texcoord_mat_set[texcoord_index] = true;
|
||||
break;
|
||||
@@ -1258,7 +1259,7 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < 4; i++)
|
||||
if (!disp->vertex_attrib_array[8 + i])
|
||||
if (!draw->vertex_attrib_array[8 + i])
|
||||
glVertexAttrib4f(8 + i, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_flags & OBJECT_VERTEX_TEXCOORD0)
|
||||
@@ -1294,10 +1295,10 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
glVertexAttrib4f(15, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
if (disp->morph_array_buffer) {
|
||||
if (draw->morph_array_buffer) {
|
||||
uniform_value[U_MORPH] = 1;
|
||||
|
||||
gl_state_bind_array_buffer(disp->morph_array_buffer);
|
||||
gl_state_bind_array_buffer(draw->morph_array_buffer);
|
||||
|
||||
offset = 0;
|
||||
if (vertex_flags & OBJECT_VERTEX_POSITION) {
|
||||
@@ -1358,28 +1359,28 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
if (vertex_flags & OBJECT_VERTEX_BONE_DATA)
|
||||
offset += 16;
|
||||
|
||||
shader_env_vert_set(&shaders_ft, 13, disp->morph_value, 1.0f - disp->morph_value, 0.0f, 0.0f);
|
||||
shader_env_vert_set(&shaders_ft, 13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
|
||||
}
|
||||
gl_state_bind_array_buffer(0);
|
||||
|
||||
gl_state_bind_element_array_buffer(disp->element_array_buffer);
|
||||
gl_state_bind_element_array_buffer(draw->element_array_buffer);
|
||||
|
||||
if (disp->instances_count)
|
||||
if (draw->instances_count)
|
||||
uniform_value[U_INSTANCE] = 1;
|
||||
}
|
||||
|
||||
static void draw_object_vertex_attrib_set_reflect(draw_object* disp) {
|
||||
object_mesh* mesh = disp->mesh;
|
||||
object_sub_mesh* sub_mesh = disp->sub_mesh;
|
||||
static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
|
||||
object_mesh* mesh = draw->mesh;
|
||||
object_sub_mesh* sub_mesh = draw->sub_mesh;
|
||||
GLsizei vertex_size = (GLsizei)mesh->vertex_size;
|
||||
object_vertex_flags vertex_flags = mesh->vertex_flags;
|
||||
|
||||
if (mesh->compressed) {
|
||||
draw_object_vertex_attrib_set_reflect_compressed(disp);
|
||||
draw_object_vertex_attrib_set_reflect_compressed(draw);
|
||||
return;
|
||||
}
|
||||
|
||||
gl_state_bind_array_buffer(disp->array_buffer);
|
||||
gl_state_bind_array_buffer(draw->array_buffer);
|
||||
|
||||
size_t offset = 0;
|
||||
if (vertex_flags & OBJECT_VERTEX_POSITION) {
|
||||
@@ -1404,7 +1405,7 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* disp) {
|
||||
if (vertex_flags & OBJECT_VERTEX_BINORMAL)
|
||||
offset += 12;
|
||||
|
||||
object_material_data* material = disp->material;
|
||||
object_material_data* material = draw->material;
|
||||
if (material->material.textures[0].texture_id != -1) {
|
||||
if (vertex_flags & OBJECT_VERTEX_TEXCOORD0) {
|
||||
enable_vertex_attrib_array(8);
|
||||
@@ -1419,9 +1420,9 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* disp) {
|
||||
mat4 mat = material->material.textures[0].tex_coord_mat;
|
||||
shader_state_matrix_set_texture(&shaders_ft, 0, &mat);
|
||||
if (material->material.textures[0].texture_flags.type == OBJECT_MATERIAL_TEXTURE_COLOR)
|
||||
for (int32_t j = 0; j < disp->texture_transform_count; j++)
|
||||
if (disp->texture_transform_array[j].id == texture_id) {
|
||||
mat = disp->texture_transform_array[j].mat;
|
||||
for (int32_t j = 0; j < draw->texture_transform_count; j++)
|
||||
if (draw->texture_transform_array[j].id == texture_id) {
|
||||
mat = draw->texture_transform_array[j].mat;
|
||||
shader_state_matrix_set_texture(&shaders_ft, 0, &mat);
|
||||
break;
|
||||
}
|
||||
@@ -1469,10 +1470,10 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* disp) {
|
||||
if (vertex_flags & OBJECT_VERTEX_UNKNOWN)
|
||||
offset += 16;
|
||||
|
||||
if (disp->morph_array_buffer) {
|
||||
if (draw->morph_array_buffer) {
|
||||
uniform_value[U_MORPH] = 1;
|
||||
|
||||
gl_state_bind_array_buffer(disp->morph_array_buffer);
|
||||
gl_state_bind_array_buffer(draw->morph_array_buffer);
|
||||
|
||||
offset = 0;
|
||||
if (vertex_flags & OBJECT_VERTEX_POSITION) {
|
||||
@@ -1542,20 +1543,20 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* disp) {
|
||||
if (vertex_flags & OBJECT_VERTEX_UNKNOWN)
|
||||
offset += 16;
|
||||
|
||||
shader_env_vert_set(&shaders_ft, 13, disp->morph_value, 1.0f - disp->morph_value, 0.0f, 0.0f);
|
||||
shader_env_vert_set(&shaders_ft, 13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
|
||||
}
|
||||
gl_state_bind_array_buffer(0);
|
||||
|
||||
gl_state_bind_element_array_buffer(disp->element_array_buffer);
|
||||
gl_state_bind_element_array_buffer(draw->element_array_buffer);
|
||||
}
|
||||
|
||||
inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object* disp) {
|
||||
object_mesh* mesh = disp->mesh;
|
||||
object_sub_mesh* sub_mesh = disp->sub_mesh;
|
||||
inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object* draw) {
|
||||
object_mesh* mesh = draw->mesh;
|
||||
object_sub_mesh* sub_mesh = draw->sub_mesh;
|
||||
GLsizei vertex_size = (GLsizei)mesh->vertex_size;
|
||||
object_vertex_flags vertex_flags = mesh->vertex_flags;
|
||||
|
||||
gl_state_bind_array_buffer(disp->array_buffer);
|
||||
gl_state_bind_array_buffer(draw->array_buffer);
|
||||
|
||||
size_t offset = 0;
|
||||
if (vertex_flags & OBJECT_VERTEX_POSITION) {
|
||||
@@ -1577,7 +1578,7 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
if (vertex_flags & OBJECT_VERTEX_TANGENT)
|
||||
offset += 8;
|
||||
|
||||
object_material_data* material = disp->material;
|
||||
object_material_data* material = draw->material;
|
||||
if (material->material.textures[0].texture_id != -1) {
|
||||
if (vertex_flags & OBJECT_VERTEX_TEXCOORD0) {
|
||||
enable_vertex_attrib_array(8);
|
||||
@@ -1592,9 +1593,9 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
mat4 mat = material->material.textures[0].tex_coord_mat;
|
||||
shader_state_matrix_set_texture(&shaders_ft, 0, &mat);
|
||||
if (material->material.textures[0].texture_flags.type == OBJECT_MATERIAL_TEXTURE_COLOR)
|
||||
for (int32_t j = 0; j < disp->texture_transform_count; j++)
|
||||
if (disp->texture_transform_array[j].id == texture_id) {
|
||||
mat = disp->texture_transform_array[j].mat;
|
||||
for (int32_t j = 0; j < draw->texture_transform_count; j++)
|
||||
if (draw->texture_transform_array[j].id == texture_id) {
|
||||
mat = draw->texture_transform_array[j].mat;
|
||||
shader_state_matrix_set_texture(&shaders_ft, 0, &mat);
|
||||
break;
|
||||
}
|
||||
@@ -1636,10 +1637,10 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
glVertexAttrib4f(15, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
if (disp->morph_array_buffer) {
|
||||
if (draw->morph_array_buffer) {
|
||||
uniform_value[U_MORPH] = 1;
|
||||
|
||||
gl_state_bind_array_buffer(disp->morph_array_buffer);
|
||||
gl_state_bind_array_buffer(draw->morph_array_buffer);
|
||||
|
||||
offset = 0;
|
||||
if (vertex_flags & OBJECT_VERTEX_POSITION) {
|
||||
@@ -1700,9 +1701,9 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
if (vertex_flags & OBJECT_VERTEX_BONE_DATA)
|
||||
offset += 16;
|
||||
|
||||
shader_env_vert_set(&shaders_ft, 13, disp->morph_value, 1.0f - disp->morph_value, 0.0f, 0.0f);
|
||||
shader_env_vert_set(&shaders_ft, 13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
|
||||
}
|
||||
gl_state_bind_array_buffer(0);
|
||||
|
||||
gl_state_bind_element_array_buffer(disp->element_array_buffer);
|
||||
gl_state_bind_element_array_buffer(draw->element_array_buffer);
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@ typedef struct texture_data_struct {
|
||||
vec3 texture_specular_offset;
|
||||
} texture_data_struct;
|
||||
|
||||
extern void draw_object_draw(render_context* rctx, draw_object* disp, mat4* model,
|
||||
void(*draw_object_func)(render_context* rctx, draw_object* disp), int32_t show_vector_old);
|
||||
extern void draw_object_draw_default(render_context* rctx, draw_object* disp);
|
||||
extern void draw_object_draw_sss(render_context* rctx, draw_object* disp);
|
||||
extern void draw_object_draw_reflect(render_context* rctx, draw_object* disp);
|
||||
extern void draw_object_draw_reflect_reflect_map(render_context* rctx, draw_object* disp);
|
||||
extern void draw_object_draw_shadow(render_context* rctx, draw_object* disp);
|
||||
extern void draw_object_draw_translucent(render_context* rctx, draw_object* disp);
|
||||
extern void draw_object_draw(render_context* rctx, draw_object* draw, mat4* model,
|
||||
void(*draw_object_func)(render_context* rctx, draw_object* draw), int32_t show_vector_old);
|
||||
extern void draw_object_draw_default(render_context* rctx, draw_object* draw);
|
||||
extern void draw_object_draw_sss(render_context* rctx, draw_object* draw);
|
||||
extern void draw_object_draw_reflect(render_context* rctx, draw_object* draw);
|
||||
extern void draw_object_draw_reflect_reflect_map(render_context* rctx, draw_object* draw);
|
||||
extern void draw_object_draw_shadow(render_context* rctx, draw_object* draw);
|
||||
extern void draw_object_draw_translucent(render_context* rctx, draw_object* draw);
|
||||
extern void draw_object_model_mat_load(render_context* rctx, mat4* mat);
|
||||
extern void model_mat_face_camera_position(mat4* view, mat4* src, mat4* dst);
|
||||
extern void model_mat_face_camera_view(mat4* view, mat4* src, mat4* dst);
|
||||
|
||||
+3
-31
@@ -249,21 +249,7 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
|
||||
mat4_mult(&proj, &temp, &proj);
|
||||
shader_state_matrix_set_projection(&shaders_ft, &proj, false);
|
||||
|
||||
vec3 up = { 0.0f, 1.0f, 0.0f };
|
||||
vec3 dir;
|
||||
float_t length;
|
||||
vec3_sub(*interest, *view_point, dir);
|
||||
vec3_length_squared(dir, length);
|
||||
if (length <= 0.000001f) {
|
||||
up.x = 0.0f;
|
||||
up.y = 0.0f;
|
||||
if (dir.z < 0.0f)
|
||||
up.z = 1.0f;
|
||||
else
|
||||
up.z = -1.0f;
|
||||
}
|
||||
|
||||
mat4_look_at(view_point, interest, &up, &rctx->view_mat);
|
||||
mat4_look_at(view_point, interest, &rctx->view_mat);
|
||||
|
||||
rctx->draw_state.shader_index = SHADER_FT_SIL;
|
||||
uniform_value[U0A] = 0;
|
||||
@@ -637,7 +623,7 @@ static void draw_pass_sss_filter(render_context* rctx, sss_data_struct* a1) {
|
||||
v46[i] = interest;
|
||||
v14[i] = 999999.0f;
|
||||
rob_chara_bone_data* v16 = rob_chara_array[i].bone_data;
|
||||
if (rob_chara_pv_data_array[i].field_0 != -1 && rob_chara_array[i].data.field_0 & 1) {
|
||||
if (rob_chara_pv_data_array[i].type != ROB_CHARA_TYPE_NONE && rob_chara_array[i].data.field_0 & 1) {
|
||||
mat4* v17 = rob_chara_bone_data_get_mats_mat(v16, MOTION_BONE_N_HARA_CP);
|
||||
if (v17) {
|
||||
mat4_get_translation(v17, &v46[i]);
|
||||
@@ -1039,20 +1025,6 @@ static void draw_pass_3d_shadow_set(shadow* shad, render_context* rctx) {
|
||||
view_point = &shad->view_point_shared;
|
||||
}
|
||||
|
||||
vec3 up = { 0.0f, 1.0f, 0.0f };
|
||||
vec3 dir;
|
||||
float_t length;
|
||||
vec3_sub(*interest, *view_point, dir);
|
||||
vec3_length_squared(dir, length);
|
||||
if (length <= 0.000001f) {
|
||||
up.x = 0.0f;
|
||||
up.y = 0.0f;
|
||||
if (dir.z < 0.0f)
|
||||
up.z = 1.0f;
|
||||
else
|
||||
up.z = -1.0f;
|
||||
}
|
||||
|
||||
mat4 temp;
|
||||
mat4_translate(0.5f, 0.5f, 0.5f, &temp);
|
||||
mat4_scale_rot(&temp, 0.5f, 0.5f, 0.5f, &temp);
|
||||
@@ -1063,7 +1035,7 @@ static void draw_pass_3d_shadow_set(shadow* shad, render_context* rctx) {
|
||||
mat4_mult(&proj, &temp, &proj);
|
||||
|
||||
mat4 view;
|
||||
mat4_look_at(view_point, interest, &up, &view);
|
||||
mat4_look_at(view_point, interest, &view);
|
||||
mat4_mult(&view, &proj, &view);
|
||||
shader_state_matrix_set_texture(&shaders_ft, 6ULL + i, &view);
|
||||
}
|
||||
|
||||
+25
-25
@@ -34,7 +34,7 @@ void draw_task_draw_objects_by_type(render_context* rctx, draw_object_type type,
|
||||
int32_t alpha_test = 0;
|
||||
float_t min_alpha = 1.0f;
|
||||
bool reflect = uniform_value[U_REFLECT] == 1;
|
||||
void(*draw_object_func)(render_context* rctx, draw_object* disp) = draw_object_draw_default;
|
||||
void(*draw_object_func)(render_context* rctx, draw_object* draw) = draw_object_draw_default;
|
||||
|
||||
for (int32_t i = 0; i < 6; i++)
|
||||
gl_state_active_bind_texture_2d(i, 0);
|
||||
@@ -645,7 +645,7 @@ inline bool draw_task_add_draw_object_by_object_info_color_vec4(render_context*
|
||||
}
|
||||
|
||||
void draw_task_add_draw_object_by_object_info_object_skin(render_context* rctx, object_info obj_info,
|
||||
vector_old_texture_pattern_struct* texture_pattern, texture_data_struct* texture_data, float_t alpha,
|
||||
std::vector<texture_pattern_struct>* texture_pattern, texture_data_struct* texture_data, float_t alpha,
|
||||
mat4* matrices, mat4* ex_data_matrices, mat4* mat, mat4* global_mat) {
|
||||
object_skin* skin = object_storage_get_object_skin(obj_info);
|
||||
if (!skin)
|
||||
@@ -681,9 +681,9 @@ void draw_task_add_draw_object_by_object_info_object_skin(render_context* rctx,
|
||||
object_data_set_texture_specular_offset(object_data, &value);
|
||||
}
|
||||
|
||||
size_t texture_pattern_count = texture_pattern ? vector_old_length(*texture_pattern) : 0;
|
||||
size_t texture_pattern_count = texture_pattern ? texture_pattern->size() : 0;
|
||||
if (texture_pattern && texture_pattern_count)
|
||||
object_data_set_texture_pattern(object_data, (int32_t)texture_pattern_count, texture_pattern->begin);
|
||||
object_data_set_texture_pattern(object_data, (int32_t)texture_pattern_count, texture_pattern->data());
|
||||
|
||||
if (fabsf(alpha - 1.0f) > 0.000001f)
|
||||
draw_task_add_draw_object_by_object_info_alpha_bone_mat(rctx,
|
||||
@@ -830,7 +830,7 @@ int32_t object_axis_aligned_bounding_box_check_visibility(
|
||||
int32_t object_bounding_sphere_check_visibility(object_bounding_sphere* sphere,
|
||||
object_data* object_data, camera* cam, mat4* mat) {
|
||||
if (object_data->object_bounding_sphere_check_func)
|
||||
return object_data->object_bounding_sphere_check_func(sphere);
|
||||
return object_data->object_bounding_sphere_check_func(sphere, cam);
|
||||
|
||||
vec3 center;
|
||||
mat4_mult_vec3_trans(mat, &sphere->center, ¢er);
|
||||
@@ -891,35 +891,35 @@ inline static void draw_task_object_init(draw_task* task, object_data* object_da
|
||||
task->data.object.element_array_buffer = element_array_buffer;
|
||||
task->data.object.morph_array_buffer = morph_array_buffer;
|
||||
|
||||
draw_object* disp = &task->data.object;
|
||||
disp->texture_pattern_count = object_data->texture_pattern_count;
|
||||
draw_object* draw = &task->data.object;
|
||||
draw->texture_pattern_count = object_data->texture_pattern_count;
|
||||
for (int32_t i = 0; i < object_data->texture_pattern_count && i < TEXTURE_PATTERN_COUNT; i++)
|
||||
disp->texture_pattern_array[i] = object_data->texture_pattern_array[i];
|
||||
draw->texture_pattern_array[i] = object_data->texture_pattern_array[i];
|
||||
|
||||
disp->texture_transform_count = object_data->texture_transform_count;
|
||||
draw->texture_transform_count = object_data->texture_transform_count;
|
||||
for (int32_t i = 0; i < object_data->texture_transform_count && i < TEXTURE_TRANSFORM_COUNT; i++)
|
||||
disp->texture_transform_array[i] = object_data->texture_transform_array[i];
|
||||
draw->texture_transform_array[i] = object_data->texture_transform_array[i];
|
||||
|
||||
if (blend_color) {
|
||||
disp->set_blend_color = true;
|
||||
disp->blend_color = *blend_color;
|
||||
draw->set_blend_color = true;
|
||||
draw->blend_color = *blend_color;
|
||||
}
|
||||
else {
|
||||
disp->set_blend_color = false;
|
||||
disp->blend_color = vec4u_identity;
|
||||
draw->set_blend_color = false;
|
||||
draw->blend_color = vec4u_identity;
|
||||
}
|
||||
|
||||
disp->chara_color = object_data->chara_color;
|
||||
disp->self_shadow = object_data->draw_task_flags & (DRAW_TASK_8 | DRAW_TASK_4) ? 1 : 0;
|
||||
disp->shadow = object_data->shadow_type;
|
||||
disp->texture_color_coeff = object_data->texture_color_coeff;
|
||||
disp->texture_color_coeff.w = object_data->wet_param;
|
||||
disp->texture_color_offset = object_data->texture_color_offset;
|
||||
disp->texture_specular_coeff = object_data->texture_specular_coeff;
|
||||
disp->texture_specular_offset = object_data->texture_specular_offset;
|
||||
disp->instances_count = instances_count;
|
||||
disp->instances_mat = instances_mat;
|
||||
disp->draw_object_func = draw_object_func;
|
||||
draw->chara_color = object_data->chara_color;
|
||||
draw->self_shadow = object_data->draw_task_flags & (DRAW_TASK_8 | DRAW_TASK_4) ? 1 : 0;
|
||||
draw->shadow = object_data->shadow_type;
|
||||
draw->texture_color_coeff = object_data->texture_color_coeff;
|
||||
draw->texture_color_coeff.w = object_data->wet_param;
|
||||
draw->texture_color_offset = object_data->texture_color_offset;
|
||||
draw->texture_specular_coeff = object_data->texture_specular_coeff;
|
||||
draw->texture_specular_offset = object_data->texture_specular_offset;
|
||||
draw->instances_count = instances_count;
|
||||
draw->instances_mat = instances_mat;
|
||||
draw->draw_object_func = draw_object_func;
|
||||
}
|
||||
|
||||
inline static void draw_task_object_translucent_init(draw_task* task, mat4* mat,
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ extern bool draw_task_add_draw_object_by_object_info_color(render_context* rctx,
|
||||
extern bool draw_task_add_draw_object_by_object_info_color_vec4(render_context* rctx, mat4* mat,
|
||||
object_info obj_info, vec4* blend_color);
|
||||
extern void draw_task_add_draw_object_by_object_info_object_skin(render_context* rctx, object_info obj_info,
|
||||
vector_old_texture_pattern_struct* texture_pattern, texture_data_struct* texture_data, float_t alpha,
|
||||
std::vector<texture_pattern_struct>* texture_pattern, texture_data_struct* texture_data, float_t alpha,
|
||||
mat4* matrices, mat4* ex_data_matrices, mat4* mat, mat4* global_mat);
|
||||
extern bool draw_task_add_draw_object_by_object_info_opaque(render_context* rctx,
|
||||
mat4* mat, object_info obj_info);
|
||||
|
||||
+47
-49
@@ -3,6 +3,7 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include <thread>
|
||||
#include "file_handler.h"
|
||||
#include "data.h"
|
||||
#include "render_context.h"
|
||||
@@ -13,11 +14,11 @@ public:
|
||||
std::list<file_handler*> list;
|
||||
farc_read_handler* farc_read_handler;
|
||||
std::deque<file_handler*> deque;
|
||||
std::mutex(farc_mtx);
|
||||
std::mutex farc_mtx;
|
||||
std::thread* thread;
|
||||
std::mutex(mtx);
|
||||
std::mutex mtx;
|
||||
std::condition_variable cnd;
|
||||
bool field_60;
|
||||
bool exit;
|
||||
bool field_61;
|
||||
int32_t field_64;
|
||||
bool read_in_thread;
|
||||
@@ -32,10 +33,10 @@ public:
|
||||
|
||||
file_handler_storage file_handler_storage_data;
|
||||
|
||||
static bool file_handler_load_file(void* data, char* path, char* file, uint32_t hash);
|
||||
static bool file_handler_load_farc_file(void* data, char* path, char* file, uint32_t hash);
|
||||
static bool file_handler_load_file(void* data, const char* path, const char* file, uint32_t hash);
|
||||
static bool file_handler_load_farc_file(void* data, const char* path, const char* file, uint32_t hash);
|
||||
static void file_handler_storage_ctrl_list();
|
||||
static int32_t file_handler_storage_thread_ctrl();
|
||||
static void file_handler_storage_thread_ctrl();
|
||||
static size_t farc_read_handler_get_file_size(farc_read_handler* frh, std::string* file);
|
||||
static bool farc_read_handler_read(farc_read_handler* frh, std::string* file_path, bool cache);
|
||||
static bool farc_read_handler_read_data(farc_read_handler* frh, void* data, size_t size, std::string* file);
|
||||
@@ -55,20 +56,14 @@ void file_handler::call_read_free_func(int32_t index) {
|
||||
|
||||
std::unique_lock<std::mutex> u_lock(mtx);
|
||||
void* data = this->data;
|
||||
void(*read_free_func_func)(void*, void*) = this->read_free_func[index].func;
|
||||
void(*read_free_func_func)(void*, void*, size_t) = this->read_free_func[index].func;
|
||||
void* read_free_func_data = this->read_free_func[index].data;
|
||||
bool ready = this->read_free_func[index].ready;
|
||||
this->read_free_func[index].ready = true;
|
||||
u_lock.unlock();
|
||||
|
||||
if (!ready && read_free_func_func)
|
||||
read_free_func_func(read_free_func_data, data);
|
||||
}
|
||||
|
||||
void file_handler::set_file(char* file) {
|
||||
std::unique_lock<std::mutex> u_lock(mtx);
|
||||
this->file = std::string(file);
|
||||
u_lock.unlock();
|
||||
read_free_func_func(read_free_func_data, data, this->size);
|
||||
}
|
||||
|
||||
void file_handler::set_file(const char* file) {
|
||||
@@ -77,13 +72,6 @@ void file_handler::set_file(const char* file) {
|
||||
u_lock.unlock();
|
||||
}
|
||||
|
||||
void file_handler::set_farc_file(char* farc_file, bool cache) {
|
||||
std::unique_lock<std::mutex> u_lock(mtx);
|
||||
this->farc_file = std::string(farc_file);
|
||||
this->cache = cache;
|
||||
u_lock.unlock();
|
||||
}
|
||||
|
||||
void file_handler::set_farc_file(const char* farc_file, bool cache) {
|
||||
std::unique_lock<std::mutex> u_lock(mtx);
|
||||
this->farc_file = std::string(farc_file);
|
||||
@@ -91,19 +79,13 @@ void file_handler::set_farc_file(const char* farc_file, bool cache) {
|
||||
u_lock.unlock();
|
||||
}
|
||||
|
||||
void file_handler::set_path(char* path) {
|
||||
std::unique_lock<std::mutex> u_lock(mtx);
|
||||
this->path = std::string(path);
|
||||
u_lock.unlock();
|
||||
}
|
||||
|
||||
void file_handler::set_path(const char* path) {
|
||||
std::unique_lock<std::mutex> u_lock(mtx);
|
||||
this->path = std::string(path);
|
||||
u_lock.unlock();
|
||||
}
|
||||
|
||||
void file_handler::set_read_free_func_data(int32_t index, void(* func)(void*, void*), void* data) {
|
||||
void file_handler::set_read_free_func_data(int32_t index, void(* func)(void*, void*, size_t), void* data) {
|
||||
std::unique_lock<std::mutex> u_lock(mtx);
|
||||
if (index < 2) {
|
||||
read_free_func[index].func = func;
|
||||
@@ -134,13 +116,13 @@ farc_read_handler::~farc_read_handler() {
|
||||
delete farc;
|
||||
}
|
||||
|
||||
file_handler_storage::file_handler_storage() : farc_read_handler(), thread(), cnd(), field_60(),
|
||||
file_handler_storage::file_handler_storage() : farc_read_handler(), thread(), cnd(), exit(),
|
||||
field_61(), field_64(), read_in_thread(), field_69(), field_6C(), field_70(), field_74() {
|
||||
thread = new std::thread(file_handler_storage_thread_ctrl);
|
||||
|
||||
}
|
||||
|
||||
file_handler_storage::~file_handler_storage() {
|
||||
delete thread;
|
||||
|
||||
}
|
||||
|
||||
void file_handler_storage_ctrl() {
|
||||
@@ -162,14 +144,26 @@ void file_handler_storage_ctrl() {
|
||||
u_lock.unlock();
|
||||
}
|
||||
|
||||
void file_handler_storage_free_thread() {
|
||||
std::unique_lock<std::mutex> u_lock(file_handler_storage_data.mtx);
|
||||
file_handler_storage_data.exit = true;
|
||||
file_handler_storage_data.cnd.notify_one();
|
||||
u_lock.unlock();
|
||||
|
||||
file_handler_storage_data.thread->join();
|
||||
delete file_handler_storage_data.thread;
|
||||
file_handler_storage_data.thread = 0;
|
||||
}
|
||||
|
||||
void file_handler_storage_init_thread() {
|
||||
file_handler_storage_data.thread = new std::thread(file_handler_storage_thread_ctrl);
|
||||
if (file_handler_storage_data.thread) {
|
||||
SetThreadDescription((HANDLE)file_handler_storage_data.thread->native_handle(), L"File Thread");
|
||||
file_handler_storage_data.thread->detach();
|
||||
//file_handler_storage_data.thread->detach();
|
||||
}
|
||||
}
|
||||
|
||||
static bool file_handler_load_file(void* data, char* path, char* file, uint32_t hash) {
|
||||
static bool file_handler_load_file(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
std::string file_path = std::string(path);
|
||||
file_path += file;
|
||||
|
||||
@@ -192,7 +186,7 @@ static bool file_handler_load_file(void* data, char* path, char* file, uint32_t
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool file_handler_load_farc_file(void* data, char* path, char* file, uint32_t hash) {
|
||||
static bool file_handler_load_farc_file(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
std::string file_path = std::string(path);
|
||||
file_path += file;
|
||||
|
||||
@@ -230,7 +224,6 @@ static bool file_handler_load_farc_file(void* data, char* path, char* file, uint
|
||||
}
|
||||
|
||||
static void file_handler_storage_ctrl_list() {
|
||||
|
||||
for (std::list<file_handler*>::iterator i = file_handler_storage_data.list.begin();
|
||||
i != file_handler_storage_data.list.end();) {
|
||||
file_handler* pfhndl = i._Ptr->_Myval;
|
||||
@@ -248,10 +241,12 @@ static void file_handler_storage_ctrl_list() {
|
||||
|
||||
extern render_context* rctx_ptr;
|
||||
|
||||
static int32_t file_handler_storage_thread_ctrl() {
|
||||
while (true) {
|
||||
std::unique_lock<std::mutex> u_lock(file_handler_storage_data.mtx);
|
||||
static void file_handler_storage_thread_ctrl() {
|
||||
std::unique_lock<std::mutex> u_lock(file_handler_storage_data.mtx);
|
||||
while (!file_handler_storage_data.exit) {
|
||||
file_handler_storage_data.cnd.wait(u_lock);
|
||||
if (file_handler_storage_data.exit)
|
||||
break;
|
||||
|
||||
for (file_handler*& i : file_handler_storage_data.deque) {
|
||||
if (i->not_ready) {
|
||||
@@ -259,11 +254,11 @@ static int32_t file_handler_storage_thread_ctrl() {
|
||||
i->reading = true;
|
||||
if (i->not_ready) {
|
||||
if (i->farc_file.size())
|
||||
data_struct_load_file((data_struct*)rctx_ptr->data,
|
||||
i, i->path.c_str(), i->farc_file.c_str(), file_handler_load_farc_file);
|
||||
rctx_ptr->data->load_file(i,
|
||||
i->path.c_str(), i->farc_file.c_str(), file_handler_load_farc_file);
|
||||
else
|
||||
data_struct_load_file((data_struct*)rctx_ptr->data,
|
||||
i, i->path.c_str(), i->file.c_str(), file_handler_load_file);
|
||||
rctx_ptr->data->load_file(i,
|
||||
i->path.c_str(), i->file.c_str(), file_handler_load_file);
|
||||
i->not_ready = false;
|
||||
}
|
||||
i->reading = false;
|
||||
@@ -272,9 +267,9 @@ static int32_t file_handler_storage_thread_ctrl() {
|
||||
i->free_data_lock();
|
||||
}
|
||||
file_handler_storage_data.deque.clear();
|
||||
u_lock.unlock();
|
||||
}
|
||||
return 0;
|
||||
file_handler_storage_data.exit = false;
|
||||
u_lock.unlock();
|
||||
}
|
||||
|
||||
static size_t farc_read_handler_get_file_size(farc_read_handler* frh, std::string* file) {
|
||||
@@ -375,7 +370,7 @@ ssize_t p_file_handler::get_size() {
|
||||
return ptr->size;
|
||||
}
|
||||
|
||||
bool p_file_handler::read_file(char* path, char* farc_file, char* file, bool cache) {
|
||||
bool p_file_handler::read_file(const char* path, const char* farc_file, const char* file, bool cache) {
|
||||
if (!path || !file)
|
||||
return false;
|
||||
|
||||
@@ -385,6 +380,9 @@ bool p_file_handler::read_file(char* path, char* farc_file, char* file, bool cac
|
||||
free_data();
|
||||
}
|
||||
|
||||
if (!rctx_ptr->data->check_file_exists(path, farc_file ? farc_file : file))
|
||||
return false;
|
||||
|
||||
ptr = new file_handler;
|
||||
if (!ptr)
|
||||
return false;
|
||||
@@ -405,7 +403,7 @@ bool p_file_handler::read_file(char* path, char* farc_file, char* file, bool cac
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p_file_handler::read_file_path(char* path, char* file) {
|
||||
bool p_file_handler::read_file_path(const char* path, const char* file) {
|
||||
return read_file(path, 0, file, false);
|
||||
}
|
||||
|
||||
@@ -420,10 +418,10 @@ void p_file_handler::read_now() {
|
||||
if (ptr->not_ready) {
|
||||
bool ret;
|
||||
if (ptr->farc_file.size())
|
||||
ret = data_struct_load_file((data_struct*)rctx_ptr->data,
|
||||
ret = ((data_struct*)rctx_ptr->data)->load_file(
|
||||
ptr, ptr->path.c_str(), ptr->farc_file.c_str(), file_handler_load_farc_file);
|
||||
else
|
||||
ret = data_struct_load_file((data_struct*)rctx_ptr->data,
|
||||
ret = ((data_struct*)rctx_ptr->data)->load_file(
|
||||
ptr, ptr->path.c_str(), ptr->file.c_str(), file_handler_load_file);
|
||||
|
||||
if (ret)
|
||||
@@ -437,7 +435,7 @@ void p_file_handler::read_now() {
|
||||
}
|
||||
}
|
||||
|
||||
void p_file_handler::set_read_free_func_data(int32_t index, void(*func)(void*, void*), void* data) {
|
||||
void p_file_handler::set_read_free_func_data(int32_t index, void(*func)(void*, void*, size_t), void* data) {
|
||||
if (ptr)
|
||||
ptr->set_read_free_func_data(index, func, data);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "../KKdLib/farc.h"
|
||||
|
||||
typedef struct file_handler_read_func_data {
|
||||
void(*func)(void*, void*);
|
||||
void(*func)(void*, void*, size_t);
|
||||
void* data;
|
||||
bool ready;
|
||||
} file_handler_read_func_data;
|
||||
@@ -22,7 +22,7 @@ typedef struct file_handler_read_func_data {
|
||||
class file_handler {
|
||||
public:
|
||||
int32_t count;
|
||||
std::mutex(mtx);
|
||||
std::mutex mtx;
|
||||
bool not_ready;
|
||||
bool reading;
|
||||
std::string path;
|
||||
@@ -38,13 +38,10 @@ public:
|
||||
|
||||
void call_read_free_func(int32_t index);
|
||||
void free_data_lock();
|
||||
void set_file(char* file);
|
||||
void set_file(const char* file);
|
||||
void set_farc_file(char* farc_file, bool cache);
|
||||
void set_farc_file(const char* farc_file, bool cache);
|
||||
void set_path(char* path);
|
||||
void set_path(const char* path);
|
||||
void set_read_free_func_data(int32_t index, void(*func)(void*, void*), void* data);
|
||||
void set_read_free_func_data(int32_t index, void(*func)(void*, void*, size_t), void* data);
|
||||
};
|
||||
|
||||
class p_file_handler {
|
||||
@@ -59,10 +56,10 @@ public:
|
||||
void free_data();
|
||||
void* get_data();
|
||||
ssize_t get_size();
|
||||
bool read_file(char* path, char* farc_file, char* file, bool cache);
|
||||
bool read_file_path(char* path, char* file);
|
||||
bool read_file(const char* path, const char* farc_file, const char* file, bool cache);
|
||||
bool read_file_path(const char* path, const char* file);
|
||||
void read_now();
|
||||
void set_read_free_func_data(int32_t index, void(* func)(void*, void*), void* data);
|
||||
void set_read_free_func_data(int32_t index, void(* func)(void*, void*, size_t), void* data);
|
||||
};
|
||||
|
||||
class farc_read_handler {
|
||||
@@ -76,4 +73,5 @@ public:
|
||||
};
|
||||
|
||||
extern void file_handler_storage_ctrl();
|
||||
extern void file_handler_storage_free_thread();
|
||||
extern void file_handler_storage_init_thread();
|
||||
|
||||
+42
-150
@@ -8,59 +8,26 @@
|
||||
#include "../KKdLib/str_utils.h"
|
||||
#include "render_context.h"
|
||||
|
||||
class light_param_storage {
|
||||
public:
|
||||
bool pv;
|
||||
uint64_t hash;
|
||||
uint32_t pv_id;
|
||||
int32_t count;
|
||||
light_param_data data;
|
||||
|
||||
light_param_storage();
|
||||
~light_param_storage();
|
||||
};
|
||||
|
||||
static void light_param_data_get_stage_name_string(std::string* str, int32_t stage_index);
|
||||
static int32_t light_param_data_load_file(light_param_data* a1, p_file_handler* a2);
|
||||
static void light_param_data_load_file_pv_cut(std::map<int32_t, light_param_data>* tree,
|
||||
farc* f, light_param_data* default_light_param, int32_t pv_id);
|
||||
static void light_param_data_load_pv_cut_file_names(light_param_data* light_param, int32_t cut_id, std::string* name);
|
||||
static void light_param_data_load_stage_file_names(light_param_data* light_param, std::string* name);
|
||||
static void light_param_data_set(light_param_data* a1, light_param_data_storage* storage);
|
||||
static void light_param_storage_free_file_handlers(light_param_data_storage* a1);
|
||||
static void light_param_storage_load_stages(light_param_data_storage* a1, std::vector<int32_t>* stage_indices);
|
||||
static int32_t light_param_storage_load_file(light_param_data_storage* a1, bool read_now);
|
||||
static void light_param_storage_set_default_light_param(light_param_data_storage* a1, int32_t stage_index);
|
||||
static void light_param_storage_set_stage(light_param_data_storage* a1,
|
||||
std::map<int32_t, light_param_data>::iterator* elem, int32_t stage_index);
|
||||
|
||||
std::vector<light_param_storage> light_param_storage_data;
|
||||
light_param_data_storage light_param_data_storage_data;
|
||||
|
||||
light_param_data::light_param_data() : id(), not_loaded() {
|
||||
extern render_context* rctx_ptr;
|
||||
|
||||
}
|
||||
light_param_data::light_param_data() : not_loaded() {
|
||||
|
||||
void light_param_data_load(light_param_data* light_param, data_struct* data, char* name) {
|
||||
char buf[_MAX_PATH];
|
||||
|
||||
light_param->id = 0;
|
||||
|
||||
sprintf_s(buf, sizeof(buf), "light_%s.txt", name);
|
||||
data_struct_load_file(data, &light_param->light, "rom/light_param/", buf, light_param_light_load_file);
|
||||
|
||||
sprintf_s(buf, sizeof(buf), "fog_%s.txt", name);
|
||||
data_struct_load_file(data, &light_param->fog, "rom/light_param/", buf, light_param_fog_load_file);
|
||||
|
||||
sprintf_s(buf, sizeof(buf), "glow_%s.txt", name);
|
||||
data_struct_load_file(data, &light_param->glow, "rom/light_param/", buf, light_param_glow_load_file);
|
||||
|
||||
sprintf_s(buf, sizeof(buf), "%s.ibl", name);
|
||||
data_struct_load_file(data, &light_param->ibl, "rom/ibl/", buf, light_param_ibl_load_file);
|
||||
|
||||
sprintf_s(buf, sizeof(buf), "wind_%s.txt", name);
|
||||
data_struct_load_file(data, &light_param->wind, "rom/light_param/", buf, light_param_wind_load_file);
|
||||
|
||||
sprintf_s(buf, sizeof(buf), "face_%s.txt", name);
|
||||
data_struct_load_file(data, &light_param->face, "rom/light_param/", buf, light_param_face_load_file);
|
||||
}
|
||||
|
||||
light_param_data::~light_param_data() {
|
||||
@@ -91,88 +58,12 @@ void light_param_data_storage::unload() {
|
||||
glDeleteTextures(5, light_param_data_storage_data.textures);
|
||||
}
|
||||
|
||||
char* light_param_get_stage_name_string(char* name) {
|
||||
size_t length = utf8_length(name);
|
||||
if (str_utils_compare_length(name, length, "STG", 3))
|
||||
return 0;
|
||||
|
||||
name += 3;
|
||||
length -= 3;
|
||||
|
||||
char* str = force_malloc_s(char, length + 1);
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
char c = name[i];
|
||||
if (c > 0x40 && c < 0x5B)
|
||||
c += 0x20;
|
||||
str[i] = c;
|
||||
}
|
||||
str[length] = 0;
|
||||
return str;
|
||||
void light_param_storage_data_free_file_handlers() {
|
||||
light_param_storage_free_file_handlers(&light_param_data_storage_data);
|
||||
}
|
||||
|
||||
inline void light_param_storage_init() {
|
||||
light_param_storage_data = {};
|
||||
}
|
||||
|
||||
inline void light_param_storage_append_light_param_data(char* name) {
|
||||
uint64_t hash = hash_utf8_fnv1a64m(name, false);
|
||||
for (light_param_storage& i : light_param_storage_data)
|
||||
if (!i.pv && i.hash == hash) {
|
||||
i.count++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
inline void light_param_storage_load_light_param_data(data_struct* data, char* name) {
|
||||
light_param_data light_param;
|
||||
light_param_data_load(&light_param, data, name);
|
||||
light_param_storage_insert_light_param_data(&light_param, name);
|
||||
}
|
||||
|
||||
inline void light_param_storage_insert_light_param_data(light_param_data* data, char* name) {
|
||||
uint64_t hash = hash_utf8_fnv1a64m(name, false);
|
||||
for (light_param_storage& i : light_param_storage_data)
|
||||
if (!i.pv && i.hash == hash) {
|
||||
i.count++;
|
||||
i.data = *data;
|
||||
return;
|
||||
}
|
||||
|
||||
light_param_storage lit_param_set_storage;
|
||||
lit_param_set_storage.pv = false;
|
||||
lit_param_set_storage.hash = hash;
|
||||
lit_param_set_storage.count = 1;
|
||||
lit_param_set_storage.data = *data;
|
||||
light_param_storage_data.push_back(lit_param_set_storage);
|
||||
}
|
||||
|
||||
inline light_param_data* light_param_storage_get_light_param_data(char* name) {
|
||||
uint64_t hash = hash_utf8_fnv1a64m(name, false);
|
||||
for (light_param_storage& i : light_param_storage_data)
|
||||
if (!i.pv && i.hash == hash)
|
||||
return &i.data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline void light_param_storage_delete_light_param_data(char* name) {
|
||||
uint64_t hash = hash_utf8_fnv1a64m(name, false);
|
||||
for (light_param_storage* i = light_param_storage_data.begin()._Ptr;
|
||||
i != light_param_storage_data.end()._Ptr;)
|
||||
if (!i->pv && i->hash == hash) {
|
||||
i->count--;
|
||||
if (i->count > 0)
|
||||
break;
|
||||
|
||||
light_param_storage_data.erase(light_param_storage_data.begin()
|
||||
+ (i - light_param_storage_data.data()));
|
||||
break;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
|
||||
inline void light_param_storage_free() {
|
||||
light_param_storage_data = {};
|
||||
int32_t light_param_storage_data_load_file() {
|
||||
return light_param_storage_load_file(&light_param_data_storage_data, false);
|
||||
}
|
||||
|
||||
void light_param_storage_data_load_stage(int32_t stage_index) {
|
||||
@@ -184,20 +75,16 @@ void light_param_storage_data_load_stages(std::vector<int32_t>* stage_indices) {
|
||||
light_param_storage_load_stages(&light_param_data_storage_data, stage_indices);
|
||||
}
|
||||
|
||||
void light_param_storage_data_set_default_light_param() {
|
||||
light_param_data_set(&light_param_data_storage_data.default_light_param, &light_param_data_storage_data);
|
||||
}
|
||||
|
||||
void light_param_storage_data_set_stage(int32_t stage_id) {
|
||||
std::map<int32_t, light_param_data>::iterator elem;
|
||||
light_param_storage_set_stage(&light_param_data_storage_data, &elem, stage_id);
|
||||
}
|
||||
|
||||
light_param_storage::light_param_storage() : pv(), hash(), pv_id(), count() {
|
||||
|
||||
}
|
||||
|
||||
light_param_storage::~light_param_storage() {
|
||||
|
||||
}
|
||||
|
||||
int32_t light_param_storage_load_file(light_param_data_storage* a1, bool read_now) {
|
||||
static int32_t light_param_storage_load_file(light_param_data_storage* a1, bool read_now) {
|
||||
if (a1->state == 1) {
|
||||
light_param_data* light_param = &a1->stage_light_param_iterator->second;
|
||||
std::string* paths = light_param->paths;
|
||||
@@ -234,38 +121,37 @@ int32_t light_param_storage_load_file(light_param_data_storage* a1, bool read_no
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else if (a1->state - 3) {
|
||||
char DstBuf[256]; // [rsp+90h] [rbp-138h] BYREF
|
||||
sprintf_s(DstBuf, 0x100ui64, "light_pv%03d.farc", a1->pv_id);
|
||||
if (a1->farc_file_handler.read_file_path((char*)"./rom/light_param/", DstBuf))
|
||||
else if (a1->state == 3) {
|
||||
char buf[0x100];
|
||||
sprintf_s(buf, sizeof(buf), "light_pv%03d.farc", a1->pv_id);
|
||||
if (a1->farc_file_handler.read_file_path((char*)"./rom/light_param/", buf))
|
||||
a1->state = 4;
|
||||
else {
|
||||
a1->farc_file_handler.free_data();
|
||||
a1->state = 0;
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
else if (a1->state == 4) {
|
||||
if (read_now)
|
||||
a1->farc_file_handler.read_now();
|
||||
else if (a1->farc_file_handler.check_not_ready())
|
||||
return true;
|
||||
return 1;
|
||||
|
||||
farc a1a;
|
||||
a1a.read(a1->farc_file_handler.get_data(), a1->farc_file_handler.get_size(), true);
|
||||
if (a1a.files.size())
|
||||
light_param_data_load_file_pv_cut(&a1->pv_cut, &a1a, &a1->default_light_param, a1->pv_id);
|
||||
a1->state = 0;
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern render_context* rctx_ptr;
|
||||
|
||||
static void light_param_data_get_stage_name_string(std::string* str, int32_t stage_index) {
|
||||
*str = {};
|
||||
str->clear();
|
||||
str->shrink_to_fit();;
|
||||
stage_database* data = &rctx_ptr->data->data_ft.stage_data;
|
||||
char* stage_name = stage_index < vector_old_length(data->stage_data)
|
||||
? string_data(&data->stage_data.begin[stage_index].name) : 0;
|
||||
@@ -299,32 +185,32 @@ static void light_param_data_get_stage_name_string(std::string* str, int32_t sta
|
||||
|
||||
static int32_t light_param_data_load_file(light_param_data* a1, p_file_handler* a2) {
|
||||
if (a2[0].ptr) {
|
||||
a1->ibl = {};
|
||||
a1->ibl = light_param_ibl();
|
||||
a1->ibl.read(a2[0].get_data(), a2[0].get_size());
|
||||
}
|
||||
|
||||
if (a2[1].ptr) {
|
||||
a1->light = {};
|
||||
a1->light = light_param_light();
|
||||
a1->light.read(a2[1].get_data(), a2[1].get_size());
|
||||
}
|
||||
|
||||
if (a2[2].ptr) {
|
||||
a1->fog = {};
|
||||
a1->fog = light_param_fog();
|
||||
a1->fog.read(a2[2].get_data(), a2[2].get_size());
|
||||
}
|
||||
|
||||
if (a2[3].ptr) {
|
||||
a1->glow = {};
|
||||
a1->glow = light_param_glow();
|
||||
a1->glow.read(a2[3].get_data(), a2[3].get_size());
|
||||
}
|
||||
|
||||
if (a2[4].ptr) {
|
||||
a1->wind = {};
|
||||
a1->wind = light_param_wind();
|
||||
a1->wind.read(a2[4].get_data(), a2[4].get_size());
|
||||
}
|
||||
|
||||
if (a2[5].ptr) {
|
||||
a1->face = {};
|
||||
a1->face = light_param_face();
|
||||
a1->face.read(a2[5].get_data(), a2[5].get_size());
|
||||
}
|
||||
|
||||
@@ -443,23 +329,23 @@ static void light_param_data_load_file_pv_cut(std::map<int32_t, light_param_data
|
||||
}
|
||||
|
||||
if (type == 1) {
|
||||
light_param->light = {};
|
||||
light_param->light = light_param_light();
|
||||
light_param->light.read(i.data, i.size);
|
||||
}
|
||||
else if (type == 2) {
|
||||
light_param->fog = {};
|
||||
light_param->fog = light_param_fog();
|
||||
light_param->fog.read(i.data, i.size);
|
||||
}
|
||||
else if (type == 3) {
|
||||
light_param->glow = {};
|
||||
light_param->glow = light_param_glow();
|
||||
light_param->glow.read(i.data, i.size);
|
||||
}
|
||||
else if (type == 4) {
|
||||
light_param->wind = {};
|
||||
light_param->wind = light_param_wind();
|
||||
light_param->wind.read(i.data, i.size);
|
||||
}
|
||||
else if (type == 5) {
|
||||
light_param->face = {};
|
||||
light_param->face = light_param_face();
|
||||
light_param->face.read(i.data, i.size);
|
||||
}
|
||||
}
|
||||
@@ -526,6 +412,12 @@ void light_param_data_load_stage_file_names(light_param_data* light_param, std::
|
||||
light_param->files[5] = std::string(buf);
|
||||
}
|
||||
|
||||
static void light_param_storage_free_file_handlers(light_param_data_storage* a1) {
|
||||
for (int32_t i = 0; i < 6; ++i)
|
||||
a1->file_handlers[i].free_data();
|
||||
a1->farc_file_handler.free_data();
|
||||
}
|
||||
|
||||
static void light_param_storage_load_stages(light_param_data_storage* a1, std::vector<int32_t>* stage_indices) {
|
||||
if (a1->state)
|
||||
for (int32_t i = 0; i < 6; ++i)
|
||||
@@ -562,7 +454,7 @@ static void light_param_storage_set_default_light_param(light_param_data_storage
|
||||
a1->default_light_param = elem->second;
|
||||
}
|
||||
|
||||
void light_param_data_set(light_param_data* a1, light_param_data_storage* storage) {
|
||||
static void light_param_data_set(light_param_data* a1, light_param_data_storage* storage) {
|
||||
if (!a1->not_loaded || a1->light.ready)
|
||||
render_context_light_param_data_light_set(rctx_ptr, &a1->light);
|
||||
if (!a1->not_loaded || a1->fog.ready)
|
||||
|
||||
+3
-15
@@ -27,7 +27,6 @@ public:
|
||||
std::string paths[6];
|
||||
std::string files[6];
|
||||
bool not_loaded;
|
||||
int32_t id;
|
||||
light_param_light light;
|
||||
light_param_fog fog;
|
||||
light_param_glow glow;
|
||||
@@ -37,8 +36,6 @@ public:
|
||||
|
||||
light_param_data();
|
||||
~light_param_data();
|
||||
|
||||
static int32_t load_file();
|
||||
};
|
||||
|
||||
class light_param_data_storage {
|
||||
@@ -63,18 +60,9 @@ public:
|
||||
static void unload();
|
||||
};
|
||||
|
||||
extern void light_param_data_load(light_param_data* light_param, data_struct* data, char* name);
|
||||
|
||||
extern char* light_param_get_stage_name_string(char* name);
|
||||
|
||||
extern void light_param_storage_init();
|
||||
extern void light_param_storage_append_light_param_data(char* name);
|
||||
extern void light_param_storage_load_light_param_data(data_struct* data, char* name);
|
||||
extern void light_param_storage_insert_light_param_data(light_param_data* data, char* name);
|
||||
extern light_param_data* light_param_storage_get_light_param_data(char* name);
|
||||
extern void light_param_storage_delete_light_param_data(char* name);
|
||||
extern void light_param_storage_free();
|
||||
|
||||
extern void light_param_storage_data_free_file_handlers();
|
||||
extern int32_t light_param_storage_data_load_file();
|
||||
extern void light_param_storage_data_load_stage(int32_t stage_index);
|
||||
extern void light_param_storage_data_load_stages(std::vector<int32_t>* stage_indices);
|
||||
extern void light_param_storage_data_set_default_light_param();
|
||||
extern void light_param_storage_data_set_stage(int32_t stage_id);
|
||||
|
||||
+94
-64
@@ -5,15 +5,88 @@
|
||||
|
||||
#include "wind.h"
|
||||
|
||||
static float_t wind_apply_spc(wind* wind, float_t frame);
|
||||
static float_t wind_apply_spc(wind* w, float_t frame);
|
||||
static void wind_ctrl(wind* w);
|
||||
|
||||
wind* wind_init() {
|
||||
wind* w = force_malloc_s(wind, 1);
|
||||
w->count = 16;
|
||||
return w;
|
||||
TaskWind task_wind;
|
||||
|
||||
wind::wind() : scale(), cycle(), rot_y(), rot_z(),
|
||||
bias(), spc(), wind_direction(), frame(), strength() {
|
||||
count = 16;
|
||||
}
|
||||
|
||||
void wind_ctrl(wind* w) {
|
||||
wind::~wind() {
|
||||
|
||||
}
|
||||
|
||||
float_t wind::get_scale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
void wind::set_scale(float_t value) {
|
||||
scale = value;
|
||||
}
|
||||
|
||||
float_t wind::get_cycle() {
|
||||
return cycle;
|
||||
}
|
||||
|
||||
void wind::set_cycle(float_t value) {
|
||||
cycle = value;
|
||||
}
|
||||
|
||||
void wind::get_rot(vec2* value) {
|
||||
value->x = rot_y;
|
||||
value->y = rot_z;
|
||||
}
|
||||
|
||||
void wind::set_rot(vec2* value) {
|
||||
rot_y = value->x;
|
||||
rot_z = value->y;
|
||||
}
|
||||
|
||||
float_t wind::get_rot_y() {
|
||||
return rot_y;
|
||||
}
|
||||
|
||||
void wind::set_rot_y(float_t value) {
|
||||
rot_y = value;
|
||||
}
|
||||
|
||||
float_t wind::get_rot_z() {
|
||||
return rot_z;
|
||||
}
|
||||
|
||||
void wind::set_rot_z(float_t value) {
|
||||
rot_z = value;
|
||||
}
|
||||
|
||||
float_t wind::get_bias() {
|
||||
return bias;
|
||||
}
|
||||
|
||||
void wind::set_bias(float_t value) {
|
||||
bias = value;
|
||||
}
|
||||
|
||||
void wind::reset() {
|
||||
strength = 0.0f;
|
||||
frame = 0.0f;
|
||||
wind_direction = vec3_null;
|
||||
}
|
||||
|
||||
static float_t wind_apply_spc(wind* w, float_t frame) {
|
||||
size_t count = w->count;
|
||||
float_t value = 0.0f;
|
||||
wind_spc* spc = w->spc;
|
||||
for (size_t i = 0; i < count; i++, spc++) {
|
||||
float_t power = (float_t)(1 << (int32_t)i) * frame;
|
||||
value += cosf(power) * spc->cos + sinf(power) * spc->sin;
|
||||
}
|
||||
return value + w->bias;
|
||||
}
|
||||
|
||||
static void wind_ctrl(wind* w) {
|
||||
float_t value = wind_apply_spc(w, w->cycle * w->frame) * w->scale;
|
||||
mat4 mat = mat4_identity;
|
||||
mat4_rotate_y_mult(&mat, w->rot_y * DEG_TO_RAD_FLOAT, &mat);
|
||||
@@ -32,72 +105,29 @@ void wind_ctrl(wind* w) {
|
||||
w->frame = 0.0f;
|
||||
}
|
||||
|
||||
float_t wind_get_scale(wind* w) {
|
||||
return w->scale;
|
||||
TaskWind::TaskWind() {
|
||||
ptr = new wind;
|
||||
}
|
||||
|
||||
void wind_set_scale(wind* w, float_t value) {
|
||||
w->scale = value;
|
||||
TaskWind:: ~TaskWind() {
|
||||
delete ptr;
|
||||
}
|
||||
|
||||
float_t wind_get_cycle(wind* w) {
|
||||
return w->cycle;
|
||||
bool TaskWind::Init() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void wind_set_cycle(wind* w, float_t value) {
|
||||
w->cycle = value;
|
||||
bool TaskWind::Ctrl() {
|
||||
//if (!pv_osage_manager_array_ptr_get_disp())
|
||||
wind_ctrl(ptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
void wind_get_rot(wind* w, vec2* value) {
|
||||
value->x = w->rot_y;
|
||||
value->y = w->rot_z;
|
||||
bool TaskWind::Dest() {
|
||||
ptr->reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
void wind_set_rot(wind* w, vec2* value) {
|
||||
w->rot_y = value->x;
|
||||
w->rot_z = value->y;
|
||||
}
|
||||
|
||||
float_t wind_get_rot_y(wind* w) {
|
||||
return w->rot_y;
|
||||
}
|
||||
|
||||
void wind_set_rot_y(wind* w, float_t value) {
|
||||
w->rot_y = value;
|
||||
}
|
||||
|
||||
float_t wind_get_rot_z(wind* w) {
|
||||
return w->rot_z;
|
||||
}
|
||||
|
||||
void wind_set_rot_z(wind* w, float_t value) {
|
||||
w->rot_z = value;
|
||||
}
|
||||
|
||||
float_t wind_get_bias(wind* w) {
|
||||
return w->bias;
|
||||
}
|
||||
|
||||
void wind_set_bias(wind* w, float_t value) {
|
||||
w->bias = value;
|
||||
}
|
||||
|
||||
void wind_reset(wind* w) {
|
||||
w->strength = 0.0f;
|
||||
w->frame = 0.0f;
|
||||
}
|
||||
|
||||
void wind_free(wind* w) {
|
||||
free(w);
|
||||
}
|
||||
|
||||
static float_t wind_apply_spc(wind* wind, float_t frame) {
|
||||
size_t count = wind->count;
|
||||
float_t value = 0.0f;
|
||||
wind_spc* spc = wind->spc;
|
||||
for (size_t i = 0; i < count; i++, spc++) {
|
||||
float_t power = (float_t)(1 << (int32_t)i) * frame;
|
||||
value += cosf(power) * spc->cos + sinf(power) * spc->sin;
|
||||
}
|
||||
return value + wind->bias;
|
||||
void TaskWind::Disp() {
|
||||
//pv_osage_manager_array_ptr_get_disp();
|
||||
}
|
||||
|
||||
+34
-18
@@ -9,13 +9,15 @@
|
||||
#include "../../KKdLib/light_param/wind.h"
|
||||
#include "../../KKdLib/vec.h"
|
||||
#include "../static_var.h"
|
||||
#include "../task.h"
|
||||
|
||||
typedef struct wind_spc {
|
||||
float_t cos;
|
||||
float_t sin;
|
||||
} wind_spc;
|
||||
|
||||
typedef struct wind {
|
||||
class wind {
|
||||
public:
|
||||
float_t scale;
|
||||
float_t cycle;
|
||||
float_t rot_y;
|
||||
@@ -26,21 +28,35 @@ typedef struct wind {
|
||||
vec3 wind_direction;
|
||||
float_t frame;
|
||||
float_t strength;
|
||||
} wind;
|
||||
|
||||
extern wind* wind_init();
|
||||
extern void wind_ctrl(wind* w);
|
||||
extern float_t wind_get_scale(wind* w);
|
||||
extern void wind_set_scale(wind* w, float_t value);
|
||||
extern float_t wind_get_cycle(wind* w);
|
||||
extern void wind_set_cycle(wind* w, float_t value);
|
||||
extern void wind_get_rot(wind* w, vec2* value);
|
||||
extern void wind_set_rot(wind* w, vec2* value);
|
||||
extern float_t wind_get_rot_y(wind* w);
|
||||
extern void wind_set_rot_y(wind* w, float_t value);
|
||||
extern float_t wind_get_rot_z(wind* w);
|
||||
extern void wind_set_rot_z(wind* w, float_t value);
|
||||
extern float_t wind_get_bias(wind* w);
|
||||
extern void wind_set_bias(wind* w, float_t value);
|
||||
extern void wind_reset(wind* w);
|
||||
extern void wind_free(wind* w);
|
||||
wind();
|
||||
~wind();
|
||||
|
||||
float_t get_scale();
|
||||
void set_scale(float_t value);
|
||||
float_t get_cycle();
|
||||
void set_cycle(float_t value);
|
||||
void get_rot(vec2* value);
|
||||
void set_rot(vec2* value);
|
||||
float_t get_rot_y();
|
||||
void set_rot_y(float_t value);
|
||||
float_t get_rot_z();
|
||||
void set_rot_z(float_t value);
|
||||
float_t get_bias();
|
||||
void set_bias(float_t value);
|
||||
void reset();
|
||||
};
|
||||
|
||||
class TaskWind : public Task {
|
||||
public:
|
||||
wind* ptr;
|
||||
|
||||
TaskWind();
|
||||
virtual ~TaskWind() override;
|
||||
virtual bool Init() override;
|
||||
virtual bool Ctrl() override;
|
||||
virtual bool Dest() override;
|
||||
virtual void Disp() override;
|
||||
};
|
||||
|
||||
extern TaskWind task_wind;
|
||||
|
||||
@@ -18,33 +18,3 @@ inline void lock_free(lock* l) {
|
||||
DeleteCriticalSection(&l->cs);
|
||||
l->init = FALSE;
|
||||
}
|
||||
|
||||
inline bool lock_data_init(lock_data* ld, lock* l,
|
||||
void* data, void(*free_func)(void* data)) {
|
||||
if (ld->lock_free && ld->lock_free != free_func) {
|
||||
lock* lock = ld->lock;
|
||||
lock_lock(lock);
|
||||
ld->lock_free(ld->lock_data);
|
||||
lock_unlock(lock);
|
||||
|
||||
if (ld->lock_free)
|
||||
return false;
|
||||
}
|
||||
else if (ld->lock_free)
|
||||
ld->lock_free(ld->lock_data);
|
||||
|
||||
ld->lock = l;
|
||||
ld->lock_data = data;
|
||||
ld->lock_free = free_func;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool lock_data_free(lock_data* ld, void(*free_func)(void* data)) {
|
||||
if (ld->lock_free != free_func)
|
||||
return false;
|
||||
|
||||
ld->lock = 0;
|
||||
ld->lock_data = 0;
|
||||
ld->lock_free = 0;
|
||||
return true;
|
||||
}
|
||||
@@ -32,7 +32,3 @@ LeaveCriticalSection(&(val)->cs); \
|
||||
extern void lock_init(lock* l);
|
||||
extern bool lock_check_init(lock* l);
|
||||
extern void lock_free(lock* l);
|
||||
|
||||
extern bool lock_data_init(lock_data* ld, lock* l,
|
||||
void* data, void(*free_func)(void* data));
|
||||
extern bool lock_data_free(lock_data* ld, void(*free_func)(void* data));
|
||||
|
||||
+49
-45
@@ -70,8 +70,8 @@ static size_t obj_vertex_flags_get_vertex_size(obj_vertex_flags flags);
|
||||
static size_t obj_vertex_flags_get_vertex_size_comp(obj_vertex_flags flags);
|
||||
static size_t object_vertex_flags_get_vertex_size(object_vertex_flags flags);
|
||||
static size_t object_vertex_flags_get_vertex_size_comp(object_vertex_flags flags);
|
||||
static bool object_set_load_file(void* data, char* path, char* file, uint32_t hash);
|
||||
static bool object_set_load_file_modern(void* data, char* path, char* file, uint32_t hash);
|
||||
static bool object_set_load_file(void* data, const char* path, const char* file, uint32_t hash);
|
||||
static bool object_set_load_file_modern(void* data, const char* path, const char* file, uint32_t hash);
|
||||
|
||||
vector_old_func(object_storage)
|
||||
|
||||
@@ -85,7 +85,7 @@ void object_set_init(object_set* set) {
|
||||
}
|
||||
|
||||
void object_set_load(object_set* set, obj_set* obj_set_file, txp_set* txp_set_file,
|
||||
texture_database* tex_db, string* name, uint32_t id, bool compressed) {
|
||||
texture_database* tex_db, const char* name, uint32_t id, bool compressed) {
|
||||
if (!set || !obj_set_file || !txp_set_file || !tex_db || !name)
|
||||
return;
|
||||
|
||||
@@ -124,7 +124,7 @@ void object_set_load(object_set* set, obj_set* obj_set_file, txp_set* txp_set_fi
|
||||
string_init_length(name, buf, len);
|
||||
}
|
||||
|
||||
string_copy(name, &set->name);
|
||||
string_init(&set->name, name);
|
||||
set->id = id;
|
||||
set->hash = hash_string_murmurhash(&set->name, 0, false);
|
||||
|
||||
@@ -668,8 +668,8 @@ void object_set_load(object_set* set, obj_set* obj_set_file, txp_set* txp_set_fi
|
||||
osage->nodes_count = nodes_count;
|
||||
osage->nodes = force_malloc_s(object_skin_osage_node, nodes_count);
|
||||
for (int32_t k = 0; k < nodes_count; k++) {
|
||||
object_skin_osage_node* node = &osage->nodes[j];
|
||||
object_skin_osage_node_file* node_file = &osage_file->nodes[j];
|
||||
object_skin_osage_node* node = &osage->nodes[k];
|
||||
object_skin_osage_node_file* node_file = &osage_file->nodes[k];
|
||||
|
||||
node->name_index = node_file->name_index;
|
||||
node->length = node_file->length;
|
||||
@@ -693,12 +693,12 @@ void object_set_load(object_set* set, obj_set* obj_set_file, txp_set* txp_set_fi
|
||||
|
||||
osage_sibling_info->name_index = osage_sibling_info_file->name_index;
|
||||
osage_sibling_info->sibling_name_index = osage_sibling_info_file->sibling_name_index;
|
||||
osage_sibling_info->distance = osage_sibling_info_file->distance;
|
||||
osage_sibling_info->max_distance = osage_sibling_info_file->max_distance;
|
||||
}
|
||||
skin->ex_data_init = true;
|
||||
}
|
||||
|
||||
int32_t textures_count = (int32_t)vector_old_length(*txp_set_file);
|
||||
int32_t textures_count = (int32_t)txp_set_file->textures.size();
|
||||
set->textures_count = textures_count;
|
||||
set->textures = force_malloc_s(GLuint, textures_count);
|
||||
texture_txp_set_load(txp_set_file, &set->texture_data, set->texture_ids);
|
||||
@@ -715,7 +715,7 @@ void object_set_load(object_set* set, obj_set* obj_set_file, txp_set* txp_set_fi
|
||||
|
||||
bool object_set_load_db_entry(object_set_info** set_info,
|
||||
void* data, object_database* obj_db, char* name) {
|
||||
if (!object_database_get_object_set_info(obj_db, name, set_info))
|
||||
if (!obj_db->get_object_set_info(name, set_info))
|
||||
return false;
|
||||
else if (object_storage_get_object_set((*set_info)->id)) {
|
||||
object_storage_append_object_set((*set_info)->id);
|
||||
@@ -725,13 +725,13 @@ bool object_set_load_db_entry(object_set_info** set_info,
|
||||
size_t temp[2];
|
||||
temp[0] = (size_t)data;
|
||||
temp[1] = (size_t)*set_info;
|
||||
return data_struct_load_file((data_struct*)data, temp, "rom/objset/",
|
||||
string_data(&(*set_info)->archive_file_name), object_set_load_file);
|
||||
return ((data_struct*)data)->load_file(temp, "rom/objset/",
|
||||
(*set_info)->archive_file_name.c_str(), object_set_load_file);
|
||||
}
|
||||
|
||||
bool object_set_load_db_entry(object_set_info** set_info,
|
||||
void* data, object_database* obj_db, const char* name) {
|
||||
if (!object_database_get_object_set_info(obj_db, name, set_info))
|
||||
if (!obj_db->get_object_set_info(name, set_info))
|
||||
return false;
|
||||
else if (object_storage_get_object_set((*set_info)->id)) {
|
||||
object_storage_append_object_set((*set_info)->id);
|
||||
@@ -741,8 +741,8 @@ bool object_set_load_db_entry(object_set_info** set_info,
|
||||
size_t temp[2];
|
||||
temp[0] = (size_t)data;
|
||||
temp[1] = (size_t)*set_info;
|
||||
return data_struct_load_file((data_struct*)data, temp, "rom/objset/",
|
||||
string_data(&(*set_info)->archive_file_name), object_set_load_file);
|
||||
return ((data_struct*)data)->load_file(temp, "rom/objset/",
|
||||
(*set_info)->archive_file_name.c_str(), object_set_load_file);
|
||||
}
|
||||
|
||||
bool object_set_load_by_db_entry(object_set_info* set_info,
|
||||
@@ -755,13 +755,13 @@ bool object_set_load_by_db_entry(object_set_info* set_info,
|
||||
size_t temp[2];
|
||||
temp[0] = (size_t)data;
|
||||
temp[1] = (size_t)set_info;
|
||||
return data_struct_load_file((data_struct*)data, temp, "rom/objset/",
|
||||
string_data(&set_info->archive_file_name), object_set_load_file);
|
||||
return ((data_struct*)data)->load_file(temp, "rom/objset/",
|
||||
set_info->archive_file_name.c_str(), object_set_load_file);
|
||||
}
|
||||
|
||||
bool object_set_load_by_db_index(object_set_info** set_info,
|
||||
void* data, object_database* obj_db, uint32_t set_id) {
|
||||
if (!object_database_get_object_set_info_by_set_id(obj_db, set_id, set_info))
|
||||
if (!obj_db->get_object_set_info_by_set_id(set_id, set_info))
|
||||
return false;
|
||||
else if (object_storage_get_object_set(set_id)) {
|
||||
object_storage_append_object_set(set_id);
|
||||
@@ -771,8 +771,8 @@ bool object_set_load_by_db_index(object_set_info** set_info,
|
||||
size_t temp[2];
|
||||
temp[0] = (size_t)data;
|
||||
temp[1] = (size_t)*set_info;
|
||||
return data_struct_load_file((data_struct*)data, temp, "rom/objset/",
|
||||
string_data(&(*set_info)->archive_file_name), object_set_load_file);
|
||||
return ((data_struct*)data)->load_file(temp, "rom/objset/",
|
||||
(*set_info)->archive_file_name.c_str(), object_set_load_file);
|
||||
}
|
||||
|
||||
bool object_set_load_by_hash(void* data,
|
||||
@@ -780,7 +780,7 @@ bool object_set_load_by_hash(void* data,
|
||||
size_t temp[2];
|
||||
temp[0] = (size_t)obj_db;
|
||||
temp[1] = (size_t)tex_db;
|
||||
return data_struct_load_file_by_hash((data_struct*)data, temp, "rom/objset/",
|
||||
return ((data_struct*)data)->load_file_by_hash(temp, "rom/objset/",
|
||||
hash, object_set_load_file_modern);
|
||||
}
|
||||
|
||||
@@ -1250,6 +1250,13 @@ inline GLuint* object_storage_get_textures(uint32_t set_id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline int32_t object_storage_get_textures_count(uint32_t set_id) {
|
||||
for (object_storage* i = object_storage_data.begin; i != object_storage_data.end; i++)
|
||||
if (i->set_id == set_id)
|
||||
return i->set.textures_count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline uint32_t* object_storage_get_texture_ids(uint32_t set_id) {
|
||||
for (object_storage* i = object_storage_data.begin; i != object_storage_data.end; i++)
|
||||
if (i->set_id == set_id)
|
||||
@@ -1257,6 +1264,13 @@ inline uint32_t* object_storage_get_texture_ids(uint32_t set_id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline int32_t object_storage_get_texture_ids_count(uint32_t set_id) {
|
||||
for (object_storage* i = object_storage_data.begin; i != object_storage_data.end; i++)
|
||||
if (i->set_id == set_id)
|
||||
return i->set.texture_ids_count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline void object_storage_delete_object_set(uint32_t set_id) {
|
||||
for (object_storage* i = object_storage_data.begin; i != object_storage_data.end; i++)
|
||||
if (i->set_id == set_id) {
|
||||
@@ -1543,7 +1557,7 @@ inline static size_t object_vertex_flags_get_vertex_size_comp(object_vertex_flag
|
||||
return size;
|
||||
}
|
||||
|
||||
static bool object_set_load_file(void* data, char* path, char* file, uint32_t hash) {
|
||||
static bool object_set_load_file(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
data_struct* ds = (data_struct*)((size_t*)data)[0];
|
||||
data_ft* d = &ds->data_ft;
|
||||
|
||||
@@ -1553,32 +1567,27 @@ static bool object_set_load_file(void* data, char* path, char* file, uint32_t ha
|
||||
if (!farc::load_file(&f, path, file, hash))
|
||||
return false;
|
||||
|
||||
farc_file* obj = f.read_file(string_data(&set_info->object_file_name));
|
||||
farc_file* tex = f.read_file(string_data(&set_info->texture_file_name));
|
||||
farc_file* obj = f.read_file(set_info->object_file_name.c_str());
|
||||
farc_file* tex = f.read_file(set_info->texture_file_name.c_str());
|
||||
|
||||
if (obj && tex) {
|
||||
obj_set obj_set;
|
||||
obj_init(&obj_set);
|
||||
obj_mread(&obj_set, obj->data, obj->size, false);
|
||||
obj_set.unpack_file(obj->data, obj->size, false);
|
||||
|
||||
txp_set txp_set;
|
||||
txp_set_init(&txp_set);
|
||||
txp_set_unpack_file(&txp_set, tex->data, false);
|
||||
txp_set.unpack_file(tex->data, false);
|
||||
|
||||
if (obj_set.ready) {
|
||||
object_set object_set;
|
||||
object_set_init(&object_set);
|
||||
object_set_load(&object_set, &obj_set, &txp_set, &d->tex_db, &set_info->name, set_info->id, false);
|
||||
object_set_load(&object_set, &obj_set, &txp_set, &d->tex_db, set_info->name.c_str(), set_info->id, false);
|
||||
object_storage_insert_object_set(&object_set, set_info->id);
|
||||
}
|
||||
|
||||
obj_free(&obj_set);
|
||||
txp_set_free(&txp_set);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool object_set_load_file_modern(void* data, char* path, char* file, uint32_t hash) {
|
||||
static bool object_set_load_file_modern(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
object_database* obj_db = (object_database*)((size_t*)data)[0];
|
||||
texture_database* tex_db = (texture_database*)((size_t*)data)[1];
|
||||
|
||||
@@ -1608,21 +1617,19 @@ static bool object_set_load_file_modern(void* data, char* path, char* file, uint
|
||||
|
||||
if (osd && txd && osi && txi) {
|
||||
obj_set obj_set;
|
||||
obj_init(&obj_set);
|
||||
obj_mread(&obj_set, osd->data, osd->size, true);
|
||||
obj_set.unpack_file(osd->data, osd->size, true);
|
||||
|
||||
txp_set txp_set;
|
||||
txp_set_init(&txp_set);
|
||||
txp_set_unpack_file_modern(&txp_set, txd->data, txd->size);
|
||||
txp_set.unpack_file_modern(txd->data, txd->size);
|
||||
|
||||
object_database_mread(obj_db, osi->data, osi->size, true);
|
||||
obj_db->read(osi->data, osi->size, true);
|
||||
tex_db->read(txi->data, txi->size, true);
|
||||
|
||||
string* name = 0;
|
||||
std::string* name = 0;
|
||||
if (obj_db->ready)
|
||||
for (object_set_info* m = obj_db->object_set.begin; m != obj_db->object_set.end; m++)
|
||||
if (m->id == hash) {
|
||||
name = &m->name;
|
||||
for (object_set_info& m : obj_db->object_set)
|
||||
if (m.id == hash) {
|
||||
name = &m.name;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1630,14 +1637,11 @@ static bool object_set_load_file_modern(void* data, char* path, char* file, uint
|
||||
if (!object_storage_get_object_set(hash)) {
|
||||
object_set object_set;
|
||||
object_set_init(&object_set);
|
||||
object_set_load(&object_set, &obj_set, &txp_set, tex_db, name, hash, false);
|
||||
object_set_load(&object_set, &obj_set, &txp_set, tex_db, name->c_str(), hash, false);
|
||||
object_storage_insert_object_set(&object_set, hash);
|
||||
}
|
||||
else
|
||||
object_storage_append_object_set(hash);
|
||||
|
||||
obj_free(&obj_set);
|
||||
txp_set_free(&txp_set);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+4
-4
@@ -469,8 +469,6 @@ typedef struct object_skin_osage_node {
|
||||
uint32_t name_index;
|
||||
float_t length;
|
||||
vec3 rotation;
|
||||
uint32_t sibling_name_index;
|
||||
float_t sibling_max_distance;
|
||||
} object_skin_osage_node;
|
||||
|
||||
typedef struct object_skin_block_osage {
|
||||
@@ -499,7 +497,7 @@ typedef struct object_skin_block {
|
||||
typedef struct object_skin_osage_sibling_info {
|
||||
uint32_t name_index;
|
||||
uint32_t sibling_name_index;
|
||||
float_t distance;
|
||||
float_t max_distance;
|
||||
} object_skin_osage_sibling_info;
|
||||
|
||||
typedef struct object_skin_ex_data {
|
||||
@@ -582,7 +580,7 @@ typedef struct object_set {
|
||||
|
||||
extern void object_set_init(object_set* set);
|
||||
extern void object_set_load(object_set* set, obj_set* obj_set_file, txp_set* txp_set_file,
|
||||
texture_database* tex_db, string* name, uint32_t id, bool compressed);
|
||||
texture_database* tex_db, const char* name, uint32_t id, bool compressed);
|
||||
extern bool object_set_load_db_entry(object_set_info** set_info,
|
||||
void* data, object_database* obj_db, char* name);
|
||||
extern bool object_set_load_db_entry(object_set_info** set_info,
|
||||
@@ -629,6 +627,8 @@ extern object_mesh_index_buffer* object_storage_get_object_mesh_index_buffer(obj
|
||||
extern object_vertex_buffer* object_storage_get_object_vertex_buffers(uint32_t set_id);
|
||||
extern object_mesh_vertex_buffer* object_storage_get_object_mesh_vertex_buffer(object_info obj_info);
|
||||
extern GLuint* object_storage_get_textures(uint32_t set_id);
|
||||
extern int32_t object_storage_get_textures_count(uint32_t set_id);
|
||||
extern uint32_t* object_storage_get_texture_ids(uint32_t set_id);
|
||||
extern int32_t object_storage_get_texture_ids_count(uint32_t set_id);
|
||||
extern void object_storage_delete_object_set(uint32_t set_id);
|
||||
extern void object_storage_free();
|
||||
|
||||
@@ -89,7 +89,7 @@ void post_process_apply(post_process_struct* pp, camera* cam, texture* light_pro
|
||||
(mat4*)&mat4_identity, (mat4*)&mat4_identity, (mat4*)&mat4_identity);
|
||||
|
||||
post_process_get_blur(pp->blur, &pp->rend_texture);
|
||||
post_process_get_exposure(pp->exposure, pp->reset_exposure,
|
||||
post_process_get_exposure(pp->exposure, cam, pp->render_width, pp->render_height, pp->reset_exposure,
|
||||
pp->blur->tex[4].color_texture->texture, pp->blur->tex[2].color_texture->texture);
|
||||
post_process_apply_tone_map(pp->tone_map, &pp->rend_texture, light_proj_tex, 0,
|
||||
&pp->rend_texture, &pp->buf_texture, &pp->sss_contour_texture,
|
||||
@@ -295,6 +295,7 @@ void post_process_reset(post_process_struct* pp) {
|
||||
vec3 tone_trans_end = { 1.0f, 1.0f, 1.0f };
|
||||
post_process_tone_map_initialize_data(pp->tone_map, 2.0f, true, 1.0f, 1, 1.0f,
|
||||
&scene_fade_color, 0.0f, 0, &tone_trans_start, &tone_trans_end, TONE_MAP_YCC_EXPONENT);
|
||||
pp->reset_exposure = true;
|
||||
}
|
||||
|
||||
void post_process_update(post_process_struct* pp, camera* cam) {
|
||||
|
||||
@@ -47,6 +47,16 @@ typedef struct post_process_struct {
|
||||
post_process_tone_map* tone_map;
|
||||
GLuint samplers[2];
|
||||
shader_glsl alpha_layer_shader;
|
||||
GLuint lens_flare_texture;
|
||||
GLuint lens_shaft_texture;
|
||||
GLuint lens_ghost_texture;
|
||||
int32_t lens_flare_count;
|
||||
vec3 lens_flare_pos;
|
||||
float_t lens_shaft_scale;
|
||||
float_t lens_shaft_inv_scale;
|
||||
float_t lens_flare_power;
|
||||
float_t field_A10;
|
||||
float_t lens_flare_appear_power;
|
||||
int32_t render_width;
|
||||
int32_t render_height;
|
||||
vec3 view_point;
|
||||
|
||||
+37
-17
@@ -6,7 +6,7 @@
|
||||
#include "dof.h"
|
||||
#include "../../KKdLib/str_utils.h"
|
||||
#include "../gl_state.h"
|
||||
#include "../camera.h"
|
||||
#include "../rob.h"
|
||||
|
||||
typedef struct post_process_dof_shader_data {
|
||||
vec4 g_depth_params;
|
||||
@@ -573,7 +573,7 @@ static const char* dof_frag_shader_step_5 =
|
||||
static const dof_debug dof_debug_default = {
|
||||
(dof_debug_flags)0,
|
||||
10.0f,
|
||||
40.0f,
|
||||
0.04f,
|
||||
1.4f,
|
||||
{
|
||||
10.0f,
|
||||
@@ -617,6 +617,8 @@ static void post_process_dof_update_data(post_process_dof* dof, float_t min_dist
|
||||
float_t max_dist, float_t fov, float_t dist, float_t focal_length,
|
||||
float_t f_number, float_t focus_range, float_t fuzzing_range, float_t ratio);
|
||||
|
||||
static void sub_1405163C0(rob_chara* rob_chr, int32_t a2, mat4* mat);
|
||||
|
||||
post_process_dof* post_process_dof_init() {
|
||||
post_process_dof* dof = force_malloc_s(post_process_dof, 1);
|
||||
post_process_dof_load_shaders(dof);
|
||||
@@ -633,25 +635,38 @@ void post_process_apply_dof(post_process_dof* dof,
|
||||
if (dof->data.debug.flags & DOF_DEBUG_ENABLE_DOF) {
|
||||
if (dof->data.debug.flags & DOF_DEBUG_ENABLE_PHYS_DOF) {
|
||||
float_t dist_to_focus = dof->data.debug.distance_to_focus;
|
||||
if (dof->data.debug.flags & DOF_DEBUG_AUTO_FOCUS && false) {
|
||||
mat4 view_transpose;
|
||||
mat4_transpose(&cam->view, &view_transpose);
|
||||
vec3 chara_trans = vec3_null;
|
||||
vec3_dot(cam->view_point, chara_trans, dist_to_focus);
|
||||
dist_to_focus = -dist_to_focus - 0.1f;
|
||||
if (dof->data.debug.flags & DOF_DEBUG_AUTO_FOCUS) {
|
||||
rob_chara* rob_chr = 0;
|
||||
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++) {
|
||||
rob_chara* rob_chr = rob_chara_array_get(i);
|
||||
if (!(rob_chr->data.field_0 & 1))
|
||||
continue;
|
||||
|
||||
mat4 mat;
|
||||
sub_1405163C0(rob_chr, 4, &mat);
|
||||
|
||||
vec3 chara_trans = vec3_null;
|
||||
mat4_get_translation(&mat, &chara_trans);
|
||||
|
||||
mat4 view_transpose;
|
||||
mat4_transpose(&cam->view, &view_transpose);
|
||||
vec3_dot(*(vec3*)&view_transpose.row2, chara_trans, dist_to_focus);
|
||||
dist_to_focus = -dist_to_focus - view_transpose.row2.w - 0.1f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dist_to_focus = max(dist_to_focus, (float_t)cam->min_distance);
|
||||
post_process_apply_dof_physical(dof, rt, samplers,
|
||||
rt->color_texture->texture, rt->depth_texture->texture,
|
||||
(float_t)cam->min_distance, (float_t)cam->max_distance, (float_t)cam->fov, dist_to_focus,
|
||||
dof->data.debug.focal_length, dof->data.debug.f_number);
|
||||
(float_t)cam->min_distance, (float_t)cam->max_distance, dist_to_focus,
|
||||
dof->data.debug.focal_length, (float_t)cam->fov_rad, dof->data.debug.f_number);
|
||||
}
|
||||
else {
|
||||
float_t fuzzing_range = max(dof->data.debug.f2.fuzzing_range, 0.01f);
|
||||
post_process_apply_dof_f2(dof, rt, samplers,
|
||||
rt->color_texture->texture, rt->depth_texture->texture,
|
||||
(float_t)cam->min_distance, (float_t)cam->max_distance, (float_t)cam->fov,
|
||||
(float_t)cam->min_distance, (float_t)cam->max_distance, (float_t)cam->fov_rad,
|
||||
dof->data.debug.f2.distance_to_focus, dof->data.debug.f2.focus_range,
|
||||
fuzzing_range, dof->data.debug.f2.ratio);
|
||||
use_dof_f2 = true;
|
||||
@@ -662,7 +677,7 @@ void post_process_apply_dof(post_process_dof* dof,
|
||||
float_t fuzzing_range = max(dof->data.pv.f2.fuzzing_range, 0.01f);
|
||||
post_process_apply_dof_f2(dof, rt, samplers,
|
||||
rt->color_texture->texture, rt->depth_texture->texture,
|
||||
(float_t)cam->min_distance, (float_t)cam->max_distance, (float_t)cam->fov,
|
||||
(float_t)cam->min_distance, (float_t)cam->max_distance, (float_t)cam->fov_rad,
|
||||
dof->data.pv.f2.distance_to_focus, dof->data.pv.f2.focus_range,
|
||||
fuzzing_range, dof->data.pv.f2.ratio);
|
||||
enum_or(dof->data.debug.flags, DOF_DEBUG_ENABLE_DOF);
|
||||
@@ -1022,14 +1037,14 @@ static void post_process_dof_update_data(post_process_dof* dof, float_t min_dist
|
||||
float_t fl = focal_length;
|
||||
if (dist <= focal_length)
|
||||
fl = dist + 0.1f;
|
||||
fl *= fl * (1.0f / ((dist - fl) * f_number));
|
||||
fl = fl / (dist - fl) * fl / f_number;
|
||||
|
||||
post_process_dof_shader_data data;
|
||||
data.g_depth_params.x = (min_dist - max_dist) / (min_dist * max_dist);
|
||||
data.g_depth_params.x = 1.0f / (min_dist * max_dist) * (min_dist - max_dist);
|
||||
data.g_depth_params.y = 1.0f / min_dist;
|
||||
data.g_depth_params.z = -dist * data.g_depth_params.x * fl;
|
||||
data.g_depth_params.w = (1.0f - dist * data.g_depth_params.y) * fl;
|
||||
data.g_spread_scale.x = 720.0f / (tanf(fov * 0.5f) * 2.0f * min_dist);
|
||||
data.g_depth_params.z = -((fl * dist * (min_dist - max_dist)) * (1.0f / (min_dist * max_dist)));
|
||||
data.g_depth_params.w = (1.0f - 1.0f / min_dist * dist) * fl;
|
||||
data.g_spread_scale.x = 720.0f / (tanf(fov * 0.5f) * (min_dist * 2.0f));
|
||||
data.g_spread_scale.y = data.g_spread_scale.x * (float_t)(1.0 / 3.0);
|
||||
data.g_spread_scale.z = (float_t)(1.0 / 3.0);
|
||||
data.g_spread_scale.w = 3.0f;
|
||||
@@ -1042,6 +1057,11 @@ static void post_process_dof_update_data(post_process_dof* dof, float_t min_dist
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(post_process_dof_shader_data), &data);
|
||||
}
|
||||
|
||||
static void sub_1405163C0(rob_chara* rob_chr, int32_t a2, mat4* mat) {
|
||||
if (a2 >= 0 && a2 <= 26)
|
||||
*mat = rob_chr->data.field_1E68.field_78[a2];
|
||||
}
|
||||
|
||||
void post_process_dof_initialize_data(post_process_dof* dof, dof_debug* debug, dof_pv* pv) {
|
||||
post_process_dof_set_dof_debug(dof, debug);
|
||||
post_process_dof_set_dof_pv(dof, pv);
|
||||
|
||||
+146
-14
@@ -7,31 +7,161 @@
|
||||
#include "../fbo.h"
|
||||
#include "../gl_state.h"
|
||||
#include "../post_process.h"
|
||||
#include "../rob.h"
|
||||
#include "../shader_ft.h"
|
||||
|
||||
typedef struct struc_188 {
|
||||
vec4u field_0[8];
|
||||
float_t field_80;
|
||||
GLuint field_84[3];
|
||||
GLuint field_90[3];
|
||||
} struc_188;
|
||||
|
||||
static void post_process_exposure_free_fbo(post_process_exposure* exp);
|
||||
static void sub_1405163C0(rob_chara* rob_chr, int32_t a2, mat4* mat);
|
||||
|
||||
post_process_exposure* post_process_exposure_init() {
|
||||
post_process_exposure* exp = force_malloc_s(post_process_exposure, 1);
|
||||
return exp;
|
||||
}
|
||||
|
||||
void post_process_get_exposure(post_process_exposure* exp,
|
||||
bool reset_exposure, GLuint in_tex_0, GLuint in_tex_1) {
|
||||
void post_process_get_exposure(post_process_exposure* exp, camera* cam, int32_t render_width,
|
||||
int32_t render_height, bool reset_exposure, GLuint in_tex_0, GLuint in_tex_1) {
|
||||
if (!exp)
|
||||
return;
|
||||
|
||||
uniform_value[U_EXPOSURE] = 1;
|
||||
render_texture_shader_set(&shaders_ft, SHADER_FT_EXPOSURE);
|
||||
struc_188 field_648[ROB_CHARA_COUNT];
|
||||
|
||||
for (struc_188& i : field_648)
|
||||
i = {};
|
||||
|
||||
bool v2 = false;
|
||||
float_t v18 = (float_t)render_height / (float_t)render_width;
|
||||
float_t v20 = powf(tanf((float_t)(cam->fov_rad * 0.5f)) * 3.4f, 2.0f);
|
||||
if (reset_exposure)
|
||||
glViewport(0, 0, 32, 1);
|
||||
else
|
||||
glViewport(exp->exposure_history_counter, 0, 1, 1);
|
||||
render_texture_bind(&exp->exposure_history, 0);
|
||||
gl_state_active_bind_texture_2d(0, in_tex_0);
|
||||
gl_state_active_bind_texture_2d(1, in_tex_1);
|
||||
render_texture_draw_params(&shaders_ft, 1, 1, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
goto LABEL_30;
|
||||
|
||||
for (struc_188& i : field_648) {
|
||||
rob_chara* rob_chr = rob_chara_array_get((int32_t)(&i - field_648));
|
||||
if (!rob_chr || !(rob_chr->data.field_0 & 1))
|
||||
continue;
|
||||
|
||||
vec4 v34 = { 0.05f, 0.0f, -0.04f, 1.0f };
|
||||
vec4 v33 = { 1.0f, 0.0f, 0.0f, 0.0f };
|
||||
|
||||
mat4 v44;
|
||||
sub_1405163C0(rob_chr, 4, &v44);
|
||||
|
||||
mat4 v42 = cam->view;
|
||||
mat4 v43 = cam->projection;
|
||||
mat4_mult(&v44, &v42, &v42);
|
||||
mat4_mult(&v42, &v43, &v43);
|
||||
|
||||
vec4 v41;
|
||||
mat4_mult_vec(&v42, &v34, &v41);
|
||||
|
||||
vec4 v40;
|
||||
mat4_mult_vec(&v43, &v34, &v40);
|
||||
|
||||
float_t v11 = v41.z;
|
||||
float_t v12 = 1.0f / v40.w;
|
||||
float_t v13 = v40.x * v12;
|
||||
float_t v14 = v40.y * v12;
|
||||
if (v41.z >= 0.0f || fabsf(v13) >= 1.0f || fabsf(v14) >= 1.0f)
|
||||
continue;
|
||||
|
||||
float_t v31 = 0.5f - (fabsf(v14) - 1.0f) * 2.5f;
|
||||
float_t v32 = 0.5f - (fabsf(v13) - 1.0f) * 2.5f;
|
||||
float_t v16;
|
||||
if (v32 <= v31)
|
||||
v16 = v32;
|
||||
else
|
||||
v16 = v31;
|
||||
v16 = min(v16, 1.0f);
|
||||
|
||||
vec4 v39;
|
||||
mat4_mult_vec(&v42, &v33, &v39);
|
||||
|
||||
float_t v17 = (v39.z + 1.0f) * 0.5f;
|
||||
v17 = clamp(v17, 0.0f, 0.8f);
|
||||
float_t v21 = 0.25f / sqrtf(v20 * (v11 * v11));
|
||||
|
||||
float_t v22;
|
||||
if (v21 >= 0.055f) {
|
||||
v22 = 1.0f;
|
||||
if (v21 > 0.5f)
|
||||
v22 = 1.0f - (v21 - 0.5f) * (float_t)(10.0 / 3.0f);
|
||||
}
|
||||
else
|
||||
v22 = (v21 - 0.035f) * 50.0f;
|
||||
v22 = max(v22, 0.0f);
|
||||
|
||||
float_t v23 = (v13 + 1.0f) * 0.5f;
|
||||
float_t v24 = (v21 * -0.5f + v14 + 1.0f) * 0.5f;
|
||||
float_t v25 = (v14 - v21 * 0.1f + 1.0f) * 0.5f;
|
||||
|
||||
i.field_80 = v16 * 1.6f * v17 * v22;
|
||||
i.field_0[0].x = v23;
|
||||
i.field_0[0].y = (v21 * 0.1f + v14 + 1.0f) * 0.5f;
|
||||
i.field_0[0].z = 0.0f;
|
||||
i.field_0[0].w = 4.0f;
|
||||
i.field_0[1].x = v23;
|
||||
i.field_0[1].y = (v14 - v21 * 0.3f + 1.0f) * 0.5f;
|
||||
i.field_0[1].z = 0.0f;
|
||||
i.field_0[1].w = 4.0f;
|
||||
i.field_0[2].x = (v21 * -0.5f * v18 + v13 + 1.0f) * 0.5f;
|
||||
i.field_0[2].y = v24;
|
||||
i.field_0[2].z = 0.0f;
|
||||
i.field_0[2].w = 3.0f;
|
||||
i.field_0[3].x = (v13 - v21 * 0.6f * v18 + 1.0f) * 0.5f;
|
||||
i.field_0[3].y = v25;
|
||||
i.field_0[3].z = 0.0f;
|
||||
i.field_0[3].w = 2.0f;
|
||||
i.field_0[4].x = (v21 * 0.6f * v18 + v13 + 1.0f) * 0.5f;
|
||||
i.field_0[4].y = v25;
|
||||
i.field_0[4].z = 0.0f;
|
||||
i.field_0[4].w = 2.0f;
|
||||
i.field_0[5].x = (v21 * 0.5f * v18 + v13 + 1.0f) * 0.5f;
|
||||
i.field_0[5].y = v24;
|
||||
i.field_0[5].z = 0.0f;
|
||||
i.field_0[5].w = 3.0f;
|
||||
i.field_0[6].x = v23;
|
||||
i.field_0[6].y = (v14 - v21 * 0.8f + 1.0f) * 0.5f;
|
||||
i.field_0[6].z = 0.0f;
|
||||
i.field_0[6].w = 3.0f;
|
||||
if (i.field_80 > 0.0f && false/*!i.field_90[pp->field_9F4]*/)
|
||||
v2 = true;
|
||||
}
|
||||
|
||||
if (!v2 || reset_exposure) {
|
||||
LABEL_30:
|
||||
uniform_value[U_EXPOSURE] = 1;
|
||||
render_texture_shader_set(&shaders_ft, SHADER_FT_EXPOSURE);
|
||||
shader_local_frag_set(&shaders_ft, 1,
|
||||
field_648[0].field_80,
|
||||
field_648[1].field_80,
|
||||
field_648[2].field_80,
|
||||
field_648[3].field_80);
|
||||
|
||||
int32_t index = 0;
|
||||
for (struc_188& i : field_648) {
|
||||
shader_local_frag_set_ptr_array(&shaders_ft, 4ULL + index * 8ULL, 8, (vec4*)field_648->field_0);
|
||||
if (++index >= 4)
|
||||
break;
|
||||
}
|
||||
|
||||
if (reset_exposure)
|
||||
glViewport(0, 0, 32, 1);
|
||||
else
|
||||
glViewport(exp->exposure_history_counter, 0, 1, 1);
|
||||
render_texture_bind(&exp->exposure_history, 0);
|
||||
gl_state_active_bind_texture_2d(0, in_tex_0);
|
||||
gl_state_active_bind_texture_2d(1, in_tex_1);
|
||||
render_texture_draw_params(&shaders_ft,
|
||||
reset_exposure ? 32 : 1, 1, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
exp->exposure_history_counter++;
|
||||
exp->exposure_history_counter %= 32;
|
||||
}
|
||||
|
||||
uniform_value[U_EXPOSURE] = 2;
|
||||
render_texture_shader_set(&shaders_ft, SHADER_FT_EXPOSURE);
|
||||
@@ -40,9 +170,6 @@ void post_process_get_exposure(post_process_exposure* exp,
|
||||
render_texture_bind(&exp->exposure, 0);
|
||||
gl_state_active_bind_texture_2d(0, exp->exposure_history.color_texture->texture);
|
||||
render_texture_draw_params(&shaders_ft, 1, 1, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
exp->exposure_history_counter++;
|
||||
exp->exposure_history_counter %= 32;
|
||||
}
|
||||
|
||||
void post_process_exposure_init_fbo(post_process_exposure* exp) {
|
||||
@@ -69,3 +196,8 @@ static void post_process_exposure_free_fbo(post_process_exposure* exp) {
|
||||
render_texture_free(&exp->exposure_history);
|
||||
render_texture_free(&exp->exposure);
|
||||
}
|
||||
|
||||
static void sub_1405163C0(rob_chara* rob_chr, int32_t a2, mat4* mat) {
|
||||
if (a2 >= 0 && a2 <= 26)
|
||||
*mat = rob_chr->data.field_1E68.field_78[a2];
|
||||
}
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
|
||||
#include "../../KKdLib/default.h"
|
||||
#include "../../KKdLib/vec.h"
|
||||
#include "../shared.h"
|
||||
#include "../camera.h"
|
||||
#include "../render_texture.h"
|
||||
#include "../shared.h"
|
||||
|
||||
typedef struct post_process_exposure {
|
||||
render_texture exposure_history;
|
||||
@@ -17,7 +18,7 @@ typedef struct post_process_exposure {
|
||||
} post_process_exposure;
|
||||
|
||||
extern post_process_exposure* post_process_exposure_init();
|
||||
extern void post_process_get_exposure(post_process_exposure* exp,
|
||||
bool reset_exposure, GLuint in_tex_0, GLuint in_tex_1);
|
||||
extern void post_process_get_exposure(post_process_exposure* exp, camera* cam, int32_t render_width,
|
||||
int32_t render_height, bool reset_exposure, GLuint in_tex_0, GLuint in_tex_1);
|
||||
extern void post_process_exposure_init_fbo(post_process_exposure* exp);
|
||||
extern void post_process_exposure_dispose(post_process_exposure* exp);
|
||||
|
||||
+20
-23
@@ -280,6 +280,11 @@ inline void object_data_set_morph(object_data* object_data, object_info object,
|
||||
object_data->morph.object = object;
|
||||
}
|
||||
|
||||
inline void object_data_set_object_bounding_sphere_check_func(object_data* object_data,
|
||||
bool(*func)(object_bounding_sphere*, camera*)) {
|
||||
object_data->object_bounding_sphere_check_func = func;
|
||||
}
|
||||
|
||||
inline void object_data_set_shadow_type(object_data* object_data, shadow_type_enum type) {
|
||||
if (type == SHADOW_CHARA || type == SHADOW_STAGE)
|
||||
object_data->shadow_type = type;
|
||||
@@ -348,7 +353,6 @@ inline render_context* render_context_init() {
|
||||
fog_init(&rctx->fog_data[i]);
|
||||
for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++)
|
||||
light_set_init(&rctx->light_set_data[i]);
|
||||
rctx->wind = wind_init();
|
||||
|
||||
post_process_init(&rctx->post_process);
|
||||
return rctx;
|
||||
@@ -356,18 +360,26 @@ inline render_context* render_context_init() {
|
||||
|
||||
extern float_t rob_frame;
|
||||
extern render_context* rctx_ptr;
|
||||
extern wind* wind_ptr;
|
||||
|
||||
inline void render_context_ctrl(render_context* rctx) {
|
||||
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++) {
|
||||
if (rob_chara_pv_data_array[i].field_0 == -1)
|
||||
if (rob_chara_pv_data_array[i].type == ROB_CHARA_TYPE_NONE)
|
||||
continue;
|
||||
|
||||
float_t frame = rob_chara_get_frame(&rob_chara_array[i]);
|
||||
float_t frame_count = rob_chara_get_frame_count(&rob_chara_array[i]);
|
||||
frame += get_delta_frame();
|
||||
if (frame >= frame_count)
|
||||
frame -= frame_count;
|
||||
//frame += get_delta_frame();
|
||||
if (frame >= frame_count) {
|
||||
frame = 0.0f;
|
||||
rob_chara_item_equip* rob_item_equip = rob_chara_array[i].item_equip;
|
||||
for (int32_t j = rob_item_equip->first_item_equip_object;
|
||||
j < rob_item_equip->max_item_equip_object; j++) {
|
||||
rob_chara_item_equip_object* itm_eq_obj = &rob_item_equip->item_equip_object[j];
|
||||
for (ExOsageBlock*& i : itm_eq_obj->osage_blocks)
|
||||
if (i)
|
||||
i->rob.osage_reset = true;
|
||||
}
|
||||
}
|
||||
//rob_chara_set_frame(&rob_chara_array[i], frame);
|
||||
rob_chara_set_frame(&rob_chara_array[i], rob_frame);
|
||||
rob_chara_array[i].item_equip->shadow_type = SHADOW_CHARA;
|
||||
@@ -385,17 +397,9 @@ inline void render_context_ctrl(render_context* rctx) {
|
||||
|
||||
rctx_ptr = rctx;
|
||||
TaskWork::Ctrl();
|
||||
wind_ctrl(rctx->wind);
|
||||
|
||||
wind_ptr = rctx->wind;
|
||||
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++)
|
||||
if (rob_chara_pv_data_array[i].field_0 != -1)
|
||||
rob_chara_calc(&rob_chara_array[i]);
|
||||
|
||||
file_handler_storage_ctrl();
|
||||
|
||||
stage_ctrl((stage*)rctx->stage, rctx);
|
||||
|
||||
shadow_ctrl(rctx->draw_pass.shadow_ptr, rctx);
|
||||
draw_state_stats_update(&rctx->draw_state);
|
||||
object_data_reset(&rctx->object_data);
|
||||
@@ -405,12 +409,6 @@ inline void render_context_disp(render_context* rctx) {
|
||||
rctx_ptr = rctx;
|
||||
TaskWork::Disp();
|
||||
|
||||
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++)
|
||||
if (rob_chara_pv_data_array[i].field_0 != -1)
|
||||
rob_chara_disp(&rob_chara_array[i], rctx);
|
||||
|
||||
stage_disp((stage*)rctx->stage, rctx);
|
||||
|
||||
post_process_update(&rctx->post_process, rctx->camera);
|
||||
draw_pass_main(rctx);
|
||||
TaskWork::Basic();
|
||||
@@ -612,7 +610,7 @@ void render_context_light_param_data_ibl_set(render_context* rctx,
|
||||
}
|
||||
|
||||
void render_context_light_param_data_wind_set(render_context* rctx, light_param_wind* w) {
|
||||
wind* wind = rctx->wind;
|
||||
wind* wind = task_wind.ptr;
|
||||
if (w->has_scale)
|
||||
wind->scale = w->scale;
|
||||
|
||||
@@ -677,7 +675,6 @@ inline void render_context_free(render_context* rctx) {
|
||||
object_data_free(&rctx->object_data);
|
||||
glDeleteVertexArrays(1, &rctx->vao);
|
||||
|
||||
wind_free(rctx->wind);
|
||||
post_process_free(&rctx->post_process);
|
||||
free(rctx);
|
||||
}
|
||||
@@ -754,7 +751,7 @@ static void object_data_init(object_data* data) {
|
||||
data->object_sort = true;
|
||||
data->chara_color = true;
|
||||
data->morph.value = 0.0f;
|
||||
data->morph.object = object_info_null;
|
||||
data->morph.object = object_info();
|
||||
data->object_bounding_sphere_check_func = 0;
|
||||
|
||||
data->buffer.offset = 0;
|
||||
|
||||
@@ -419,7 +419,7 @@ typedef struct object_data {
|
||||
float_t wet_param;
|
||||
int32_t texture_transform_count;
|
||||
texture_transform_struct texture_transform_array[TEXTURE_TRANSFORM_COUNT];
|
||||
bool(*object_bounding_sphere_check_func)(object_bounding_sphere*);
|
||||
bool(*object_bounding_sphere_check_func)(object_bounding_sphere*, camera*);
|
||||
} object_data;
|
||||
|
||||
struct render_context {
|
||||
@@ -433,9 +433,7 @@ struct render_context {
|
||||
fog fog_data[FOG_MAX];
|
||||
light_proj* litproj;
|
||||
light_set light_set_data[LIGHT_SET_MAX];
|
||||
wind* wind;
|
||||
|
||||
void* stage;
|
||||
data_struct* data;
|
||||
post_process_struct post_process;
|
||||
bool chara_reflect;
|
||||
@@ -515,6 +513,8 @@ extern float_t object_data_get_wet_param(object_data* object_data);
|
||||
extern void object_data_set_chara_color(object_data* object_data, bool value);
|
||||
extern void object_data_set_draw_task_flags(object_data* object_data, draw_task_flags flags);
|
||||
extern void object_data_set_morph(object_data* object_data, object_info object, float_t value);
|
||||
extern void object_data_set_object_bounding_sphere_check_func(object_data* object_data,
|
||||
bool(*func)(object_bounding_sphere*, camera*));
|
||||
extern void object_data_set_shadow_type(object_data* object_data, shadow_type_enum type);
|
||||
extern void object_data_set_texture_color_coeff(object_data* object_data, vec4* value);
|
||||
extern void object_data_set_texture_color_offset(object_data* object_data, vec4* value);
|
||||
|
||||
@@ -35,12 +35,14 @@ int32_t render_texture_init(render_texture* rt, int32_t width, int32_t height,
|
||||
|
||||
render_texture_counter++;
|
||||
color_texture = rt->color_texture->texture;
|
||||
gl_state_bind_texture_2d(rt->color_texture->texture);
|
||||
if (color_format == GL_RGBA32F) {
|
||||
gl_state_bind_texture_2d(rt->color_texture->texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
gl_state_bind_texture_2d(0);
|
||||
}
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
gl_state_bind_texture_2d(0);
|
||||
}
|
||||
else {
|
||||
rt->color_texture = 0;
|
||||
|
||||
+8063
-2268
File diff suppressed because it is too large
Load Diff
+1352
-677
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -126,7 +126,7 @@ void shader_load(shader_set_data* set, farc* f, bool ignore_cache, bool not_load
|
||||
wcscat_s(temp_buf, sizeof(temp_buf) / sizeof(wchar_t), buf);
|
||||
|
||||
swprintf_s(buf, sizeof(buf) / sizeof(wchar_t), L"%ls.farc", temp_buf);
|
||||
if (path_wcheck_file_exists(buf) && !not_load_cache)
|
||||
if (path_check_file_exists(buf) && !not_load_cache)
|
||||
shader_cache_farc.read(buf, true, false);
|
||||
}
|
||||
|
||||
@@ -2240,7 +2240,7 @@ static GLuint shader_compile_shader(GLenum type, char* data, char* file) {
|
||||
buf[sizeof(buf) / sizeof(wchar_t) - 1] = 0;
|
||||
|
||||
stream s;
|
||||
io_wopen(&s, buf, L"wb");
|
||||
io_open(&s, buf, L"wb");
|
||||
io_write(&s, data, utf8_length(data));
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ void shader_glsl_wload_file(shader_glsl* s, wchar_t* vert_path,
|
||||
char* frag = 0;
|
||||
char* geom = 0;
|
||||
|
||||
io_wopen(&st, vert_path, L"rb");
|
||||
io_open(&st, vert_path, L"rb");
|
||||
if (st.io.stream) {
|
||||
l = st.length;
|
||||
vert = force_malloc_s(char, l + 1);
|
||||
@@ -322,7 +322,7 @@ void shader_glsl_wload_file(shader_glsl* s, wchar_t* vert_path,
|
||||
}
|
||||
io_free(&st);
|
||||
|
||||
io_wopen(&st, frag_path, L"rb");
|
||||
io_open(&st, frag_path, L"rb");
|
||||
if (st.io.stream) {
|
||||
l = st.length;
|
||||
frag = force_malloc_s(char, l + 1);
|
||||
@@ -331,7 +331,7 @@ void shader_glsl_wload_file(shader_glsl* s, wchar_t* vert_path,
|
||||
}
|
||||
io_free(&st);
|
||||
|
||||
io_wopen(&st, geom_path, L"rb");
|
||||
io_open(&st, geom_path, L"rb");
|
||||
if (st.io.stream) {
|
||||
l = st.length;
|
||||
geom = force_malloc_s(char, l + 1);
|
||||
|
||||
+706
-218
@@ -6,170 +6,727 @@
|
||||
#include "stage.h"
|
||||
#include "../KKdLib/hash.h"
|
||||
#include "../KKdLib/str_utils.h"
|
||||
#include "../KKdLib/vec.h"
|
||||
#include "draw_task.h"
|
||||
#include "light_param.h"
|
||||
#include "render_context.h"
|
||||
#include "rob.h"
|
||||
|
||||
void stage_init(stage* s) {
|
||||
memset(s, 0, sizeof(stage));
|
||||
namespace stage_detail {
|
||||
static void TaskStage_CtrlInner(stage_detail::TaskStage* a1);
|
||||
static void TaskStage_DispShadow(stage_detail::TaskStage* a1);
|
||||
static stage* TaskStage_GetCurrentStage(stage_detail::TaskStage* a1);
|
||||
static stage* TaskStage_GetStage(stage_detail::TaskStage* a1, task_stage_info stg_info);
|
||||
static void TaskStage_GetTaskStageInfo(stage_detail::TaskStage* a1,
|
||||
task_stage_info* stg_info, size_t index);
|
||||
static void TaskStage_GetCurrentStageInfo(stage_detail::TaskStage* a1,
|
||||
task_stage_info* stg_info);
|
||||
static void TaskStage_GetLoadedStageInfos(stage_detail::TaskStage* a1,
|
||||
std::vector<task_stage_info>* vec);
|
||||
static bool TaskStage_Load(stage_detail::TaskStage* a1, const char* name);
|
||||
static void TaskStage_Reset(stage_detail::TaskStage* a1);
|
||||
static void TaskStage_SetStage(stage_detail::TaskStage* a1, task_stage_info stg_info);
|
||||
static void TaskStage_TaskWindAppend(stage_detail::TaskStage* a1);
|
||||
static void TaskStage_Unload(stage_detail::TaskStage* a1);
|
||||
}
|
||||
|
||||
void stage_ctrl(stage* s, render_context* rctx) {
|
||||
if (!s || s->modern || !s->stage_data)
|
||||
return;
|
||||
static bool object_bounding_sphere_check_visibility_shadow(object_bounding_sphere* sphere, camera* cam, mat4* mat);
|
||||
static bool object_bounding_sphere_check_visibility_shadow_chara(object_bounding_sphere* sphere, camera* cam);
|
||||
static bool object_bounding_sphere_check_visibility_shadow_stage(object_bounding_sphere* sphere, camera* cam);
|
||||
|
||||
static bool stage_ctrl(stage* s);
|
||||
static void stage_disp(stage* s);
|
||||
static void stage_disp_shadow(stage* s);
|
||||
static void stage_disp_shadow_object(object_info object, mat4* mat);
|
||||
static void stage_free(stage* s);
|
||||
static void stage_load(stage* s);
|
||||
static void stage_reset(stage* s);
|
||||
static void stage_set(stage* s, stage* other);
|
||||
static void stage_set_by_stage_index(stage* s, int32_t stage_index, uint16_t stage_counter);
|
||||
|
||||
const task_stage_info task_stage_info_null = { -1, 0 };
|
||||
|
||||
stage_detail::TaskStage task_stage;
|
||||
|
||||
extern render_context* rctx_ptr;
|
||||
|
||||
extern bool light_chara_ambient;
|
||||
extern vec4 npr_spec_color;
|
||||
|
||||
static uint16_t stage_counter;
|
||||
|
||||
stage::stage() : index(), counter(), state(), stage_data(), stage_display(),
|
||||
lens_flare(), ground(), ring(), sky(), auth_3d_loaded(), mat(), rot_y(), obj_set(), effects() {
|
||||
|
||||
}
|
||||
|
||||
void stage_ctrl_modern(stage* s, render_context* rctx) {
|
||||
if (!s || !s->modern || !s->stage_modern)
|
||||
return;
|
||||
stage::~stage() {
|
||||
|
||||
}
|
||||
|
||||
void stage_disp(stage* s, render_context* rctx) {
|
||||
if (!s || s->modern || !s->stage_data || !s->display)
|
||||
return;
|
||||
stage_detail::TaskStage::TaskStage() : state(), current_stage(), stage_display(),
|
||||
field_FB1(), field_FB2(), field_FB3(), field_FB4(), mat(), field_FF8() {
|
||||
|
||||
stage_data* data = s->stage_data;
|
||||
|
||||
if (s->ground)
|
||||
draw_task_add_draw_object_by_object_info_opaque(rctx,
|
||||
(mat4*)&mat4_identity, data->object_ground);
|
||||
|
||||
if (s->sky)
|
||||
draw_task_add_draw_object_by_object_info_opaque(rctx,
|
||||
(mat4*)&mat4_identity, data->object_sky);
|
||||
}
|
||||
|
||||
void stage_disp_modern(stage* s, render_context* rctx) {
|
||||
if (!s || !s->modern || !s->stage_modern || !s->display)
|
||||
return;
|
||||
stage_detail::TaskStage:: ~TaskStage() {
|
||||
|
||||
stage_data_modern* data = s->stage_modern;
|
||||
|
||||
if (s->ground)
|
||||
draw_task_add_draw_object_by_object_info_opaque(rctx,
|
||||
(mat4*)&mat4_identity, data->object_ground);
|
||||
|
||||
if (s->sky)
|
||||
draw_task_add_draw_object_by_object_info_opaque(rctx,
|
||||
(mat4*)&mat4_identity, data->object_sky);
|
||||
}
|
||||
|
||||
void stage_load(stage* s, data_struct* data, auth_3d_database* auth_3d_db, object_database* obj_db,
|
||||
texture_database* tex_db, stage_database* stage_data, char* name, render_context* rctx) {
|
||||
if (!s || !stage_data || !name)
|
||||
return;
|
||||
bool stage_detail::TaskStage::Init() {
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t name_len = utf8_length(name);
|
||||
bool stage_detail::TaskStage::Ctrl() {
|
||||
stage_detail::TaskStage_CtrlInner(this);
|
||||
|
||||
s->modern = stage_data->modern;
|
||||
s->display = true;
|
||||
s->ring = true;
|
||||
s->ground = true;
|
||||
s->sky = true;
|
||||
s->effects = true;
|
||||
|
||||
string auth_3d_category = string_empty;
|
||||
uint32_t auth_3d_count = 0;
|
||||
uint32_t* auth_3d_ids = 0;
|
||||
uint32_t render_texture = -1;
|
||||
uint32_t movie_texture = -1;
|
||||
s->light_param_name = 0;
|
||||
if (!s->modern) {
|
||||
s->stage_data = 0;
|
||||
vector_old_stage_data* stage = &stage_data->stage_data;
|
||||
for (::stage_data* i = stage->begin; i != stage->end; i++)
|
||||
if (!str_utils_compare_length(name, name_len + 1,
|
||||
string_data(&i->name), i->name.length + 1)) {
|
||||
string_copy(&i->auth_3d_name, &auth_3d_category);
|
||||
s->stage_data = i;
|
||||
auth_3d_count = i->auth_3d_count;
|
||||
auth_3d_ids = i->auth_3d_ids;
|
||||
render_texture = i->render_texture;
|
||||
movie_texture = i->movie_texture;
|
||||
s->light_param_name = light_param_get_stage_name_string(string_data(&i->name));
|
||||
break;
|
||||
}
|
||||
|
||||
if (!s->stage_data)
|
||||
return;
|
||||
}
|
||||
else {
|
||||
s->stage_modern = 0;
|
||||
vector_old_stage_data_modern* stage = &stage_data->stage_modern;
|
||||
for (stage_data_modern* i = stage->begin; i != stage->end; i++)
|
||||
if (!str_utils_compare_length(name, name_len + 1,
|
||||
string_data(&i->name), i->name.length + 1)) {
|
||||
string_copy(&i->auth_3d_name, &auth_3d_category);
|
||||
s->stage_modern = i;
|
||||
auth_3d_count = i->auth_3d_count;
|
||||
auth_3d_ids = i->auth_3d_ids;
|
||||
render_texture = i->render_texture;
|
||||
movie_texture = i->movie_texture;
|
||||
s->light_param_name = light_param_get_stage_name_string(string_data(&i->name));
|
||||
break;
|
||||
}
|
||||
|
||||
if (!s->stage_modern)
|
||||
return;
|
||||
}
|
||||
|
||||
light_param_storage_load_light_param_data(data, s->light_param_name);
|
||||
|
||||
auth_3d_database_uid* uids = auth_3d_db->uid.data();
|
||||
if (auth_3d_category.length) {
|
||||
for (auth_3d_database_category& i : auth_3d_db->category) {
|
||||
if (str_utils_compare_length(i.name.c_str(), i.name.size(),
|
||||
string_data(&auth_3d_category), auth_3d_category.length))
|
||||
continue;
|
||||
else if (i.name.size() > (size_t)auth_3d_category.length
|
||||
&& i.name.c_str()[auth_3d_category.length] != 'S')
|
||||
continue;
|
||||
|
||||
std::string auth_3d_farc = i.name;;
|
||||
auth_3d_farc += ".farc";
|
||||
|
||||
farc f;
|
||||
data_struct_load_file(data, &f, "rom/auth_3d/", auth_3d_farc.c_str(), farc::load_file);
|
||||
|
||||
if (f.files.size() < 1)
|
||||
continue;
|
||||
|
||||
for (int32_t& j : i.uid)
|
||||
for (uint32_t k = 0; k < auth_3d_count; k++) {
|
||||
if (uids[j].enabled && uids[j].org_uid != auth_3d_ids[k])
|
||||
continue;
|
||||
|
||||
std::string auth_3d_file = uids[j].category;
|
||||
auth_3d_file += ".a3da";
|
||||
|
||||
farc_file* ff = f.read_file(auth_3d_file.c_str());
|
||||
|
||||
if (!ff || !ff->data || !ff->size)
|
||||
continue;
|
||||
|
||||
const char* l_str = ff->name.c_str();
|
||||
const char* t = strrchr(l_str, '.');
|
||||
size_t l_len = ff->name.size();
|
||||
if (t)
|
||||
l_len = t - l_str;
|
||||
|
||||
uint32_t h = hash_murmurhash((uint8_t*)l_str, l_len, 0, false, false);
|
||||
|
||||
a3da a3da_file;
|
||||
a3da_file.read(ff->data, ff->size);
|
||||
if (!a3da_file.ready)
|
||||
continue;
|
||||
a3da_file.hash = h;
|
||||
|
||||
int32_t id = auth_3d_data_load_uid(uids[j].org_uid, auth_3d_db);
|
||||
auth_3d* auth = auth_3d_data_get_auth_3d(id);
|
||||
if (auth) {
|
||||
auth->load(&a3da_file, obj_db, tex_db);
|
||||
vector_old_int32_t_push_back(&s->auth_3d_ids, &id);
|
||||
}
|
||||
}
|
||||
for (int32_t i = 0; i < TASK_STAGE_STAGE_COUNT; i++)
|
||||
if (stages[i].index != -1 && stage_ctrl(&stages[i]))
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool stage_detail::TaskStage::Dest() {
|
||||
stage_detail::TaskStage_Unload(this);
|
||||
if (state)
|
||||
return false;
|
||||
stage_detail::TaskStage_Reset(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
void stage_detail::TaskStage::Disp() {
|
||||
if (state != 6 || !stage_display)
|
||||
return;
|
||||
|
||||
stage* s = stage_detail::TaskStage_GetCurrentStage(this);
|
||||
if (s)
|
||||
stage_disp(s);
|
||||
}
|
||||
|
||||
static void stage_detail::TaskStage_CtrlInner(stage_detail::TaskStage* a1) {
|
||||
if (a1->load_stage_indices.size())
|
||||
if (!a1->state)
|
||||
{
|
||||
a1->state = 3;
|
||||
int32_t stage_count = (int32_t)a1->load_stage_indices.size();
|
||||
stage_count = min(stage_count, TASK_STAGE_STAGE_COUNT);
|
||||
for (int32_t i = 0; i < stage_count; i++)
|
||||
if (a1->stages[i].index == -1)
|
||||
stage_set_by_stage_index(&a1->stages[i], a1->load_stage_indices[i], stage_counter++);
|
||||
a1->stage_indices = a1->load_stage_indices;
|
||||
a1->load_stage_indices.clear();
|
||||
}
|
||||
else if (a1->state == 6) {
|
||||
stage_detail::TaskStage_Unload(a1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (a1->state == 3) {
|
||||
//sub_140229F30("rom/STGTST_COLI.000.bin");
|
||||
light_param_storage_data_load_stages(&a1->stage_indices);
|
||||
a1->state = 4;
|
||||
}
|
||||
else if (a1->state == 4 && !light_param_storage_data_load_file()/* && !sub_14022A380()*/) {
|
||||
bool v5 = 0;
|
||||
for (int32_t i = 0; i < TASK_STAGE_STAGE_COUNT; i++)
|
||||
if (a1->stages[i].index != -1 && a1->stages[i].state != 6) {
|
||||
v5 = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!v5) {
|
||||
//sub_140343B20(&a1->stage_indices);
|
||||
//task_stage_current_set_effect_display(a1->stage_display);
|
||||
a1->state = 5;
|
||||
//sub_14064DC10();
|
||||
}
|
||||
}
|
||||
string_free(&auth_3d_category);
|
||||
else if (a1->state == 5/* && !sub_1403446E0()*/) {
|
||||
std::vector<task_stage_info> vec;
|
||||
stage_detail::TaskStage_GetLoadedStageInfos(a1, &vec);
|
||||
if (vec.size())
|
||||
stage_detail::TaskStage_SetStage(a1, vec[0]);
|
||||
a1->state = 6;
|
||||
}
|
||||
else if (a1->state >= 7 && a1->state <= 9)
|
||||
stage_detail::TaskStage_Unload(a1);
|
||||
}
|
||||
|
||||
static void stage_detail::TaskStage_DispShadow(stage_detail::TaskStage* a1) {
|
||||
stage* s = stage_detail::TaskStage_GetCurrentStage(a1);
|
||||
if (s)
|
||||
stage_disp_shadow(s);
|
||||
}
|
||||
|
||||
static stage* stage_detail::TaskStage_GetCurrentStage(stage_detail::TaskStage* a1) {
|
||||
if (a1->current_stage >= 0 && a1->current_stage <= TASK_STAGE_STAGE_COUNT)
|
||||
return &a1->stages[a1->current_stage];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static stage* stage_detail::TaskStage_GetStage(stage_detail::TaskStage* a1, task_stage_info stg_info) {
|
||||
if (stg_info.load_index >= 0 && stg_info.load_index <= TASK_STAGE_STAGE_COUNT) {
|
||||
stage* s = &a1->stages[stg_info.load_index];
|
||||
if (s->index != -1 && s->counter == stg_info.load_counter)
|
||||
return s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void stage_detail::TaskStage_GetTaskStageInfo(stage_detail::TaskStage* a1,
|
||||
task_stage_info* stg_info, size_t index) {
|
||||
*stg_info = task_stage_info_null;
|
||||
if (index >= 0 && index < TASK_STAGE_STAGE_COUNT) {
|
||||
stg_info->load_index = (int16_t)index;
|
||||
stg_info->load_counter = a1->stages[index].counter;
|
||||
}
|
||||
}
|
||||
|
||||
bool task_stage_check_not_loaded() {
|
||||
return task_stage.load_stage_indices.size() || task_stage.state != 6;
|
||||
}
|
||||
|
||||
void task_stage_disp_shadow() {
|
||||
stage_detail::TaskStage_DispShadow(&task_stage);
|
||||
}
|
||||
|
||||
stage* task_stage_get_current_stage() {
|
||||
return stage_detail::TaskStage_GetCurrentStage(&task_stage);
|
||||
}
|
||||
|
||||
void task_stage_get_current_stage_info(task_stage_info* stg_info) {
|
||||
stage_detail::TaskStage_GetCurrentStageInfo(&task_stage, stg_info);
|
||||
}
|
||||
|
||||
void task_stage_get_loaded_stage_infos(std::vector<task_stage_info>* vec) {
|
||||
stage_detail::TaskStage_GetLoadedStageInfos(&task_stage, vec);
|
||||
}
|
||||
|
||||
bool task_stage_load(char* name) {
|
||||
return stage_detail::TaskStage_Load(&task_stage, (const char*)name);
|
||||
}
|
||||
|
||||
bool task_stage_load(const char* name) {
|
||||
return stage_detail::TaskStage_Load(&task_stage, name);
|
||||
}
|
||||
|
||||
void task_stage_set_mat(mat4* mat) {
|
||||
task_stage.mat = *mat;
|
||||
}
|
||||
|
||||
void task_stage_set_mat(mat4u* mat) {
|
||||
task_stage.mat = *mat;
|
||||
}
|
||||
|
||||
void task_stage_set_stage(task_stage_info* stg_info) {
|
||||
stage_detail::TaskStage_SetStage(&task_stage, *stg_info);
|
||||
}
|
||||
|
||||
void task_stage_set_stage_index(int32_t stage_index) {
|
||||
data_struct* data = rctx_ptr->data;
|
||||
stage_database* stage_data = &data->data_ft.stage_data;
|
||||
|
||||
if (stage_index >= vector_old_length(stage_data->stage_data))
|
||||
return;
|
||||
|
||||
std::vector<int32_t> stage_indices;
|
||||
stage_indices.push_back(stage_index);
|
||||
task_stage.load_stage_indices = stage_indices;
|
||||
}
|
||||
|
||||
void task_stage_set_stage_indices(std::vector<int32_t>* stage_indices) {
|
||||
task_stage.load_stage_indices = *stage_indices;
|
||||
}
|
||||
|
||||
bool task_stage_unload() {
|
||||
return task_stage.SetDest();
|
||||
}
|
||||
|
||||
static void stage_detail::TaskStage_GetCurrentStageInfo(stage_detail::TaskStage* a1,
|
||||
task_stage_info* stg_info) {
|
||||
stage_detail::TaskStage_GetTaskStageInfo(a1, stg_info, a1->current_stage);
|
||||
}
|
||||
|
||||
static void stage_detail::TaskStage_GetLoadedStageInfos(stage_detail::TaskStage* a1,
|
||||
std::vector<task_stage_info>* vec) {
|
||||
vec->clear();
|
||||
vec->shrink_to_fit();
|
||||
for (int32_t i = 0; i < TASK_STAGE_STAGE_COUNT; i++)
|
||||
if (a1->stages[i].index != -1) {
|
||||
task_stage_info stg_info;
|
||||
stage_detail::TaskStage_GetTaskStageInfo(a1, &stg_info, i);
|
||||
vec->push_back(stg_info);
|
||||
}
|
||||
}
|
||||
|
||||
static bool stage_detail::TaskStage_Load(stage_detail::TaskStage* a1, const char* name) {
|
||||
if (TaskWork::AppendTask(a1, name)) {
|
||||
stage_detail::TaskStage_Reset(a1);
|
||||
stage_detail::TaskStage_TaskWindAppend(a1);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if (!TaskWork::HasTaskDest(a1))
|
||||
a1->SetDest();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static void stage_detail::TaskStage_Reset(stage_detail::TaskStage* a1) {
|
||||
a1->state = 0;
|
||||
for (int32_t i = 0; i < TASK_STAGE_STAGE_COUNT; i++)
|
||||
stage_reset(&a1->stages[i]);
|
||||
a1->current_stage = -1;
|
||||
a1->stage_indices.clear();
|
||||
a1->load_stage_indices.clear();
|
||||
a1->stage_display = true;
|
||||
a1->field_FB1 = true;
|
||||
a1->field_FB2 = true;
|
||||
a1->field_FB3 = true;
|
||||
a1->field_FB4 = true;
|
||||
a1->mat = mat4u_identity;
|
||||
a1->field_FF8 = 0.0f;
|
||||
}
|
||||
|
||||
static void stage_detail::TaskStage_SetStage(stage_detail::TaskStage* a1, task_stage_info stg_info) {
|
||||
int16_t load_index = stg_info.load_index;
|
||||
stage* s = stage_detail::TaskStage_GetStage(a1, stg_info);
|
||||
stage* curr = stage_detail::TaskStage_GetCurrentStage(a1);
|
||||
stage_set(curr, s);
|
||||
a1->current_stage = load_index;
|
||||
}
|
||||
|
||||
static void stage_detail::TaskStage_TaskWindAppend(stage_detail::TaskStage* a1) {
|
||||
TaskWork::AppendTask(&task_wind, a1, "CHARA WIND");
|
||||
}
|
||||
|
||||
static void stage_detail::TaskStage_Unload(stage_detail::TaskStage* a1) {
|
||||
if (!a1->state)
|
||||
return;
|
||||
|
||||
if (a1->state == 3 || a1->state == 4) {
|
||||
for (int32_t i = 0; i < TASK_STAGE_STAGE_COUNT; i++)
|
||||
stage_free(&a1->stages[i]);
|
||||
a1->state = 9;
|
||||
}
|
||||
else if (a1->state == 5 || a1->state == 6) {
|
||||
if (a1->state == 6)
|
||||
stage_detail::TaskStage_SetStage(a1, task_stage_info_null);
|
||||
|
||||
for (int32_t i = 0; i < TASK_STAGE_STAGE_COUNT; i++)
|
||||
stage_free(&a1->stages[i]);
|
||||
a1->state = 7;
|
||||
}
|
||||
|
||||
if (a1->state == 7) {
|
||||
//sub_140343C30();
|
||||
a1->state = 8;
|
||||
}
|
||||
else if (a1->state == 8) {
|
||||
//if (!sub_140344700())
|
||||
a1->state = 9;
|
||||
}
|
||||
else if (a1->state == 9) {
|
||||
bool v5 = 0;
|
||||
for (int32_t i = 0; i < TASK_STAGE_STAGE_COUNT; i++)
|
||||
if (a1->stages[i].state == 6) {
|
||||
v5 = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!v5) {
|
||||
//sub_140228ED0();
|
||||
light_param_storage_data_free_file_handlers();
|
||||
a1->stage_indices.clear();
|
||||
a1->state = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool object_bounding_sphere_check_visibility_shadow(object_bounding_sphere* sphere, camera* cam, mat4* mat) {
|
||||
vec3 center;
|
||||
mat4_mult_vec3_trans(mat, &sphere->center, ¢er);
|
||||
mat4_mult_vec3_trans(&cam->view, ¢er, ¢er);
|
||||
float_t radius = sphere->radius;
|
||||
|
||||
shadow* shad = rctx_ptr->draw_pass.shadow_ptr;
|
||||
float_t v9 = shad->field_170 * shad->field_174;
|
||||
if ((center.x + radius) < -v9
|
||||
|| (center.x - radius) > v9
|
||||
|| (center.y + radius) < -v9
|
||||
|| (center.y - radius) > v9
|
||||
|| (center.z - radius) > -shad->z_near
|
||||
|| (center.z + radius) < -shad->z_far)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool object_bounding_sphere_check_visibility_shadow_chara(object_bounding_sphere* sphere, camera* cam) {
|
||||
mat4 mat;
|
||||
shadow* shad = rctx_ptr->draw_pass.shadow_ptr;
|
||||
mat4_look_at(&shad->view_point[0], &shad->interest[0], &mat);
|
||||
return object_bounding_sphere_check_visibility_shadow(sphere, cam, &mat);
|
||||
}
|
||||
|
||||
static bool object_bounding_sphere_check_visibility_shadow_stage(object_bounding_sphere* sphere, camera* cam) {
|
||||
mat4 mat;
|
||||
shadow* shad = rctx_ptr->draw_pass.shadow_ptr;
|
||||
mat4_look_at(&shad->view_point[1], &shad->interest[1], &mat);
|
||||
return object_bounding_sphere_check_visibility_shadow(sphere, cam, &mat);
|
||||
}
|
||||
|
||||
static bool stage_ctrl(stage* s) {
|
||||
if (s->state >= 1 && s->state <= 5) {
|
||||
stage_load(s);
|
||||
return true;
|
||||
}
|
||||
else if (s->state >= 7 && s->state <= 9) {
|
||||
stage_free(s);
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int32_t& i : s->auth_3d_uids)
|
||||
auth_3d_data_set_visibility(&i, s->effects);
|
||||
return false;
|
||||
}
|
||||
|
||||
static void stage_disp(stage* s) {
|
||||
if (s->state != 6 || !s->stage_display)
|
||||
return;
|
||||
|
||||
object_data* object_data = &rctx_ptr->object_data;
|
||||
|
||||
mat4 mat;
|
||||
mat4_rotate_y(s->rot_y, &mat);
|
||||
|
||||
if (s->stage_data->object_ground.not_null() && s->ground)
|
||||
draw_task_add_draw_object_by_object_info(rctx_ptr, &mat, s->stage_data->object_ground, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
if (s->stage_data->object_ring.not_null() && s->ring)
|
||||
draw_task_add_draw_object_by_object_info(rctx_ptr, &mat, s->stage_data->object_ring, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
if (s->stage_data->object_reflect.not_null()) {
|
||||
object_data_set_draw_task_flags(object_data,
|
||||
(draw_task_flags)(DRAW_TASK_NO_TRANSLUCENCY | DRAW_TASK_REFRACT));
|
||||
draw_task_add_draw_object_by_object_info(rctx_ptr, &mat, s->stage_data->object_reflect, 0, 0, 0, 0, 0, 0);
|
||||
object_data_set_draw_task_flags(object_data, (draw_task_flags)0);
|
||||
}
|
||||
|
||||
if (s->stage_data->object_refract.not_null()) {
|
||||
object_data_set_draw_task_flags(object_data,
|
||||
(draw_task_flags)(DRAW_TASK_NO_TRANSLUCENCY | DRAW_TASK_REFRACT));
|
||||
draw_task_add_draw_object_by_object_info(rctx_ptr, &mat, s->stage_data->object_refract, 0, 0, 0, 0, 0, 0);
|
||||
object_data_set_draw_task_flags(object_data, (draw_task_flags)0);
|
||||
}
|
||||
|
||||
if (s->stage_data->object_sky.not_null() && s->sky) {
|
||||
mat4 t = s->mat;
|
||||
mat4_mult(&t, &mat, &t);
|
||||
draw_task_add_draw_object_by_object_info(rctx_ptr, &t, s->stage_data->object_sky, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
if (s->stage_data->lens_flare_texture != -1 && s->lens_flare) {
|
||||
int32_t object_set_id = s->stage_data->object_set_id;
|
||||
GLuint* textures = object_storage_get_textures(object_set_id);
|
||||
int32_t textures_count = object_storage_get_textures_count(object_set_id);
|
||||
uint32_t* texture_ids = object_storage_get_texture_ids(object_set_id);
|
||||
int32_t texture_ids_count = object_storage_get_texture_ids_count(object_set_id);
|
||||
|
||||
GLuint texs[3];
|
||||
texs[0] = 0;
|
||||
uint32_t lens_flare_texture = s->stage_data->lens_flare_texture;
|
||||
for (int32_t i = 0; i < texture_ids_count; i++)
|
||||
if (texture_ids[i] == lens_flare_texture) {
|
||||
texs[0] = textures[i];
|
||||
break;
|
||||
}
|
||||
|
||||
texs[1] = 0;
|
||||
uint32_t lens_shaft_texture = s->stage_data->lens_shaft_texture;
|
||||
for (int32_t i = 0; i < texture_ids_count; i++)
|
||||
if (texture_ids[i] == lens_shaft_texture) {
|
||||
texs[1] = textures[i];
|
||||
break;
|
||||
}
|
||||
|
||||
texs[2] = 0;
|
||||
uint32_t lens_ghost_texture = s->stage_data->lens_ghost_texture;
|
||||
for (int32_t i = 0; i < texture_ids_count; i++)
|
||||
if (texture_ids[i] == lens_ghost_texture) {
|
||||
texs[2] = textures[i];
|
||||
break;
|
||||
}
|
||||
|
||||
post_process_struct* pp = &rctx_ptr->post_process;
|
||||
pp->lens_flare_texture = texs[0];
|
||||
pp->lens_shaft_texture = texs[1];
|
||||
pp->lens_ghost_texture = texs[2];
|
||||
pp->lens_flare_count = 16;
|
||||
pp->lens_shaft_inv_scale = s->stage_data->lens_shaft_inv_scale;
|
||||
}
|
||||
}
|
||||
|
||||
static void stage_disp_shadow(stage* s) {
|
||||
if (s->state != 6 || !s->stage_display)
|
||||
return;
|
||||
|
||||
mat4 mat;
|
||||
mat4_rotate_y(s->rot_y, &mat);
|
||||
if (s->stage_data->object_shadow.not_null())
|
||||
stage_disp_shadow_object(s->stage_data->object_shadow, &mat);
|
||||
}
|
||||
|
||||
static void stage_disp_shadow_object(object_info object, mat4* mat) {
|
||||
object_data* object_data = &rctx_ptr->object_data;
|
||||
|
||||
for (int32_t i = SHADOW_CHARA; i < SHADOW_MAX; i++) {
|
||||
object_data_set_shadow_type(object_data, (shadow_type_enum)i);
|
||||
object_data_set_object_bounding_sphere_check_func(object_data,
|
||||
i == SHADOW_CHARA ? object_bounding_sphere_check_visibility_shadow_chara : object_bounding_sphere_check_visibility_shadow_stage);
|
||||
object_data_set_draw_task_flags(object_data,
|
||||
(draw_task_flags)(DRAW_TASK_NO_TRANSLUCENCY | DRAW_TASK_SHADOW_OBJECT));
|
||||
draw_task_add_draw_object_by_object_info(rctx_ptr, mat, object, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
object_data_set_draw_task_flags(object_data, (draw_task_flags)0);
|
||||
object_data_set_object_bounding_sphere_check_func(object_data, 0);
|
||||
object_data_set_shadow_type(object_data, SHADOW_CHARA);
|
||||
}
|
||||
|
||||
static void stage_free(stage* s) {
|
||||
if (!s->state)
|
||||
return;
|
||||
|
||||
if (s->state >= 1 && s->state <= 6) {
|
||||
s->state = 9;
|
||||
}
|
||||
|
||||
if (s->state < 7 || s->state > 9)
|
||||
return;
|
||||
|
||||
draw_pass* draw_pass = &rctx_ptr->draw_pass;
|
||||
if (s->stage_data->render_texture != -1) {
|
||||
post_process_render_texture_free(&rctx_ptr->post_process,
|
||||
texture_storage_get_texture(s->stage_data->render_texture), 0);
|
||||
s->stage_data->render_texture = -1;
|
||||
}
|
||||
|
||||
if (s->stage_data->movie_texture != -1) {
|
||||
post_process_movie_texture_free(&rctx_ptr->post_process,
|
||||
texture_storage_get_texture(s->stage_data->movie_texture));
|
||||
s->stage_data->movie_texture = -1;
|
||||
}
|
||||
|
||||
draw_pass->shadow = true;
|
||||
//rctx_ptr->post_process.field_14 = 0;
|
||||
//rctx_ptr->post_process.field_ED8 = 1;
|
||||
npr_spec_color.w = 1.0f;
|
||||
draw_pass->field_31D = 0;
|
||||
draw_pass->field_31E = 0;
|
||||
draw_pass->field_31F = false;
|
||||
draw_pass->field_320 = 0;
|
||||
light_chara_ambient = false;
|
||||
|
||||
if (s->auth_3d_loaded) {
|
||||
auth_3d_data_unload_category(string_data(&s->stage_data->auth_3d_name));
|
||||
auth_3d_data_unload_category(string_data(&s->stage_data->name));
|
||||
s->auth_3d_loaded = false;
|
||||
}
|
||||
|
||||
object_storage_delete_object_set(s->stage_data->object_set_id);
|
||||
if (s->obj_set >= 0)
|
||||
object_storage_delete_object_set(s->obj_set);
|
||||
|
||||
s->obj_set = -1;
|
||||
s->index = -1;
|
||||
s->state = 0;
|
||||
}
|
||||
|
||||
static void stage_load(stage* s) {
|
||||
if (s->state == 1) {
|
||||
data_struct* data = rctx_ptr->data;
|
||||
object_database* obj_db = &data->data_ft.obj_db;
|
||||
object_set_info* set_info = 0;
|
||||
if (obj_db->get_object_set_info_by_set_id(s->obj_set, &set_info))
|
||||
object_set_load_by_db_index(&set_info, data, obj_db, set_info->id);
|
||||
s->state = 2;
|
||||
}
|
||||
else if (s->state == 2) {
|
||||
if (s->obj_set < 0 || true/*!obj_database_load_obj_set_check_not_read(s->obj_set)*/)
|
||||
s->state = 3;
|
||||
}
|
||||
else if (s->state == 3) {
|
||||
data_struct* data = rctx_ptr->data;
|
||||
object_database* obj_db = &data->data_ft.obj_db;
|
||||
object_set_info* set_info = 0;
|
||||
if (obj_db->get_object_set_info_by_set_id(s->stage_data->object_set_id, &set_info))
|
||||
object_set_load_by_db_index(&set_info, data, obj_db, set_info->id);
|
||||
|
||||
auth_3d_data_load_category(string_data(&s->stage_data->name));
|
||||
auth_3d_data_load_category(string_data(&s->stage_data->auth_3d_name));
|
||||
s->auth_3d_loaded = true;
|
||||
s->state = 4;
|
||||
}
|
||||
else if (s->state == 4
|
||||
&& true/*!obj_database_load_obj_set_check_not_read(s->stage_data->object_set_id)*/
|
||||
&& auth_3d_data_check_category_loaded(string_data(&s->stage_data->name))
|
||||
&& auth_3d_data_check_category_loaded(string_data(&s->stage_data->auth_3d_name))) {
|
||||
if (s->stage_data->render_texture != -1)
|
||||
post_process_render_texture_set(&rctx_ptr->post_process,
|
||||
texture_storage_get_texture(s->stage_data->render_texture), 0);
|
||||
|
||||
if (s->stage_data->movie_texture != -1)
|
||||
post_process_movie_texture_set(&rctx_ptr->post_process,
|
||||
texture_storage_get_texture(s->stage_data->movie_texture));
|
||||
s->state = 6;
|
||||
|
||||
data_struct* data = rctx_ptr->data;
|
||||
auth_3d_database* auth_3d_db = &data->data_ft.auth_3d_db;
|
||||
int32_t auth_3d_count = s->stage_data->auth_3d_count;
|
||||
int32_t* auth_3d_ids = s->stage_data->auth_3d_ids;
|
||||
for (int32_t i = 0; i < auth_3d_count; i++) {
|
||||
int32_t id = auth_3d_data_load_uid(auth_3d_ids[i], auth_3d_db);
|
||||
auth_3d_data_read_file(&id, auth_3d_db);
|
||||
s->auth_3d_uids.push_back(id);
|
||||
}
|
||||
|
||||
for (int32_t& i : s->auth_3d_uids)
|
||||
auth_3d_data_set_visibility(&i, true);
|
||||
}
|
||||
}
|
||||
|
||||
static void stage_reset(stage* s) {
|
||||
s->index = -1;
|
||||
s->counter = 0;
|
||||
s->state = 0;
|
||||
s->stage_data = 0;
|
||||
s->stage_display = true;
|
||||
s->lens_flare = true;
|
||||
s->ground = true;
|
||||
s->ring = true;
|
||||
s->sky = true;
|
||||
s->auth_3d_loaded = 0;
|
||||
s->mat = mat4u_identity;
|
||||
s->rot_y = 0.0;
|
||||
s->obj_set = -1;
|
||||
|
||||
for (int32_t& i : s->auth_3d_uids)
|
||||
auth_3d_data_unload_id(i, rctx_ptr);
|
||||
s->auth_3d_uids.clear();
|
||||
s->auth_3d_uids.shrink_to_fit();
|
||||
s->effects = true;
|
||||
}
|
||||
|
||||
static void stage_set(stage* s, stage* other) {
|
||||
if (other && s == other)
|
||||
return;
|
||||
|
||||
draw_pass* draw_pass = &rctx_ptr->draw_pass;
|
||||
if (s) {
|
||||
//flt_14CC925C0 = 0.0;
|
||||
//flt_140CB3704 = -1001.0;
|
||||
draw_pass->enable[DRAW_PASS_REFLECT] = false;
|
||||
draw_pass->reflect = false;
|
||||
draw_pass->enable[DRAW_PASS_REFRACT] = false;
|
||||
draw_pass->refract = true;
|
||||
draw_pass->field_31D = 0;
|
||||
draw_pass->field_31E = 0;
|
||||
draw_pass->field_31F = false;
|
||||
draw_pass->field_320 = 0;
|
||||
draw_pass->shadow = true;
|
||||
//rctx_ptr->post_process.field_14 = 0;
|
||||
//rctx_ptr->post_process.field_ED8 = 1;
|
||||
npr_spec_color.w = 1.0f;
|
||||
draw_pass->npr_param = 0;
|
||||
light_chara_ambient = false;
|
||||
}
|
||||
|
||||
if (other) {
|
||||
rctx_ptr->chara_reflect = other->stage_data->reflect_type != STAGE_DATA_REFLECT_DISABLE;
|
||||
draw_pass->reflect_type = other->stage_data->reflect_type;
|
||||
rctx_ptr->chara_refract = other->stage_data->refract_enable;
|
||||
|
||||
if (other->stage_data->reflect) {
|
||||
stage_data_reflect* reflect = &other->stage_data->reflect_data;
|
||||
draw_pass->enable[DRAW_PASS_REFLECT] = true;
|
||||
draw_pass->reflect_blur_num = reflect->blur_num;
|
||||
draw_pass->reflect_blur_filter = (blur_filter_mode)reflect->blur_filter;
|
||||
draw_pass->reflect = true;
|
||||
/*reflect_refract_resolution_mode reflect_resolution_mode = REFLECT_REFRACT_RESOLUTION_512x512;
|
||||
if (other->stage_data->reflect_type != STAGE_DATA_REFLECT_REFLECT_MAP)
|
||||
reflect_resolution_mode = (reflect_refract_resolution_mode)reflect->mode;
|
||||
draw_pass_data_set_reflect_resolution_mode(reflect_resolution_mode);*/
|
||||
}
|
||||
|
||||
if (other->stage_data->refract) {
|
||||
stage_data_refract* refract = &other->stage_data->refract_data;
|
||||
draw_pass->enable[DRAW_PASS_REFRACT] = true;
|
||||
//draw_pass_data_set_refract_resolution_mode(refract->mode);
|
||||
draw_pass->refract = true;
|
||||
}
|
||||
|
||||
if (other->stage_data->flags & STAGE_DATA_FLAG_1)
|
||||
draw_pass->field_31D = true;
|
||||
if (other->stage_data->flags & STAGE_DATA_FLAG_4)
|
||||
draw_pass->field_31E = true;
|
||||
if (other->stage_data->flags & STAGE_DATA_FLAG_8)
|
||||
draw_pass->field_320 = true;
|
||||
if (other->stage_data->flags & STAGE_DATA_LIGHT_CHARA_AMBIENT)
|
||||
light_chara_ambient = true;
|
||||
//if (stru_14CC92630.pv_id == 421)
|
||||
//draw_pass->field_31F = true;
|
||||
//sub_14064DC10();
|
||||
//sub_140344160(other->index);
|
||||
}
|
||||
//else
|
||||
//sub_140344160(-1);
|
||||
|
||||
if (other)
|
||||
light_param_storage_data_set_stage(other->index);
|
||||
else
|
||||
light_param_storage_data_set_default_light_param();
|
||||
|
||||
if (s)
|
||||
for (int32_t& i : s->auth_3d_uids) {
|
||||
auth_3d_data_set_req_frame(&i, 0.0f);
|
||||
auth_3d_data_set_visibility(&i, false);
|
||||
}
|
||||
|
||||
if (other)
|
||||
for (int32_t& i : other->auth_3d_uids) {
|
||||
auth_3d_data_set_req_frame(&i, 0.0f);
|
||||
auth_3d_data_set_visibility(&i, true);
|
||||
}
|
||||
|
||||
//sub_140344180(0);
|
||||
|
||||
if (/*!pv_osage_manager_array_ptr_get_disp() && */other)
|
||||
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++) {
|
||||
rob_chara* rob_chr = rob_chara_array_get(i);
|
||||
//if (rob_chr)
|
||||
//sub_1405559D0(rob_chr, &other->index);
|
||||
}
|
||||
}
|
||||
|
||||
static void stage_set_by_stage_index(stage* s, int32_t stage_index, uint16_t stage_counter) {
|
||||
data_struct* data = rctx_ptr->data;
|
||||
object_database* obj_db = &data->data_ft.obj_db;
|
||||
stage_database* stage_data = &data->data_ft.stage_data;
|
||||
|
||||
stage_reset(s);
|
||||
s->index = stage_index;
|
||||
s->counter = stage_counter;
|
||||
s->state = 1;
|
||||
|
||||
if (stage_index >= vector_old_length(stage_data->stage_data)) {
|
||||
s->stage_data = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
s->stage_data = &stage_data->stage_data.begin[stage_index];
|
||||
|
||||
char* name = string_data(&s->stage_data->name);
|
||||
size_t name_len = s->stage_data->name.length;
|
||||
|
||||
char set_name[11];
|
||||
set_name[0] = 0;
|
||||
@@ -178,83 +735,14 @@ void stage_load(stage* s, data_struct* data, auth_3d_database* auth_3d_db, objec
|
||||
set_name[8] = 0;
|
||||
|
||||
}
|
||||
else if(!str_utils_compare_length(name, name_len, "STGD2PV", 7)) {
|
||||
else if (!str_utils_compare_length(name, name_len, "STGD2PV", 7)) {
|
||||
memcpy(set_name, name, 10);
|
||||
set_name[10] = 0;
|
||||
}
|
||||
|
||||
s->obj_set = -1;
|
||||
object_set_info* set_info;
|
||||
s->set_id = -1;
|
||||
if (set_name[0] && object_database_get_object_set_info(obj_db, set_name, &set_info)) {
|
||||
s->set_id = set_info->id;
|
||||
object_set_load_by_db_index(&set_info, data, obj_db, set_info->id);
|
||||
if (set_name[0] && obj_db->get_object_set_info(set_name, &set_info)) {
|
||||
s->obj_set = set_info->id;
|
||||
}
|
||||
|
||||
s->stage_set_id = -1;
|
||||
if (object_database_get_object_set_info(obj_db, name, &set_info)) {
|
||||
s->stage_set_id = set_info->id;
|
||||
object_set_load_by_db_index(&set_info, data, obj_db, set_info->id);
|
||||
}
|
||||
|
||||
if (render_texture != -1)
|
||||
post_process_render_texture_set(&rctx->post_process,
|
||||
texture_storage_get_texture(render_texture), 0);
|
||||
|
||||
if (movie_texture != -1)
|
||||
post_process_movie_texture_set(&rctx->post_process,
|
||||
texture_storage_get_texture(movie_texture));
|
||||
}
|
||||
|
||||
inline void stage_load(stage* s, data_struct* data, auth_3d_database* auth_3d_db, object_database* obj_db,
|
||||
texture_database* tex_db, stage_database* stage_data, const char* name, render_context* rctx) {
|
||||
stage_load(s, data, auth_3d_db, obj_db, tex_db, stage_data, (char*)name, rctx);
|
||||
}
|
||||
|
||||
extern int32_t stage_index;
|
||||
|
||||
void stage_set(stage* s, render_context* rctx) {
|
||||
if (!s || !rctx || s == rctx->stage)
|
||||
return;
|
||||
|
||||
rctx->stage = s;
|
||||
stage_index = (uint32_t)(s->modern ? s->stage_modern->id : s->stage_data->id);
|
||||
render_context_set_light_param(rctx,
|
||||
light_param_storage_get_light_param_data(s->light_param_name));
|
||||
}
|
||||
|
||||
void stage_free(stage* s, render_context* rctx) {
|
||||
uint32_t render_texture = -1;
|
||||
uint32_t movie_texture = -1;
|
||||
if (!s->modern && s->stage_data) {
|
||||
stage_data* info = s->stage_data;
|
||||
render_texture = info->render_texture;
|
||||
movie_texture = info->movie_texture;
|
||||
|
||||
for (int32_t* i = s->auth_3d_ids.begin; i != s->auth_3d_ids.end; i++)
|
||||
auth_3d_data_unload_id(*i, rctx);
|
||||
vector_old_int32_t_free(&s->auth_3d_ids, 0);
|
||||
}
|
||||
else if (s->modern && s->stage_modern) {
|
||||
stage_data_modern* info = s->stage_modern;
|
||||
render_texture = info->render_texture;
|
||||
movie_texture = info->movie_texture;
|
||||
|
||||
for (int32_t* i = s->auth_3d_ids.begin; i != s->auth_3d_ids.end; i++)
|
||||
auth_3d_data_unload_id(*i, rctx);
|
||||
vector_old_int32_t_free(&s->auth_3d_ids, 0);
|
||||
}
|
||||
|
||||
if (render_texture != -1)
|
||||
post_process_render_texture_free(&rctx->post_process,
|
||||
texture_storage_get_texture(render_texture), false);
|
||||
|
||||
if (movie_texture != -1)
|
||||
post_process_movie_texture_free(&rctx->post_process,
|
||||
texture_storage_get_texture(movie_texture));
|
||||
|
||||
object_storage_delete_object_set(s->set_id);
|
||||
object_storage_delete_object_set(s->stage_set_id);
|
||||
free(s->light_param_name);
|
||||
|
||||
rctx->stage = 0;
|
||||
}
|
||||
|
||||
+65
-27
@@ -5,40 +5,78 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "../KKdLib/default.h"
|
||||
#include "../KKdLib/database/stage.h"
|
||||
#include "../KKdLib/vec.h"
|
||||
#include "../KKdLib/vector.h"
|
||||
#include "render_context.h"
|
||||
#include "auth_3d.h"
|
||||
|
||||
typedef struct stage {
|
||||
union {
|
||||
stage_data* stage_data;
|
||||
stage_data_modern* stage_modern;
|
||||
};
|
||||
|
||||
bool modern;
|
||||
bool display;
|
||||
bool ring;
|
||||
class stage {
|
||||
public:
|
||||
int32_t index;
|
||||
uint16_t counter;
|
||||
int32_t state;
|
||||
stage_data* stage_data;
|
||||
bool stage_display;
|
||||
bool lens_flare;
|
||||
bool ground;
|
||||
bool ring;
|
||||
bool sky;
|
||||
bool auth_3d_loaded;
|
||||
mat4u mat;
|
||||
float_t rot_y;
|
||||
int32_t obj_set;
|
||||
|
||||
// Temp
|
||||
std::vector<int32_t> auth_3d_uids;
|
||||
bool effects;
|
||||
|
||||
uint32_t set_id;
|
||||
uint32_t stage_set_id;
|
||||
char* light_param_name;
|
||||
vector_old_int32_t auth_3d_ids;
|
||||
} stage;
|
||||
stage();
|
||||
~stage();
|
||||
};
|
||||
|
||||
extern void stage_init(stage* s);
|
||||
extern void stage_ctrl(stage* s, render_context* rctx);
|
||||
extern void stage_ctrl_modern(stage* s, render_context* rctx);
|
||||
extern void stage_disp(stage* s, render_context* rctx);
|
||||
extern void stage_disp_modern(stage* s, render_context* rctx);
|
||||
extern void stage_load(stage* s, data_struct* data, auth_3d_database* auth_3d_db, object_database* obj_db,
|
||||
texture_database* tex_db, stage_database* stage_data, char* name, render_context* rctx);
|
||||
extern void stage_load(stage* s, data_struct* data, auth_3d_database* auth_3d_db, object_database* obj_db,
|
||||
texture_database* tex_db, stage_database* stage_data, const char* name, render_context* rctx);
|
||||
extern void stage_set(stage* s, render_context* rctx);
|
||||
extern void stage_free(stage* s, render_context* rctx);
|
||||
#define TASK_STAGE_STAGE_COUNT 37
|
||||
|
||||
namespace stage_detail {
|
||||
class TaskStage : public Task {
|
||||
public:
|
||||
int32_t state;
|
||||
stage stages[TASK_STAGE_STAGE_COUNT];
|
||||
int16_t current_stage;
|
||||
std::vector<int32_t> stage_indices;
|
||||
std::vector<int32_t> load_stage_indices;
|
||||
bool stage_display;
|
||||
bool field_FB1;
|
||||
bool field_FB2;
|
||||
bool field_FB3;
|
||||
bool field_FB4;
|
||||
mat4u mat;
|
||||
float_t field_FF8;
|
||||
|
||||
TaskStage();
|
||||
virtual ~TaskStage() override;
|
||||
virtual bool Init() override;
|
||||
virtual bool Ctrl() override;
|
||||
virtual bool Dest() override;
|
||||
virtual void Disp() override;
|
||||
};
|
||||
}
|
||||
|
||||
typedef struct task_stage_info {
|
||||
int16_t load_index;
|
||||
uint16_t load_counter;
|
||||
} task_stage_info;
|
||||
|
||||
extern bool task_stage_check_not_loaded();
|
||||
extern void task_stage_disp_shadow();
|
||||
extern stage* task_stage_get_current_stage();
|
||||
extern void task_stage_get_current_stage_info(task_stage_info* stg_info);
|
||||
extern void task_stage_get_loaded_stage_infos(std::vector<task_stage_info>* vec);
|
||||
extern bool task_stage_load(char* name);
|
||||
extern bool task_stage_load(const char* name);
|
||||
extern void task_stage_set_mat(mat4* mat);
|
||||
extern void task_stage_set_mat(mat4u* mat);
|
||||
extern void task_stage_set_stage(task_stage_info* stg_info);
|
||||
extern void task_stage_set_stage_index(int32_t stage_index);
|
||||
extern void task_stage_set_stage_indices(std::vector<int32_t>* stage_indices);
|
||||
extern bool task_stage_unload();
|
||||
|
||||
+54
-15
@@ -10,7 +10,6 @@ extern float_t get_delta_frame();
|
||||
extern uint32_t get_frame_counter();
|
||||
|
||||
static void Task_add_base_calc_time(Task* t, uint32_t calc_time);
|
||||
static void Task_add_disp_time(Task* t, uint32_t disp_time);
|
||||
static void Task_do_basic(Task* t);
|
||||
static void Task_do_ctrl(Task* t);
|
||||
static void Task_do_ctrl_frames(int32_t frames, bool a2);
|
||||
@@ -23,7 +22,6 @@ static void Task_sub_14019C480(Task* t, uint32_t a2);
|
||||
static void Task_sub_14019C5A0(Task* t);
|
||||
|
||||
static bool TaskWork_has_task_dest(Task* t);
|
||||
static bool TaskWork_sub_14019B6B0(Task* t);
|
||||
|
||||
TaskWork task_work;
|
||||
|
||||
@@ -71,6 +69,34 @@ void Task::Basic() {
|
||||
|
||||
}
|
||||
|
||||
uint32_t Task::GetCalcTime() {
|
||||
return calc_time;
|
||||
}
|
||||
|
||||
uint32_t Task::GetCalcTimeMax() {
|
||||
return calc_time_max;
|
||||
}
|
||||
|
||||
uint32_t Task::GetDispTime() {
|
||||
return disp_time;
|
||||
}
|
||||
|
||||
uint32_t Task::GetDispTimeMax() {
|
||||
return disp_time_max;
|
||||
}
|
||||
|
||||
char* Task::GetName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
bool Task::SetDest() {
|
||||
if (!TaskWork::HasTask(this) || !Task_sub_14019B810(this, 2))
|
||||
return 0;
|
||||
|
||||
Task_sub_14019C480(this, 2);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Task::SetName(char* name) {
|
||||
if (!name) {
|
||||
this->name[0] = 0;
|
||||
@@ -129,6 +155,10 @@ void TaskWork::Basic() {
|
||||
Task_do_basic(j);
|
||||
}
|
||||
|
||||
bool TaskWork::CheckTaskNotReady(Task* t) {
|
||||
return TaskWork::HasTask(t) && (t->field_18 == TASK_NONE || t->field_1C);
|
||||
}
|
||||
|
||||
void TaskWork::Ctrl() {
|
||||
std::vector<Task*>* tasks = &task_work.tasks;
|
||||
for (Task*& i : task_work.tasks) {
|
||||
@@ -148,17 +178,17 @@ void TaskWork::Ctrl() {
|
||||
task_work.current = tsk;
|
||||
Task_do_ctrl(tsk);
|
||||
task_work.current = 0;
|
||||
Task_add_base_calc_time(tsk, (uint32_t)time_struct_calc_time(&t));
|
||||
Task_add_base_calc_time(tsk, (uint32_t)(time_struct_calc_time(&t) * 1000.0));
|
||||
}
|
||||
|
||||
for (Task** i = task_work.tasks.begin()._Ptr; i != task_work.tasks.end()._Ptr; ) {
|
||||
if (TaskWork_sub_14019B6B0(*i)) {
|
||||
if (TaskWork::CheckTaskNotReady(*i)) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
task_work.tasks.erase(task_work.tasks.begin()
|
||||
+ (i - task_work.tasks.begin()._Ptr));
|
||||
+ (i - task_work.tasks.data()));
|
||||
}
|
||||
|
||||
int32_t delta_frame = (int32_t)get_delta_frame();
|
||||
@@ -183,11 +213,21 @@ void TaskWork::Disp() {
|
||||
time_struct t;
|
||||
time_struct_init(&t);
|
||||
Task_do_disp(tsk);
|
||||
Task_add_disp_time(tsk, (uint32_t)time_struct_calc_time(&t));
|
||||
Task_set_disp_time(tsk, (uint32_t)(time_struct_calc_time(&t) * 1000.0));
|
||||
}
|
||||
task_work.disp = false;
|
||||
}
|
||||
|
||||
Task* TaskWork::GetTaskByIndex(int32_t index) {
|
||||
int32_t k = 0;
|
||||
for (int32_t i = 0; i < 3; i++)
|
||||
for (Task*& j : task_work.tasks)
|
||||
if (j->priority == i)
|
||||
if (k++ == index)
|
||||
return j;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool TaskWork::HasTask(Task* t) {
|
||||
std::vector<Task*>* tasks = &task_work.tasks;
|
||||
for (Task*& i : task_work.tasks)
|
||||
@@ -196,12 +236,15 @@ bool TaskWork::HasTask(Task* t) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void Task_add_base_calc_time(Task* t, uint32_t calc_time) {
|
||||
t->base_calc_time += calc_time;
|
||||
bool TaskWork::HasTaskDest(Task* t) {
|
||||
if (TaskWork::HasTask(t))
|
||||
return t->field_18 == TASK_DEST;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
static void Task_add_disp_time(Task* t, uint32_t disp_time) {
|
||||
t->disp_time += disp_time;
|
||||
static void Task_add_base_calc_time(Task* t, uint32_t calc_time) {
|
||||
t->base_calc_time += calc_time;
|
||||
}
|
||||
|
||||
static void Task_do_basic(Task* t) {
|
||||
@@ -246,7 +289,7 @@ static void Task_do_ctrl_frames(int32_t frames, bool a2) {
|
||||
task_work.current = tsk;
|
||||
Task_do_ctrl(tsk);
|
||||
task_work.current = 0;
|
||||
Task_add_base_calc_time(tsk, (uint32_t)time_struct_calc_time(&t));
|
||||
Task_add_base_calc_time(tsk, (uint32_t)(time_struct_calc_time(&t) * 1000.0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +378,3 @@ static bool TaskWork_has_task_dest(Task* t) {
|
||||
return t->field_18 == TASK_DEST;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TaskWork_sub_14019B6B0(Task* t) {
|
||||
return TaskWork::HasTask(t) && (t->field_18 == TASK_NONE || t->field_1C);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,13 @@ public:
|
||||
virtual void Disp();
|
||||
virtual void Basic();
|
||||
|
||||
uint32_t GetCalcTime();
|
||||
uint32_t GetCalcTimeMax();
|
||||
uint32_t GetDispTime();
|
||||
uint32_t GetDispTimeMax();
|
||||
char* GetName();
|
||||
|
||||
bool SetDest();
|
||||
void SetName(char* name);
|
||||
void SetName(const char* name);
|
||||
void SetPriority(int32_t priority);
|
||||
@@ -67,7 +74,10 @@ public:
|
||||
static bool AppendTask(Task* t, Task* parent_task = task_work.current,
|
||||
const char* name = "(unknown)", int32_t priority = 1);
|
||||
static void Basic();
|
||||
static bool CheckTaskNotReady(Task* t);
|
||||
static void Ctrl();
|
||||
static void Disp();
|
||||
static Task* GetTaskByIndex(int32_t index);
|
||||
static bool HasTask(Task* t);
|
||||
static bool HasTaskDest(Task* t);
|
||||
};
|
||||
|
||||
+8
-8
@@ -41,18 +41,18 @@ texture* texture_load_tex_cube_map(uint32_t id, GLenum internal_format, int32_t
|
||||
}
|
||||
|
||||
texture* texture_txp_load(txp* t, uint32_t id) {
|
||||
if (!t || !t->data.begin)
|
||||
if (!t || !t->mipmaps.size())
|
||||
return 0;
|
||||
|
||||
int32_t count = t->array_size * t->mipmaps_count;
|
||||
void** data_ptr = force_malloc_s(void*, count);
|
||||
for (uint32_t i = 0, k = 0; i < t->array_size; i++)
|
||||
for (uint32_t j = 0; j < t->mipmaps_count; j++, k++)
|
||||
data_ptr[k] = t->data.begin[k].data;
|
||||
data_ptr[k] = t->mipmaps[k].data.data();
|
||||
|
||||
GLenum internal_format = texture_txp_get_internal_format(t);
|
||||
int32_t width = t->data.begin->width;
|
||||
int32_t height = t->data.begin->height;
|
||||
int32_t width = t->mipmaps[0].width;
|
||||
int32_t height = t->mipmaps[0].height;
|
||||
int32_t max_mipmap_level = t->mipmaps_count - 1;
|
||||
|
||||
texture* tex;
|
||||
@@ -72,11 +72,11 @@ bool texture_txp_set_load(txp_set* t, texture*** texs, uint32_t* ids) {
|
||||
if (!t || !texs || !ids)
|
||||
return false;
|
||||
|
||||
size_t count = vector_old_length(*t);
|
||||
size_t count = t->textures.size();
|
||||
*texs = force_malloc_s(texture*, count + 1);
|
||||
texture** tex = *texs;
|
||||
for (size_t i = 0; i < count; i++)
|
||||
tex[i] = texture_txp_load(&t->begin[i], ids[i]);
|
||||
tex[i] = texture_txp_load(&t->textures[i], ids[i]);
|
||||
tex[count] = 0;
|
||||
return true;
|
||||
}
|
||||
@@ -491,10 +491,10 @@ static void texture_set_params(GLenum target, int32_t max_mipmap_level, bool use
|
||||
}
|
||||
|
||||
static GLenum texture_txp_get_internal_format(txp* t) {
|
||||
if (!t || !t->data.begin)
|
||||
if (!t || !t->mipmaps.size())
|
||||
return GL_ZERO;
|
||||
|
||||
switch (t->data.begin->format) {
|
||||
switch (t->mipmaps[0].format) {
|
||||
case TXP_A8:
|
||||
return GL_ALPHA8;
|
||||
case TXP_RGB8:
|
||||
|
||||
@@ -188,7 +188,6 @@
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<ObjectFileName>$(IntDir)/%(RelativeDir)</ObjectFileName>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@@ -224,7 +223,6 @@ del "$(SolutionDir)bin\$(TargetName).lib"</Command>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<ObjectFileName>$(IntDir)/%(RelativeDir)</ObjectFileName>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@@ -264,7 +262,6 @@ del "$(SolutionDir)bin\$(TargetName).lib"</Command>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalOptions>/Gw %(AdditionalOptions)</AdditionalOptions>
|
||||
<ObjectFileName>$(IntDir)/%(RelativeDir)</ObjectFileName>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<UseFullPaths>false</UseFullPaths>
|
||||
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
|
||||
@@ -300,10 +297,9 @@ del "$(SolutionDir)bin\$(TargetName).lib"</Command>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<CallingConvention>FastCall</CallingConvention>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalOptions>/Gw %(AdditionalOptions)</AdditionalOptions>
|
||||
<ObjectFileName>$(IntDir)/%(RelativeDir)</ObjectFileName>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<UseFullPaths>false</UseFullPaths>
|
||||
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
|
||||
@@ -345,7 +341,6 @@ del "$(SolutionDir)bin\$(TargetName).lib"</Command>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalOptions>/Gw %(AdditionalOptions)</AdditionalOptions>
|
||||
<ObjectFileName>$(IntDir)/%(RelativeDir)</ObjectFileName>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<UseFullPaths>false</UseFullPaths>
|
||||
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
|
||||
@@ -386,7 +381,6 @@ del "$(SolutionDir)bin\$(TargetName).lib"</Command>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalOptions>/Gw %(AdditionalOptions)</AdditionalOptions>
|
||||
<ObjectFileName>$(IntDir)/%(RelativeDir)</ObjectFileName>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<UseFullPaths>false</UseFullPaths>
|
||||
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
|
||||
@@ -431,7 +425,6 @@ del "$(SolutionDir)bin\$(TargetName).lib"</Command>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalOptions>/Gw %(AdditionalOptions)</AdditionalOptions>
|
||||
<ObjectFileName>$(IntDir)/%(RelativeDir)</ObjectFileName>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<UseFullPaths>false</UseFullPaths>
|
||||
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
|
||||
@@ -474,7 +467,6 @@ del "$(SolutionDir)bin\$(TargetName).lib"</Command>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalOptions>/Gw %(AdditionalOptions)</AdditionalOptions>
|
||||
<ObjectFileName>$(IntDir)/%(RelativeDir)</ObjectFileName>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<UseFullPaths>false</UseFullPaths>
|
||||
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
|
||||
|
||||
+675
-465
File diff suppressed because it is too large
Load Diff
+134
-137
@@ -1060,7 +1060,7 @@ struct rob_sub_action {
|
||||
typedef struct struc_389 {
|
||||
float_t frame;
|
||||
float_t prev_frame;
|
||||
float_t last_frame;
|
||||
float_t last_set_frame;
|
||||
} struc_389;
|
||||
|
||||
typedef struct struc_406 {
|
||||
@@ -1114,30 +1114,30 @@ typedef struct rob_eyelid_motion {
|
||||
rob_partial_motion base;
|
||||
} rob_eyelid_motion;
|
||||
|
||||
typedef struct struc_269 {
|
||||
uint8_t field_0;
|
||||
float_t field_4;
|
||||
float_t field_8;
|
||||
vec3 field_C;
|
||||
typedef struct rob_chara_data_parts_adjust {
|
||||
bool enable;
|
||||
float_t frame;
|
||||
float_t transition_frame;
|
||||
vec3 curr_external_force;
|
||||
float_t curr_force;
|
||||
float_t curr_strength;
|
||||
int32_t motion_id;
|
||||
int32_t set_frame;
|
||||
float_t force_duration;
|
||||
int32_t type;
|
||||
int32_t cycle_type;
|
||||
bool ignore_gravity;
|
||||
vec3 external_force_min;
|
||||
vec3 external_force_strength;
|
||||
vec3 external_force;
|
||||
float_t cycle;
|
||||
float_t phase;
|
||||
float_t force;
|
||||
float_t field_1C;
|
||||
int32_t field_20;
|
||||
int32_t field_24;
|
||||
float_t field_28;
|
||||
int32_t field_2C;
|
||||
int32_t field_30;
|
||||
uint8_t field_34;
|
||||
vec3 field_38;
|
||||
vec3 field_44;
|
||||
vec3 field_50;
|
||||
float_t field_5C;
|
||||
float_t field_60;
|
||||
float_t field_64;
|
||||
float_t field_68;
|
||||
float_t field_6C;
|
||||
} struc_269;
|
||||
float_t strength;
|
||||
float_t strength_transition;
|
||||
} rob_chara_data_parts_adjust;
|
||||
|
||||
typedef struct struc_229 {
|
||||
typedef struct rob_chara_data_hand_adjust {
|
||||
uint8_t field_0;
|
||||
uint8_t field_1;
|
||||
int16_t field_2;
|
||||
@@ -1156,15 +1156,15 @@ typedef struct struc_229 {
|
||||
vec3 field_30;
|
||||
int32_t field_3C;
|
||||
int32_t field_40;
|
||||
} struc_229;
|
||||
} rob_chara_data_hand_adjust;
|
||||
|
||||
typedef struct struc_222 {
|
||||
uint8_t field_0;
|
||||
float_t field_4;
|
||||
float_t field_8;
|
||||
float_t field_C;
|
||||
float_t field_10;
|
||||
float_t field_14;
|
||||
float_t duration;
|
||||
float_t frame;
|
||||
} struc_222;
|
||||
|
||||
typedef struct aft_object_info {
|
||||
@@ -1187,11 +1187,11 @@ typedef struct struc_405 {
|
||||
float_t field_1C4;
|
||||
} struc_405;
|
||||
|
||||
typedef struct struc_268 {
|
||||
typedef struct rob_chara_adjust {
|
||||
int32_t motion_id;
|
||||
int32_t prev_motion_id;
|
||||
struc_389 field_8;
|
||||
struc_406 field_14;
|
||||
struc_389 frame_data;
|
||||
struc_406 step_data;
|
||||
float_t step;
|
||||
int32_t field_24;
|
||||
uint8_t field_28;
|
||||
@@ -1214,13 +1214,13 @@ typedef struct struc_268 {
|
||||
aft_object_info field_3A8;
|
||||
aft_object_info field_3AC;
|
||||
struc_405 field_3B0;
|
||||
struc_269 field_578[13];
|
||||
struc_269 field_B28[13];
|
||||
struc_269 field_10D8[2];
|
||||
struc_229 field_11B8[2];
|
||||
struc_229 field_1240[2];
|
||||
rob_chara_data_parts_adjust parts_adjust[13];
|
||||
rob_chara_data_parts_adjust parts_adjust_prev[13];
|
||||
rob_chara_data_parts_adjust field_10D8[2];
|
||||
rob_chara_data_hand_adjust hand_adjust[2];
|
||||
rob_chara_data_hand_adjust hand_adjust_prev[2];
|
||||
struc_222 field_12C8[2];
|
||||
} struc_268;
|
||||
} rob_chara_adjust;
|
||||
|
||||
typedef struct struc_228 {
|
||||
int32_t field_0;
|
||||
@@ -1404,7 +1404,7 @@ typedef struct struc_223 {
|
||||
int32_t field_7A8;
|
||||
} struc_223;
|
||||
|
||||
typedef struct struc_399 {
|
||||
typedef struct rob_chara_data_miku_rot {
|
||||
int16_t field_0;
|
||||
int16_t field_2;
|
||||
int16_t field_4;
|
||||
@@ -1427,7 +1427,7 @@ typedef struct struc_399 {
|
||||
int32_t field_64;
|
||||
int32_t field_68;
|
||||
mat4u field_6C;
|
||||
} struc_399;
|
||||
} rob_chara_data_miku_rot;
|
||||
|
||||
typedef struct rob_chara_adjust_data {
|
||||
float_t scale;
|
||||
@@ -1605,9 +1605,9 @@ typedef struct rob_chara_data {
|
||||
int32_t field_4;
|
||||
struc_264 field_8;
|
||||
rob_sub_action rob_sub_action;
|
||||
struc_268 field_290;
|
||||
rob_chara_adjust adjust;
|
||||
struc_223 field_1588;
|
||||
struc_399 field_1D38;
|
||||
rob_chara_data_miku_rot miku_rot;
|
||||
rob_chara_adjust_data adjust_data;
|
||||
struc_209 field_1E68;
|
||||
float_t field_3D90;
|
||||
@@ -2345,7 +2345,7 @@ typedef struct mot_data {
|
||||
uint16_t* bone_info;
|
||||
} mot_data;
|
||||
|
||||
typedef struct mot_parent {
|
||||
typedef struct mot_key_data {
|
||||
bool key_sets_ready;
|
||||
size_t key_set_count;
|
||||
vector_old_mot_key_set key_set;
|
||||
@@ -2357,7 +2357,7 @@ typedef struct mot_parent {
|
||||
int32_t motion_id;
|
||||
float_t frame;
|
||||
struc_369 field_68;
|
||||
} mot_parent;
|
||||
} mot_key_data;
|
||||
|
||||
typedef struct bone_data {
|
||||
aft_bone_database_bone_type type;
|
||||
@@ -2388,13 +2388,24 @@ typedef struct bone_data {
|
||||
|
||||
vector_old(bone_data)
|
||||
|
||||
typedef struct struc_400 {
|
||||
bool field_0;
|
||||
bool field_1;
|
||||
bool field_2;
|
||||
bool field_3;
|
||||
bool field_4;
|
||||
float_t frame;
|
||||
float_t eyes_adjust;
|
||||
float_t prev_eyes_adjust;
|
||||
} struc_400;
|
||||
|
||||
typedef struct motion_blend motion_blend;
|
||||
|
||||
typedef struct motion_blend_vtbl {
|
||||
void(*dispose)(motion_blend*);
|
||||
void(*field_8)(motion_blend*);
|
||||
void(*field_10)(motion_blend*);
|
||||
void(*field_18)(motion_blend*, uint8_t*);
|
||||
void(*field_18)(motion_blend*, struc_400*);
|
||||
void(*field_20)(motion_blend*, vector_old_bone_data*, vector_old_bone_data*);
|
||||
void(*field_28)(motion_blend*, bone_data*, bone_data*);
|
||||
bool(*field_30)(motion_blend*);
|
||||
@@ -2439,24 +2450,13 @@ typedef struct motion_blend_combine {
|
||||
motion_blend_cross base;
|
||||
} motion_blend_combine;
|
||||
|
||||
typedef struct struc_400 {
|
||||
uint8_t field_0;
|
||||
char field_1;
|
||||
char field_2;
|
||||
char field_3;
|
||||
char field_4;
|
||||
float_t field_8;
|
||||
float_t field_C;
|
||||
float_t field_10;
|
||||
} struc_400;
|
||||
|
||||
typedef struct struc_240 {
|
||||
bool(*bone_check_func)(motion_bone_index bone_index);
|
||||
struc_313 field_8;
|
||||
size_t motion_bone_count;
|
||||
} struc_240;
|
||||
|
||||
typedef struct struc_346 {
|
||||
typedef struct mot_play_frame_data {
|
||||
float_t frame;
|
||||
float_t field_4;
|
||||
float_t field_8;
|
||||
@@ -2469,20 +2469,23 @@ typedef struct struc_346 {
|
||||
float_t field_24;
|
||||
uint8_t field_28;
|
||||
int32_t field_2C;
|
||||
} struc_346;
|
||||
} mot_play_frame_data;
|
||||
|
||||
typedef struct mot_play_data {
|
||||
mot_play_frame_data frame_data;
|
||||
int32_t field_30;
|
||||
bool field_34;
|
||||
float_t field_38;
|
||||
float_t* field_40;
|
||||
float_t* field_48;
|
||||
} mot_play_data;
|
||||
|
||||
typedef struct mot_blend {
|
||||
struc_240 field_0;
|
||||
uint8_t field_30;
|
||||
mot_parent field_38;
|
||||
struc_346 field_A8;
|
||||
int32_t field_D8;
|
||||
uint8_t field_DC;
|
||||
int32_t field_E0;
|
||||
int32_t field_E4;
|
||||
int64_t field_E8;
|
||||
int64_t field_F0;
|
||||
motion_blend field_F8;
|
||||
mot_key_data mot_key_data;
|
||||
mot_play_data mot_play_data;
|
||||
motion_blend_freeze blend;
|
||||
} mot_blend;
|
||||
|
||||
typedef struct struc_241 {
|
||||
@@ -2609,15 +2612,6 @@ typedef struct bone_data_parent {
|
||||
float_t rotation_y;
|
||||
} bone_data_parent;
|
||||
|
||||
typedef struct struc_370 {
|
||||
struc_346 field_0;
|
||||
int32_t field_30;
|
||||
bool field_34;
|
||||
float_t field_38;
|
||||
float_t* field_40;
|
||||
float_t* field_48;
|
||||
} struc_370;
|
||||
|
||||
typedef struct struc_308 {
|
||||
int32_t field_0;
|
||||
int32_t field_4;
|
||||
@@ -2629,7 +2623,7 @@ typedef struct struc_308 {
|
||||
vec3 field_9C;
|
||||
vec3 field_A8;
|
||||
float_t eyes_adjust;
|
||||
float_t field_B8;
|
||||
float_t prev_eyes_adjust;
|
||||
uint8_t field_BC;
|
||||
uint8_t field_BD;
|
||||
float_t field_C0;
|
||||
@@ -2643,11 +2637,11 @@ typedef struct motion_blend_mot {
|
||||
motion_blend_freeze freeze;
|
||||
motion_blend_combine combine;
|
||||
bone_data_parent bone_data;
|
||||
mot_parent mot_data;
|
||||
struc_370 field_4A8;
|
||||
mot_key_data mot_key_data;
|
||||
mot_play_data mot_play_data;
|
||||
struc_308 field_4F8;
|
||||
int32_t field_5CC;
|
||||
motion_blend* field_5D0;
|
||||
motion_blend* blend;
|
||||
} motion_blend_mot;
|
||||
|
||||
vector_old_ptr(motion_blend_mot)
|
||||
@@ -2693,16 +2687,16 @@ struct rob_chara_bone_data {
|
||||
struc_312 field_958;
|
||||
};
|
||||
|
||||
typedef struct struc_373 {
|
||||
typedef struct opd_blend_data {
|
||||
int32_t motion_id;
|
||||
float_t frame;
|
||||
float_t frame_count;
|
||||
uint8_t field_C;
|
||||
int32_t field_10;
|
||||
motion_blend_type type;
|
||||
float_t blend;
|
||||
} struc_373;
|
||||
} opd_blend_data;
|
||||
|
||||
vector_old(struc_373)
|
||||
vector_old(opd_blend_data)
|
||||
|
||||
typedef struct aft_obj_skin_block_node {
|
||||
char* parent_name;
|
||||
@@ -2853,12 +2847,12 @@ typedef struct ex_node_block ex_node_block;
|
||||
|
||||
typedef struct ex_node_block_vtbl {
|
||||
void* (*dispose)(ex_node_block*, bool dispose);
|
||||
void(*field_8)(ex_node_block*);
|
||||
void(*init)(ex_node_block*);
|
||||
void(*field_10)(ex_node_block*);
|
||||
void(*field_18)(ex_node_block*, int64_t, int64_t);
|
||||
void(*update)(ex_node_block*);
|
||||
void(*field_28)(ex_node_block*);
|
||||
void(*draw)(ex_node_block*);
|
||||
void(*field_20)(ex_node_block*);
|
||||
void(*set_osage_play_data)(ex_node_block*);
|
||||
void(*disp)(ex_node_block*);
|
||||
void(*reset)(ex_node_block*);
|
||||
void(*field_40)(ex_node_block*);
|
||||
void(*field_48)(ex_node_block*);
|
||||
@@ -2920,13 +2914,13 @@ typedef struct rob_osage_node_data {
|
||||
skin_param_osage_node skp_osg_node;
|
||||
} rob_osage_node_data;
|
||||
|
||||
typedef struct struc_331 {
|
||||
int64_t field_0;
|
||||
int64_t field_8;
|
||||
int64_t field_10;
|
||||
} struc_331;
|
||||
typedef struct opd_vec3_data {
|
||||
float_t* x;
|
||||
float_t* y;
|
||||
float_t* z;
|
||||
} opd_vec3_data;
|
||||
|
||||
vector_old(struc_331)
|
||||
vector_old(opd_vec3_data)
|
||||
|
||||
typedef struct struc_477 {
|
||||
float_t length;
|
||||
@@ -2938,12 +2932,12 @@ typedef struct struc_476 {
|
||||
struc_477 field_10;
|
||||
} struc_476;
|
||||
|
||||
typedef struct struc_479 {
|
||||
typedef struct rob_osage_node_reset_data {
|
||||
vec3 trans;
|
||||
vec3 trans_diff;
|
||||
vec3 rotation;
|
||||
float_t field_24;
|
||||
} struc_479;
|
||||
float_t length;
|
||||
} rob_osage_node_reset_data;
|
||||
|
||||
struct rob_osage_node {
|
||||
float_t length;
|
||||
@@ -2952,20 +2946,20 @@ struct rob_osage_node {
|
||||
vec3 trans_diff;
|
||||
vec3 field_28;
|
||||
float_t child_length;
|
||||
bone_node* bone_node;
|
||||
bone_node* bone_node_ptr;
|
||||
mat4* bone_node_mat;
|
||||
mat4u mat;
|
||||
rob_osage_node* sibling_node;
|
||||
float_t distance;
|
||||
vec3 field_94;
|
||||
struc_479 field_A0;
|
||||
rob_osage_node_reset_data reset_data;
|
||||
float_t field_C8;
|
||||
float_t field_CC;
|
||||
vec3 field_D0;
|
||||
vec3 external_force;
|
||||
float_t force;
|
||||
rob_osage_node_data* data_ptr;
|
||||
rob_osage_node_data data;
|
||||
vector_old_struc_331 field_198;
|
||||
vector_old_opd_vec3_data opd_data;
|
||||
struc_476 field_1B0;
|
||||
};
|
||||
|
||||
@@ -3024,27 +3018,36 @@ typedef struct osage_ring_data {
|
||||
vector_old_skin_param_osage_root_coli skp_root_coli;
|
||||
} osage_ring_data;
|
||||
|
||||
typedef struct struc_478 {
|
||||
int32_t field_0;
|
||||
int32_t field_4;
|
||||
int64_t field_8;
|
||||
int64_t field_10;
|
||||
} struc_478;
|
||||
typedef struct pair_int32_t_int32_t {
|
||||
int32_t key;
|
||||
int32_t value;
|
||||
} pair_int32_t_int32_t;
|
||||
|
||||
tree_def(struc_478)
|
||||
typedef struct list_rob_osage_node_reset_data_node list_rob_osage_node_reset_data_node;
|
||||
|
||||
typedef struct list_struc_479_node list_struc_479_node;
|
||||
|
||||
struct list_struc_479_node {
|
||||
list_struc_479_node* next;
|
||||
list_struc_479_node* prev;
|
||||
struc_479 value;
|
||||
struct list_rob_osage_node_reset_data_node {
|
||||
list_rob_osage_node_reset_data_node* next;
|
||||
list_rob_osage_node_reset_data_node* prev;
|
||||
rob_osage_node_reset_data value;
|
||||
};
|
||||
|
||||
typedef struct list_struc_479 {
|
||||
list_struc_479_node* head;
|
||||
typedef struct list_rob_osage_node_reset_data {
|
||||
list_rob_osage_node_reset_data_node* head;
|
||||
size_t size;
|
||||
} list_struc_479;
|
||||
} list_rob_osage_node_reset_data;
|
||||
|
||||
typedef struct pair_pair_int32_t_int32_t_list_rob_osage_node_reset_data {
|
||||
pair_int32_t_int32_t key;
|
||||
list_rob_osage_node_reset_data value;
|
||||
} pair_pair_int32_t_int32_t_list_rob_osage_node_reset_data;
|
||||
|
||||
tree_def(pair_pair_int32_t_int32_t_list_rob_osage_node_reset_data)
|
||||
typedef pair_pair_int32_t_int32_t_list_rob_osage_node_reset_data motion_reset_data;
|
||||
|
||||
typedef struct osage_setting_osg_cat {
|
||||
int32_t parts;
|
||||
size_t exf;
|
||||
} osage_setting_osg_cat;
|
||||
|
||||
typedef struct rob_osage {
|
||||
skin_param* skin_param_ptr;
|
||||
@@ -3052,8 +3055,7 @@ typedef struct rob_osage {
|
||||
vector_old_rob_osage_node nodes;
|
||||
rob_osage_node node;
|
||||
skin_param skin_param;
|
||||
int32_t field_290;
|
||||
int64_t field_298;
|
||||
osage_setting_osg_cat osage_setting;
|
||||
bool field_2A0;
|
||||
bool field_2A1;
|
||||
float_t field_2A4;
|
||||
@@ -3061,20 +3063,20 @@ typedef struct rob_osage {
|
||||
osage_coli coli_ring[64];
|
||||
vec3 wind_direction;
|
||||
float_t field_1EB4;
|
||||
int32_t field_1EB8;
|
||||
int32_t yz_order;
|
||||
int32_t field_1EBC;
|
||||
mat4* parent_mat_ptr;
|
||||
mat4u parent_mat;
|
||||
float_t move_cancel;
|
||||
bool field_1F0C;
|
||||
bool wind_reset;
|
||||
bool osage_reset;
|
||||
bool field_1F0E;
|
||||
bool field_1F0F;
|
||||
osage_ring_data ring;
|
||||
tree_struc_478 field_1F60;
|
||||
list_struc_479* field_1F70;
|
||||
bool field_1F78;
|
||||
vec3 field_1F7C;
|
||||
tree_pair_pair_int32_t_int32_t_list_rob_osage_node_reset_data motion_reset_data;
|
||||
list_rob_osage_node_reset_data* reset_data_list;
|
||||
bool set_external_force;
|
||||
vec3 external_force;
|
||||
} rob_osage;
|
||||
|
||||
typedef struct ex_osage_block {
|
||||
@@ -3090,7 +3092,7 @@ typedef struct ex_constraint_block {
|
||||
ex_node_block base;
|
||||
aft_obj_skin_block_constraint_type type;
|
||||
bone_node* source_node_bone_node;
|
||||
bone_node* direction_up_vector_old_bone_node;
|
||||
bone_node* direction_up_vector_bone_node;
|
||||
aft_obj_skin_block_constraint* cns_data;
|
||||
int64_t field_80;
|
||||
} ex_constraint_block;
|
||||
@@ -3510,11 +3512,6 @@ typedef struct aft_obj_bounding_box {
|
||||
vec3 size;
|
||||
} aft_obj_bounding_box;
|
||||
|
||||
typedef struct pair_int32_t_int32_t {
|
||||
int32_t key;
|
||||
int32_t value;
|
||||
} pair_int32_t_int32_t;
|
||||
|
||||
typedef struct texture {
|
||||
int32_t init_count;
|
||||
int32_t id;
|
||||
@@ -3647,7 +3644,7 @@ struct rob_chara_item_equip_object {
|
||||
bool disp;
|
||||
int32_t field_A4;
|
||||
mat4* field_A8;
|
||||
int32_t field_B0;
|
||||
int32_t osage_iterations;
|
||||
bone_node* bone_nodes;
|
||||
vector_old_ptr_ex_node_block node_blocks;
|
||||
vector_old_bone_node ex_data_bone_nodes;
|
||||
@@ -3717,11 +3714,11 @@ struct rob_chara_item_equip {
|
||||
int64_t field_928;
|
||||
int64_t field_930;
|
||||
float_t step;
|
||||
uint8_t field_93C;
|
||||
vector_old_struc_373 field_940;
|
||||
uint8_t field_958;
|
||||
uint8_t field_959;
|
||||
uint8_t field_95A;
|
||||
bool use_opd;
|
||||
vector_old_opd_blend_data field_940;
|
||||
bool parts_short;
|
||||
bool parts_append;
|
||||
bool parts_white_one_l;
|
||||
};
|
||||
|
||||
extern void bone_data_mult_ik(bone_data* a1, int32_t a2);
|
||||
@@ -3736,10 +3733,10 @@ extern void rob_chara_reset_data(rob_chara* a1, rob_chara_pv_data* a2);
|
||||
extern void ex_node_block_field_10(ex_node_block* node);
|
||||
|
||||
extern void* ex_osage_block_dispose(ex_osage_block* osg, bool dispose);
|
||||
extern void ex_osage_block_field_8(ex_osage_block* osg);
|
||||
extern void ex_osage_block_init(ex_osage_block* osg);
|
||||
extern void ex_osage_block_field_18(ex_osage_block* osg, int32_t a2, bool a3);
|
||||
extern void ex_osage_block_update(ex_osage_block* osg);
|
||||
extern void ex_osage_block_field_28(ex_osage_block* osg);
|
||||
extern void ex_osage_block_field_20(ex_osage_block* osg);
|
||||
extern void ex_osage_block_set_osage_play_data(ex_osage_block* osg);
|
||||
extern void ex_osage_block_disp(ex_osage_block* osg);
|
||||
extern void ex_osage_block_reset(ex_osage_block* osg);
|
||||
extern void ex_osage_block_field_40(ex_osage_block* osg);
|
||||
|
||||
+3
-3
@@ -75,11 +75,11 @@ static patch_struct patch_data[] = {
|
||||
//{ (void*)0x0000000140418870, (uint64_t)&rob_chara_data_bone_data_interpolate, },
|
||||
//{ (void*)0x0000000140418A60, (uint64_t)&rob_chara_data_bone_data_update, },
|
||||
{ (void*)0x00000001405EEAE0, (uint64_t)&ex_osage_block_dispose, },
|
||||
{ (void*)0x00000001405F3640, (uint64_t)&ex_osage_block_field_8, },
|
||||
{ (void*)0x00000001405F3640, (uint64_t)&ex_osage_block_init, },
|
||||
{ (void*)0x00000001405F39E0, (uint64_t)&ex_node_block_field_10, },
|
||||
{ (void*)0x00000001405F49F0, (uint64_t)&ex_osage_block_field_18, },
|
||||
{ (void*)0x00000001405F2140, (uint64_t)&ex_osage_block_update, },
|
||||
{ (void*)0x00000001405F2470, (uint64_t)&ex_osage_block_field_28, },
|
||||
{ (void*)0x00000001405F2140, (uint64_t)&ex_osage_block_field_20, },
|
||||
{ (void*)0x00000001405F2470, (uint64_t)&ex_osage_block_set_osage_play_data, },
|
||||
{ (void*)0x00000001405F26F0, (uint64_t)&ex_osage_block_disp, },
|
||||
{ (void*)0x00000001405F2640, (uint64_t)&ex_osage_block_reset, },
|
||||
{ (void*)0x00000001405F2860, (uint64_t)&ex_osage_block_field_40, },
|
||||
|
||||
+403
-431
File diff suppressed because it is too large
Load Diff
+6
-6
@@ -538,12 +538,12 @@ public:
|
||||
a3da();
|
||||
~a3da();
|
||||
|
||||
void read(char* path);
|
||||
void read(wchar_t* path);
|
||||
void read(void* data, size_t length);
|
||||
void write(char* path);
|
||||
void write(wchar_t* path);
|
||||
void read(const char* path);
|
||||
void read(const wchar_t* path);
|
||||
void read(const void* data, size_t length);
|
||||
void write(const char* path);
|
||||
void write(const wchar_t* path);
|
||||
void write(void** data, size_t* length);
|
||||
|
||||
static bool load_file(void* data, char* path, char* file, uint32_t hash);
|
||||
static bool load_file(void* data, const char* path, const char* file, uint32_t hash);
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ auth_3d_database_file::~auth_3d_database_file() {
|
||||
|
||||
}
|
||||
|
||||
void auth_3d_database_file::read(char* path) {
|
||||
void auth_3d_database_file::read(const char* path) {
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
@@ -45,14 +45,14 @@ void auth_3d_database_file::read(char* path) {
|
||||
free(path_bin);
|
||||
}
|
||||
|
||||
void auth_3d_database_file::read(wchar_t* path) {
|
||||
void auth_3d_database_file::read(const wchar_t* path) {
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
wchar_t* path_bin = str_utils_wadd(path, L".bin");
|
||||
if (path_wcheck_file_exists(path_bin)) {
|
||||
if (path_check_file_exists(path_bin)) {
|
||||
stream s;
|
||||
io_wopen(&s, path_bin, L"rb");
|
||||
io_open(&s, path_bin, L"rb");
|
||||
if (s.io.stream)
|
||||
auth_3d_database_file_read_inner(this, &s);
|
||||
io_free(&s);
|
||||
@@ -60,17 +60,17 @@ void auth_3d_database_file::read(wchar_t* path) {
|
||||
free(path_bin);
|
||||
}
|
||||
|
||||
void auth_3d_database_file::read(void* data, size_t length) {
|
||||
void auth_3d_database_file::read(const void* data, size_t length) {
|
||||
if (!data || !length)
|
||||
return;
|
||||
|
||||
stream s;
|
||||
io_mopen(&s, data, length);
|
||||
io_open(&s, data, length);
|
||||
auth_3d_database_file_read_inner(this, &s);
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
void auth_3d_database_file::write(char* path) {
|
||||
void auth_3d_database_file::write(const char* path) {
|
||||
if (!path || !ready)
|
||||
return;
|
||||
|
||||
@@ -83,13 +83,13 @@ void auth_3d_database_file::write(char* path) {
|
||||
free(path_bin);
|
||||
}
|
||||
|
||||
void auth_3d_database_file::write(wchar_t* path) {
|
||||
void auth_3d_database_file::write(const wchar_t* path) {
|
||||
if (!path || !ready)
|
||||
return;
|
||||
|
||||
wchar_t* path_bin = str_utils_wadd(path, L".bin");
|
||||
stream s;
|
||||
io_wopen(&s, path_bin, L"wb");
|
||||
io_open(&s, path_bin, L"wb");
|
||||
if (s.io.stream)
|
||||
auth_3d_database_file_write_inner(this, &s);
|
||||
io_free(&s);
|
||||
@@ -101,16 +101,16 @@ void auth_3d_database_file::write(void** data, size_t* length) {
|
||||
return;
|
||||
|
||||
stream s;
|
||||
io_mopen(&s, 0, 0);
|
||||
io_open(&s);
|
||||
auth_3d_database_file_write_inner(this, &s);
|
||||
io_mcopy(&s, data, length);
|
||||
io_copy(&s, data, length);
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
bool auth_3d_database_file::load_file(void* data, char* path, char* file, uint32_t hash) {
|
||||
bool auth_3d_database_file::load_file(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
size_t file_len = utf8_length(file);
|
||||
|
||||
char* t = strrchr(file, '.');
|
||||
const char* t = strrchr(file, '.');
|
||||
if (t)
|
||||
file_len = t - file;
|
||||
|
||||
@@ -314,16 +314,16 @@ static void auth_3d_database_file_read_text(auth_3d_database_file* auth_3d_db_fi
|
||||
size_t off;
|
||||
|
||||
key_val kv;
|
||||
key_val_init(&kv, (uint8_t*)data, length);
|
||||
kv.parse((uint8_t*)data, length);
|
||||
key_val lkv;
|
||||
|
||||
len = 8;
|
||||
memcpy(buf, "category", 8);
|
||||
off = len;
|
||||
|
||||
auth_3d_db_file->category = vector_old_empty(string);
|
||||
if (key_val_read_int32_t(&kv, buf, off, ".length", 8, &count)
|
||||
&& key_val_get_local_key_val(&kv, "category", &lkv)) {
|
||||
auth_3d_db_file->category.clear();
|
||||
if (kv.read_int32_t(buf, off, ".length", 8, &count)
|
||||
&& kv.get_local_key_val("category", &lkv)) {
|
||||
std::vector<std::string>& vc = auth_3d_db_file->category;
|
||||
|
||||
vc.resize(count);
|
||||
@@ -332,22 +332,21 @@ static void auth_3d_database_file_read_text(auth_3d_database_file* auth_3d_db_fi
|
||||
len1 = sprintf_s(buf + len, AUTH_3D_DATABASE_TEXT_BUF_SIZE - len, ".%d", i);
|
||||
off = len + len1;
|
||||
|
||||
key_val_read_string(&lkv,
|
||||
lkv.read_string(
|
||||
buf, off, ".value", 7, c);
|
||||
}
|
||||
key_val_free(&lkv);
|
||||
}
|
||||
|
||||
len = 3;
|
||||
memcpy(buf, "uid", 3);
|
||||
off = len;
|
||||
|
||||
auth_3d_db_file->uid = vector_old_empty(auth_3d_database_uid_file);
|
||||
if (!key_val_read_int32_t(&kv, buf, off, ".max", 5, &auth_3d_db_file->uid_max))
|
||||
auth_3d_db_file->uid.clear();
|
||||
if (!kv.read_int32_t(buf, off, ".max", 5, &auth_3d_db_file->uid_max))
|
||||
auth_3d_db_file->uid_max = -1;
|
||||
|
||||
if (key_val_read_int32_t(&kv, buf, off, ".length", 8, &count)
|
||||
&& key_val_get_local_key_val(&kv, "uid", &lkv)) {
|
||||
if (kv.read_int32_t(buf, off, ".length", 8, &count)
|
||||
&& kv.get_local_key_val("uid", &lkv)) {
|
||||
std::vector<auth_3d_database_uid_file>& vu = auth_3d_db_file->uid;
|
||||
|
||||
vu.resize(count);
|
||||
@@ -356,21 +355,18 @@ static void auth_3d_database_file_read_text(auth_3d_database_file* auth_3d_db_fi
|
||||
len1 = sprintf_s(buf + len, AUTH_3D_DATABASE_TEXT_BUF_SIZE - len, ".%d", i);
|
||||
off = len + len1;
|
||||
|
||||
key_val_read_string(&lkv,
|
||||
lkv.read_string(
|
||||
buf, off, ".category", 10, &u->category);
|
||||
if (key_val_read_int32_t(&lkv,
|
||||
if (lkv.read_int32_t(
|
||||
buf, off, ".org_uid", 9, &u->org_uid))
|
||||
enum_or(u->flags, AUTH_3D_DATABASE_UID_ORG_UID);
|
||||
if (key_val_read_float_t(&lkv,
|
||||
if (lkv.read_float_t(
|
||||
buf, off, ".size", 6, &u->size))
|
||||
enum_or(u->flags, AUTH_3D_DATABASE_UID_SIZE);
|
||||
key_val_read_string(&lkv,
|
||||
lkv.read_string(
|
||||
buf, off, ".value", 7, &u->value);
|
||||
}
|
||||
key_val_free(&lkv);
|
||||
}
|
||||
|
||||
key_val_free(&kv);
|
||||
}
|
||||
|
||||
static void auth_3d_database_file_write_text(auth_3d_database_file* auth_3d_db_file, void** data, size_t* length) {
|
||||
@@ -381,12 +377,11 @@ static void auth_3d_database_file_write_text(auth_3d_database_file* auth_3d_db_f
|
||||
size_t off;
|
||||
|
||||
stream s;
|
||||
io_mopen(&s, 0, 0);
|
||||
io_open(&s);
|
||||
|
||||
io_write(&s, "#A3DA__________\n", 16);
|
||||
io_write(&s, "# date time was eliminated.\n", 28);
|
||||
|
||||
vector_old_int32_t sort_index = vector_old_empty(int32_t);
|
||||
if (auth_3d_db_file->category.size() > 0) {
|
||||
len = 8;
|
||||
memcpy(buf, "category", 8);
|
||||
@@ -394,19 +389,19 @@ static void auth_3d_database_file_write_text(auth_3d_database_file* auth_3d_db_f
|
||||
|
||||
std::vector<std::string>& vc = auth_3d_db_file->category;
|
||||
count = (int32_t)vc.size();
|
||||
key_val_get_lexicographic_order(&sort_index, count);
|
||||
if (sort_index.begin)
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
std::string* c = &vc[sort_index.begin[i]];
|
||||
std::vector<int32_t> sort_index;
|
||||
key_val::get_lexicographic_order(&sort_index, count);
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
std::string* c = &vc[sort_index[i]];
|
||||
|
||||
len1 = sprintf_s(buf + len, AUTH_3D_DATABASE_TEXT_BUF_SIZE - len, ".%d", sort_index.begin[i]);
|
||||
off = len + len1;
|
||||
len1 = sprintf_s(buf + len, AUTH_3D_DATABASE_TEXT_BUF_SIZE - len, ".%d", sort_index[i]);
|
||||
off = len + len1;
|
||||
|
||||
key_val_write_string(&s, buf, off, ".value", 7, c);
|
||||
}
|
||||
key_val::write_string(&s, buf, off, ".value", 7, c);
|
||||
}
|
||||
|
||||
off = len;
|
||||
key_val_write_int32_t(&s, buf, off, ".length", 8, count);
|
||||
key_val::write_int32_t(&s, buf, off, ".length", 8, count);
|
||||
}
|
||||
|
||||
if (auth_3d_db_file->uid.size() > 0) {
|
||||
@@ -417,35 +412,33 @@ static void auth_3d_database_file_write_text(auth_3d_database_file* auth_3d_db_f
|
||||
int32_t uid_max = -1;
|
||||
std::vector<auth_3d_database_uid_file>& vu = auth_3d_db_file->uid;
|
||||
count = (int32_t)vu.size();
|
||||
key_val_get_lexicographic_order(&sort_index, count);
|
||||
if (sort_index.begin)
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
auth_3d_database_uid_file* u = &vu[sort_index.begin[i]];
|
||||
std::vector<int32_t> sort_index;
|
||||
key_val::get_lexicographic_order(&sort_index, count);
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
auth_3d_database_uid_file* u = &vu[sort_index[i]];
|
||||
|
||||
len1 = sprintf_s(buf + len, AUTH_3D_DATABASE_TEXT_BUF_SIZE - len, ".%d", sort_index.begin[i]);
|
||||
off = len + len1;
|
||||
len1 = sprintf_s(buf + len, AUTH_3D_DATABASE_TEXT_BUF_SIZE - len, ".%d", sort_index[i]);
|
||||
off = len + len1;
|
||||
|
||||
key_val_write_string(&s, buf, off, ".category", 10, &u->category);
|
||||
if ((int32_t)(u->flags & AUTH_3D_DATABASE_UID_ORG_UID))
|
||||
key_val_write_int32_t(&s, buf, off, ".org_uid", 9, u->org_uid);
|
||||
if ((int32_t)(u->flags & AUTH_3D_DATABASE_UID_SIZE))
|
||||
key_val_write_float_t(&s, buf, off, ".size", 6, u->size);
|
||||
key_val_write_string(&s, buf, off, ".value", 7, &u->value);
|
||||
key_val::write_string(&s, buf, off, ".category", 10, &u->category);
|
||||
if ((int32_t)(u->flags & AUTH_3D_DATABASE_UID_ORG_UID))
|
||||
key_val::write_int32_t(&s, buf, off, ".org_uid", 9, u->org_uid);
|
||||
if ((int32_t)(u->flags & AUTH_3D_DATABASE_UID_SIZE))
|
||||
key_val::write_float_t(&s, buf, off, ".size", 6, u->size);
|
||||
key_val::write_string(&s, buf, off, ".value", 7, &u->value);
|
||||
|
||||
if ((int32_t)(u->flags & AUTH_3D_DATABASE_UID_ORG_UID) && u->org_uid > uid_max)
|
||||
uid_max = u->org_uid;
|
||||
}
|
||||
if ((int32_t)(u->flags & AUTH_3D_DATABASE_UID_ORG_UID) && u->org_uid > uid_max)
|
||||
uid_max = u->org_uid;
|
||||
}
|
||||
|
||||
if (uid_max == 0)
|
||||
uid_max = count;
|
||||
|
||||
off = len;
|
||||
key_val_write_int32_t(&s, buf, off, ".length", 8, count);
|
||||
key_val_write_int32_t(&s, buf, off, ".max", 5, uid_max);
|
||||
key_val::write_int32_t(&s, buf, off, ".length", 8, count);
|
||||
key_val::write_int32_t(&s, buf, off, ".max", 5, uid_max);
|
||||
}
|
||||
|
||||
vector_old_int32_t_free(&sort_index, 0);
|
||||
|
||||
io_mcopy(&s, data, length);
|
||||
io_copy(&s, data, length);
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
@@ -58,14 +58,14 @@ public:
|
||||
auth_3d_database_file();
|
||||
~auth_3d_database_file();
|
||||
|
||||
void read(char* path);
|
||||
void read(wchar_t* path);
|
||||
void read(void* data, size_t length);
|
||||
void write(char* path);
|
||||
void write(wchar_t* path);
|
||||
void read(const char* path);
|
||||
void read(const wchar_t* path);
|
||||
void read(const void* data, size_t length);
|
||||
void write(const char* path);
|
||||
void write(const wchar_t* path);
|
||||
void write(void** data, size_t* length);
|
||||
|
||||
static bool load_file(void* data, char* path, char* file, uint32_t hash);
|
||||
static bool load_file(void* data, const char* path, const char* file, uint32_t hash);
|
||||
};
|
||||
|
||||
class auth_3d_database {
|
||||
|
||||
+422
-490
File diff suppressed because it is too large
Load Diff
+48
-52
@@ -5,10 +5,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../default.h"
|
||||
#include "../string.h"
|
||||
#include "../vec.h"
|
||||
#include "../vector.h"
|
||||
|
||||
typedef enum bone_database_bone_type {
|
||||
BONE_DATABASE_BONE_ROTATION = 0x00,
|
||||
@@ -35,72 +35,68 @@ typedef enum bone_database_skeleton_type {
|
||||
BONE_DATABASE_SKELETON_NONE = -1,
|
||||
} bone_database_skeleton_type;
|
||||
|
||||
typedef struct bone_database_bone {
|
||||
class bone_database_bone {
|
||||
public:
|
||||
bone_database_bone_type type;
|
||||
bool has_parent;
|
||||
uint8_t parent;
|
||||
uint8_t pole_target;
|
||||
uint8_t mirror;
|
||||
uint8_t flags;
|
||||
string name;
|
||||
} bone_database_bone;
|
||||
std::string name;
|
||||
|
||||
vector_old(bone_database_bone)
|
||||
bone_database_bone();
|
||||
~bone_database_bone();
|
||||
};
|
||||
|
||||
typedef struct bone_database_skeleton {
|
||||
vector_old_bone_database_bone bone;
|
||||
vector_old_vec3 position;
|
||||
class bone_database_skeleton {
|
||||
public:
|
||||
std::vector<bone_database_bone> bone;
|
||||
std::vector<vec3> position;
|
||||
float_t heel_height;
|
||||
vector_old_string object_bone;
|
||||
vector_old_string motion_bone;
|
||||
vector_old_uint16_t parent_index;
|
||||
string name;
|
||||
} bone_database_skeleton;
|
||||
std::vector<std::string> object_bone;
|
||||
std::vector<std::string> motion_bone;
|
||||
std::vector<uint16_t> parent_index;
|
||||
std::string name;
|
||||
|
||||
vector_old(bone_database_skeleton)
|
||||
bone_database_skeleton();
|
||||
~bone_database_skeleton();
|
||||
};
|
||||
|
||||
typedef struct bone_database {
|
||||
class bone_database {
|
||||
public:
|
||||
bool ready;
|
||||
bool modern;
|
||||
bool is_x;
|
||||
|
||||
vector_old_bone_database_skeleton skeleton;
|
||||
} bone_database;
|
||||
std::vector<bone_database_skeleton> skeleton;
|
||||
|
||||
extern void bone_database_init(bone_database* bone_data);
|
||||
extern void bone_database_read(bone_database* bone_data, char* path, bool modern);
|
||||
extern void bone_database_wread(bone_database* bone_data, wchar_t* path, bool modern);
|
||||
extern void bone_database_mread(bone_database* bone_data, void* data, size_t length, bool modern);
|
||||
extern void bone_database_write(bone_database* bone_data, char* path);
|
||||
extern void bone_database_wwrite(bone_database* bone_data, wchar_t* path);
|
||||
extern void bone_database_mwrite(bone_database* bone_data, void** data, size_t* length);
|
||||
extern bool bone_database_load_file(void* data, char* path, char* file, uint32_t hash);
|
||||
extern void bone_database_bones_calculate_count(vector_old_bone_database_bone* bones, size_t* object_bone_count,
|
||||
bone_database();
|
||||
~bone_database();
|
||||
|
||||
void read(const char* path, bool modern);
|
||||
void read(const wchar_t* path, bool modern);
|
||||
void read(const void* data, size_t length, bool modern);
|
||||
void write(const char* path);
|
||||
void write(const wchar_t* path);
|
||||
void write(void** data, size_t* length);
|
||||
|
||||
|
||||
bool get_skeleton(const char* name, bone_database_skeleton** skeleton);
|
||||
int32_t get_skeleton_bone_index(const char* name, const char* bone_name);
|
||||
bool get_skeleton_bones(const char* name, std::vector<bone_database_bone>** bone);
|
||||
bool get_skeleton_positions(const char* name, std::vector<vec3>** positions);
|
||||
int32_t get_skeleton_object_bone_index(const char* name, char* bone_name);
|
||||
bool get_skeleton_object_bones(const char* name, std::vector<std::string>** object_bones);
|
||||
int32_t get_skeleton_motion_bone_index(const char* name, char* bone_name);
|
||||
bool get_skeleton_motion_bones(const char* name, std::vector<std::string>** motion_bones);
|
||||
bool get_skeleton_parent_indices(const char* name, std::vector<uint16_t>** parent_indices);
|
||||
bool get_skeleton_heel_height(const char* name, float_t** unknown_value);
|
||||
|
||||
static bool load_file(void* data, const char* path, const char* file, uint32_t hash);
|
||||
};
|
||||
|
||||
extern void bone_database_bones_calculate_count(std::vector<bone_database_bone>* bones, size_t* object_bone_count,
|
||||
size_t* motion_bone_count, size_t* total_bone_count, size_t* ik_bone_count, size_t* chain_pos);
|
||||
extern bool bone_database_get_skeleton(bone_database* bone_data,
|
||||
char* name, bone_database_skeleton** skeleton);
|
||||
extern int32_t bone_database_get_skeleton_bone_index(bone_database* bone_data,
|
||||
const char* name, char* bone_name);
|
||||
extern int32_t bone_database_get_skeleton_bone_index(bone_database* bone_data,
|
||||
const char* name, const char* bone_name);
|
||||
extern bool bone_database_get_skeleton_bones(bone_database* bone_data,
|
||||
char* name, vector_old_bone_database_bone** bone);
|
||||
extern bool bone_database_get_skeleton_positions(bone_database* bone_data,
|
||||
char* name, vector_old_vec3** positions);
|
||||
extern int32_t bone_database_get_skeleton_object_bone_index(bone_database* bone_data,
|
||||
char* name, char* bone_name);
|
||||
extern bool bone_database_get_skeleton_object_bones(bone_database* bone_data,
|
||||
char* name, vector_old_string** object_bones);
|
||||
extern int32_t bone_database_get_skeleton_motion_bone_index(bone_database* bone_data,
|
||||
char* name, char* bone_name);
|
||||
extern bool bone_database_get_skeleton_motion_bones(bone_database* bone_data,
|
||||
char* name, vector_old_string** motion_bones);
|
||||
extern bool bone_database_get_skeleton_parent_indices(bone_database* bone_data,
|
||||
char* name, vector_old_uint16_t** parent_indices);
|
||||
extern bool bone_database_get_skeleton_heel_height(bone_database* bone_data,
|
||||
char* name, float_t** unknown_value);
|
||||
extern void bone_database_free(bone_database* bone_data);
|
||||
|
||||
extern const char* bone_database_skeleton_type_to_string(bone_database_skeleton_type type);
|
||||
extern void bone_database_bone_free(bone_database_bone* bone);
|
||||
extern void bone_database_skeleton_free(bone_database_skeleton* skel);
|
||||
|
||||
@@ -0,0 +1,376 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "item_table.h"
|
||||
#include "../io/path.h"
|
||||
#include "../io/stream.h"
|
||||
#include "../key_val.h"
|
||||
#include "../sort.h"
|
||||
#include "../str_utils.h"
|
||||
|
||||
#define ITEM_TABLE_TEXT_BUF_SIZE 0x400
|
||||
|
||||
static void itm_table_read_inner(itm_table* itm_tbl, stream* s);
|
||||
static void itm_table_write_inner(itm_table* itm_tbl, stream* s);
|
||||
static void itm_table_read_text(itm_table* itm_tbl, void* data, size_t length);
|
||||
static void itm_table_write_text(itm_table* itm_tbl, void** data, size_t* length);
|
||||
|
||||
itm_table::itm_table() : ready() {
|
||||
|
||||
}
|
||||
|
||||
itm_table::~itm_table() {
|
||||
|
||||
}
|
||||
|
||||
void itm_table::read(const char* path) {
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
char* path_bin = str_utils_add(path, ".txt");
|
||||
if (path_check_file_exists(path_bin)) {
|
||||
stream s;
|
||||
io_open(&s, path_bin, "rb");
|
||||
if (s.io.stream)
|
||||
itm_table_read_inner(this, &s);
|
||||
io_free(&s);
|
||||
}
|
||||
free(path_bin);
|
||||
}
|
||||
|
||||
void itm_table::read(const wchar_t* path) {
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
wchar_t* path_bin = str_utils_wadd(path, L".txt");
|
||||
if (path_check_file_exists(path_bin)) {
|
||||
stream s;
|
||||
io_open(&s, path_bin, L"rb");
|
||||
if (s.io.stream)
|
||||
itm_table_read_inner(this, &s);
|
||||
io_free(&s);
|
||||
}
|
||||
free(path_bin);
|
||||
}
|
||||
|
||||
void itm_table::read(const void* data, size_t length) {
|
||||
if (!data || !length)
|
||||
return;
|
||||
|
||||
stream s;
|
||||
io_open(&s, data, length);
|
||||
itm_table_read_inner(this, &s);
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
void itm_table::write(const char* path) {
|
||||
if (!path || !ready)
|
||||
return;
|
||||
|
||||
char* path_bin = str_utils_add(path, ".txt");
|
||||
stream s;
|
||||
io_open(&s, path_bin, "wb");
|
||||
if (s.io.stream)
|
||||
itm_table_write_inner(this, &s);
|
||||
io_free(&s);
|
||||
free(path_bin);
|
||||
}
|
||||
|
||||
void itm_table::write(const wchar_t* path) {
|
||||
if (!path || !ready)
|
||||
return;
|
||||
|
||||
wchar_t* path_bin = str_utils_wadd(path, L".txt");
|
||||
stream s;
|
||||
io_open(&s, path_bin, L"wb");
|
||||
if (s.io.stream)
|
||||
itm_table_write_inner(this, &s);
|
||||
io_free(&s);
|
||||
free(path_bin);
|
||||
}
|
||||
|
||||
void itm_table::write(void** data, size_t* length) {
|
||||
if (!data || !length || !ready)
|
||||
return;
|
||||
|
||||
stream s;
|
||||
io_open(&s);
|
||||
itm_table_write_inner(this, &s);
|
||||
io_copy(&s, data, length);
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
bool itm_table::load_file(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
size_t file_len = utf8_length(file);
|
||||
|
||||
const char* t = strrchr(file, '.');
|
||||
if (t)
|
||||
file_len = t - file;
|
||||
|
||||
string s;
|
||||
string_init(&s, path);
|
||||
string_add_length(&s, file, file_len);
|
||||
|
||||
itm_table* itm_tbl = (itm_table*)data;
|
||||
itm_tbl->read(string_data(&s));
|
||||
|
||||
string_free(&s);
|
||||
return itm_tbl->ready;
|
||||
}
|
||||
|
||||
itm_table_itm_data::itm_table_itm_data() {
|
||||
|
||||
}
|
||||
|
||||
itm_table_itm_data::~itm_table_itm_data() {
|
||||
|
||||
}
|
||||
|
||||
itm_table_item::itm_table_item() : flag(), type(), attr(), des_id(),
|
||||
sub_id(), exclusion_point(), field_AC(), org_itm(), npr_flag(), face_depth() {
|
||||
|
||||
}
|
||||
|
||||
itm_table_item::~itm_table_item() {
|
||||
|
||||
}
|
||||
|
||||
itm_table_cos::itm_table_cos() : id() {
|
||||
|
||||
}
|
||||
|
||||
itm_table_cos::~itm_table_cos() {
|
||||
|
||||
}
|
||||
|
||||
itm_table_dbgset::itm_table_dbgset() {
|
||||
|
||||
}
|
||||
|
||||
itm_table_dbgset::~itm_table_dbgset() {
|
||||
|
||||
}
|
||||
|
||||
static void itm_table_read_inner(itm_table* itm_tbl, stream* s) {
|
||||
void* itm_tbl_data = force_malloc(s->length);
|
||||
io_read(s, itm_tbl_data, s->length);
|
||||
itm_table_read_text(itm_tbl, itm_tbl_data, s->length);
|
||||
free(itm_tbl_data);
|
||||
|
||||
itm_tbl->ready = true;
|
||||
}
|
||||
|
||||
static void itm_table_write_inner(itm_table* itm_tbl, stream* s) {
|
||||
void* itm_tbl_data = 0;
|
||||
size_t itm_tbl_data_length = 0;
|
||||
itm_table_write_text(itm_tbl, &itm_tbl_data, &itm_tbl_data_length);
|
||||
io_write(s, itm_tbl_data, itm_tbl_data_length);
|
||||
free(itm_tbl_data);
|
||||
}
|
||||
|
||||
static void itm_table_read_text(itm_table* itm_tbl, void* data, size_t length) {
|
||||
char buf[ITEM_TABLE_TEXT_BUF_SIZE];
|
||||
int32_t count;
|
||||
int32_t count1;
|
||||
size_t len;
|
||||
size_t len1;
|
||||
size_t len2;
|
||||
size_t len3;
|
||||
size_t off;
|
||||
|
||||
key_val kv;
|
||||
kv.parse((uint8_t*)data, length);
|
||||
key_val lkv;
|
||||
|
||||
len = 3;
|
||||
memcpy(buf, "cos", 3);
|
||||
off = len;
|
||||
|
||||
itm_tbl->item.clear();
|
||||
if (kv.read_int32_t(buf, off, ".length", 8, &count)
|
||||
&& kv.get_local_key_val("cos", &lkv)) {
|
||||
std::vector<itm_table_cos>& vc = itm_tbl->cos;
|
||||
|
||||
vc.resize(count);
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
itm_table_cos* c = &vc[i];
|
||||
|
||||
len1 = sprintf_s(buf + len, ITEM_TABLE_TEXT_BUF_SIZE - len, ".%d", i);
|
||||
off = len + len1;
|
||||
|
||||
lkv.read_int32_t(
|
||||
buf, off, ".id", 4, &c->id);
|
||||
|
||||
len2 = 5;
|
||||
memcpy(buf + len + len1, ".item", 5);
|
||||
off = len + len1 + len2;
|
||||
|
||||
if (off >= 0 && off < ITEM_TABLE_TEXT_BUF_SIZE)
|
||||
buf[off] = 0;
|
||||
key_val sub_local_key_val;
|
||||
if (lkv.read_int32_t(buf, off, ".length", 8, &count1)
|
||||
&& lkv.get_local_key_val(buf, &sub_local_key_val)) {
|
||||
std::vector<int32_t>& vci = c->item;
|
||||
|
||||
vci.resize(count1);
|
||||
for (int32_t j = 0; j < count1; j++) {
|
||||
len3 = sprintf_s(buf + len + len1 + len2,
|
||||
ITEM_TABLE_TEXT_BUF_SIZE - len - len1 - len2, ".%d", j);
|
||||
off = len + len1 + len2 + len3;
|
||||
|
||||
sub_local_key_val.read_int32_t(
|
||||
buf, off, "", 1, &vci[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
len = 6;
|
||||
memcpy(buf, "dbgset", 6);
|
||||
off = len;
|
||||
|
||||
itm_tbl->item.clear();
|
||||
if (kv.read_int32_t(buf, off, ".length", 8, &count)
|
||||
&& kv.get_local_key_val("dbgset", &lkv)) {
|
||||
std::vector<itm_table_dbgset>& vd = itm_tbl->dbgset;
|
||||
|
||||
vd.resize(count);
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
itm_table_dbgset* d = &vd[i];
|
||||
|
||||
len1 = sprintf_s(buf + len, ITEM_TABLE_TEXT_BUF_SIZE - len, ".%d", i);
|
||||
off = len + len1;
|
||||
|
||||
len2 = 5;
|
||||
memcpy(buf + len + len1, ".item", 5);
|
||||
off = len + len1 + len2;
|
||||
|
||||
if (off >= 0 && off < ITEM_TABLE_TEXT_BUF_SIZE)
|
||||
buf[off] = 0;
|
||||
key_val sub_local_key_val;
|
||||
if (lkv.read_int32_t(buf, off, ".length", 8, &count1)
|
||||
&& lkv.get_local_key_val(buf, &sub_local_key_val)) {
|
||||
std::vector<int32_t>& vdi = d->item;
|
||||
|
||||
vdi.resize(count1);
|
||||
for (int32_t j = 0; j < count1; j++) {
|
||||
len3 = sprintf_s(buf + len + len1 + len2,
|
||||
ITEM_TABLE_TEXT_BUF_SIZE - len - len1 - len2, ".%d", j);
|
||||
off = len + len1 + len2 + len3;
|
||||
|
||||
sub_local_key_val.read_int32_t(
|
||||
buf, off, "", 1, &vdi[j]);
|
||||
}
|
||||
}
|
||||
|
||||
off = len + len1;
|
||||
lkv.read_string(
|
||||
buf, off, ".name", 6, &d->name);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void itm_table_write_text(itm_table* itm_tbl, void** data, size_t* length) {
|
||||
char buf[ITEM_TABLE_TEXT_BUF_SIZE];
|
||||
int32_t count;
|
||||
int32_t count1;
|
||||
size_t len;
|
||||
size_t len1;
|
||||
size_t len2;
|
||||
size_t len3;
|
||||
size_t off;
|
||||
|
||||
stream s;
|
||||
io_open(&s);
|
||||
|
||||
if (itm_tbl->cos.size() > 0) {
|
||||
len = 3;
|
||||
memcpy(buf, "cos", 3);
|
||||
off = len;
|
||||
|
||||
std::vector<itm_table_cos>& vc = itm_tbl->cos;
|
||||
count = (int32_t)vc.size();
|
||||
std::vector<int32_t> sort_index;
|
||||
key_val::get_lexicographic_order(&sort_index, count);
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
itm_table_cos* c = &vc[sort_index[i]];
|
||||
|
||||
len1 = sprintf_s(buf + len, ITEM_TABLE_TEXT_BUF_SIZE - len, ".%d", sort_index[i]);
|
||||
off = len + len1;
|
||||
|
||||
key_val::write_int32_t(&s, buf, off, ".id", 4, c->id);
|
||||
|
||||
len2 = 5;
|
||||
memcpy(buf + len + len1, ".item", 5);
|
||||
off = len + len1 + len2;
|
||||
|
||||
std::vector<int32_t>& vci = c->item;
|
||||
count1 = (int32_t)vci.size();
|
||||
std::vector<int32_t> sort_index1;
|
||||
key_val::get_lexicographic_order(&sort_index1, count1);
|
||||
for (int32_t j = 0; j < count1; j++) {
|
||||
len3 = sprintf_s(buf + len + len1 + len2,
|
||||
ITEM_TABLE_TEXT_BUF_SIZE - len - len1 - len2, ".%d", sort_index1[j]);
|
||||
off = len + len1 + len2 + len3;
|
||||
|
||||
key_val::write_int32_t(&s,
|
||||
buf, off, "", 1, vci[sort_index1[j]]);
|
||||
}
|
||||
|
||||
off = len + len1 + len2;
|
||||
key_val::write_int32_t(&s, buf, off, ".length", 8, count1);
|
||||
}
|
||||
|
||||
off = len;
|
||||
key_val::write_int32_t(&s, buf, off, ".length", 8, count);
|
||||
}
|
||||
|
||||
if (itm_tbl->dbgset.size() > 0) {
|
||||
len = 6;
|
||||
memcpy(buf, "dbgset", 6);
|
||||
off = len;
|
||||
|
||||
std::vector<itm_table_dbgset>& vc = itm_tbl->dbgset;
|
||||
count = (int32_t)vc.size();
|
||||
std::vector<int32_t> sort_index;
|
||||
key_val::get_lexicographic_order(&sort_index, count);
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
itm_table_dbgset* d = &vc[sort_index[i]];
|
||||
|
||||
len1 = sprintf_s(buf + len, ITEM_TABLE_TEXT_BUF_SIZE - len, ".%d", sort_index[i]);
|
||||
off = len + len1;
|
||||
|
||||
len2 = 5;
|
||||
memcpy(buf + len + len1, ".item", 5);
|
||||
off = len + len1 + len2;
|
||||
|
||||
std::vector<int32_t>& vdi = d->item;
|
||||
count1 = (int32_t)vdi.size();
|
||||
std::vector<int32_t> sort_index1;
|
||||
key_val::get_lexicographic_order(&sort_index1, count1);
|
||||
for (int32_t j = 0; j < count1; j++) {
|
||||
len3 = sprintf_s(buf + len + len1 + len2,
|
||||
ITEM_TABLE_TEXT_BUF_SIZE - len - len1 - len2, ".%d", sort_index1[j]);
|
||||
off = len + len1 + len2 + len3;
|
||||
|
||||
key_val::write_int32_t(&s,
|
||||
buf, off, "", 1, vdi[sort_index1[j]]);
|
||||
}
|
||||
|
||||
off = len + len1 + len2;
|
||||
key_val::write_int32_t(&s, buf, off, ".length", 8, count1);
|
||||
|
||||
off = len + len1;
|
||||
key_val::write_string(&s, buf, off, ".name", 6, &d->name);
|
||||
}
|
||||
|
||||
off = len;
|
||||
key_val::write_int32_t(&s, buf, off, ".length", 8, count);
|
||||
}
|
||||
|
||||
io_copy(&s, data, length);
|
||||
io_free(&s);
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../default.h"
|
||||
#include "../vec.h"
|
||||
|
||||
typedef enum itm_id {
|
||||
ITM_NONE = -1,
|
||||
ITM_BODY = 0x00,
|
||||
ITM_ATAMA = 0x01,
|
||||
ITM_KATA_R = 0x02,
|
||||
ITM_MUNE = 0x03,
|
||||
ITM_KATA_L = 0x04,
|
||||
ITM_UDE_R = 0x05,
|
||||
ITM_SENAKA = 0x06,
|
||||
ITM_UDE_L = 0x07,
|
||||
ITM_HARA = 0x08,
|
||||
ITM_KOSI = 0x09,
|
||||
ITM_TE_R = 0x0A,
|
||||
ITM_TE_L = 0x0B,
|
||||
ITM_MOMO = 0x0C,
|
||||
ITM_SUNE = 0x0D,
|
||||
ITM_ASI = 0x0E,
|
||||
ITM_KAMI = 0x0F,
|
||||
ITM_OUTER = 0x10,
|
||||
ITM_PANTS = 0x11,
|
||||
ITM_ZUJO = 0x12,
|
||||
ITM_MEGANE = 0x13,
|
||||
ITM_KUBI = 0x14,
|
||||
ITM_JOHA_USHIRO = 0x15,
|
||||
ITM_KUCHI = 0x16,
|
||||
ITM_ITEM09 = 0x17,
|
||||
ITM_ITEM10 = 0x18,
|
||||
ITM_ITEM11 = 0x19,
|
||||
ITM_ITEM12 = 0x1A,
|
||||
ITM_ITEM13 = 0x1B,
|
||||
ITM_ITEM14 = 0x1C,
|
||||
ITM_ITEM15 = 0x1D,
|
||||
ITM_ITEM16 = 0x1E,
|
||||
ITM_MAX = 0x1F,
|
||||
} itm_id;
|
||||
|
||||
typedef enum itm_sub_id {
|
||||
ITM_SUB_NONE = -1,
|
||||
ITM_SUB_ZUJO = 0x00,
|
||||
ITM_SUB_KAMI = 0x01,
|
||||
ITM_SUB_HITAI = 0x02,
|
||||
ITM_SUB_ME = 0x03,
|
||||
ITM_SUB_MEGANE = 0x04,
|
||||
ITM_SUB_MIMI = 0x05,
|
||||
ITM_SUB_KUCHI = 0x06,
|
||||
ITM_SUB_MAKI = 0x07,
|
||||
ITM_SUB_KUBI = 0x08,
|
||||
ITM_SUB_INNER = 0x09,
|
||||
ITM_SUB_OUTER = 0x0A,
|
||||
ITM_SUB_JOHA_MAE = 0x0B,
|
||||
ITM_SUB_JOHA_USHIRO = 0x0C,
|
||||
ITM_SUB_HADA = 0x0D,
|
||||
ITM_SUB_KATA = 0x0E,
|
||||
ITM_SUB_U_UDE = 0x0F,
|
||||
ITM_SUB_L_UDE = 0x10,
|
||||
ITM_SUB_TE = 0x11,
|
||||
ITM_SUB_BELT = 0x12,
|
||||
ITM_SUB_COSI = 0x13,
|
||||
ITM_SUB_PANTS = 0x14,
|
||||
ITM_SUB_ASI = 0x15,
|
||||
ITM_SUB_SUNE = 0x16,
|
||||
ITM_SUB_KUTSU = 0x17,
|
||||
ITM_SUB_HEAD = 0x18,
|
||||
ITM_SUB_MAX = 0x19,
|
||||
} itm_sub_id;
|
||||
|
||||
typedef struct itm_table_itm_data_obj {
|
||||
std::string uid;
|
||||
itm_id rpk;
|
||||
} itm_table_itm_data_obj;
|
||||
|
||||
typedef struct itm_table_itm_data_ofs {
|
||||
itm_sub_id sub_id;
|
||||
int32_t no;
|
||||
vec3 position;
|
||||
vec3 rotation;
|
||||
vec3 scale;
|
||||
} itm_table_itm_data_ofs;
|
||||
|
||||
typedef struct itm_table_itm_data_tex {
|
||||
std::string org;
|
||||
std::string chg;
|
||||
} itm_table_itm_data_tex;
|
||||
|
||||
typedef struct itm_table_itm_data_col_data {
|
||||
vec3 blend;
|
||||
vec3 offset;
|
||||
float_t hue;
|
||||
float_t saturation;
|
||||
float_t value;
|
||||
float_t constrast;
|
||||
bool inverse;
|
||||
} itm_table_itm_data_col_data;
|
||||
|
||||
typedef struct itm_table_itm_data_col {
|
||||
std::string tex;
|
||||
int32_t flag;
|
||||
itm_table_itm_data_col_data data;
|
||||
} itm_table_itm_data_col;
|
||||
|
||||
class itm_table_itm_data {
|
||||
public:
|
||||
std::vector<itm_table_itm_data_obj> obj;
|
||||
std::vector<itm_table_itm_data_ofs> ofs;
|
||||
std::vector<itm_table_itm_data_tex> tex;
|
||||
std::vector<itm_table_itm_data_col> col;
|
||||
|
||||
itm_table_itm_data();
|
||||
~itm_table_itm_data();
|
||||
};
|
||||
|
||||
class itm_table_item {
|
||||
public:
|
||||
int32_t flag;
|
||||
std::string name;
|
||||
std::vector<std::string> objset;
|
||||
int32_t type;
|
||||
int32_t attr;
|
||||
int32_t des_id;
|
||||
itm_sub_id sub_id;
|
||||
itm_table_itm_data data;
|
||||
int32_t exclusion_point;
|
||||
int32_t field_AC;
|
||||
int32_t org_itm;
|
||||
bool npr_flag;
|
||||
float_t face_depth;
|
||||
|
||||
itm_table_item();
|
||||
~itm_table_item();
|
||||
};
|
||||
|
||||
class itm_table_cos {
|
||||
public:
|
||||
int32_t id;
|
||||
std::vector<int32_t> item;
|
||||
|
||||
itm_table_cos();
|
||||
~itm_table_cos();
|
||||
};
|
||||
|
||||
class itm_table_dbgset {
|
||||
public:
|
||||
std::string name;
|
||||
std::vector<int32_t> item;
|
||||
|
||||
itm_table_dbgset();
|
||||
~itm_table_dbgset();
|
||||
};
|
||||
|
||||
class itm_table {
|
||||
public:
|
||||
bool ready;
|
||||
|
||||
std::vector<std::pair<int32_t, itm_table_item>> item;
|
||||
std::vector<itm_table_cos> cos;
|
||||
std::vector<itm_table_dbgset> dbgset;
|
||||
|
||||
itm_table();
|
||||
~itm_table();
|
||||
|
||||
void read(const char* path);
|
||||
void read(const wchar_t* path);
|
||||
void read(const void* data, size_t length);
|
||||
void write(const char* path);
|
||||
void write(const wchar_t* path);
|
||||
void write(void** data, size_t* length);
|
||||
|
||||
static bool load_file(void* data, const char* path, const char* file, uint32_t hash);
|
||||
};
|
||||
@@ -21,7 +21,7 @@ motion_database::~motion_database() {
|
||||
|
||||
}
|
||||
|
||||
void motion_database::read(char* path) {
|
||||
void motion_database::read(const char* path) {
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
@@ -33,7 +33,7 @@ void motion_database::read(char* path) {
|
||||
farc_file* ff = f.read_file("mot_db.bin");
|
||||
if (ff) {
|
||||
stream s;
|
||||
io_mopen(&s, ff->data, ff->size);
|
||||
io_open(&s, ff->data, ff->size);
|
||||
motion_database_read_inner(this, &s);
|
||||
io_free(&s);
|
||||
}
|
||||
@@ -41,19 +41,19 @@ void motion_database::read(char* path) {
|
||||
free(path_farc);
|
||||
}
|
||||
|
||||
void motion_database::read(wchar_t* path) {
|
||||
void motion_database::read(const wchar_t* path) {
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
wchar_t* path_farc = str_utils_wadd(path, L".farc");
|
||||
if (path_wcheck_file_exists(path_farc)) {
|
||||
if (path_check_file_exists(path_farc)) {
|
||||
farc f;
|
||||
f.read(path_farc, true, false);
|
||||
|
||||
farc_file* ff = f.read_file("mot_db.bin");
|
||||
if (ff) {
|
||||
stream s;
|
||||
io_mopen(&s, ff->data, ff->size);
|
||||
io_open(&s, ff->data, ff->size);
|
||||
motion_database_read_inner(this, &s);
|
||||
io_free(&s);
|
||||
}
|
||||
@@ -61,17 +61,17 @@ void motion_database::read(wchar_t* path) {
|
||||
free(path_farc);
|
||||
}
|
||||
|
||||
void motion_database::read(void* data, size_t length) {
|
||||
void motion_database::read(const void* data, size_t length) {
|
||||
if (!data || !length)
|
||||
return;
|
||||
|
||||
stream s;
|
||||
io_mopen(&s, data, length);
|
||||
io_open(&s, data, length);
|
||||
motion_database_read_inner(this, &s);
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
void motion_database::write(char* path) {
|
||||
void motion_database::write(const char* path) {
|
||||
if (!path || !ready)
|
||||
return;
|
||||
|
||||
@@ -81,9 +81,9 @@ void motion_database::write(char* path) {
|
||||
ff.name = std::string("mot_db.bin", 10);
|
||||
|
||||
stream s;
|
||||
io_mopen(&s, 0, 0);
|
||||
io_open(&s);
|
||||
motion_database_write_inner(this, &s);
|
||||
io_mcopy(&s, &ff.data, &ff.size);
|
||||
io_copy(&s, &ff.data, &ff.size);
|
||||
io_free(&s);
|
||||
|
||||
f.files.push_back(ff);
|
||||
@@ -91,7 +91,7 @@ void motion_database::write(char* path) {
|
||||
f.write(path, FARC_COMPRESS_FArC, false);
|
||||
}
|
||||
|
||||
void motion_database::write(wchar_t* path) {
|
||||
void motion_database::write(const wchar_t* path) {
|
||||
if (!path || !this->ready)
|
||||
return;
|
||||
|
||||
@@ -100,9 +100,9 @@ void motion_database::write(wchar_t* path) {
|
||||
farc_file ff;
|
||||
ff.name = std::string("mot_db.bin", 10);
|
||||
stream s;
|
||||
io_mopen(&s, 0, 0);
|
||||
io_open(&s);
|
||||
motion_database_write_inner(this, &s);
|
||||
io_mcopy(&s, &ff.data, &ff.size);
|
||||
io_copy(&s, &ff.data, &ff.size);
|
||||
io_free(&s);
|
||||
|
||||
f.files.push_back(ff);
|
||||
@@ -115,9 +115,9 @@ void motion_database::write(void** data, size_t* length) {
|
||||
return;
|
||||
|
||||
stream s;
|
||||
io_mopen(&s, 0, 0);
|
||||
io_open(&s);
|
||||
motion_database_write_inner(this, &s);
|
||||
io_mcopy(&s, data, length);
|
||||
io_copy(&s, data, length);
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
@@ -202,18 +202,6 @@ motion_set_info* motion_database::get_motion_set_by_id(uint32_t id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
motion_set_info* motion_database::get_motion_set_by_name(char* name) {
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
uint64_t name_hash = hash_utf8_fnv1a64m(name, false);
|
||||
|
||||
for (motion_set_info& i : motion_set)
|
||||
if (name_hash == i.name_hash)
|
||||
return &i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
motion_set_info* motion_database::get_motion_set_by_name(const char* name) {
|
||||
if (!name)
|
||||
return 0;
|
||||
@@ -226,18 +214,6 @@ motion_set_info* motion_database::get_motion_set_by_name(const char* name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t motion_database::get_motion_set_id(char* name) {
|
||||
if (!name)
|
||||
return -1;
|
||||
|
||||
uint64_t name_hash = hash_utf8_fnv1a64m(name, false);
|
||||
|
||||
for (motion_set_info& i : motion_set)
|
||||
if (name_hash == i.name_hash)
|
||||
return i.id;
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t motion_database::get_motion_set_id(const char* name) {
|
||||
if (!name)
|
||||
return -1;
|
||||
@@ -271,19 +247,6 @@ motion_info* motion_database::get_motion_by_id(uint32_t id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
motion_info* motion_database::get_motion_by_name(char* name) {
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
uint64_t name_hash = hash_utf8_fnv1a64m(name, false);
|
||||
|
||||
for (motion_set_info& i : motion_set)
|
||||
for (motion_info& j : i.motion)
|
||||
if (name_hash == j.name_hash)
|
||||
return &j;
|
||||
return 0;
|
||||
}
|
||||
|
||||
motion_info* motion_database::get_motion_by_name(const char* name) {
|
||||
if (!name)
|
||||
return 0;
|
||||
@@ -297,19 +260,6 @@ motion_info* motion_database::get_motion_by_name(const char* name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t motion_database::get_motion_id(char* name) {
|
||||
if (!name)
|
||||
return -1;
|
||||
|
||||
uint64_t name_hash = hash_utf8_fnv1a64m(name, false);
|
||||
|
||||
for (motion_set_info& i : motion_set)
|
||||
for (motion_info& j : i.motion)
|
||||
if (name_hash == j.name_hash)
|
||||
return j.id;
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t motion_database::get_motion_id(const char* name) {
|
||||
if (!name)
|
||||
return -1;
|
||||
@@ -334,10 +284,10 @@ const char* motion_database::get_motion_name(uint32_t id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool motion_database::load_file(void* data, char* path, char* file, uint32_t hash) {
|
||||
bool motion_database::load_file(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
size_t file_len = utf8_length(file);
|
||||
|
||||
char* t = strrchr(file, '.');
|
||||
const char* t = strrchr(file, '.');
|
||||
if (t)
|
||||
file_len = t - file;
|
||||
|
||||
|
||||
@@ -40,28 +40,24 @@ public:
|
||||
motion_database();
|
||||
~motion_database();
|
||||
|
||||
void read(char* path);
|
||||
void read(wchar_t* path);
|
||||
void read(void* data, size_t length);
|
||||
void write(char* path);
|
||||
void write(wchar_t* path);
|
||||
void read(const char* path);
|
||||
void read(const wchar_t* path);
|
||||
void read(const void* data, size_t length);
|
||||
void write(const char* path);
|
||||
void write(const wchar_t* path);
|
||||
void write(void** data, size_t* length);
|
||||
|
||||
void merge_mdata(motion_database* base_mot_db, motion_database* mdata_mot_db);
|
||||
void split_mdata(motion_database* base_mot_db, motion_database* mdata_mot_db);
|
||||
|
||||
motion_set_info* get_motion_set_by_id(uint32_t id);
|
||||
motion_set_info* get_motion_set_by_name(char* name);
|
||||
motion_set_info* get_motion_set_by_name(const char* name);
|
||||
uint32_t get_motion_set_id(char* name);
|
||||
uint32_t get_motion_set_id(const char* name);
|
||||
const char* get_motion_set_name(uint32_t id);
|
||||
motion_info* get_motion_by_id(uint32_t id);
|
||||
motion_info* get_motion_by_name(char* name);
|
||||
motion_info* get_motion_by_name(const char* name);
|
||||
uint32_t get_motion_id(char* name);
|
||||
uint32_t get_motion_id(const char* name);
|
||||
const char* get_motion_name(uint32_t id);
|
||||
|
||||
static bool load_file(void* data, char* path, char* file, uint32_t hash);
|
||||
static bool load_file(void* data, const char* path, const char* file, uint32_t hash);
|
||||
};
|
||||
|
||||
+413
-507
File diff suppressed because it is too large
Load Diff
@@ -5,87 +5,78 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../default.h"
|
||||
#include "../string.h"
|
||||
#include "../vector.h"
|
||||
|
||||
typedef struct object_info {
|
||||
uint32_t id;
|
||||
uint32_t set_id;
|
||||
|
||||
object_info();
|
||||
object_info(uint32_t id, uint32_t set_id);
|
||||
inline bool is_null() { return id == (uint32_t)-1 && set_id == (uint32_t)-1; }
|
||||
inline bool not_null() { return id != (uint32_t)-1 || set_id != (uint32_t)-1; }
|
||||
inline bool operator ==(object_info& right) { return id == right.id && set_id == right.set_id; }
|
||||
inline bool operator !=(object_info& right) { return id != right.id || set_id != right.set_id; }
|
||||
} object_info;
|
||||
|
||||
vector_old(object_info)
|
||||
|
||||
typedef struct object_info_data {
|
||||
class object_info_data {
|
||||
public:
|
||||
uint32_t id;
|
||||
string name;
|
||||
std::string name;
|
||||
uint64_t name_hash_fnv1a64m;
|
||||
uint64_t name_hash_fnv1a64m_upper;
|
||||
uint32_t name_hash_murmurhash;
|
||||
} object_info_data;
|
||||
|
||||
vector_old(object_info_data)
|
||||
object_info_data();
|
||||
~object_info_data();
|
||||
};
|
||||
|
||||
typedef struct object_set_info {
|
||||
string name;
|
||||
class object_set_info {
|
||||
public:
|
||||
std::string name;
|
||||
uint64_t name_hash;
|
||||
uint32_t id;
|
||||
string object_file_name;
|
||||
string texture_file_name;
|
||||
string archive_file_name;
|
||||
vector_old_object_info_data object;
|
||||
} object_set_info;
|
||||
std::string object_file_name;
|
||||
std::string texture_file_name;
|
||||
std::string archive_file_name;
|
||||
std::vector<object_info_data> object;
|
||||
|
||||
vector_old(object_set_info)
|
||||
object_set_info();
|
||||
~object_set_info();
|
||||
};
|
||||
|
||||
typedef struct object_database {
|
||||
class object_database {
|
||||
public:
|
||||
bool ready;
|
||||
bool modern;
|
||||
bool is_x;
|
||||
|
||||
vector_old_string bone_name;
|
||||
vector_old_object_set_info object_set;
|
||||
} object_database;
|
||||
std::vector<std::string> bone_name;
|
||||
std::vector<object_set_info> object_set;
|
||||
|
||||
extern const object_info object_info_null;
|
||||
object_database();
|
||||
~object_database();
|
||||
|
||||
extern void object_database_init(object_database* obj_db);
|
||||
extern void object_database_read(object_database* obj_db, char* path, bool modern);
|
||||
extern void object_database_wread(object_database* obj_db, wchar_t* path, bool modern);
|
||||
extern void object_database_mread(object_database* obj_db, void* data, size_t length, bool modern);
|
||||
extern void object_database_write(object_database* obj_db, char* path);
|
||||
extern void object_database_wwrite(object_database* obj_db, wchar_t* path);
|
||||
extern void object_database_mwrite(object_database* obj_db, void** data, size_t* length);
|
||||
extern bool object_database_load_file(void* data, char* path, char* file, uint32_t hash);
|
||||
extern void object_database_merge_mdata(object_database* obj_db,
|
||||
object_database* base_obj_db, object_database* mdata_obj_db);
|
||||
extern void object_database_split_mdata(object_database* obj_db,
|
||||
object_database* base_obj_db, object_database* mdata_obj_db);
|
||||
extern bool object_database_get_object_set_info(object_database* obj_db,
|
||||
char* name, object_set_info** set_info);
|
||||
extern bool object_database_get_object_set_info(object_database* obj_db,
|
||||
const char* name, object_set_info** set_info);
|
||||
extern bool object_database_get_object_set_info_by_set_id(object_database* obj_db,
|
||||
uint32_t set_id, object_set_info** set_info);
|
||||
extern bool object_database_get_object_info_data(object_database* obj_db,
|
||||
char* name, object_info_data** info);
|
||||
extern bool object_database_get_object_info_data(object_database* obj_db,
|
||||
const char* name, object_info_data** info);
|
||||
extern bool object_database_get_object_info_data_by_fnv1a64m_hash(object_database* obj_db,
|
||||
uint64_t hash, object_info_data** info);
|
||||
extern bool object_database_get_object_info_data_by_fnv1a64m_hash_upper(object_database* obj_db,
|
||||
uint64_t hash, object_info_data** info);
|
||||
extern bool object_database_get_object_info_data_by_murmurhash(object_database* obj_db,
|
||||
uint32_t hash, object_info_data** info);
|
||||
extern object_info object_database_get_object_info(object_database* obj_db, char* name);
|
||||
extern object_info object_database_get_object_info(object_database* obj_db, const char* name);
|
||||
extern char* object_database_get_object_name(object_database* obj_db, object_info obj_info);
|
||||
extern void object_database_free(object_database* obj_db);
|
||||
void read(const char* path, bool modern);
|
||||
void read(const wchar_t* path, bool modern);
|
||||
void read(const void* data, size_t length, bool modern);
|
||||
void write(const char* path);
|
||||
void write(const wchar_t* path);
|
||||
void write(void** data, size_t* length);
|
||||
|
||||
extern void object_info_data_free(object_info_data* info);
|
||||
extern void object_set_info_free(object_set_info* set_info);
|
||||
void merge_mdata(object_database* base_obj_db, object_database* mdata_obj_db);
|
||||
void split_mdata(object_database* base_obj_db, object_database* mdata_obj_db);
|
||||
|
||||
bool get_object_set_info(const char* name, object_set_info** set_info);
|
||||
bool get_object_set_info_by_set_id(uint32_t set_id, object_set_info** set_info);
|
||||
bool get_object_info_data(const char* name, object_info_data** info);
|
||||
bool get_object_info_data_by_fnv1a64m_hash(uint64_t hash, object_info_data** info);
|
||||
bool get_object_info_data_by_fnv1a64m_hash_upper(uint64_t hash, object_info_data** info);
|
||||
bool get_object_info_data_by_murmurhash(uint32_t hash, object_info_data** info);
|
||||
object_info get_object_info(const char* name);
|
||||
const char* get_object_name(object_info obj_info);
|
||||
|
||||
static bool load_file(void* data, const char* path, const char* file, uint32_t hash);
|
||||
};
|
||||
|
||||
+41
-42
@@ -21,7 +21,7 @@ void stage_database_init(stage_database* stage_data) {
|
||||
memset(stage_data, 0, sizeof(stage_database));
|
||||
}
|
||||
|
||||
void stage_database_read(stage_database* stage_data, char* path, bool modern) {
|
||||
void stage_database_read(stage_database* stage_data, const char* path, bool modern) {
|
||||
if (!stage_data || !path)
|
||||
return;
|
||||
|
||||
@@ -34,7 +34,7 @@ void stage_database_read(stage_database* stage_data, char* path, bool modern) {
|
||||
uint8_t* data = force_malloc_s(uint8_t, s.length);
|
||||
io_read(&s, data, s.length);
|
||||
stream s_bin;
|
||||
io_mopen(&s_bin, data, s.length);
|
||||
io_open(&s_bin, data, s.length);
|
||||
stage_database_classic_read_inner(stage_data, &s_bin);
|
||||
io_free(&s_bin);
|
||||
free(data);
|
||||
@@ -50,7 +50,7 @@ void stage_database_read(stage_database* stage_data, char* path, bool modern) {
|
||||
f2_struct_read(&st, path_stg);
|
||||
if (st.header.signature == reverse_endianness_uint32_t('STGC')) {
|
||||
stream s_stgc;
|
||||
io_mopen(&s_stgc, st.data, st.length);
|
||||
io_open(&s_stgc, st.data, st.length);
|
||||
s_stgc.is_big_endian = st.header.use_big_endian;
|
||||
stage_database_modern_read_inner(stage_data, &s_stgc, st.header.length);
|
||||
io_free(&s_stgc);
|
||||
@@ -61,20 +61,20 @@ void stage_database_read(stage_database* stage_data, char* path, bool modern) {
|
||||
}
|
||||
}
|
||||
|
||||
void stage_database_wread(stage_database* stage_data, wchar_t* path, bool modern) {
|
||||
void stage_database_read(stage_database* stage_data, const wchar_t* path, bool modern) {
|
||||
if (!stage_data || !path)
|
||||
return;
|
||||
|
||||
if (!modern) {
|
||||
wchar_t* path_bin = str_utils_wadd(path, L".bin");
|
||||
if (path_wcheck_file_exists(path_bin)) {
|
||||
if (path_check_file_exists(path_bin)) {
|
||||
stream s;
|
||||
io_wopen(&s, path_bin, L"rb");
|
||||
io_open(&s, path_bin, L"rb");
|
||||
if (s.io.stream) {
|
||||
uint8_t* data = force_malloc_s(uint8_t, s.length);
|
||||
io_read(&s, data, s.length);
|
||||
stream s_bin;
|
||||
io_mopen(&s_bin, data, s.length);
|
||||
io_open(&s_bin, data, s.length);
|
||||
stage_database_classic_read_inner(stage_data, &s_bin);
|
||||
io_free(&s_bin);
|
||||
free(data);
|
||||
@@ -85,12 +85,12 @@ void stage_database_wread(stage_database* stage_data, wchar_t* path, bool modern
|
||||
}
|
||||
else {
|
||||
wchar_t* path_stg = str_utils_wadd(path, L".stg");
|
||||
if (path_wcheck_file_exists(path_stg)) {
|
||||
if (path_check_file_exists(path_stg)) {
|
||||
f2_struct st;
|
||||
f2_struct_wread(&st, path_stg);
|
||||
f2_struct_read(&st, path_stg);
|
||||
if (st.header.signature == reverse_endianness_uint32_t('STGC')) {
|
||||
stream s_stgc;
|
||||
io_mopen(&s_stgc, st.data, st.length);
|
||||
io_open(&s_stgc, st.data, st.length);
|
||||
s_stgc.is_big_endian = st.header.use_big_endian;
|
||||
stage_database_modern_read_inner(stage_data, &s_stgc, st.header.length);
|
||||
io_free(&s_stgc);
|
||||
@@ -101,22 +101,22 @@ void stage_database_wread(stage_database* stage_data, wchar_t* path, bool modern
|
||||
}
|
||||
}
|
||||
|
||||
void stage_database_mread(stage_database* stage_data, void* data, size_t length, bool modern) {
|
||||
void stage_database_read(stage_database* stage_data, const void* data, size_t length, bool modern) {
|
||||
if (!stage_data || !data || !length)
|
||||
return;
|
||||
|
||||
if (!modern) {
|
||||
stream s;
|
||||
io_mopen(&s, data, length);
|
||||
io_open(&s, data, length);
|
||||
stage_database_classic_read_inner(stage_data, &s);
|
||||
io_free(&s);
|
||||
}
|
||||
else {
|
||||
f2_struct st;
|
||||
f2_struct_mread(&st, data, length);
|
||||
f2_struct_read(&st, data, length);
|
||||
if (st.header.signature == reverse_endianness_uint32_t('STGC')) {
|
||||
stream s_stgc;
|
||||
io_mopen(&s_stgc, st.data, st.length);
|
||||
io_open(&s_stgc, st.data, st.length);
|
||||
s_stgc.is_big_endian = st.header.use_big_endian;
|
||||
stage_database_modern_read_inner(stage_data, &s_stgc, st.header.length);
|
||||
io_free(&s_stgc);
|
||||
@@ -125,7 +125,7 @@ void stage_database_mread(stage_database* stage_data, void* data, size_t length,
|
||||
}
|
||||
}
|
||||
|
||||
void stage_database_write(stage_database* stage_data, char* path) {
|
||||
void stage_database_write(stage_database* stage_data, const char* path) {
|
||||
if (!stage_data || !path || !stage_data->ready)
|
||||
return;
|
||||
|
||||
@@ -149,14 +149,14 @@ void stage_database_write(stage_database* stage_data, char* path) {
|
||||
}
|
||||
}
|
||||
|
||||
void stage_database_wwrite(stage_database* stage_data, wchar_t* path) {
|
||||
void stage_database_write(stage_database* stage_data, const wchar_t* path) {
|
||||
if (!stage_data || !path || !stage_data->ready)
|
||||
return;
|
||||
|
||||
if (!stage_data->modern) {
|
||||
wchar_t* path_bin = str_utils_wadd(path, L".bin");
|
||||
stream s;
|
||||
io_wopen(&s, path_bin, L"wb");
|
||||
io_open(&s, path_bin, L"wb");
|
||||
if (s.io.stream)
|
||||
stage_database_classic_write_inner(stage_data, &s);
|
||||
io_free(&s);
|
||||
@@ -165,7 +165,7 @@ void stage_database_wwrite(stage_database* stage_data, wchar_t* path) {
|
||||
else {
|
||||
wchar_t* path_stg = str_utils_wadd(path, L".stg");
|
||||
stream s;
|
||||
io_wopen(&s, path_stg, L"wb");
|
||||
io_open(&s, path_stg, L"wb");
|
||||
if (s.io.stream)
|
||||
stage_database_modern_write_inner(stage_data, &s);
|
||||
io_free(&s);
|
||||
@@ -173,25 +173,25 @@ void stage_database_wwrite(stage_database* stage_data, wchar_t* path) {
|
||||
}
|
||||
}
|
||||
|
||||
void stage_database_mwrite(stage_database* stage_data, void** data, size_t* length) {
|
||||
void stage_database_write(stage_database* stage_data, void** data, size_t* length) {
|
||||
if (!stage_data || !data || !stage_data->ready)
|
||||
return;
|
||||
|
||||
stream s;
|
||||
io_mopen(&s, 0, 0);
|
||||
io_open(&s);
|
||||
if (!stage_data->modern)
|
||||
stage_database_classic_write_inner(stage_data, &s);
|
||||
else
|
||||
stage_database_modern_write_inner(stage_data, &s);
|
||||
io_align_write(&s, 0x10);
|
||||
io_mcopy(&s, data, length);
|
||||
io_copy(&s, data, length);
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
bool stage_database_load_file(void* data, char* path, char* file, uint32_t hash) {
|
||||
bool stage_database_load_file(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
size_t file_len = utf8_length(file);
|
||||
|
||||
char* t = strrchr(file, '.');
|
||||
const char* t = strrchr(file, '.');
|
||||
if (t)
|
||||
file_len = t - file;
|
||||
|
||||
@@ -230,8 +230,8 @@ void stage_database_merge_mdata(stage_database* stage_data,
|
||||
string_copy(&b_info->collision_file_path, &info->collision_file_path);
|
||||
if (b_info->auth_3d_count) {
|
||||
info->auth_3d_count = b_info->auth_3d_count;
|
||||
info->auth_3d_ids = force_malloc_s(uint32_t, b_info->auth_3d_count);
|
||||
memcpy(info->auth_3d_ids, b_info->auth_3d_ids, sizeof(uint32_t) * b_info->auth_3d_count);
|
||||
info->auth_3d_ids = force_malloc_s(int32_t, b_info->auth_3d_count);
|
||||
memcpy(info->auth_3d_ids, b_info->auth_3d_ids, sizeof(int32_t) * b_info->auth_3d_count);
|
||||
}
|
||||
else {
|
||||
info->auth_3d_count = 0;
|
||||
@@ -266,8 +266,8 @@ void stage_database_merge_mdata(stage_database* stage_data,
|
||||
string_copy(&m_info->collision_file_path, &info->collision_file_path);
|
||||
if (m_info->auth_3d_count) {
|
||||
info->auth_3d_count = m_info->auth_3d_count;
|
||||
info->auth_3d_ids = force_malloc_s(uint32_t, m_info->auth_3d_count);
|
||||
memcpy(info->auth_3d_ids, m_info->auth_3d_ids, sizeof(uint32_t) * m_info->auth_3d_count);
|
||||
info->auth_3d_ids = force_malloc_s(int32_t, m_info->auth_3d_count);
|
||||
memcpy(info->auth_3d_ids, m_info->auth_3d_ids, sizeof(int32_t) * m_info->auth_3d_count);
|
||||
}
|
||||
else {
|
||||
info->auth_3d_count = 0;
|
||||
@@ -363,24 +363,24 @@ static void stage_database_classic_read_inner(stage_database* stage_data, stream
|
||||
int32_t reflect_offset = io_read_uint32_t(s);
|
||||
if (reflect_offset) {
|
||||
io_position_push(s, reflect_offset, SEEK_SET);
|
||||
stage->reflect_data = true;
|
||||
stage->reflect.mode = (stage_data_reflect_resolution_mode)io_read_uint32_t(s);
|
||||
stage->reflect.blur_num = io_read_uint32_t(s);
|
||||
stage->reflect.blur_filter = (stage_data_blur_filter_mode)io_read_uint32_t(s);
|
||||
stage->reflect = true;
|
||||
stage->reflect_data.mode = (stage_data_reflect_resolution_mode)io_read_uint32_t(s);
|
||||
stage->reflect_data.blur_num = io_read_uint32_t(s);
|
||||
stage->reflect_data.blur_filter = (stage_data_blur_filter_mode)io_read_uint32_t(s);
|
||||
io_position_pop(s);
|
||||
}
|
||||
else
|
||||
stage->reflect_data = false;
|
||||
stage->reflect = false;
|
||||
|
||||
int32_t refract_offset = io_read_uint32_t(s);
|
||||
if (refract_offset) {
|
||||
io_position_push(s, refract_offset, SEEK_SET);
|
||||
stage->refract_data = true;
|
||||
stage->refract.mode = (stage_data_refract_resolution_mode)io_read_uint32_t(s);
|
||||
stage->refract = true;
|
||||
stage->refract_data.mode = (stage_data_refract_resolution_mode)io_read_uint32_t(s);
|
||||
io_position_pop(s);
|
||||
}
|
||||
else
|
||||
stage->refract_data = false;
|
||||
stage->refract = false;
|
||||
|
||||
if (stage_data->format > STAGE_DATA_F)
|
||||
stage->flags = (stage_data_flags)io_read_uint32_t(s);
|
||||
@@ -441,7 +441,7 @@ static void stage_database_classic_read_inner(stage_database* stage_data, stream
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
::stage_data* stage = &stage_data->stage_data.begin[i];
|
||||
|
||||
stage->auth_3d_count = io_read_uint32_t(s);
|
||||
stage->auth_3d_count = io_read_int32_t(s);
|
||||
}
|
||||
io_position_pop(s);
|
||||
|
||||
@@ -457,19 +457,18 @@ static void stage_database_classic_read_inner(stage_database* stage_data, stream
|
||||
}
|
||||
|
||||
io_position_push(s, offset, SEEK_SET);
|
||||
for (uint32_t j = 0; j < stage->auth_3d_count; j++) {
|
||||
if (io_read_uint32_t(s) == -1) {
|
||||
for (int32_t j = 0; j < stage->auth_3d_count; j++)
|
||||
if (io_read_int32_t(s) == -1) {
|
||||
stage->auth_3d_count = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
io_position_pop(s);
|
||||
|
||||
if (stage->auth_3d_count) {
|
||||
io_position_push(s, offset, SEEK_SET);
|
||||
stage->auth_3d_ids = force_malloc_s(uint32_t, stage->auth_3d_count);
|
||||
for (uint32_t j = 0; j < stage->auth_3d_count; j++)
|
||||
stage->auth_3d_ids[j] = io_read_uint32_t(s);
|
||||
stage->auth_3d_ids = force_malloc_s(int32_t, stage->auth_3d_count);
|
||||
for (int32_t j = 0; j < stage->auth_3d_count; j++)
|
||||
stage->auth_3d_ids[j] = io_read_int32_t(s);
|
||||
io_position_pop(s);
|
||||
}
|
||||
|
||||
|
||||
+15
-15
@@ -85,10 +85,10 @@ typedef struct stage_data {
|
||||
string collision_file_path;
|
||||
stage_data_reflect_type reflect_type;
|
||||
bool refract_enable;
|
||||
bool reflect_data;
|
||||
stage_data_reflect reflect;
|
||||
bool refract_data;
|
||||
stage_data_refract refract;
|
||||
bool reflect;
|
||||
stage_data_reflect reflect_data;
|
||||
bool refract;
|
||||
stage_data_refract refract_data;
|
||||
stage_data_flags flags;
|
||||
float_t ring_rectangle_x;
|
||||
float_t ring_rectangle_y;
|
||||
@@ -97,8 +97,8 @@ typedef struct stage_data {
|
||||
float_t ring_height;
|
||||
float_t ring_out_height;
|
||||
stage_effects effects;
|
||||
uint32_t auth_3d_count;
|
||||
uint32_t* auth_3d_ids;
|
||||
int32_t auth_3d_count;
|
||||
int32_t* auth_3d_ids;
|
||||
} stage_data;
|
||||
|
||||
typedef struct stage_data_modern {
|
||||
@@ -137,8 +137,8 @@ typedef struct stage_data_modern {
|
||||
float_t ring_out_height;
|
||||
uint32_t field_13;
|
||||
stage_effects effects;
|
||||
uint32_t auth_3d_count;
|
||||
uint32_t* auth_3d_ids;
|
||||
int32_t auth_3d_count;
|
||||
int32_t* auth_3d_ids;
|
||||
} stage_data_modern;
|
||||
|
||||
vector_old(stage_data)
|
||||
@@ -159,13 +159,13 @@ typedef struct stage_database {
|
||||
} stage_database;
|
||||
|
||||
extern void stage_database_init(stage_database* stage_data);
|
||||
extern void stage_database_read(stage_database* stage_data, char* path, bool modern);
|
||||
extern void stage_database_wread(stage_database* stage_data, wchar_t* path, bool modern);
|
||||
extern void stage_database_mread(stage_database* stage_data, void* data, size_t length, bool modern);
|
||||
extern void stage_database_write(stage_database* stage_data, char* path);
|
||||
extern void stage_database_wwrite(stage_database* stage_data, wchar_t* path);
|
||||
extern void stage_database_mwrite(stage_database* stage_data, void** data, size_t* length);
|
||||
extern bool stage_database_load_file(void* data, char* path, char* file, uint32_t hash);
|
||||
extern void stage_database_read(stage_database* stage_data, const char* path, bool modern);
|
||||
extern void stage_database_read(stage_database* stage_data, const wchar_t* path, bool modern);
|
||||
extern void stage_database_read(stage_database* stage_data, const void* data, size_t length, bool modern);
|
||||
extern void stage_database_write(stage_database* stage_data, const char* path);
|
||||
extern void stage_database_write(stage_database* stage_data, const wchar_t* path);
|
||||
extern void stage_database_write(stage_database* stage_data, void** data, size_t* length);
|
||||
extern bool stage_database_load_file(void* data, const char* path, const char* file, uint32_t hash);
|
||||
extern void stage_database_merge_mdata(stage_database* stage_data,
|
||||
stage_database* base_stage_data, stage_database* mdata_stage_data);
|
||||
extern void stage_database_split_mdata(stage_database* stage_data,
|
||||
|
||||
@@ -27,7 +27,7 @@ texture_database::~texture_database() {
|
||||
|
||||
}
|
||||
|
||||
void texture_database::read(char* path, bool modern) {
|
||||
void texture_database::read(const char* path, bool modern) {
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
@@ -40,7 +40,7 @@ void texture_database::read(char* path, bool modern) {
|
||||
uint8_t* data = force_malloc_s(uint8_t, s.length);
|
||||
io_read(&s, data, s.length);
|
||||
stream s_bin;
|
||||
io_mopen(&s_bin, data, s.length);
|
||||
io_open(&s_bin, data, s.length);
|
||||
texture_database_classic_read_inner(this, &s_bin);
|
||||
io_free(&s_bin);
|
||||
free(data);
|
||||
@@ -56,7 +56,7 @@ void texture_database::read(char* path, bool modern) {
|
||||
f2_struct_read(&st, path_txi);
|
||||
if (st.header.signature == reverse_endianness_uint32_t('MTXI')) {
|
||||
stream s_mtxi;
|
||||
io_mopen(&s_mtxi, st.data, st.length);
|
||||
io_open(&s_mtxi, st.data, st.length);
|
||||
s_mtxi.is_big_endian = st.header.use_big_endian;
|
||||
texture_database_modern_read_inner(this, &s_mtxi, st.header.length);
|
||||
io_free(&s_mtxi);
|
||||
@@ -67,20 +67,20 @@ void texture_database::read(char* path, bool modern) {
|
||||
}
|
||||
}
|
||||
|
||||
void texture_database::read(wchar_t* path, bool modern) {
|
||||
void texture_database::read(const wchar_t* path, bool modern) {
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
if (!modern) {
|
||||
wchar_t* path_bin = str_utils_wadd(path, L".bin");
|
||||
if (path_wcheck_file_exists(path_bin)) {
|
||||
if (path_check_file_exists(path_bin)) {
|
||||
stream s;
|
||||
io_wopen(&s, path_bin, L"rb");
|
||||
io_open(&s, path_bin, L"rb");
|
||||
if (s.io.stream) {
|
||||
uint8_t* data = force_malloc_s(uint8_t, s.length);
|
||||
io_read(&s, data, s.length);
|
||||
stream s_bin;
|
||||
io_mopen(&s_bin, data, s.length);
|
||||
io_open(&s_bin, data, s.length);
|
||||
texture_database_classic_read_inner(this, &s_bin);
|
||||
io_free(&s_bin);
|
||||
free(data);
|
||||
@@ -91,12 +91,12 @@ void texture_database::read(wchar_t* path, bool modern) {
|
||||
}
|
||||
else {
|
||||
wchar_t* path_txi = str_utils_wadd(path, L".txi");
|
||||
if (path_wcheck_file_exists(path_txi)) {
|
||||
if (path_check_file_exists(path_txi)) {
|
||||
f2_struct st;
|
||||
f2_struct_wread(&st, path_txi);
|
||||
f2_struct_read(&st, path_txi);
|
||||
if (st.header.signature == reverse_endianness_uint32_t('MTXI')) {
|
||||
stream s_mtxi;
|
||||
io_mopen(&s_mtxi, st.data, st.length);
|
||||
io_open(&s_mtxi, st.data, st.length);
|
||||
s_mtxi.is_big_endian = st.header.use_big_endian;
|
||||
texture_database_modern_read_inner(this, &s_mtxi, st.header.length);
|
||||
io_free(&s_mtxi);
|
||||
@@ -107,22 +107,22 @@ void texture_database::read(wchar_t* path, bool modern) {
|
||||
}
|
||||
}
|
||||
|
||||
void texture_database::read(void* data, size_t length, bool modern) {
|
||||
void texture_database::read(const void* data, size_t length, bool modern) {
|
||||
if (!data || !length)
|
||||
return;
|
||||
|
||||
if (!modern) {
|
||||
stream s;
|
||||
io_mopen(&s, data, length);
|
||||
io_open(&s, data, length);
|
||||
texture_database_classic_read_inner(this, &s);
|
||||
io_free(&s);
|
||||
}
|
||||
else {
|
||||
f2_struct st;
|
||||
f2_struct_mread(&st, data, length);
|
||||
f2_struct_read(&st, data, length);
|
||||
if (st.header.signature == reverse_endianness_uint32_t('MTXI')) {
|
||||
stream s_mtxi;
|
||||
io_mopen(&s_mtxi, st.data, st.length);
|
||||
io_open(&s_mtxi, st.data, st.length);
|
||||
s_mtxi.is_big_endian = st.header.use_big_endian;
|
||||
texture_database_modern_read_inner(this, &s_mtxi, st.header.length);
|
||||
io_free(&s_mtxi);
|
||||
@@ -131,7 +131,7 @@ void texture_database::read(void* data, size_t length, bool modern) {
|
||||
}
|
||||
}
|
||||
|
||||
void texture_database::write(char* path) {
|
||||
void texture_database::write(const char* path) {
|
||||
if (!path || !ready)
|
||||
return;
|
||||
|
||||
@@ -155,14 +155,14 @@ void texture_database::write(char* path) {
|
||||
}
|
||||
}
|
||||
|
||||
void texture_database::write(wchar_t* path) {
|
||||
void texture_database::write(const wchar_t* path) {
|
||||
if (!path || !ready)
|
||||
return;
|
||||
|
||||
if (!modern) {
|
||||
wchar_t* path_bin = str_utils_wadd(path, L".bin");
|
||||
stream s;
|
||||
io_wopen(&s, path_bin, L"wb");
|
||||
io_open(&s, path_bin, L"wb");
|
||||
if (s.io.stream)
|
||||
texture_database_classic_write_inner(this, &s);
|
||||
io_free(&s);
|
||||
@@ -171,7 +171,7 @@ void texture_database::write(wchar_t* path) {
|
||||
else {
|
||||
wchar_t* path_txi = str_utils_wadd(path, L".txi");
|
||||
stream s;
|
||||
io_wopen(&s, path_txi, L"wb");
|
||||
io_open(&s, path_txi, L"wb");
|
||||
if (s.io.stream)
|
||||
texture_database_modern_write_inner(this, &s);
|
||||
io_free(&s);
|
||||
@@ -184,13 +184,13 @@ void texture_database::write(void** data, size_t* length) {
|
||||
return;
|
||||
|
||||
stream s;
|
||||
io_mopen(&s, 0, 0);
|
||||
io_open(&s);
|
||||
if (!modern)
|
||||
texture_database_classic_write_inner(this, &s);
|
||||
else
|
||||
texture_database_modern_write_inner(this, &s);
|
||||
io_align_write(&s, 0x10);
|
||||
io_mcopy(&s, data, length);
|
||||
io_copy(&s, data, length);
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
@@ -276,10 +276,10 @@ const char* texture_database::get_texture_name(uint32_t id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool texture_database::load_file(void* data, char* path, char* file, uint32_t hash) {
|
||||
bool texture_database::load_file(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
size_t file_len = utf8_length(file);
|
||||
|
||||
char* t = strrchr(file, '.');
|
||||
const char* t = strrchr(file, '.');
|
||||
if (t)
|
||||
file_len = t - file;
|
||||
|
||||
@@ -398,7 +398,7 @@ static void texture_database_modern_read_inner(texture_database* tex_db, stream*
|
||||
|
||||
static void texture_database_modern_write_inner(texture_database* tex_db, stream* s) {
|
||||
stream s_mtxi;
|
||||
io_mopen(&s_mtxi, 0, 0);
|
||||
io_open(&s_mtxi);
|
||||
uint32_t off;
|
||||
vector_old_enrs_entry e = vector_old_empty(enrs_entry);
|
||||
enrs_entry ee;
|
||||
@@ -478,7 +478,7 @@ static void texture_database_modern_write_inner(texture_database* tex_db, stream
|
||||
f2_struct st;
|
||||
memset(&st, 0, sizeof(f2_struct));
|
||||
io_align_write(&s_mtxi, 0x10);
|
||||
io_mcopy(&s_mtxi, &st.data, &st.length);
|
||||
io_copy(&s_mtxi, &st.data, &st.length);
|
||||
io_free(&s_mtxi);
|
||||
|
||||
st.enrs = e;
|
||||
@@ -489,7 +489,7 @@ static void texture_database_modern_write_inner(texture_database* tex_db, stream
|
||||
st.header.use_big_endian = false;
|
||||
st.header.use_section_size = true;
|
||||
|
||||
f2_struct_swrite(&st, s, true, tex_db->is_x);
|
||||
f2_struct_write(&st, s, true, tex_db->is_x);
|
||||
f2_struct_free(&st);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@ public:
|
||||
texture_database();
|
||||
~texture_database();
|
||||
|
||||
void read(char* path, bool modern);
|
||||
void read(wchar_t* path, bool modern);
|
||||
void read(void* data, size_t length, bool modern);
|
||||
void write(char* path);
|
||||
void write(wchar_t* path);
|
||||
void read(const char* path, bool modern);
|
||||
void read(const wchar_t* path, bool modern);
|
||||
void read(const void* data, size_t length, bool modern);
|
||||
void write(const char* path);
|
||||
void write(const wchar_t* path);
|
||||
void write(void** data, size_t* length);
|
||||
|
||||
void merge_mdata(texture_database* base_tex_db,
|
||||
@@ -46,5 +46,5 @@ public:
|
||||
uint32_t get_texture_id(const char* name);
|
||||
const char* get_texture_name(uint32_t id);
|
||||
|
||||
static bool load_file(void* data, char* path, char* file, uint32_t hash);
|
||||
static bool load_file(void* data, const char* path, const char* file, uint32_t hash);
|
||||
} texture_database;
|
||||
|
||||
+5
-5
@@ -170,7 +170,7 @@ void dds_wread(dds* d, wchar_t* path) {
|
||||
memset(d, 0, sizeof(dds));
|
||||
wchar_t* path_dds = str_utils_wadd(path, L".dds");
|
||||
stream s;
|
||||
io_wopen(&s, path_dds, L"rb");
|
||||
io_open(&s, path_dds, L"rb");
|
||||
if (s.io.stream) {
|
||||
if (io_read_uint32_t_reverse_endianness(&s, true) != DDS_MAGIC)
|
||||
goto End;
|
||||
@@ -259,7 +259,7 @@ void dds_wread(dds* d, wchar_t* path) {
|
||||
for (uint32_t i = 0; i < d->mipmaps_count; i++) {
|
||||
uint32_t width = max(d->width >> i, 1);
|
||||
uint32_t height = max(d->height >> i, 1);
|
||||
uint32_t size = txp_get_size(d->format,
|
||||
uint32_t size = txp::get_size(d->format,
|
||||
max(d->width >> i, 1), max(d->height >> i, 1));
|
||||
void* data = force_malloc(size);
|
||||
io_read(&s, data, size);
|
||||
@@ -291,7 +291,7 @@ void dds_wwrite(dds* d, wchar_t* path) {
|
||||
|
||||
wchar_t* path_dds = str_utils_wadd(path, L".dds");
|
||||
stream s;
|
||||
io_wopen(&s, path_dds, L"wb");
|
||||
io_open(&s, path_dds, L"wb");
|
||||
if (s.io.stream) {
|
||||
DDS_HEADER dds_h;
|
||||
memset(&dds_h, 0, sizeof(DDS_HEADER));
|
||||
@@ -301,7 +301,7 @@ void dds_wwrite(dds* d, wchar_t* path) {
|
||||
dds_h.flags |= DDSD_MIPMAPCOUNT;
|
||||
dds_h.height = d->height;
|
||||
dds_h.width = d->width;
|
||||
dds_h.pitchOrLinearSize = txp_get_size(d->format, d->width, d->height);
|
||||
dds_h.pitchOrLinearSize = txp::get_size(d->format, d->width, d->height);
|
||||
dds_h.mipMapCount = d->mipmaps_count;
|
||||
dds_h.caps |= DDS_SURFACE_FLAGS_TEXTURE;
|
||||
if (d->has_cube_map)
|
||||
@@ -362,7 +362,7 @@ void dds_wwrite(dds* d, wchar_t* path) {
|
||||
uint32_t index = 0;
|
||||
do
|
||||
for (uint32_t i = 0; i < d->mipmaps_count; i++) {
|
||||
uint32_t size = txp_get_size(d->format,
|
||||
uint32_t size = txp::get_size(d->format,
|
||||
max(d->width >> i, 1), max(d->height >> i, 1));
|
||||
void* data = force_malloc(size);
|
||||
memcpy(data, d->data.begin[index], size);
|
||||
|
||||
+10
-10
@@ -16,44 +16,44 @@ void* force_malloc(size_t size) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
inline int16_t load_reverse_endianness_int16_t(void* ptr) {
|
||||
inline int16_t load_reverse_endianness_int16_t(const void* ptr) {
|
||||
return (int16_t)_byteswap_ushort(*(uint16_t*)ptr);
|
||||
}
|
||||
|
||||
inline uint16_t load_reverse_endianness_uint16_t(void* ptr) {
|
||||
inline uint16_t load_reverse_endianness_uint16_t(const void* ptr) {
|
||||
return (uint16_t)_byteswap_ushort(*(uint16_t*)ptr);
|
||||
}
|
||||
|
||||
inline int32_t load_reverse_endianness_int32_t(void* ptr) {
|
||||
inline int32_t load_reverse_endianness_int32_t(const void* ptr) {
|
||||
return (int32_t)_byteswap_ulong(*(uint32_t*)ptr);
|
||||
}
|
||||
|
||||
inline uint32_t load_reverse_endianness_uint32_t(void* ptr) {
|
||||
inline uint32_t load_reverse_endianness_uint32_t(const void* ptr) {
|
||||
return (uint32_t)_byteswap_ulong(*(uint32_t*)ptr);
|
||||
}
|
||||
|
||||
inline int64_t load_reverse_endianness_int64_t(void* ptr) {
|
||||
inline int64_t load_reverse_endianness_int64_t(const void* ptr) {
|
||||
return (int64_t)_byteswap_uint64(*(uint64_t*)ptr);
|
||||
}
|
||||
|
||||
inline uint64_t load_reverse_endianness_uint64_t(void* ptr) {
|
||||
inline uint64_t load_reverse_endianness_uint64_t(const void* ptr) {
|
||||
return (uint64_t)_byteswap_uint64(*(uint64_t*)ptr);
|
||||
}
|
||||
|
||||
inline ssize_t load_reverse_endianness_ssize_t(void* ptr) {
|
||||
inline ssize_t load_reverse_endianness_ssize_t(const void* ptr) {
|
||||
return (ssize_t)_byteswap_uint64(*(uint64_t*)ptr);
|
||||
}
|
||||
|
||||
inline size_t load_reverse_endianness_size_t(void* ptr) {
|
||||
inline size_t load_reverse_endianness_size_t(const void* ptr) {
|
||||
return (size_t)_byteswap_uint64(*(uint64_t*)ptr);
|
||||
}
|
||||
|
||||
inline float_t load_reverse_endianness_float_t(void* ptr) {
|
||||
inline float_t load_reverse_endianness_float_t(const void* ptr) {
|
||||
uint32_t v = (uint32_t)_byteswap_ulong(*(uint32_t*)ptr);
|
||||
return *(float_t*)&v;
|
||||
}
|
||||
|
||||
inline double_t load_reverse_endianness_double_t(void* ptr) {
|
||||
inline double_t load_reverse_endianness_double_t(const void* ptr) {
|
||||
uint64_t v = (uint64_t)_byteswap_uint64(*(uint64_t*)ptr);
|
||||
return *(double_t*)&v;
|
||||
}
|
||||
|
||||
+10
-10
@@ -106,16 +106,16 @@ extern void* force_malloc(size_t size);
|
||||
#define enum_not(s0, s1) \
|
||||
(s0) = (decltype(s0))(~(int32_t)(s0))
|
||||
|
||||
extern int16_t load_reverse_endianness_int16_t(void* ptr);
|
||||
extern uint16_t load_reverse_endianness_uint16_t(void* ptr);
|
||||
extern int32_t load_reverse_endianness_int32_t(void* ptr);
|
||||
extern uint32_t load_reverse_endianness_uint32_t(void* ptr);
|
||||
extern int64_t load_reverse_endianness_int64_t(void* ptr);
|
||||
extern uint64_t load_reverse_endianness_uint64_t(void* ptr);
|
||||
extern ssize_t load_reverse_endianness_ssize_t(void* ptr);
|
||||
extern size_t load_reverse_endianness_size_t(void* ptr);
|
||||
extern float_t load_reverse_endianness_float_t(void* ptr);
|
||||
extern double_t load_reverse_endianness_double_t(void* ptr);
|
||||
extern int16_t load_reverse_endianness_int16_t(const void* ptr);
|
||||
extern uint16_t load_reverse_endianness_uint16_t(const void* ptr);
|
||||
extern int32_t load_reverse_endianness_int32_t(const void* ptr);
|
||||
extern uint32_t load_reverse_endianness_uint32_t(const void* ptr);
|
||||
extern int64_t load_reverse_endianness_int64_t(const void* ptr);
|
||||
extern uint64_t load_reverse_endianness_uint64_t(const void* ptr);
|
||||
extern ssize_t load_reverse_endianness_ssize_t(const void* ptr);
|
||||
extern size_t load_reverse_endianness_size_t(const void* ptr);
|
||||
extern float_t load_reverse_endianness_float_t(const void* ptr);
|
||||
extern double_t load_reverse_endianness_double_t(const void* ptr);
|
||||
extern void store_reverse_endianness_int16_t(int16_t value, void* ptr);
|
||||
extern void store_reverse_endianness_int16_t(uint16_t value, void* ptr);
|
||||
extern void store_reverse_endianness_uint16_t(int16_t value, void* ptr);
|
||||
|
||||
@@ -25,7 +25,7 @@ inline void divafile_decrypt(const char* path) {
|
||||
void divafile_wdecrypt(wchar_t* path) {
|
||||
wchar_t* file_temp = str_utils_wadd(path, L"_dec");
|
||||
stream s_enc;
|
||||
io_wopen(&s_enc, path, L"rb");
|
||||
io_open(&s_enc, path, L"rb");
|
||||
if (s_enc.io.stream) {
|
||||
uint64_t signature = io_read_uint64_t(&s_enc);
|
||||
if (signature == 0x454C494641564944) {
|
||||
@@ -39,7 +39,7 @@ void divafile_wdecrypt(wchar_t* path) {
|
||||
aes_ecb_decrypt_buffer(&ctx, (uint8_t*)data, stream_length);
|
||||
|
||||
stream s_dec;
|
||||
io_wopen(&s_dec, file_temp, L"wb");
|
||||
io_open(&s_dec, file_temp, L"wb");
|
||||
io_write(&s_dec, data, min(file_length, stream_length));
|
||||
io_free(&s_dec);
|
||||
free(data);
|
||||
@@ -100,7 +100,7 @@ void divafile_sdecrypt(stream* s) {
|
||||
aes_ecb_decrypt_buffer(&ctx, (uint8_t*)data, stream_length);
|
||||
|
||||
io_free(s);
|
||||
io_mopen(s, data, file_length);
|
||||
io_open(s, data, file_length);
|
||||
free(data);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ inline void divafile_encrypt(const char* path) {
|
||||
void divafile_wencrypt(wchar_t* path) {
|
||||
wchar_t* file_temp = str_utils_wadd(path, L"_enc");
|
||||
stream s_dec;
|
||||
io_wopen(&s_dec, path, L"rb");
|
||||
io_open(&s_dec, path, L"rb");
|
||||
if (s_dec.io.stream) {
|
||||
size_t len = s_dec.length;
|
||||
size_t len_align = align_val(len, 0x10);
|
||||
@@ -130,7 +130,7 @@ void divafile_wencrypt(wchar_t* path) {
|
||||
aes_ecb_encrypt_buffer(&ctx, (uint8_t*)data, len_align);
|
||||
|
||||
stream s_enc;
|
||||
io_wopen(&s_enc, file_temp, L"wb");
|
||||
io_open(&s_enc, file_temp, L"wb");
|
||||
io_write_uint64_t(&s_enc, 0x454C494641564944);
|
||||
io_write_uint32_t(&s_enc, (uint32_t)len_align);
|
||||
io_write_uint32_t(&s_enc, (uint32_t)len);
|
||||
|
||||
+3
-3
@@ -1898,7 +1898,7 @@ bool dsc_parse(dsc* d, void* data, size_t length, dsc_type type) {
|
||||
case DSC_MGF:
|
||||
case DSC_X:
|
||||
case DSC_VRFL:
|
||||
f2_struct_mread(&st, data, length);
|
||||
f2_struct_read(&st, data, length);
|
||||
data_dsc = (uint32_t*)st.data;
|
||||
if (st.header.use_big_endian)
|
||||
for (size_t i = length / 4; i; i--, data_dsc++)
|
||||
@@ -2040,7 +2040,7 @@ void dsc_unparse(dsc* d, void** data, size_t* length) {
|
||||
st.header.length = 0x40;
|
||||
st.header.use_section_size = true;
|
||||
st.header.inner_signature = 0x13120420;
|
||||
f2_struct_mwrite(&st, data, length, true, false);
|
||||
f2_struct_write(&st, data, length, true, false);
|
||||
f2_struct_free(&st);
|
||||
}
|
||||
else {
|
||||
@@ -2049,7 +2049,7 @@ void dsc_unparse(dsc* d, void** data, size_t* length) {
|
||||
}
|
||||
}
|
||||
|
||||
bool dsc_load_file(void* data, char* path, char* file, uint32_t hash) {
|
||||
bool dsc_load_file(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
string s;
|
||||
string_init(&s, path);
|
||||
string_add(&s, file);
|
||||
|
||||
+1
-1
@@ -431,7 +431,7 @@ extern uint32_t* dsc_data_get_func_data(dsc* d, dsc_data* data);
|
||||
extern void dsc_merge(dsc* d, int32_t count, ...);
|
||||
extern bool dsc_parse(dsc* d, void* data, size_t length, dsc_type type);
|
||||
extern void dsc_unparse(dsc* d, void** data, size_t* length);
|
||||
extern bool dsc_load_file(void* data, char* path, char* file, uint32_t hash);
|
||||
extern bool dsc_load_file(void* data, const char* path, const char* file, uint32_t hash);
|
||||
extern void dsc_free(dsc* d);
|
||||
|
||||
extern void dsc_replace_init(dsc_replace* dr, dsc_type src_type,
|
||||
|
||||
+13
-13
@@ -16,7 +16,7 @@ static void f2_struct_get_length(f2_struct* s, bool shift_x);
|
||||
static void f2_struct_write_pof(stream* s, vector_old_size_t* pof, uint32_t depth, bool shift_x);
|
||||
static void f2_struct_write_enrs(stream* s, vector_old_enrs_entry* enrs, uint32_t depth);
|
||||
|
||||
void f2_struct_read(f2_struct* st, char* path) {
|
||||
void f2_struct_read(f2_struct* st, const char* path) {
|
||||
memset(st, 0, sizeof(f2_struct));
|
||||
|
||||
stream s;
|
||||
@@ -31,11 +31,11 @@ void f2_struct_read(f2_struct* st, char* path) {
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
void f2_struct_wread(f2_struct* st, wchar_t* path) {
|
||||
void f2_struct_read(f2_struct* st, const wchar_t* path) {
|
||||
memset(st, 0, sizeof(f2_struct));
|
||||
|
||||
stream s;
|
||||
io_wopen(&s, path, L"rb");
|
||||
io_open(&s, path, L"rb");
|
||||
if (&s.io.stream) {
|
||||
divafile_sdecrypt(&s);
|
||||
|
||||
@@ -46,11 +46,11 @@ void f2_struct_wread(f2_struct* st, wchar_t* path) {
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
void f2_struct_mread(f2_struct* st, void* data, size_t length) {
|
||||
void f2_struct_read(f2_struct* st, const void* data, size_t length) {
|
||||
memset(st, 0, sizeof(f2_struct));
|
||||
|
||||
stream s;
|
||||
io_mopen(&s, data, length);
|
||||
io_open(&s, data, length);
|
||||
if (&s.io.data.data) {
|
||||
divafile_sdecrypt(&s);
|
||||
|
||||
@@ -61,7 +61,7 @@ void f2_struct_mread(f2_struct* st, void* data, size_t length) {
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
void f2_struct_sread(f2_struct* st, stream* s) {
|
||||
void f2_struct_read(f2_struct* st, stream* s) {
|
||||
memset(st, 0, sizeof(f2_struct));
|
||||
|
||||
if (s->io.stream || s->io.data.data) {
|
||||
@@ -73,7 +73,7 @@ void f2_struct_sread(f2_struct* st, stream* s) {
|
||||
}
|
||||
}
|
||||
|
||||
void f2_struct_write(f2_struct* st, char* path, bool use_depth, bool shift_x) {
|
||||
void f2_struct_write(f2_struct* st, const char* path, bool use_depth, bool shift_x) {
|
||||
stream s;
|
||||
io_open(&s, path, "wb");
|
||||
if (s.io.stream) {
|
||||
@@ -83,9 +83,9 @@ void f2_struct_write(f2_struct* st, char* path, bool use_depth, bool shift_x) {
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
void f2_struct_wwrite(f2_struct* st, wchar_t* path, bool use_depth, bool shift_x) {
|
||||
void f2_struct_write(f2_struct* st, const wchar_t* path, bool use_depth, bool shift_x) {
|
||||
stream s;
|
||||
io_wopen(&s, path, L"wb");
|
||||
io_open(&s, path, L"wb");
|
||||
if (s.io.stream) {
|
||||
f2_struct_get_length(st, shift_x);
|
||||
f2_struct_write_inner(&s, st, 0, use_depth, shift_x);
|
||||
@@ -93,20 +93,20 @@ void f2_struct_wwrite(f2_struct* st, wchar_t* path, bool use_depth, bool shift_x
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
void f2_struct_mwrite(f2_struct* st, void** data, size_t* length, bool use_depth, bool shift_x) {
|
||||
void f2_struct_write(f2_struct* st, void** data, size_t* length, bool use_depth, bool shift_x) {
|
||||
if (!st || !data)
|
||||
return;
|
||||
|
||||
f2_struct_get_length(st, shift_x);
|
||||
stream s;
|
||||
io_mopen(&s, 0, st->header.data_size + 0x40ULL);
|
||||
io_open(&s, 0, st->header.data_size + 0x40ULL);
|
||||
f2_struct_write_inner(&s, st, 0, use_depth, shift_x);
|
||||
|
||||
io_mcopy(&s, data, length);
|
||||
io_copy(&s, data, length);
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
void f2_struct_swrite(f2_struct* st, stream* s, bool use_depth, bool shift_x) {
|
||||
void f2_struct_write(f2_struct* st, stream* s, bool use_depth, bool shift_x) {
|
||||
if (s->io.stream || s->type == STREAM_MEMORY) {
|
||||
f2_struct_get_length(st, shift_x);
|
||||
f2_struct_write_inner(s, st, 0, use_depth, shift_x);
|
||||
|
||||
@@ -25,12 +25,12 @@ struct f2_struct {
|
||||
vector_old_size_t pof;
|
||||
};
|
||||
|
||||
extern void f2_struct_read(f2_struct* st, char* path);
|
||||
extern void f2_struct_wread(f2_struct* st, wchar_t* path);
|
||||
extern void f2_struct_mread(f2_struct* st, void* data, size_t length);
|
||||
extern void f2_struct_sread(f2_struct* st, stream* s);
|
||||
extern void f2_struct_write(f2_struct* st, char* path, bool use_depth, bool shift_x);
|
||||
extern void f2_struct_wwrite(f2_struct* st, wchar_t* path, bool use_depth, bool shift_x);
|
||||
extern void f2_struct_mwrite(f2_struct* st, void** data, size_t* length, bool use_depth, bool shift_x);
|
||||
extern void f2_struct_swrite(f2_struct* st, stream* s, bool use_depth, bool shift_x);
|
||||
extern void f2_struct_read(f2_struct* st, const char* path);
|
||||
extern void f2_struct_read(f2_struct* st, const wchar_t* path);
|
||||
extern void f2_struct_read(f2_struct* st, const void* data, size_t length);
|
||||
extern void f2_struct_read(f2_struct* st, stream* s);
|
||||
extern void f2_struct_write(f2_struct* st, const char* path, bool use_depth, bool shift_x);
|
||||
extern void f2_struct_write(f2_struct* st, const wchar_t* path, bool use_depth, bool shift_x);
|
||||
extern void f2_struct_write(f2_struct* st, void** data, size_t* length, bool use_depth, bool shift_x);
|
||||
extern void f2_struct_write(f2_struct* st, stream* s, bool use_depth, bool shift_x);
|
||||
extern void f2_struct_free(f2_struct* st);
|
||||
|
||||
+62
-86
@@ -40,10 +40,11 @@ data(), data_compressed(), flags(), data_changed() {
|
||||
}
|
||||
|
||||
farc_file::~farc_file() {
|
||||
|
||||
delete data;
|
||||
delete data_compressed;
|
||||
}
|
||||
|
||||
size_t farc::get_file_size(char* name) {
|
||||
size_t farc::get_file_size(const char* name) {
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
@@ -53,11 +54,7 @@ size_t farc::get_file_size(char* name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t farc::get_file_size(const char* name) {
|
||||
return get_file_size((char*)name);
|
||||
}
|
||||
|
||||
size_t farc::get_file_size(wchar_t* name) {
|
||||
size_t farc::get_file_size(const wchar_t* name) {
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
@@ -71,19 +68,6 @@ size_t farc::get_file_size(wchar_t* name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t farc::get_file_size(const wchar_t* name) {
|
||||
return get_file_size((wchar_t*)name);
|
||||
}
|
||||
|
||||
void farc::read(char* path, bool unpack, bool save) {
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
wchar_t* path_buf = utf8_to_utf16(path);
|
||||
read(path_buf, unpack, save);
|
||||
free(path_buf);
|
||||
}
|
||||
|
||||
void farc::read(const char* path, bool unpack, bool save) {
|
||||
if (!path)
|
||||
return;
|
||||
@@ -93,55 +77,56 @@ void farc::read(const char* path, bool unpack, bool save) {
|
||||
free(path_buf);
|
||||
}
|
||||
|
||||
void farc::read(wchar_t* path, bool unpack, bool save) {
|
||||
void farc::read(const wchar_t* path, bool unpack, bool save) {
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
files = {};
|
||||
files.clear();
|
||||
files.shrink_to_fit();
|
||||
|
||||
wchar_t full_path_buf[MAX_PATH];
|
||||
wchar_t* full_path = _wfullpath(full_path_buf, path, MAX_PATH);
|
||||
|
||||
if (!full_path)
|
||||
return;
|
||||
else if (!path_wcheck_file_exists(full_path_buf))
|
||||
else if (!path_check_file_exists(full_path_buf))
|
||||
return;
|
||||
|
||||
size_t full_path_buf_len = utf16_length(full_path_buf);
|
||||
file_path = std::wstring(full_path_buf, full_path_buf_len);
|
||||
directory_path = std::wstring(full_path_buf, full_path_buf_len);
|
||||
const wchar_t* dot = wcsrchr(directory_path.c_str(), L'.');
|
||||
char* dir_temp = utf16_to_utf8(full_path_buf);
|
||||
size_t dir_temp_len = utf8_length(dir_temp);
|
||||
file_path = std::string(dir_temp, dir_temp_len);
|
||||
directory_path = std::string(dir_temp, dir_temp_len);
|
||||
free(dir_temp);
|
||||
|
||||
const char* dot = strrchr(directory_path.c_str(), '.');
|
||||
if (dot)
|
||||
directory_path = std::wstring(directory_path.c_str(), dot - directory_path.c_str());
|
||||
directory_path = std::string(directory_path.c_str(), dot - directory_path.c_str());
|
||||
|
||||
stream s;
|
||||
io_wopen(&s, file_path.c_str(), L"rb");
|
||||
io_open(&s, file_path.c_str(), "rb");
|
||||
if (s.io.stream && !farc_read_header(this, &s) && unpack)
|
||||
farc_unpack_files(this, &s, save);
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
void farc::read(const wchar_t* path, bool unpack, bool save) {
|
||||
read((wchar_t*)path, unpack, save);
|
||||
}
|
||||
|
||||
void farc::read(void* data, size_t length, bool unpack) {
|
||||
void farc::read(const void* data, size_t length, bool unpack) {
|
||||
if (!data || !length)
|
||||
return;
|
||||
|
||||
files = {};
|
||||
files.clear();
|
||||
files.shrink_to_fit();
|
||||
|
||||
file_path = std::wstring(L"", 0);
|
||||
directory_path = std::wstring(L"", 0);
|
||||
file_path = std::string("", 0);
|
||||
directory_path = std::string("", 0);
|
||||
|
||||
stream s;
|
||||
io_mopen(&s, data, length);
|
||||
io_open(&s, data, length);
|
||||
if (!farc_read_header(this, &s) && unpack)
|
||||
farc_unpack_files(this, &s, false);
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
farc_file* farc::read_file(char* name) {
|
||||
farc_file* farc::read_file(const char* name) {
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
@@ -154,7 +139,7 @@ farc_file* farc::read_file(char* name) {
|
||||
&i.data, &i.size, DEFLATE_MODE_GZIP);
|
||||
else if (!i.data) {
|
||||
stream s;
|
||||
io_wopen(&s, file_path.c_str(), L"rb");
|
||||
io_open(&s, file_path.c_str(), "rb");
|
||||
if (s.io.stream)
|
||||
farc_unpack_file(this, &s, &i);
|
||||
io_free(&s);
|
||||
@@ -164,11 +149,7 @@ farc_file* farc::read_file(char* name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
farc_file* farc::read_file(const char* name) {
|
||||
return read_file((char*)name);
|
||||
}
|
||||
|
||||
farc_file* farc::read_file(wchar_t* name) {
|
||||
farc_file* farc::read_file(const wchar_t* name) {
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
@@ -179,7 +160,7 @@ farc_file* farc::read_file(wchar_t* name) {
|
||||
|
||||
if (!i.data) {
|
||||
stream s;
|
||||
io_wopen(&s, file_path.c_str(), L"rb");
|
||||
io_open(&s, file_path.c_str(), "rb");
|
||||
if (s.io.stream)
|
||||
farc_unpack_file(this, &s, &i);
|
||||
io_free(&s);
|
||||
@@ -191,11 +172,7 @@ farc_file* farc::read_file(wchar_t* name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
farc_file* farc::read_file(const wchar_t* name) {
|
||||
return read_file((wchar_t*)name);
|
||||
}
|
||||
|
||||
void farc::write(char* path, farc_compress_mode mode, bool get_files) {
|
||||
void farc::write(const char* path, farc_compress_mode mode, bool get_files) {
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
@@ -204,49 +181,53 @@ void farc::write(char* path, farc_compress_mode mode, bool get_files) {
|
||||
free(path_buf);
|
||||
}
|
||||
|
||||
void farc::write(wchar_t* path, farc_compress_mode mode, bool get_files) {
|
||||
void farc::write(const wchar_t* path, farc_compress_mode mode, bool get_files) {
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
if (get_files)
|
||||
files = {};
|
||||
if (get_files) {
|
||||
files.clear();
|
||||
files.shrink_to_fit();
|
||||
}
|
||||
|
||||
wchar_t full_path_buf[MAX_PATH];
|
||||
wchar_t* full_path = _wfullpath(full_path_buf, path, MAX_PATH);
|
||||
|
||||
if (!full_path)
|
||||
return;
|
||||
else if (get_files && !path_wcheck_directory_exists(full_path_buf))
|
||||
else if (get_files && !path_check_directory_exists(full_path_buf))
|
||||
return;
|
||||
|
||||
size_t full_path_buf_len = utf16_length(full_path_buf);
|
||||
directory_path = std::wstring(full_path_buf, full_path_buf_len);
|
||||
file_path = std::wstring(full_path_buf, full_path_buf_len);
|
||||
file_path += L".farc", 6;
|
||||
char* dir_temp = utf16_to_utf8(full_path_buf);
|
||||
size_t dir_temp_len = utf8_length(dir_temp);
|
||||
directory_path = std::string(dir_temp, dir_temp_len);
|
||||
file_path = std::string(dir_temp, dir_temp_len);
|
||||
file_path += ".farc", 6;
|
||||
free(dir_temp);
|
||||
|
||||
if (!get_files || (get_files && !farc_get_files(this))) {
|
||||
stream s;
|
||||
io_wopen(&s, file_path.c_str(), L"wb");
|
||||
io_open(&s, file_path.c_str(), "wb");
|
||||
if (s.io.stream)
|
||||
farc_pack_files(this, &s, mode, get_files);
|
||||
io_free(&s);
|
||||
}
|
||||
}
|
||||
|
||||
void farc::write( void** data, size_t* length, farc_compress_mode mode) {
|
||||
void farc::write(void** data, size_t* length, farc_compress_mode mode) {
|
||||
if (!data || !length)
|
||||
return;
|
||||
|
||||
directory_path = std::wstring(L"", 0);
|
||||
file_path = std::wstring(L"", 0);
|
||||
directory_path = std::string("", 0);
|
||||
file_path = std::string("", 0);
|
||||
|
||||
stream s;
|
||||
io_mopen(&s, 0, 0);
|
||||
io_open(&s);
|
||||
farc_pack_files(this, &s, mode, false);
|
||||
io_free(&s);
|
||||
}
|
||||
|
||||
bool farc::load_file(void* data, char* path, char* file, uint32_t hash) {
|
||||
bool farc::load_file(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
size_t file_len = utf8_length(file);
|
||||
if (file_len >= 5 && memcmp(&file[file_len - 5], ".farc", 6))
|
||||
return false;
|
||||
@@ -267,25 +248,17 @@ bool farc::load_file(void* data, char* path, char* file, uint32_t hash) {
|
||||
}
|
||||
|
||||
static errno_t farc_get_files(farc* f) {
|
||||
f->files = {};
|
||||
f->files.clear();
|
||||
f->files.shrink_to_fit();
|
||||
|
||||
vector_old_wstring files = vector_old_empty(wstring);
|
||||
path_wget_files(&files, f->directory_path.c_str());
|
||||
if (vector_old_length(files) < 1) {
|
||||
vector_old_wstring_free(&files, wstring_free);
|
||||
std::vector<std::string> files;
|
||||
path_get_files(&files, f->directory_path.c_str());
|
||||
if (files.size() < 1)
|
||||
return -1;
|
||||
}
|
||||
|
||||
f->files = std::vector<farc_file>(vector_old_length(files));
|
||||
if (files.begin)
|
||||
for (farc_file& i : f->files) {
|
||||
wstring* str = &files.begin[&i - f->files.data()];
|
||||
char* temp = utf16_to_utf8(wstring_data(str));
|
||||
i.name = std::string(temp);
|
||||
free(temp)
|
||||
}
|
||||
|
||||
vector_old_wstring_free(&files, wstring_free);
|
||||
f->files = std::vector<farc_file>(files.size());
|
||||
for (farc_file& i : f->files)
|
||||
i.name = files[&i - f->files.data()];
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -371,7 +344,7 @@ static void farc_pack_files(farc* f, stream* s, farc_compress_mode mode, bool ge
|
||||
i.offset = io_get_position(s);
|
||||
|
||||
stream s_t;
|
||||
io_wopen(&s_t, temp, L"rb");
|
||||
io_open(&s_t, temp, L"rb");
|
||||
if (!s_t.io.stream) {
|
||||
io_free(&s_t);
|
||||
continue;
|
||||
@@ -579,7 +552,8 @@ static errno_t farc_read_header(farc* f, stream* s) {
|
||||
header_length -= 0x0C;
|
||||
}
|
||||
|
||||
f->files = {};
|
||||
f->files.clear();
|
||||
f->files.shrink_to_fit();
|
||||
|
||||
uint8_t* d_t;
|
||||
uint8_t* dt;
|
||||
@@ -676,10 +650,12 @@ static void farc_unpack_files(farc* f, stream* s, bool save) {
|
||||
max_path_len = path_len;
|
||||
}
|
||||
|
||||
CreateDirectoryW(f->directory_path.c_str(), 0);
|
||||
wchar_t* dir_temp = utf8_to_utf16(f->directory_path.c_str());
|
||||
CreateDirectoryW(dir_temp, 0);
|
||||
wchar_t* temp_path = force_malloc_s(wchar_t, max_path_len + 1);
|
||||
memcpy(temp_path, f->directory_path.c_str(), sizeof(wchar_t) * dir_len);
|
||||
memcpy(temp_path, dir_temp, sizeof(wchar_t) * dir_len);
|
||||
temp_path[dir_len] = L'\\';
|
||||
free(dir_temp);
|
||||
|
||||
for (farc_file& i : f->files) {
|
||||
wchar_t* name_buf = utf8_to_utf16(i.name.c_str());
|
||||
@@ -692,7 +668,7 @@ static void farc_unpack_files(farc* f, stream* s, bool save) {
|
||||
|
||||
if (i.data) {
|
||||
stream temp_s;
|
||||
io_wopen(&temp_s, temp_path, L"wb");
|
||||
io_open(&temp_s, temp_path, L"wb");
|
||||
if (temp_s.io.stream)
|
||||
io_write(&temp_s, i.data, i.size);
|
||||
io_free(&temp_s);
|
||||
|
||||
+6
-12
@@ -47,8 +47,8 @@ public:
|
||||
|
||||
class farc {
|
||||
public:
|
||||
std::wstring file_path;
|
||||
std::wstring directory_path;
|
||||
std::string file_path;
|
||||
std::string directory_path;
|
||||
std::vector<farc_file> files;
|
||||
farc_signature signature;
|
||||
farc_flags flags;
|
||||
@@ -58,22 +58,16 @@ public:
|
||||
farc();
|
||||
~farc();
|
||||
|
||||
size_t get_file_size(char* name);
|
||||
size_t get_file_size(const char* name);
|
||||
size_t get_file_size(wchar_t* name);
|
||||
size_t get_file_size(const wchar_t* name);
|
||||
void read(char* path, bool unpack, bool save);
|
||||
void read(const char* path, bool unpack, bool save);
|
||||
void read(wchar_t* path, bool unpack, bool save);
|
||||
void read(const wchar_t* path, bool unpack, bool save);
|
||||
void read(void* data, size_t length, bool unpack);
|
||||
farc_file* read_file(char* name);
|
||||
void read(const void* data, size_t length, bool unpack);
|
||||
farc_file* read_file(const char* name);
|
||||
farc_file* read_file(wchar_t* name);
|
||||
farc_file* read_file(const wchar_t* name);
|
||||
void write(char* path, farc_compress_mode mode, bool get_files);
|
||||
void write(wchar_t* path, farc_compress_mode mode, bool get_files);
|
||||
void write(const char* path, farc_compress_mode mode, bool get_files);
|
||||
void write(const wchar_t* path, farc_compress_mode mode, bool get_files);
|
||||
void write(void** data, size_t* length, farc_compress_mode mode);
|
||||
|
||||
static bool load_file(void* data, char* path, char* file, uint32_t hash);
|
||||
static bool load_file(void* data, const char* path, const char* file, uint32_t hash);
|
||||
};
|
||||
|
||||
+9
-69
@@ -46,8 +46,8 @@ const uint32_t hash_crc16_ccitt_empty = 0xFFFF;
|
||||
|
||||
// FNV 1a 64-bit Modified
|
||||
// 0x1403B04D0 in SBZV_7.10
|
||||
inline uint64_t hash_fnv1a64m(void* data, size_t length, bool make_upper) {
|
||||
uint8_t* d = (uint8_t*)data;
|
||||
inline uint64_t hash_fnv1a64m(const void* data, size_t length, bool make_upper) {
|
||||
const uint8_t* d = (const uint8_t*)data;
|
||||
|
||||
uint64_t hash = 0xCBF29CE484222325;
|
||||
if (data)
|
||||
@@ -67,27 +67,11 @@ inline uint64_t hash_fnv1a64m(void* data, size_t length, bool make_upper) {
|
||||
return (hash >> 32) ^ hash; // Actual Modification
|
||||
}
|
||||
|
||||
inline uint64_t hash_fnv1a64m(const void* data, size_t length, bool make_upper) {
|
||||
return hash_fnv1a64m((void*)data, length, make_upper);
|
||||
}
|
||||
|
||||
inline uint64_t hash_utf8_fnv1a64m(char* data, bool make_upper) {
|
||||
uint64_t hash = hash_fnv1a64m(data, utf8_length(data), make_upper);
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline uint64_t hash_utf8_fnv1a64m(const char* data, bool make_upper) {
|
||||
uint64_t hash = hash_fnv1a64m(data, utf8_length(data), make_upper);
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline uint64_t hash_utf16_fnv1a64m(wchar_t* data, bool make_upper) {
|
||||
char* temp = utf16_to_utf8(data);
|
||||
uint64_t hash = hash_fnv1a64m(temp, utf8_length(temp), make_upper);
|
||||
free(temp);
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline uint64_t hash_utf16_fnv1a64m(const wchar_t* data, bool make_upper) {
|
||||
char* temp = utf16_to_utf8(data);
|
||||
uint64_t hash = hash_fnv1a64m(temp, utf8_length(temp), make_upper);
|
||||
@@ -95,14 +79,10 @@ inline uint64_t hash_utf16_fnv1a64m(const wchar_t* data, bool make_upper) {
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline uint64_t hash_string_fnv1a64m(string* data, bool make_upper) {
|
||||
inline uint64_t hash_string_fnv1a64m(const string* data, bool make_upper) {
|
||||
return hash_fnv1a64m(string_data(data), data->length, make_upper);
|
||||
}
|
||||
|
||||
inline uint64_t hash_string_fnv1a64m(std::string* data, bool make_upper) {
|
||||
return hash_fnv1a64m(data->c_str(), data->size(), make_upper);
|
||||
}
|
||||
|
||||
inline uint64_t hash_string_fnv1a64m(const std::string* data, bool make_upper) {
|
||||
return hash_fnv1a64m(data->c_str(), data->size(), make_upper);
|
||||
}
|
||||
@@ -111,9 +91,9 @@ inline uint64_t hash_string_fnv1a64m(const std::string* data, bool make_upper) {
|
||||
// 0x814D7A9C in PCSB00554
|
||||
// 0x8134C304 in PCSB01007
|
||||
// 0x0069CEA4 in NPEB02013
|
||||
uint32_t hash_murmurhash(void* data, size_t length,
|
||||
uint32_t hash_murmurhash(const void* data, size_t length,
|
||||
uint32_t seed, bool upper, bool big_endian) {
|
||||
uint8_t* d = (uint8_t*)data;
|
||||
const uint8_t* d = (const uint8_t*)data;
|
||||
|
||||
uint32_t a, b, hash;
|
||||
size_t i;
|
||||
@@ -240,27 +220,11 @@ uint32_t hash_murmurhash(void* data, size_t length,
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline uint32_t hash_murmurhash(const void* data, size_t length, uint32_t seed, bool upper, bool big_endian) {
|
||||
return hash_murmurhash((void*)data, length, seed, upper, big_endian);
|
||||
}
|
||||
|
||||
inline uint32_t hash_utf8_murmurhash(char* data, uint32_t seed, bool upper) {
|
||||
uint32_t hash = hash_murmurhash(data, utf8_length(data), seed, upper, false);
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline uint32_t hash_utf8_murmurhash(const char* data, uint32_t seed, bool upper) {
|
||||
uint32_t hash = hash_murmurhash(data, utf8_length(data), seed, upper, false);
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline uint32_t hash_utf16_murmurhash(wchar_t* data, uint32_t seed, bool upper) {
|
||||
char* temp = utf16_to_utf8(data);
|
||||
uint32_t hash = hash_murmurhash(temp, utf8_length(temp), seed, upper, false);
|
||||
free(temp);
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline uint32_t hash_utf16_murmurhash(const wchar_t* data, uint32_t seed, bool upper) {
|
||||
char* temp = utf16_to_utf8(data);
|
||||
uint32_t hash = hash_murmurhash(temp, utf8_length(temp), seed, upper, false);
|
||||
@@ -268,22 +232,18 @@ inline uint32_t hash_utf16_murmurhash(const wchar_t* data, uint32_t seed, bool u
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline uint32_t hash_string_murmurhash(string* data, uint32_t seed, bool upper) {
|
||||
inline uint32_t hash_string_murmurhash(const string* data, uint32_t seed, bool upper) {
|
||||
return hash_murmurhash(string_data(data), data->length, seed, upper, false);
|
||||
}
|
||||
|
||||
inline uint32_t hash_string_murmurhash(std::string* data, uint32_t seed, bool upper) {
|
||||
return hash_murmurhash(data->c_str(), data->size(), seed, upper, false);
|
||||
}
|
||||
|
||||
inline uint32_t hash_string_murmurhash(const std::string* data, uint32_t seed, bool upper) {
|
||||
return hash_murmurhash(data->c_str(), data->size(), seed, upper, false);
|
||||
}
|
||||
|
||||
// CRC16-CCITT
|
||||
// 0x140011A90 in SBZV_7.10
|
||||
inline uint16_t hash_crc16_ccitt(void* data, size_t length, bool make_upper) {
|
||||
uint8_t* d = (uint8_t*)data;
|
||||
inline uint16_t hash_crc16_ccitt(const void* data, size_t length, bool make_upper) {
|
||||
const uint8_t* d = (const uint8_t*)data;
|
||||
|
||||
uint16_t hash = 0xFFFF;
|
||||
if (make_upper) // Modification for only uppercase latin text
|
||||
@@ -299,27 +259,11 @@ inline uint16_t hash_crc16_ccitt(void* data, size_t length, bool make_upper) {
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline uint16_t hash_crc16_ccitt(const void* data, size_t length, bool make_upper) {
|
||||
return hash_crc16_ccitt((void*)data, length, make_upper);
|
||||
}
|
||||
|
||||
inline uint16_t hash_utf8_crc16_ccitt(char* data, bool make_upper) {
|
||||
uint32_t hash = hash_crc16_ccitt(data, utf8_length(data), make_upper);
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline uint16_t hash_utf8_crc16_ccitt(const char* data, bool make_upper) {
|
||||
uint32_t hash = hash_crc16_ccitt(data, utf8_length(data), make_upper);
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline uint16_t hash_utf16_crc16_ccitt(wchar_t* data, bool make_upper) {
|
||||
char* temp = utf16_to_utf8(data);
|
||||
uint32_t hash = hash_crc16_ccitt(temp, utf8_length(temp), make_upper);
|
||||
free(temp);
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline uint16_t hash_utf16_crc16_ccitt(const wchar_t* data, bool make_upper) {
|
||||
char* temp = utf16_to_utf8(data);
|
||||
uint32_t hash = hash_crc16_ccitt(temp, utf8_length(temp), make_upper);
|
||||
@@ -327,14 +271,10 @@ inline uint16_t hash_utf16_crc16_ccitt(const wchar_t* data, bool make_upper) {
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline uint16_t hash_string_crc16_ccitt(string* data, bool make_upper) {
|
||||
inline uint16_t hash_string_crc16_ccitt(const string* data, bool make_upper) {
|
||||
return hash_crc16_ccitt(string_data(data), data->length, make_upper);
|
||||
}
|
||||
|
||||
inline uint16_t hash_string_crc16_ccitt(std::string* data, bool make_upper) {
|
||||
return hash_crc16_ccitt(data->c_str(), data->size(), make_upper);
|
||||
}
|
||||
|
||||
inline uint16_t hash_string_crc16_ccitt(const std::string* data, bool make_upper) {
|
||||
return hash_crc16_ccitt(data->c_str(), data->size(), make_upper);
|
||||
}
|
||||
|
||||
+4
-16
@@ -13,30 +13,18 @@ extern const uint64_t hash_fnv1a64m_empty;
|
||||
extern const uint32_t hash_murmurhash_empty;
|
||||
extern const uint32_t hash_crc16_ccitt_empty;
|
||||
|
||||
extern uint64_t hash_fnv1a64m(void* data, size_t length, bool make_upper);
|
||||
inline uint64_t hash_fnv1a64m(const void* data, size_t length, bool make_upper);
|
||||
extern uint64_t hash_utf8_fnv1a64m(char* data, bool make_upper);
|
||||
extern uint64_t hash_fnv1a64m(const void* data, size_t length, bool make_upper);
|
||||
extern uint64_t hash_utf8_fnv1a64m(const char* data, bool make_upper);
|
||||
extern uint64_t hash_utf16_fnv1a64m(wchar_t* data, bool make_upper);
|
||||
extern uint64_t hash_utf16_fnv1a64m(const wchar_t* data, bool make_upper);
|
||||
extern uint64_t hash_string_fnv1a64m(string* data, bool make_upper);
|
||||
extern uint64_t hash_string_fnv1a64m(std::string* data, bool make_upper);
|
||||
extern uint64_t hash_string_fnv1a64m(const string* data, bool make_upper);
|
||||
extern uint64_t hash_string_fnv1a64m(const std::string* data, bool make_upper);
|
||||
extern uint32_t hash_murmurhash(void* data, size_t length, uint32_t seed, bool upper, bool big_endian);
|
||||
extern uint32_t hash_murmurhash(const void* data, size_t length, uint32_t seed, bool upper, bool big_endian);
|
||||
extern uint32_t hash_utf8_murmurhash(char* data, uint32_t seed, bool upper);
|
||||
extern uint32_t hash_utf8_murmurhash(const char* data, uint32_t seed, bool upper);
|
||||
extern uint32_t hash_utf16_murmurhash(wchar_t* data, uint32_t seed, bool upper);
|
||||
extern uint32_t hash_utf16_murmurhash(const wchar_t* data, uint32_t seed, bool upper);
|
||||
extern uint32_t hash_string_murmurhash(string* data, uint32_t seed, bool upper);
|
||||
extern uint32_t hash_string_murmurhash(std::string* data, uint32_t seed, bool upper);
|
||||
extern uint32_t hash_string_murmurhash(const string* data, uint32_t seed, bool upper);
|
||||
extern uint32_t hash_string_murmurhash(const std::string* data, uint32_t seed, bool upper);
|
||||
extern uint16_t hash_crc16_ccitt(void* data, size_t length, bool make_upper);
|
||||
extern uint16_t hash_crc16_ccitt(const void* data, size_t length, bool make_upper);
|
||||
extern uint16_t hash_utf8_crc16_ccitt(char* data, bool make_upper);
|
||||
extern uint16_t hash_utf8_crc16_ccitt(const char* data, bool make_upper);
|
||||
extern uint16_t hash_utf16_crc16_ccitt(wchar_t* data, bool make_upper);
|
||||
extern uint16_t hash_utf16_crc16_ccitt(const wchar_t* data, bool make_upper);
|
||||
extern uint16_t hash_string_crc16_ccitt(string* data, bool make_upper);
|
||||
extern uint16_t hash_string_crc16_ccitt(std::string* data, bool make_upper);
|
||||
extern uint16_t hash_string_crc16_ccitt(const string* data, bool make_upper);
|
||||
extern uint16_t hash_string_crc16_ccitt(const std::string* data, bool make_upper);
|
||||
|
||||
+81
-85
@@ -20,7 +20,7 @@ inline bool path_check_path_exists(const char* path) {
|
||||
return path_check_path_exists((char*)path);
|
||||
}
|
||||
|
||||
bool path_wcheck_path_exists(wchar_t* path) {
|
||||
bool path_check_path_exists(wchar_t* path) {
|
||||
DWORD ftyp = GetFileAttributesW(path);
|
||||
if (ftyp == INVALID_FILE_ATTRIBUTES)
|
||||
return false;
|
||||
@@ -28,8 +28,8 @@ bool path_wcheck_path_exists(wchar_t* path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool path_wcheck_path_exists(const wchar_t* path) {
|
||||
return path_wcheck_path_exists((wchar_t*)path);
|
||||
inline bool path_check_path_exists(const wchar_t* path) {
|
||||
return path_check_path_exists((wchar_t*)path);
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ inline bool path_check_file_exists(const char* path) {
|
||||
return path_check_file_exists((char*)path);
|
||||
}
|
||||
|
||||
bool path_wcheck_file_exists(wchar_t* path) {
|
||||
bool path_check_file_exists(wchar_t* path) {
|
||||
DWORD ftyp = GetFileAttributesW(path);
|
||||
if (ftyp == INVALID_FILE_ATTRIBUTES)
|
||||
return false;
|
||||
@@ -55,8 +55,8 @@ bool path_wcheck_file_exists(wchar_t* path) {
|
||||
return ftyp & FILE_ATTRIBUTE_DIRECTORY ? false : true;
|
||||
}
|
||||
|
||||
inline bool path_wcheck_file_exists(const wchar_t* path) {
|
||||
return path_wcheck_file_exists((wchar_t*)path);
|
||||
inline bool path_check_file_exists(const wchar_t* path) {
|
||||
return path_check_file_exists((wchar_t*)path);
|
||||
}
|
||||
|
||||
bool path_check_directory_exists(char* path) {
|
||||
@@ -73,7 +73,7 @@ inline bool path_check_directory_exists(const char* path) {
|
||||
return path_check_directory_exists((char*)path);
|
||||
}
|
||||
|
||||
bool path_wcheck_directory_exists(wchar_t* path) {
|
||||
bool path_check_directory_exists(wchar_t* path) {
|
||||
DWORD ftyp = GetFileAttributesW(path);
|
||||
if (ftyp == INVALID_FILE_ATTRIBUTES)
|
||||
return false;
|
||||
@@ -81,12 +81,13 @@ bool path_wcheck_directory_exists(wchar_t* path) {
|
||||
return ftyp & FILE_ATTRIBUTE_DIRECTORY ? true : false;
|
||||
}
|
||||
|
||||
inline bool path_wcheck_directory_exists(const wchar_t* path) {
|
||||
return path_wcheck_directory_exists((wchar_t*)path);
|
||||
inline bool path_check_directory_exists(const wchar_t* path) {
|
||||
return path_check_directory_exists((wchar_t*)path);
|
||||
}
|
||||
|
||||
void path_get_files(vector_old_string* files, char* path) {
|
||||
vector_old_string_free(files, string_free);
|
||||
void path_get_files(std::vector<std::string>* files, char* path) {
|
||||
files->clear();
|
||||
files->shrink_to_fit();
|
||||
|
||||
wchar_t* dir_temp = utf8_to_utf16(path);
|
||||
size_t dir_len = utf16_length(dir_temp);
|
||||
@@ -122,20 +123,21 @@ void path_get_files(vector_old_string* files, char* path) {
|
||||
continue;
|
||||
|
||||
char* file_temp = utf16_to_utf8(fdata.cFileName);
|
||||
string* file = vector_old_string_reserve_back(files);
|
||||
string_init(file, file_temp);
|
||||
std::string file = std::string(file_temp);
|
||||
files->push_back(file);
|
||||
free(file_temp);
|
||||
} while (FindNextFileW(h, &fdata));
|
||||
FindClose(h);
|
||||
free(dir);
|
||||
}
|
||||
|
||||
inline void path_get_files(vector_old_string* files, const char* path) {
|
||||
inline void path_get_files(std::vector<std::string>* files, const char* path) {
|
||||
path_get_files(files, (char*)path);
|
||||
}
|
||||
|
||||
void path_wget_files(vector_old_wstring* files, wchar_t* path) {
|
||||
vector_old_wstring_free(files, wstring_free);
|
||||
void path_get_files(std::vector<std::wstring>* files, wchar_t* path) {
|
||||
files->clear();
|
||||
files->shrink_to_fit();
|
||||
|
||||
size_t dir_len = utf16_length(path);
|
||||
|
||||
@@ -166,20 +168,21 @@ void path_wget_files(vector_old_wstring* files, wchar_t* path) {
|
||||
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
|
||||
wstring* file = vector_old_wstring_reserve_back(files);
|
||||
wstring_init(file, fdata.cFileName);
|
||||
std::wstring file = std::wstring(fdata.cFileName);
|
||||
files->push_back(file);
|
||||
} while (FindNextFileW(h, &fdata));
|
||||
FindClose(h);
|
||||
free(dir);
|
||||
}
|
||||
|
||||
inline void path_wget_files(vector_old_wstring* files, const wchar_t* path) {
|
||||
path_wget_files(files, (wchar_t*)path);
|
||||
inline void path_get_files(std::vector<std::wstring>* files, const wchar_t* path) {
|
||||
path_get_files(files, (wchar_t*)path);
|
||||
}
|
||||
|
||||
void path_get_directories(vector_old_string* directories, char* path,
|
||||
void path_get_directories(std::vector<std::string>* directories, char* path,
|
||||
char** exclude_list, size_t exclude_count) {
|
||||
vector_old_string_free(directories, string_free);
|
||||
directories->clear();
|
||||
directories->shrink_to_fit();
|
||||
|
||||
wchar_t* dir_temp = utf8_to_utf16(path);
|
||||
size_t dir_len = utf16_length(dir_temp);
|
||||
@@ -247,8 +250,8 @@ void path_get_directories(vector_old_string* directories, char* path,
|
||||
|
||||
|
||||
char* directory_temp = utf16_to_utf8(fdata.cFileName);
|
||||
string* directory = vector_old_string_reserve_back(directories);
|
||||
string_init(directory, directory_temp);
|
||||
std::string directory = std::string(directory_temp);
|
||||
directories->push_back(directory);
|
||||
free(directory_temp);
|
||||
} while (FindNextFileW(h, &fdata));
|
||||
FindClose(h);
|
||||
@@ -256,14 +259,15 @@ void path_get_directories(vector_old_string* directories, char* path,
|
||||
free(dir);
|
||||
}
|
||||
|
||||
inline void path_get_directories(vector_old_string* directories, const char* path,
|
||||
inline void path_get_directories(std::vector<std::string>* directories, const char* path,
|
||||
char** exclude_list, size_t exclude_count) {
|
||||
path_get_directories(directories, (char*)path, exclude_list, exclude_count);
|
||||
}
|
||||
|
||||
void path_wget_directories(vector_old_wstring* directories, wchar_t* path,
|
||||
void path_get_directories(std::vector<std::wstring>* directories, wchar_t* path,
|
||||
wchar_t** exclude_list, size_t exclude_count) {
|
||||
vector_old_wstring_free(directories, wstring_free);
|
||||
directories->clear();
|
||||
directories->shrink_to_fit();
|
||||
|
||||
size_t dir_len = utf16_length(path);
|
||||
|
||||
@@ -323,22 +327,23 @@ void path_wget_directories(vector_old_wstring* directories, wchar_t* path,
|
||||
continue;
|
||||
}
|
||||
|
||||
wstring* directory = vector_old_wstring_reserve_back(directories);
|
||||
wstring_init(directory, fdata.cFileName);
|
||||
std::wstring directory = std::wstring(fdata.cFileName);
|
||||
directories->push_back(directory);
|
||||
} while (FindNextFileW(h, &fdata));
|
||||
FindClose(h);
|
||||
free(temp);
|
||||
free(dir);
|
||||
}
|
||||
|
||||
inline void path_wget_directories(vector_old_wstring* directories, const wchar_t* path,
|
||||
inline void path_get_directories(std::vector<std::wstring>* directories, const wchar_t* path,
|
||||
wchar_t** exclude_list, size_t exclude_count) {
|
||||
path_wget_directories(directories, (wchar_t*)path, exclude_list, exclude_count);
|
||||
path_get_directories(directories, (wchar_t*)path, exclude_list, exclude_count);
|
||||
}
|
||||
|
||||
void path_get_directories_recursive(vector_old_string* directories, char* path,
|
||||
void path_get_directories_recursive(std::vector<std::string>* directories, char* path,
|
||||
char** exclude_list, size_t exclude_count) {
|
||||
vector_old_string_free(directories, string_free);
|
||||
directories->clear();
|
||||
directories->shrink_to_fit();
|
||||
|
||||
wchar_t* dir_temp = utf8_to_utf16(path);
|
||||
size_t dir_len = utf16_length(dir_temp);
|
||||
@@ -379,7 +384,7 @@ void path_get_directories_recursive(vector_old_string* directories, char* path,
|
||||
return;
|
||||
}
|
||||
|
||||
vector_old_string temp_vec = vector_old_empty(string);
|
||||
std::vector<std::string> temp_vec;
|
||||
do {
|
||||
if (~fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
@@ -406,8 +411,8 @@ void path_get_directories_recursive(vector_old_string* directories, char* path,
|
||||
}
|
||||
|
||||
char* directory_temp = utf16_to_utf8(fdata.cFileName);
|
||||
string* directory = vector_old_string_reserve_back(&temp_vec);
|
||||
string_init(directory, directory_temp);
|
||||
std::string directory = std::string(directory_temp);
|
||||
temp_vec.push_back(directory);
|
||||
free(directory_temp);
|
||||
} while (FindNextFileW(h, &fdata));
|
||||
FindClose(h);
|
||||
@@ -415,8 +420,8 @@ void path_get_directories_recursive(vector_old_string* directories, char* path,
|
||||
free(dir);
|
||||
|
||||
size_t max_len = 0;
|
||||
for (string* i = temp_vec.begin; i != temp_vec.end; i++) {
|
||||
size_t len = i->length;
|
||||
for (std::string& i : temp_vec) {
|
||||
size_t len = i.size();
|
||||
if (max_len < len)
|
||||
max_len = len;
|
||||
}
|
||||
@@ -425,54 +430,50 @@ void path_get_directories_recursive(vector_old_string* directories, char* path,
|
||||
char* path_temp = force_malloc_s(char, path_length + max_len + 2);
|
||||
memcpy(path_temp, path, path_length);
|
||||
path_temp[path_length] = '\\';
|
||||
for (string* i = temp_vec.begin; i != temp_vec.end; i++) {
|
||||
memcpy(&path_temp[path_length + 1], string_data(i), i->length + 1);
|
||||
for (std::string& i : temp_vec) {
|
||||
memcpy(&path_temp[path_length + 1], i.c_str(), i.size() + 1);
|
||||
|
||||
vector_old_string temp = vector_old_empty(string);
|
||||
std::vector<std::string> temp;
|
||||
path_get_directories_recursive(&temp, path_temp, exclude_list, exclude_count);
|
||||
|
||||
vector_old_string_push_back(directories, i);
|
||||
directories->push_back(i);
|
||||
|
||||
if (vector_old_length(temp) < 1) {
|
||||
vector_old_string_free(&temp, string_free);
|
||||
if (temp.size() < 1)
|
||||
continue;
|
||||
}
|
||||
|
||||
max_len = 0;
|
||||
for (string* j = temp.begin; j != temp.end; j++) {
|
||||
size_t len = j->length;
|
||||
for (std::string& j : temp) {
|
||||
size_t len = j.size();
|
||||
if (max_len < len)
|
||||
max_len = len;
|
||||
}
|
||||
|
||||
size_t sub_path_length = i->length;
|
||||
size_t sub_path_length = i.size();
|
||||
char* sub_path_temp = force_malloc_s(char, sub_path_length + max_len + 1);
|
||||
if (sub_path_temp) {
|
||||
memcpy(sub_path_temp, string_data(i), sub_path_length);
|
||||
memcpy(sub_path_temp, i.c_str(), sub_path_length);
|
||||
sub_path_temp[sub_path_length] = '\\';
|
||||
for (string* j = temp.begin; j != temp.end; j++) {
|
||||
memcpy(&sub_path_temp[sub_path_length + 1], string_data(j), j->length);
|
||||
for (std::string& j : temp) {
|
||||
memcpy(&sub_path_temp[sub_path_length + 1], j.c_str(), j.size());
|
||||
|
||||
string* directory = vector_old_string_reserve_back(&temp_vec);
|
||||
string_init_length(directory, sub_path_temp, sub_path_length + 1 + j->length);
|
||||
std::string directory = std::string(sub_path_temp, sub_path_length + 1 + j.size());
|
||||
temp_vec.push_back(directory);
|
||||
}
|
||||
}
|
||||
free(sub_path_temp);
|
||||
|
||||
vector_old_string_free(&temp, string_free);
|
||||
}
|
||||
free(path_temp);
|
||||
vector_old_string_free(&temp_vec, 0);
|
||||
}
|
||||
|
||||
inline void path_get_directories_recursive(vector_old_string* directories, const char* path,
|
||||
inline void path_get_directories_recursive(std::vector<std::string>* directories, const char* path,
|
||||
char** exclude_list, size_t exclude_count) {
|
||||
path_get_directories_recursive(directories, (char*)path, exclude_list, exclude_count);
|
||||
}
|
||||
|
||||
void path_wget_directories_recursive(vector_old_wstring* directories, wchar_t* path,
|
||||
void path_get_directories_recursive(std::vector<std::wstring>* directories, wchar_t* path,
|
||||
wchar_t** exclude_list, size_t exclude_count) {
|
||||
vector_old_wstring_free(directories, wstring_free);
|
||||
directories->clear();
|
||||
directories->shrink_to_fit();
|
||||
|
||||
size_t dir_len = utf16_length(path);
|
||||
|
||||
@@ -509,7 +510,7 @@ void path_wget_directories_recursive(vector_old_wstring* directories, wchar_t* p
|
||||
return;
|
||||
}
|
||||
|
||||
vector_old_wstring temp_vec = vector_old_empty(wstring);
|
||||
std::vector<std::wstring> temp_vec;
|
||||
do {
|
||||
if (~fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
@@ -533,16 +534,16 @@ void path_wget_directories_recursive(vector_old_wstring* directories, wchar_t* p
|
||||
continue;
|
||||
}
|
||||
|
||||
wstring* directory = vector_old_wstring_reserve_back(&temp_vec);
|
||||
wstring_init(directory, fdata.cFileName);
|
||||
std::wstring directory = std::wstring(fdata.cFileName);
|
||||
temp_vec.push_back(directory);
|
||||
} while (FindNextFileW(h, &fdata));
|
||||
FindClose(h);
|
||||
free(temp);
|
||||
free(dir);
|
||||
|
||||
size_t max_len = 0;
|
||||
for (wstring* i = temp_vec.begin; i != temp_vec.end; i++) {
|
||||
size_t len = i->length;
|
||||
for (std::wstring& i : temp_vec) {
|
||||
size_t len = i.size();
|
||||
if (max_len < len)
|
||||
max_len = len;
|
||||
}
|
||||
@@ -551,47 +552,42 @@ void path_wget_directories_recursive(vector_old_wstring* directories, wchar_t* p
|
||||
wchar_t* path_temp = force_malloc_s(wchar_t, path_length + max_len + 2);
|
||||
memcpy(path_temp, path, path_length);
|
||||
path_temp[path_length] = '\\';
|
||||
for (wstring* i = temp_vec.begin; i != temp_vec.end; i++) {
|
||||
memcpy(&path_temp[path_length + 1], wstring_data(i), sizeof(wchar_t) * (i->length + 1));
|
||||
for (std::wstring& i : temp_vec) {
|
||||
memcpy(&path_temp[path_length + 1], i.c_str(), sizeof(wchar_t) * (i.size() + 1));
|
||||
|
||||
vector_old_wstring temp = vector_old_empty(wstring);
|
||||
path_wget_directories_recursive(&temp, path_temp, exclude_list, exclude_count);
|
||||
std::vector<std::wstring> temp;
|
||||
path_get_directories_recursive(&temp, path_temp, exclude_list, exclude_count);
|
||||
|
||||
vector_old_wstring_push_back(directories, i);
|
||||
directories->push_back(i);
|
||||
|
||||
if (vector_old_length(temp) < 1) {
|
||||
vector_old_wstring_free(&temp, wstring_free);
|
||||
if (temp.size() < 1)
|
||||
continue;
|
||||
}
|
||||
|
||||
max_len = 0;
|
||||
for (wstring* j = temp.begin; j != temp.end; j++) {
|
||||
size_t len = j->length;
|
||||
for (std::wstring& j : temp) {
|
||||
size_t len = j.size();
|
||||
if (max_len < len)
|
||||
max_len = len;
|
||||
}
|
||||
|
||||
size_t sub_path_length = i->length;
|
||||
size_t sub_path_length = i.size();
|
||||
wchar_t* sub_path_temp = force_malloc_s(wchar_t, sub_path_length + max_len + 1);
|
||||
if (sub_path_temp) {
|
||||
memcpy(sub_path_temp, wstring_data(i), sub_path_length);
|
||||
memcpy(sub_path_temp, i.c_str(), sub_path_length);
|
||||
sub_path_temp[sub_path_length] = '\\';
|
||||
for (wstring* j = temp.begin; j != temp.end; j++) {
|
||||
memcpy(&sub_path_temp[sub_path_length + 1], wstring_data(j), sizeof(wchar_t) * j->length);
|
||||
for (std::wstring& j : temp) {
|
||||
memcpy(&sub_path_temp[sub_path_length + 1], j.c_str(), sizeof(wchar_t) * j.size());
|
||||
|
||||
wstring* directory = vector_old_wstring_reserve_back(directories);
|
||||
wstring_init_length(directory, sub_path_temp, sub_path_length + 1 + j->length);
|
||||
std::wstring directory = std::wstring(sub_path_temp, sub_path_length + 1 + j.size());
|
||||
directories->push_back(directory);
|
||||
}
|
||||
}
|
||||
free(sub_path_temp);
|
||||
|
||||
vector_old_wstring_free(&temp, wstring_free);
|
||||
}
|
||||
free(path_temp);
|
||||
vector_old_wstring_free(&temp_vec, 0);
|
||||
}
|
||||
|
||||
inline void path_wget_directories_recursive(vector_old_wstring* directories, const wchar_t* path,
|
||||
inline void path_get_directories_recursive(std::vector<std::wstring>* directories, const wchar_t* path,
|
||||
wchar_t** exclude_list, size_t exclude_count) {
|
||||
path_wget_directories_recursive(directories, (wchar_t*)path, exclude_list, exclude_count);
|
||||
path_get_directories_recursive(directories, (wchar_t*)path, exclude_list, exclude_count);
|
||||
}
|
||||
|
||||
+20
-20
@@ -5,39 +5,39 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../default.h"
|
||||
#include "../string.h"
|
||||
#include "../vector.h"
|
||||
|
||||
extern bool path_check_path_exists(char* path);
|
||||
extern bool path_check_path_exists(const char* path);
|
||||
extern bool path_wcheck_path_exists(wchar_t* path);
|
||||
extern bool path_wcheck_path_exists(const wchar_t* path);
|
||||
extern bool path_check_path_exists(wchar_t* path);
|
||||
extern bool path_check_path_exists(const wchar_t* path);
|
||||
extern bool path_check_file_exists(char* path);
|
||||
extern bool path_check_file_exists(const char* path);
|
||||
extern bool path_wcheck_file_exists(wchar_t* path);
|
||||
extern bool path_wcheck_file_exists(const wchar_t* path);
|
||||
extern bool path_check_file_exists(wchar_t* path);
|
||||
extern bool path_check_file_exists(const wchar_t* path);
|
||||
extern bool path_check_directory_exists(char* path);
|
||||
extern bool path_check_directory_exists(const char* path);
|
||||
extern bool path_wcheck_directory_exists(wchar_t* path);
|
||||
extern bool path_wcheck_directory_exists(const wchar_t* path);
|
||||
extern void path_get_files(vector_old_string* files, char* path);
|
||||
extern void path_get_files(vector_old_string* files, char* path);
|
||||
extern void path_wget_files(vector_old_wstring* files, wchar_t* path);
|
||||
extern void path_wget_files(vector_old_wstring* files, const wchar_t* path);
|
||||
extern void path_get_directories(vector_old_string* directories, char* path,
|
||||
extern bool path_check_directory_exists(wchar_t* path);
|
||||
extern bool path_check_directory_exists(const wchar_t* path);
|
||||
extern void path_get_files(std::vector<std::string>* files, char* path);
|
||||
extern void path_get_files(std::vector<std::string>* files, const char* path);
|
||||
extern void path_get_files(std::vector<std::wstring>* files, wchar_t* path);
|
||||
extern void path_get_files(std::vector<std::wstring>* files, const wchar_t* path);
|
||||
extern void path_get_directories(std::vector<std::string>* directories, char* path,
|
||||
char** exclude_list, size_t exclude_count);
|
||||
extern void path_get_directories(vector_old_string* directories, const char* path,
|
||||
extern void path_get_directories(std::vector<std::string>* directories, const char* path,
|
||||
char** exclude_list, size_t exclude_count);
|
||||
extern void path_wget_directories(vector_old_wstring* directories, wchar_t* path,
|
||||
extern void path_get_directories(std::vector<std::wstring>* directories, wchar_t* path,
|
||||
wchar_t** exclude_list, size_t exclude_count);
|
||||
extern void path_wget_directories(vector_old_wstring* directories, const wchar_t* path,
|
||||
extern void path_get_directories(std::vector<std::wstring>* directories, const wchar_t* path,
|
||||
wchar_t** exclude_list, size_t exclude_count);
|
||||
extern void path_get_directories_recursive(vector_old_string* directories, char* path,
|
||||
extern void path_get_directories_recursive(std::vector<std::string>* directories, char* path,
|
||||
char** exclude_list, size_t exclude_count);
|
||||
extern void path_get_directories_recursive(vector_old_string* directories, const char* path,
|
||||
extern void path_get_directories_recursive(std::vector<std::string>* directories, const char* path,
|
||||
char** exclude_list, size_t exclude_count);
|
||||
extern void path_wget_directories_recursive(vector_old_wstring* directories, wchar_t* path,
|
||||
extern void path_get_directories_recursive(std::vector<std::wstring>* directories, wchar_t* path,
|
||||
wchar_t** exclude_list, size_t exclude_count);
|
||||
extern void path_wget_directories_recursive(vector_old_wstring* directories, const wchar_t* path,
|
||||
extern void path_get_directories_recursive(std::vector<std::wstring>* directories, const wchar_t* path,
|
||||
wchar_t** exclude_list, size_t exclude_count);
|
||||
+12
-14
@@ -6,7 +6,13 @@
|
||||
#include "stream.h"
|
||||
#include <share.h>
|
||||
|
||||
void io_open(stream* s, char* path, const char* mode) {
|
||||
void io_open(stream* s) {
|
||||
memset(s, 0, sizeof(stream));
|
||||
s->type = STREAM_MEMORY;
|
||||
s->length = 0;
|
||||
}
|
||||
|
||||
void io_open(stream* s, const char* path, const char* mode) {
|
||||
memset(s, 0, sizeof(stream));
|
||||
if (!path || !mode)
|
||||
return;
|
||||
@@ -21,11 +27,7 @@ void io_open(stream* s, char* path, const char* mode) {
|
||||
free(temp_mode);
|
||||
}
|
||||
|
||||
inline void io_open(stream* s, const char* path, const char* mode) {
|
||||
io_open(s, (char*)path, mode);
|
||||
}
|
||||
|
||||
void io_wopen(stream* s, wchar_t* path, const wchar_t* mode) {
|
||||
void io_open(stream* s, const wchar_t* path, const wchar_t* mode) {
|
||||
memset(s, 0, sizeof(stream));
|
||||
if (!path || !mode)
|
||||
return;
|
||||
@@ -36,11 +38,7 @@ void io_wopen(stream* s, wchar_t* path, const wchar_t* mode) {
|
||||
io_get_length(s);
|
||||
}
|
||||
|
||||
inline void io_wopen(stream* s, const wchar_t* path, const wchar_t* mode) {
|
||||
io_wopen(s, (wchar_t*)path, mode);
|
||||
}
|
||||
|
||||
void io_mopen(stream* s, void* data, size_t length) {
|
||||
void io_open(stream* s, const void* data, size_t length) {
|
||||
memset(s, 0, sizeof(stream));
|
||||
if (!data || !length) {
|
||||
s->type = STREAM_MEMORY;
|
||||
@@ -59,7 +57,7 @@ void io_mopen(stream* s, void* data, size_t length) {
|
||||
s->length = length;
|
||||
}
|
||||
|
||||
void io_mcopy(stream* s, void** data, size_t* length) {
|
||||
void io_copy(stream* s, void** data, size_t* length) {
|
||||
if (!s || !data || !length || s->type != STREAM_MEMORY)
|
||||
return;
|
||||
|
||||
@@ -475,7 +473,7 @@ inline void io_read_string_null_terminated_offset(stream* s,
|
||||
free(temp);
|
||||
}
|
||||
else
|
||||
*str = {};
|
||||
*str = std::string();
|
||||
}
|
||||
|
||||
inline void io_read_wstring_null_terminated_offset(stream* s,
|
||||
@@ -499,7 +497,7 @@ inline void io_read_wstring_null_terminated_offset(stream* s,
|
||||
free(temp);
|
||||
}
|
||||
else
|
||||
*str = {};
|
||||
*str = std::wstring();
|
||||
}
|
||||
|
||||
inline char* io_read_utf8_string_null_terminated(stream* s) {
|
||||
|
||||
@@ -32,12 +32,11 @@ typedef struct stream {
|
||||
vector_old_ssize_t position_stack;
|
||||
} stream;
|
||||
|
||||
extern void io_open(stream* s, char* path, const char* mode);
|
||||
extern void io_open(stream* s);
|
||||
extern void io_open(stream* s, const char* path, const char* mode);
|
||||
extern void io_wopen(stream* s, wchar_t* path, const wchar_t* mode);
|
||||
extern void io_wopen(stream* s, const wchar_t* path, const wchar_t* mode);
|
||||
extern void io_mopen(stream* s, void* data, size_t length);
|
||||
extern void io_mcopy(stream* s, void** data, size_t* length);
|
||||
extern void io_open(stream* s, const wchar_t* path, const wchar_t* mode);
|
||||
extern void io_open(stream* s, const void* data, size_t length);
|
||||
extern void io_copy(stream* s, void** data, size_t* length);
|
||||
extern void io_align_read(stream* s, ssize_t align);
|
||||
extern void io_align_write(stream* s, ssize_t align);
|
||||
extern int io_flush(stream* s);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user