diff --git a/src/CRE/app_system_detail.cpp b/src/CRE/app_system_detail.cpp index 3ab0094d..6ebf484a 100644 --- a/src/CRE/app_system_detail.cpp +++ b/src/CRE/app_system_detail.cpp @@ -261,7 +261,7 @@ void app_system_detail::SystemInfo::MeasureFps::exec() { break; if (res_window_get()->resolution_mode == RESOLUTION_MODE_HD && (fps < 59.940002f || fps > 60.060001f)) { - printf_debug("%s: %f(%zu) -> retry\n", __FUNCTION__, fps, retry_count); + printf_debug_info("%s: %f(%zu) -> retry\n", __FUNCTION__, fps, retry_count); retry_count++; if (retry_count < 3) { state = 1; @@ -273,7 +273,7 @@ void app_system_detail::SystemInfo::MeasureFps::exec() { this->fps = fps; state = 3; - printf_debug("%s: %f(%zu)\n", __FUNCTION__, fps, retry_count);*/ + printf_debug_info("%s: %f(%zu)\n", __FUNCTION__, fps, retry_count);*/ this->fps = 60.0; state = 3; diff --git a/src/CRE/effect.cpp b/src/CRE/effect.cpp index 4895e8ac..6cc47362 100644 --- a/src/CRE/effect.cpp +++ b/src/CRE/effect.cpp @@ -2242,7 +2242,7 @@ TaskEffectFogAnim::~TaskEffectFogAnim() { } bool TaskEffectFogAnim::init() { - //sub_1400DE640("TaskEffectFogAnim::init()\n"); + printf_debug_info(__FUNCTION__ "()\n"); return true; } @@ -2254,7 +2254,7 @@ bool TaskEffectFogAnim::ctrl() { bool TaskEffectFogAnim::dest() { data.reset(); effect_fog_anim = 0; - //sub_1400DE640("TaskEffectFogAnim::dest()\n"); + printf_debug_info(__FUNCTION__ "()\n"); return true; } @@ -2265,7 +2265,7 @@ void TaskEffectFogAnim::disp() { void TaskEffectFogAnim::pre_init(int32_t) { data.reset(); effect_fog_anim = &data; - //sub_1400DE640("TaskEffectFogAnim::pre_init()\n"); + printf_debug_info(__FUNCTION__ "()\n"); } void TaskEffectFogAnim::reset() { @@ -2696,7 +2696,7 @@ TaskEffectFogRing::~TaskEffectFogRing() { } bool TaskEffectFogRing::init() { - //sub_1400DE640("TaskEffectFogRing::init()\n"); + printf_debug_info(__FUNCTION__ "()\n"); return true; } @@ -2709,7 +2709,7 @@ bool TaskEffectFogRing::ctrl() { bool TaskEffectFogRing::dest() { data.dest(); effect_fog_ring = 0; - //sub_1400DE640("TaskEffectFogRing::dest()\n"); + printf_debug_info(__FUNCTION__ "()\n"); return 1; } @@ -3657,7 +3657,7 @@ TaskEffectRipple::~TaskEffectRipple() { bool TaskEffectRipple::init() { ripple_emit_init(); - //sub_1400DE640("TaskEffectRipple::init()\n"); + printf_debug_info(__FUNCTION__ "()\n"); return true; } @@ -3669,7 +3669,7 @@ bool TaskEffectRipple::ctrl() { bool TaskEffectRipple::dest() { emit->dest(); - //sub_1400DE640("TaskEffectRipple::dest()\n"); + printf_debug_info(__FUNCTION__ "()\n"); ripple_emit_free(); return true; } @@ -4704,7 +4704,7 @@ TaskEffectSplash::~TaskEffectSplash() { bool TaskEffectSplash::init() { water_particle_init(); set_enable(true); - //sub_1400DE640("TaskEffectSplash::init()\n"); + printf_debug_info(__FUNCTION__ "()\n"); return true; } @@ -4719,7 +4719,7 @@ bool TaskEffectSplash::dest() { water_particle_free(); effect_splash = 0; - //sub_1400DE640("TaskEffectSplash::dest()\n"); + printf_debug_info(__FUNCTION__ "()\n"); return true; } diff --git a/src/CRE/rob/ex_block.cpp b/src/CRE/rob/ex_block.cpp index 52696b97..3981dce3 100644 --- a/src/CRE/rob/ex_block.cpp +++ b/src/CRE/rob/ex_block.cpp @@ -126,6 +126,18 @@ static const exp_func_op3 exp_func_op3_array[] = { { 0 , 0 }, }; +static const char* expression_component_names[] = { + "posx", + "posy", + "posz", + "rotx", + "roty", + "rotz", + "scalex", + "scaley", + "scalez", +}; + size_t rob_cloth_iterations_count = 0; int32_t rob_cloth_update_vertices_flags = 0x03; bool rob_cloth_update_normals_select = false; @@ -3736,8 +3748,14 @@ void ExExpressionBlock::InitData(rob_chara_item_equip_object* itm_eq_obj, std::string value_type; expression = str_utils_get_next_string(expression, value_type, ' '); if (!value_type.size() || !memcmp(value_type.c_str(), "error", - min_def(value_type.size(), 5)) && value_type.size() == 5) + min_def(value_type.size(), 5)) && value_type.size() == 5) { + printf_debug_info("Expression error: %s.", this->name); + if (index >= 0 && index < 9) + printf_debug_info("%s\n", expression_component_names[index]); + else + printf_debug_info("\n"); break; + } if (value_type[0] == 'n') { stack_val->type = EX_EXPRESSION_BLOCK_STACK_NUMBER; diff --git a/src/CRE/rob/motion.cpp b/src/CRE/rob/motion.cpp index 31229480..bc799a14 100644 --- a/src/CRE/rob/motion.cpp +++ b/src/CRE/rob/motion.cpp @@ -244,8 +244,10 @@ void MotFile::ParseFileParent(MotFile* mot, const void* file_data, size_t size) void motion_set_load_mothead(uint32_t set, std::string&& mdata_dir, const motion_database* mot_db) { const motion_set_info* set_info = mot_db->get_motion_set_by_id(set); - if (!set_info) + if (!set_info) { + printf_debug_error("request_load_mhd_file(): illegal file_id(%d).\n", set); return; + } std::string file; file.assign("mothead_"); @@ -344,8 +346,10 @@ MotFile* motion_storage_get_mot_file(uint32_t set_id) { const mot_data* motion_storage_get_mot_data(uint32_t motion_id, const motion_database* mot_db) { const motion_set_info* set_info = mot_db->get_motion_set_by_motion_id(motion_id); - if (!set_info) + if (!set_info) { + printf_debug_info("%08x : illegal motfile Num.\n", motion_id); return 0; + } for (const motion_info& i : set_info->motion) { if (i.id != motion_id) diff --git a/src/CRE/rob/rob.cpp b/src/CRE/rob/rob.cpp index a625a6d0..0bce03f6 100644 --- a/src/CRE/rob/rob.cpp +++ b/src/CRE/rob/rob.cpp @@ -914,9 +914,9 @@ static bool mot_load_file(mot* a1, const mot_data* a2); static void mot_key_data_get_key_set_count_by_bone_database_bones(mot_key_data* a1, const std::vector* a2); -static void mot_key_data_get_key_set_count(mot_key_data* a1, size_t motion_bone_count, size_t ik_bone_count); +static void mot_key_data_get_key_set_count(mot_key_data* a1, size_t motion_bone_count, size_t leaf_pos); static void mot_key_data_init_key_sets(mot_key_data* a1, bone_database_skeleton_type type, - size_t motion_bone_count, size_t ik_bone_count); + size_t motion_bone_count, size_t leaf_pos); static const mot_data* mot_key_data_load_file(mot_key_data* a1, uint32_t motion_id, const motion_database* mot_db); static void mot_key_data_reserve_key_sets(mot_key_data* a1); @@ -5966,8 +5966,8 @@ static void bone_data_parent_load_bone_database(bone_data_parent* bone, const std::vector* bones, const vec3* common_position, const vec3* position) { rob_chara_bone_data* rob_bone_data = bone->rob_bone_data; size_t chain_pos = 0; - size_t total_bone_count = 0; - size_t ik_bone_count = 0; + size_t node_count = 0; + size_t leaf_pos = 0; bone_data* bone_node = bone->bones.data(); for (const bone_database_bone& i : *bones ) { @@ -5982,7 +5982,7 @@ static void bone_data_parent_load_bone_database(bone_data_parent* bone, bone_node->key_set_count = 3; bone_node->base_position[0] = *common_position++; bone_node->base_position[1] = *position++; - bone_node->node = &rob_bone_data->nodes[total_bone_count]; + bone_node->node = &rob_bone_data->nodes[node_count]; bone_node->has_parent = i.has_parent; if (i.has_parent) bone_node->parent_mat = &rob_bone_data->mats[i.parent]; @@ -5995,20 +5995,20 @@ static void bone_data_parent_load_bone_database(bone_data_parent* bone, case BONE_DATABASE_BONE_TYPE_1: case BONE_DATABASE_BONE_POSITION: chain_pos++; - total_bone_count++; + node_count++; break; case BONE_DATABASE_BONE_POSITION_ROTATION: chain_pos++; - ik_bone_count++; - total_bone_count++; + leaf_pos++; + node_count++; break; case BONE_DATABASE_BONE_HEAD_IK_ROTATION: bone_node->ik_segment_length[0] = (common_position++)->x; bone_node->ik_segment_length[1] = (position++)->x; chain_pos += 2; - ik_bone_count++; - total_bone_count += 3; + leaf_pos++; + node_count += 3; break; case BONE_DATABASE_BONE_ARM_IK_ROTATION: case BONE_DATABASE_BONE_LEGS_IK_ROTATION: @@ -6023,12 +6023,19 @@ static void bone_data_parent_load_bone_database(bone_data_parent* bone, bone_node->pole_target_mat = pole_target; chain_pos += 3; - ik_bone_count++; - total_bone_count += 4; + leaf_pos++; + node_count += 4; break; } bone_node++; } + + if (node_count != rob_bone_data->node_count) + printf_debug_error("Node mismatch"); + if (leaf_pos != bone->leaf_pos) + printf_debug_error("LeafPos mismatch"); + if (chain_pos != bone->chain_pos) + printf_debug_error("ChainPos mismatch"); } static void bone_data_parent_load_bone_indices_from_mot(bone_data_parent* a1, @@ -6076,12 +6083,12 @@ static void bone_data_parent_load_rob_chara(bone_data_parent* bone) { return; bone->motion_bone_count = rob_bone_data->motion_bone_count; - bone->ik_bone_count = rob_bone_data->ik_bone_count; + bone->leaf_pos = rob_bone_data->leaf_pos; bone->chain_pos = rob_bone_data->chain_pos; bone->bones.clear(); bone->bones.resize(rob_bone_data->motion_bone_count); bone->global_key_set_count = 6; - bone->bone_key_set_count = (uint32_t)((bone->motion_bone_count + bone->ik_bone_count) * 3); + bone->bone_key_set_count = (uint32_t)((bone->motion_bone_count + bone->leaf_pos) * 3); } static void sub_14040F650(struc_313* a1, size_t a2) { @@ -6342,16 +6349,16 @@ static void mot_key_data_get_key_set_count_by_bone_database_bones(mot_key_data* const std::vector* a2) { size_t object_bone_count; size_t motion_bone_count; - size_t total_bone_count; - size_t ik_bone_count; + size_t node_count; + size_t leaf_pos; size_t chain_pos; - bone_database_bones_calculate_count(a2, &object_bone_count, - &motion_bone_count, &total_bone_count, &ik_bone_count, &chain_pos); - mot_key_data_get_key_set_count(a1, motion_bone_count, ik_bone_count); + bone_database_bones_calculate_count(a2, object_bone_count, + motion_bone_count, node_count, leaf_pos, chain_pos); + mot_key_data_get_key_set_count(a1, motion_bone_count, leaf_pos); } -static void mot_key_data_get_key_set_count(mot_key_data* a1, size_t motion_bone_count, size_t ik_bone_count) { - a1->key_set_count = (motion_bone_count + ik_bone_count) * 3 + 16; +static void mot_key_data_get_key_set_count(mot_key_data* a1, size_t motion_bone_count, size_t leaf_pos) { + a1->key_set_count = (motion_bone_count + leaf_pos) * 3 + 16; } static void mot_key_data_init(mot_key_data* a1, @@ -6367,8 +6374,8 @@ static void mot_key_data_init(mot_key_data* a1, } static void mot_key_data_init_key_sets(mot_key_data* a1, bone_database_skeleton_type type, - size_t motion_bone_count, size_t ik_bone_count) { - mot_key_data_get_key_set_count(a1, motion_bone_count, ik_bone_count); + size_t motion_bone_count, size_t leaf_pos) { + mot_key_data_get_key_set_count(a1, motion_bone_count, leaf_pos); mot_key_data_reserve_key_sets(a1); a1->skeleton_type = type; } @@ -8127,7 +8134,7 @@ static void motion_blend_mot_load_bone_data(motion_blend_mot* a1, &a1->mot_key_data, a1->bone_data.rob_bone_data->base_skeleton_type, a1->bone_data.motion_bone_count, - a1->bone_data.ik_bone_count); + a1->bone_data.leaf_pos); sub_140413350(&a1->field_0, bone_check_func, a1->bone_data.motion_bone_count); } @@ -10781,9 +10788,9 @@ static void rob_chara_age_age_set_step_full(rob_chara_age_age* arr, static void rob_chara_bone_data_calculate_bones(rob_chara_bone_data* rob_bone_data, const std::vector* bones) { - bone_database_bones_calculate_count(bones, &rob_bone_data->object_bone_count, - &rob_bone_data->motion_bone_count, &rob_bone_data->total_bone_count, - &rob_bone_data->ik_bone_count, &rob_bone_data->chain_pos); + bone_database_bones_calculate_count(bones, rob_bone_data->object_bone_count, + rob_bone_data->motion_bone_count, rob_bone_data->node_count, + rob_bone_data->leaf_pos, rob_bone_data->chain_pos); } static void rob_chara_bone_data_get_ik_scale( @@ -11167,13 +11174,13 @@ static void rob_chara_bone_data_reserve(rob_chara_bone_data* rob_bone_data) { i = mat4_identity; rob_bone_data->mats2.clear(); - rob_bone_data->mats2.resize(rob_bone_data->total_bone_count - rob_bone_data->object_bone_count); + rob_bone_data->mats2.resize(rob_bone_data->node_count - rob_bone_data->object_bone_count); for (mat4& i : rob_bone_data->mats2) i = mat4_identity; rob_bone_data->nodes.clear(); - rob_bone_data->nodes.resize(rob_bone_data->total_bone_count); + rob_bone_data->nodes.resize(rob_bone_data->node_count); } static void sub_140412BB0(motion_blend_mot* a1, std::vector& bones) { @@ -11328,86 +11335,97 @@ static void rob_chara_bone_data_set_look_anim_param(rob_chara_bone_data* rob_bon static void rob_chara_bone_data_set_mats(rob_chara_bone_data* rob_bone_data, const std::vector* bones, const std::string* motion_bones) { + size_t node = 0; + size_t matrix = 0; + size_t matrix2 = 0; + size_t leaf_pos = 0; size_t chain_pos = 0; - size_t ik_bone_count = 0; - size_t total_bone_count = 0; - mat4* mats = rob_bone_data->mats.data(); - mat4* mats2 = rob_bone_data->mats2.data(); bone_node* nodes = rob_bone_data->nodes.data(); - for (const bone_database_bone& i : *bones) + for (const bone_database_bone& i : *bones) { + chain_pos++; + switch (i.type) { case BONE_DATABASE_BONE_ROTATION: case BONE_DATABASE_BONE_TYPE_1: case BONE_DATABASE_BONE_POSITION: - nodes->mat = mats++; + nodes->mat = &rob_bone_data->mats[matrix++]; nodes->name = motion_bones->c_str(); nodes++; motion_bones++; - - chain_pos++; - total_bone_count++; break; case BONE_DATABASE_BONE_POSITION_ROTATION: - nodes->mat = mats++; + nodes->mat = &rob_bone_data->mats[matrix++]; + nodes->name = motion_bones->c_str(); + nodes++; + motion_bones++; + + leaf_pos++; + break; + case BONE_DATABASE_BONE_HEAD_IK_ROTATION: + nodes->mat = &rob_bone_data->mats[matrix2++]; + nodes->name = motion_bones->c_str(); + nodes++; + motion_bones++; + + nodes->mat = &rob_bone_data->mats[matrix++]; + nodes->name = motion_bones->c_str(); + nodes++; + motion_bones++; + + nodes->mat = &rob_bone_data->mats[matrix2++]; nodes->name = motion_bones->c_str(); nodes++; motion_bones++; chain_pos++; - ik_bone_count++; - total_bone_count++; + leaf_pos++; + node += 2; break; - case BONE_DATABASE_BONE_HEAD_IK_ROTATION: - nodes->mat = mats2++; + case BONE_DATABASE_BONE_ARM_IK_ROTATION: + case BONE_DATABASE_BONE_LEGS_IK_ROTATION: + nodes->mat = &rob_bone_data->mats[matrix++]; nodes->name = motion_bones->c_str(); nodes++; motion_bones++; - nodes->mat = mats++; + nodes->mat = &rob_bone_data->mats[matrix++]; nodes->name = motion_bones->c_str(); nodes++; motion_bones++; - nodes->mat = mats2++; + nodes->mat = &rob_bone_data->mats[matrix++]; + nodes->name = motion_bones->c_str(); + nodes++; + motion_bones++; + + nodes->mat = &rob_bone_data->mats[matrix2++]; nodes->name = motion_bones->c_str(); nodes++; motion_bones++; chain_pos += 2; - ik_bone_count++; - total_bone_count += 3; - break; - case BONE_DATABASE_BONE_ARM_IK_ROTATION: - case BONE_DATABASE_BONE_LEGS_IK_ROTATION: - nodes->mat = mats++; - nodes->name = motion_bones->c_str(); - nodes++; - motion_bones++; - - nodes->mat = mats++; - nodes->name = motion_bones->c_str(); - nodes++; - motion_bones++; - - nodes->mat = mats++; - nodes->name = motion_bones->c_str(); - nodes++; - motion_bones++; - - nodes->mat = mats2++; - nodes->name = motion_bones->c_str(); - nodes++; - motion_bones++; - - chain_pos += 3; - ik_bone_count++; - total_bone_count += 4; + leaf_pos++; + node += 3; break; } + node++; + } for (bone_node& i : rob_bone_data->nodes) i.ex_data_mat = i.mat; + + if (node != rob_bone_data->node_count) + printf_debug_error("Node mismatch"); + if (matrix != rob_bone_data->object_bone_count) + printf_debug_error("Matrix mismatch"); + if (matrix2 != rob_bone_data->node_count - rob_bone_data->object_bone_count) + printf_debug_error("Matrix2 mismatch"); + if (leaf_pos != rob_bone_data->leaf_pos) + printf_debug_error("LeafPos mismatch"); + if (chain_pos != rob_bone_data->chain_pos) + printf_debug_error("ChainPos mismatch"); + rob_bone_data->field_1 = true; } static void rob_chara_bone_data_set_parent_mats(rob_chara_bone_data* rob_bone_data, @@ -12608,7 +12626,7 @@ void bone_data::store_curr_rot_trans(int32_t skeleton_select) { } bone_data_parent::bone_data_parent() : rob_bone_data(), -motion_bone_count(), ik_bone_count(), chain_pos(), global_position(), +motion_bone_count(), leaf_pos(), chain_pos(), global_position(), global_rotation(), bone_key_set_count(), global_key_set_count(), rot_y() { } @@ -13333,8 +13351,8 @@ void rob_chara_sleeve_adjust::reset() { field_80 = 0.0f; } -rob_chara_bone_data::rob_chara_bone_data() : field_0(), field_1(), object_bone_count(), total_bone_count(), -motion_bone_count(), ik_bone_count(), chain_pos(), disable_eye_motion(), look_anim() { +rob_chara_bone_data::rob_chara_bone_data() : field_0(), field_1(), object_bone_count(), node_count(), +motion_bone_count(), leaf_pos(), chain_pos(), disable_eye_motion(), look_anim() { base_skeleton_type = BONE_DATABASE_SKELETON_NONE; skeleton_type = BONE_DATABASE_SKELETON_NONE; } @@ -13613,8 +13631,8 @@ void rob_chara_bone_data::motion_step() { void rob_chara_bone_data::reset() { object_bone_count = 0; motion_bone_count = 0; - total_bone_count = 0; - ik_bone_count = 0; + node_count = 0; + leaf_pos = 0; chain_pos = 0; mats.clear(); mats2.clear(); diff --git a/src/CRE/rob/rob.hpp b/src/CRE/rob/rob.hpp index c2774c6c..ee9b5354 100644 --- a/src/CRE/rob/rob.hpp +++ b/src/CRE/rob/rob.hpp @@ -995,7 +995,7 @@ struct bone_data { struct bone_data_parent { rob_chara_bone_data* rob_bone_data; size_t motion_bone_count; - size_t ik_bone_count; + size_t leaf_pos; size_t chain_pos; std::vector bones; std::vector bone_indices; @@ -1371,9 +1371,9 @@ struct rob_chara_bone_data { bool field_0; bool field_1; size_t object_bone_count; - size_t total_bone_count; + size_t node_count; size_t motion_bone_count; - size_t ik_bone_count; + size_t leaf_pos; size_t chain_pos; std::vector mats; std::vector mats2; diff --git a/src/KKdLib/database/bone.cpp b/src/KKdLib/database/bone.cpp index 1f4acd6a..e6b166ba 100644 --- a/src/KKdLib/database/bone.cpp +++ b/src/KKdLib/database/bone.cpp @@ -398,51 +398,35 @@ bool bone_database::load_file(void* data, const char* dir, const char* file, uin } void bone_database_bones_calculate_count(const std::vector* 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) { - size_t _object_bone_count = 0; - size_t _motion_bone_count = 0; - size_t _total_bone_count = 0; - size_t _ik_bone_count = 0; - size_t _chain_pos = 0; - for (const bone_database_bone& i : *bones) - switch (i.type) { - case BONE_DATABASE_BONE_ROTATION: - case BONE_DATABASE_BONE_TYPE_1: - case BONE_DATABASE_BONE_POSITION: - _object_bone_count++; - _motion_bone_count++; - _total_bone_count++; - _chain_pos++; - break; - case BONE_DATABASE_BONE_POSITION_ROTATION: - _object_bone_count++; - _motion_bone_count++; - _total_bone_count++; - _ik_bone_count++; - _chain_pos++; - break; - case BONE_DATABASE_BONE_HEAD_IK_ROTATION: - _object_bone_count++; - _motion_bone_count++; - _total_bone_count += 3; - _ik_bone_count++; - _chain_pos += 2; - break; - case BONE_DATABASE_BONE_ARM_IK_ROTATION: - case BONE_DATABASE_BONE_LEGS_IK_ROTATION: - _object_bone_count += 3; - _motion_bone_count++; - _total_bone_count += 4; - _ik_bone_count++; - _chain_pos += 3; - break; + size_t& object_bone_count, size_t& motion_bone_count, + size_t& node_count, size_t& leaf_pos, size_t& chain_pos) { + object_bone_count = 0; + motion_bone_count = 0; + node_count = 0; + leaf_pos = 0; + chain_pos = 0; + + for (const bone_database_bone& i : *bones) { + object_bone_count++; + node_count++; + if (i.type >= BONE_DATABASE_BONE_ARM_IK_ROTATION) + object_bone_count += 2; + chain_pos++; + + if (i.type >= BONE_DATABASE_BONE_HEAD_IK_ROTATION) { + chain_pos++; + node_count += 2; + + if (i.type >= BONE_DATABASE_BONE_ARM_IK_ROTATION) { + chain_pos++; + node_count++; + } } - *object_bone_count = _object_bone_count; - *motion_bone_count = _motion_bone_count; - *total_bone_count = _total_bone_count; - *ik_bone_count = _ik_bone_count; - *chain_pos = _chain_pos; + + if (i.type >= BONE_DATABASE_BONE_POSITION_ROTATION) + leaf_pos++; + motion_bone_count++; + } } const char* bone_database_skeleton_type_to_string(bone_database_skeleton_type type) { diff --git a/src/KKdLib/database/bone.hpp b/src/KKdLib/database/bone.hpp index dcd516ba..177395fc 100644 --- a/src/KKdLib/database/bone.hpp +++ b/src/KKdLib/database/bone.hpp @@ -102,7 +102,7 @@ struct bone_database { }; extern void bone_database_bones_calculate_count(const std::vector* 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); + size_t& object_bone_count, size_t& motion_bone_count, + size_t& node_count, size_t& leaf_pos, size_t& chain_pos); extern const char* bone_database_skeleton_type_to_string(bone_database_skeleton_type type); diff --git a/src/KKdLib/default.hpp b/src/KKdLib/default.hpp index 20ebf05a..f85288be 100644 --- a/src/KKdLib/default.hpp +++ b/src/KKdLib/default.hpp @@ -391,6 +391,50 @@ inline void wprintf_debug(_In_z_ _Printf_format_string_ const wchar_t* fmt, ...) #endif } +inline void printf_debug_error(_In_z_ _Printf_format_string_ const char* fmt, ...) { +#ifdef DEBUG + printf("[Error] "); + + va_list args; + va_start(args, fmt); + vprintf(fmt, args); + va_end(args); +#endif +} + +inline void wprintf_debug_error(_In_z_ _Printf_format_string_ const wchar_t* fmt, ...) { +#ifdef DEBUG + printf("[Error] "); + + va_list args; + va_start(args, fmt); + vwprintf(fmt, args); + va_end(args); +#endif +} + +inline void printf_debug_info(_In_z_ _Printf_format_string_ const char* fmt, ...) { +#ifdef DEBUG + printf("[Info] "); + + va_list args; + va_start(args, fmt); + vprintf(fmt, args); + va_end(args); +#endif +} + +inline void wprintf_debug_info(_In_z_ _Printf_format_string_ const wchar_t* fmt, ...) { +#ifdef DEBUG + printf("[Info] "); + + va_list args; + va_start(args, fmt); + vwprintf(fmt, args); + va_end(args); +#endif +} + inline _Check_return_ constexpr size_t utf8_length(_In_z_ const char* s) { if (!s) return 0; diff --git a/src/KKdLib/light_param/ibl.cpp b/src/KKdLib/light_param/ibl.cpp index 7a5e1031..3637ef6e 100644 --- a/src/KKdLib/light_param/ibl.cpp +++ b/src/KKdLib/light_param/ibl.cpp @@ -95,8 +95,10 @@ static void light_param_ibl_read_inner(light_param_ibl* ibl, stream& s) { char buf[0x200]; const char* d = light_param_read_line(buf, sizeof(buf), data); - if (str_utils_compare(buf, "VF5_IBL")) + if (str_utils_compare(buf, "VF5_IBL")) { + printf_debug_error("Not VF5_IBL file\n"); return; + } int32_t widths[6] = { 0 }; int32_t heights[6] = { 0 }; @@ -105,7 +107,43 @@ static void light_param_ibl_read_inner(light_param_ibl* ibl, stream& s) { d = light_param_read_line(buf, sizeof(buf), d); while (buf[0] == '#'); - if (!str_utils_compare(buf, "VERSION")) + if (!str_utils_compare(buf, "BINARY")) { + half_t* dh = (half_t*)d; + for (int32_t i = 0, j = -2; i < 6; i++, j++) { + size_t size = widths[i]; + size = 4 * (size * size); + + if (i < 2) { + light_param_ibl_diffuse* diffuse = &ibl->diffuse[i]; + diffuse->data = std::vector(size * 6); + diffuse->size = widths[i]; + diffuse->level = i; + + for (int32_t k = 0; k < 6; k++, dh += size) + memcpy(&diffuse->data[size * k], dh, sizeof(half_t) * size); + } + else { + const int32_t max_level = 2; + + light_param_ibl_specular* specular = &ibl->specular[j]; + specular->data = std::vector>(max_level + 1ULL); + specular->max_level = max_level; + specular->size = widths[i]; + + size_t img_size = widths[i]; + for (int32_t i = 0; i <= max_level; i++, img_size /= 2) + specular->data[i] = std::vector(4 * (img_size * img_size) * 6); + + std::vector& specular_data = specular->data[0]; + for (int32_t k = 0; k < 6; k++, dh += size) + memcpy(&specular_data[size * k], dh, sizeof(half_t) * size); + + light_param_ibl_specular_generate_mipmaps(specular); + } + } + break; + } + else if (!str_utils_compare(buf, "VERSION")) d = light_param_read_line(buf, sizeof(buf), d); else if (!str_utils_compare(buf, "LIT_DIR")) { d = light_param_read_line(buf, sizeof(buf), d); @@ -190,44 +228,10 @@ static void light_param_ibl_read_inner(light_param_ibl* ibl, stream& s) { widths[index] = w; heights[index] = h; } - else if (!str_utils_compare(buf, "BINARY")) { - half_t* dh = (half_t*)d; - for (int32_t i = 0, j = -2; i < 6; i++, j++) { - size_t size = widths[i]; - size = 4 * (size * size); - - if (i < 2) { - light_param_ibl_diffuse* diffuse = &ibl->diffuse[i]; - diffuse->data = std::vector(size * 6); - diffuse->size = widths[i]; - diffuse->level = i; - - for (int32_t k = 0; k < 6; k++, dh += size) - memcpy(&diffuse->data[size * k], dh, sizeof(half_t) * size); - } - else { - const int32_t max_level = 2; - - light_param_ibl_specular* specular = &ibl->specular[j]; - specular->data = std::vector>(max_level + 1ULL); - specular->max_level = max_level; - specular->size = widths[i]; - - size_t img_size = widths[i]; - for (int32_t i = 0; i <= max_level; i++, img_size /= 2) - specular->data[i] = std::vector(4 * (img_size * img_size) * 6); - - std::vector& specular_data = specular->data[0]; - for (int32_t k = 0; k < 6; k++, dh += size) - memcpy(&specular_data[size * k], dh, sizeof(half_t) * size); - - light_param_ibl_specular_generate_mipmaps(specular); - } - } - break; - } - else + else { + printf_debug_error("%s: unknown tag %s\n", "light_table_detail::LightDataIbl::load", buf); goto End; + } } free_def(data);