mirror of
https://github.com/korenkonder/ReDIVA.git
synced 2026-10-01 03:08:16 +03:00
Temp commit. Auth3D Object HRC breakdown
This commit is contained in:
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
+5190
-4698
File diff suppressed because it is too large
Load Diff
@@ -29,4 +29,18 @@ namespace Glitter {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Animation& Animation::operator=(const Animation& anim) {
|
||||
for (Curve*& i : curves)
|
||||
delete i;
|
||||
curves.clear();
|
||||
|
||||
curves.reserve(anim.curves.size());
|
||||
for (Curve* i : anim.curves) {
|
||||
Curve* curv = new Curve(i->version > 0x01 ? Glitter::X : Glitter::F2);
|
||||
*curv = *i;
|
||||
curves.push_back(curv);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,8 +123,8 @@ namespace Glitter {
|
||||
if (key_type == KEY_CONSTANT)
|
||||
return F2RandomizeKey(GLT_VAL, curr, random);
|
||||
|
||||
float_t df = frame - (float_t)curr->frame;
|
||||
float_t t = df / (float_t)(next->frame - curr->frame);
|
||||
float_t df = (float_t)(next->frame - curr->frame);
|
||||
float_t t = (frame - (float_t)curr->frame) / df;
|
||||
float_t val;
|
||||
if (key_type == KEY_HERMITE) {
|
||||
float_t t_1 = t - 1.0f;
|
||||
@@ -132,7 +132,7 @@ namespace Glitter {
|
||||
float_t curr_val = F2RandomizeKey(GLT_VAL, curr, random);
|
||||
val = F2RandomizeKey(GLT_VAL, curr, random);
|
||||
val += t * t * (3.0f - 2.0f * t) * (next_val - curr_val)
|
||||
+ (t_1 * curr->tangent2 + t * next->tangent1) * df * t_1;
|
||||
+ (t_1 * curr->tangent2 + t * next->tangent1) * t_1 * df;
|
||||
}
|
||||
else {
|
||||
float_t curr_val = F2RandomizeKey(GLT_VAL, curr, random);
|
||||
@@ -597,7 +597,7 @@ namespace Glitter {
|
||||
float_t curr_val = XRandomizeKey(curr, random);
|
||||
val = XRandomizeKey(curr, random);
|
||||
val += t * t * (3.0f - 2.0f * t) * (next_val - curr_val)
|
||||
+ (t_1 * curr->tangent2 + t * next->tangent1) * df * t_1;
|
||||
+ (t_1 * curr->tangent2 + t * next->tangent1) * t_1 * df;
|
||||
}
|
||||
else {
|
||||
float_t curr_val = XRandomizeKey(curr, random);
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Glitter {
|
||||
color = { 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
name_hash = GLT_VAL != Glitter::FT
|
||||
? hash_murmurhash_empty : hash_fnv1a64m_empty;
|
||||
ext_anim_is_x = GLT_VAL == Glitter::X;
|
||||
}
|
||||
|
||||
Effect::Effect(GLT) : data(GLT_VAL) {
|
||||
@@ -29,5 +30,38 @@ namespace Glitter {
|
||||
Effect::~Effect() {
|
||||
for (Emitter*& i : emitters)
|
||||
delete i;
|
||||
|
||||
if (data.ext_anim)
|
||||
free(data.ext_anim);
|
||||
}
|
||||
|
||||
Effect& Effect::operator=(const Effect& eff) {
|
||||
if (data.ext_anim)
|
||||
free(data.ext_anim);
|
||||
|
||||
data = eff.data;
|
||||
version = eff.version;
|
||||
|
||||
if (eff.data.ext_anim)
|
||||
if (!data.ext_anim_is_x) {
|
||||
data.ext_anim = force_malloc_s(Effect::ExtAnim, 1);
|
||||
*data.ext_anim = *eff.data.ext_anim;
|
||||
}
|
||||
else {
|
||||
data.ext_anim_x = force_malloc_s(Effect::ExtAnimX, 1);
|
||||
*data.ext_anim_x = *eff.data.ext_anim_x;
|
||||
}
|
||||
|
||||
for (Emitter*& i : emitters)
|
||||
delete i;
|
||||
emitters.clear();
|
||||
|
||||
emitters.reserve(eff.emitters.size());
|
||||
for (Emitter* i : eff.emitters) {
|
||||
Emitter* emit = new Emitter(i->version > 0x02 ? Glitter::X : Glitter::F2);
|
||||
*emit = *i;
|
||||
emitters.push_back(emit);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,9 +59,8 @@ namespace Glitter {
|
||||
obj* obj = &set->obj_data[i];
|
||||
for (uint32_t j = 0; j < obj->num_material; j++) {
|
||||
obj_material* mat = &obj->material_array[j].material;
|
||||
if (!memcmp(&mat->color.emission, &vec3_null, sizeof(vec3))
|
||||
&& mat->color.emission.w == 1.0f)
|
||||
mat->color.emission = vec4_identity;
|
||||
if (*(vec3*)&mat->color.emission == 0.0f && mat->color.emission.w == 1.0f)
|
||||
mat->color.emission = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,34 +123,3 @@ namespace Glitter {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
#include "effect_group.hpp"
|
||||
#include "../../KKdLib/database/object.h"
|
||||
#include "../../KKdLib/database/texture.h"
|
||||
#include "../../KKdLib/io/path.hpp"
|
||||
#include "../../KKdLib/obj.h"
|
||||
#include "../../KKdLib/farc.h"
|
||||
#include "../../KKdLib/obj.h"
|
||||
#include "../../KKdLib/str_utils.hpp"
|
||||
#include "../data.h"
|
||||
#include "../object.h"
|
||||
#include "effect.hpp"
|
||||
#include "scene.hpp"
|
||||
#include "texture.hpp"
|
||||
|
||||
bool EffectGroup::ParseFile(f2_struct* st, object_database* obj_db) {
|
||||
for (f2_struct& i : st->sub_structs) {
|
||||
if (!i.header.data_size)
|
||||
continue;
|
||||
|
||||
if (i.header.signature == reverse_endianness_uint32_t('EFCT')
|
||||
&& !glitter_effect_parse_file(this, &i, &effects, obj_db))
|
||||
return false;
|
||||
else if (i.header.signature == reverse_endianness_uint32_t('DVRS')
|
||||
&& !glitter_texture_hashes_unpack_file(this, &i))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
@@ -13,7 +13,7 @@ namespace Glitter {
|
||||
size_t id, float_t emission, bool appear_now) : data(GLT_VAL) {
|
||||
effect = eff;
|
||||
data = eff->data;
|
||||
color = vec4_identity;
|
||||
color = 1.0f;
|
||||
scale_all = 1.0f;
|
||||
this->id = id;
|
||||
translation = eff->translation;
|
||||
@@ -25,8 +25,8 @@ namespace Glitter {
|
||||
flags = (EffectInstFlag)0;
|
||||
random = 0;
|
||||
req_frame = 0.0f;
|
||||
ext_color = vec4_null;
|
||||
ext_anim_scale = vec3_null;
|
||||
ext_color = 0.0f;
|
||||
ext_anim_scale = 0.0f;
|
||||
some_scale = -1.0f;
|
||||
|
||||
if (appear_now)
|
||||
@@ -39,6 +39,17 @@ namespace Glitter {
|
||||
|
||||
}
|
||||
|
||||
bool EffectInst::GetExtAnimScale(vec3* ext_anim_scale, float_t* some_scale) {
|
||||
if (!(flags & EFFECT_INST_HAS_EXT_ANIM_SCALE))
|
||||
return false;
|
||||
|
||||
if (ext_anim_scale)
|
||||
*ext_anim_scale = this->ext_anim_scale;
|
||||
if (some_scale)
|
||||
*some_scale = this->some_scale;
|
||||
return true;
|
||||
}
|
||||
|
||||
void EffectInst::SetExtColor(bool set, float_t r, float_t g, float_t b, float_t a) {
|
||||
ext_color.x = r;
|
||||
ext_color.y = g;
|
||||
@@ -97,7 +108,7 @@ namespace Glitter {
|
||||
object_is_hrc = false;
|
||||
mesh_name = 0;
|
||||
mat = mat4_identity;
|
||||
translation = vec3_null;
|
||||
translation = 0.0f;
|
||||
}
|
||||
|
||||
F2EffectInst::ExtAnim::~ExtAnim() {
|
||||
@@ -185,21 +196,16 @@ namespace Glitter {
|
||||
GetValue(GLT_VAL);
|
||||
|
||||
mat4 mat;
|
||||
if (GetExtAnimMat(&mat)) {
|
||||
vec3 trans = translation;
|
||||
mat4_translate_mult(&mat, trans.x, trans.y, trans.z, &mat);
|
||||
}
|
||||
else {
|
||||
vec3 trans = translation;
|
||||
mat4_translate(trans.x, trans.y, trans.z, &mat);
|
||||
}
|
||||
if (GetExtAnimMat(&mat))
|
||||
mat4_translate_mult(&mat, &translation, &mat);
|
||||
else
|
||||
mat4_translate(&translation, &mat);
|
||||
|
||||
vec3 rot = rotation;
|
||||
vec3 scale;
|
||||
vec3_mult_scalar(this->scale, scale_all, scale);
|
||||
vec3 scale = this->scale * scale_all;
|
||||
|
||||
mat4_rotate_mult(&mat, rot.x, rot.y, rot.z, &mat);
|
||||
mat4_scale_rot(&mat, scale.x, scale.y, scale.z, &this->mat);
|
||||
mat4_rotate_mult(&mat, &rot, &mat);
|
||||
mat4_scale_rot(&mat, &scale, &this->mat);
|
||||
|
||||
for (F2EmitterInst*& i : emitters)
|
||||
if (i)
|
||||
@@ -293,15 +299,13 @@ namespace Glitter {
|
||||
GetValue(GLT_VAL);
|
||||
|
||||
mat4 mat;
|
||||
vec3 trans = translation;
|
||||
mat4_translate(trans.x, trans.y, trans.z, &mat);
|
||||
mat4_translate(&translation, &mat);
|
||||
|
||||
vec3 rot = rotation;
|
||||
vec3 scale;
|
||||
vec3_mult_scalar(this->scale, scale_all, scale);
|
||||
vec3 scale = this->scale * scale_all;
|
||||
|
||||
mat4_rotate_mult(&mat, rot.x, rot.y, rot.z, &mat);
|
||||
mat4_scale_rot(&mat, scale.x, scale.y, scale.z, &mat);
|
||||
mat4_rotate_mult(&mat, &rot, &mat);
|
||||
mat4_scale_rot(&mat, &scale, &mat);
|
||||
for (F2EmitterInst*& i : emitters)
|
||||
if (i)
|
||||
i->CtrlInit(GPM_VAL, GLT_VAL, this, delta_frame);
|
||||
@@ -333,13 +337,12 @@ namespace Glitter {
|
||||
|
||||
vec3 trans = translation;
|
||||
vec3 rot = rotation;
|
||||
vec3 scale;
|
||||
vec3_mult_scalar(this->scale, scale_all, scale);
|
||||
vec3 scale = this->scale * scale_all;
|
||||
|
||||
mat4 mat;
|
||||
mat4_translate(trans.x, trans.y, trans.z, &mat);
|
||||
mat4_rotate_mult(&mat, rot.x, rot.y, rot.z, &mat);
|
||||
mat4_scale_rot(&mat, scale.x, scale.y, scale.z, &mat);
|
||||
mat4_translate(&trans, &mat);
|
||||
mat4_rotate_mult(&mat, &rot, &mat);
|
||||
mat4_scale_rot(&mat, &scale, &mat);
|
||||
this->mat = mat;
|
||||
|
||||
for (F2EmitterInst*& i : emitters)
|
||||
@@ -375,7 +378,7 @@ namespace Glitter {
|
||||
|
||||
vec3 scale;
|
||||
mat4_get_scale(&mat, &scale);
|
||||
vec3_sub_scalar(scale, 1.0f, ext_anim_scale);
|
||||
ext_anim_scale = scale - 1.0f;
|
||||
ext_anim_scale.z = 0.0f;
|
||||
enum_or(flags, EFFECT_INST_HAS_EXT_ANIM_SCALE);
|
||||
|
||||
@@ -425,7 +428,7 @@ namespace Glitter {
|
||||
|
||||
vec3 scale;
|
||||
mat4_get_scale(&mat, &scale);
|
||||
vec3_sub_scalar(scale, 1.0f, ext_anim_scale);
|
||||
ext_anim_scale = scale - 1.0f;
|
||||
ext_anim_scale.z = 0.0f;
|
||||
enum_or(flags, EFFECT_INST_HAS_EXT_ANIM_SCALE);
|
||||
}
|
||||
@@ -489,8 +492,7 @@ namespace Glitter {
|
||||
if (!(flags & EFFECT_INST_HAS_EXT_ANIM_TRANS) || !ext_anim)
|
||||
return false;
|
||||
|
||||
vec3 trans = ext_anim->translation;
|
||||
mat4_translate_mult(&ext_anim->mat, trans.x, trans.y, trans.z, mat);
|
||||
mat4_translate_mult(&ext_anim->mat, &ext_anim->translation, mat);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -600,7 +602,7 @@ namespace Glitter {
|
||||
instance_id = 0;
|
||||
mesh_name = 0;
|
||||
mat = mat4_identity;
|
||||
translation = vec3_null;
|
||||
translation = 0.0f;
|
||||
}
|
||||
|
||||
XEffectInst::ExtAnim::~ExtAnim() {
|
||||
@@ -709,7 +711,7 @@ namespace Glitter {
|
||||
|
||||
GetValue();
|
||||
|
||||
vec3 rot = rotation;
|
||||
vec3& rot = rotation;
|
||||
|
||||
mat4 mat;
|
||||
if (GetExtAnimMat(&mat)) {
|
||||
@@ -717,25 +719,22 @@ namespace Glitter {
|
||||
mat4_clear_trans(&mat_rot, &mat_rot);
|
||||
|
||||
mat_rot_eff_rot = mat_rot;
|
||||
mat4_rotate_mult(&mat_rot, rot.x, rot.y, rot.z, &mat_rot);
|
||||
mat4_rotate_mult(&mat_rot, &rot, &mat_rot);
|
||||
|
||||
vec3 trans = translation;
|
||||
mat4_translate_mult(&mat, trans.x, trans.y, trans.z, &mat);
|
||||
mat4_translate_mult(&mat, &translation, &mat);
|
||||
}
|
||||
else {
|
||||
mat_rot = mat4_identity;
|
||||
mat_rot_eff_rot = mat4_identity;
|
||||
mat4_rotate(rot.x, rot.y, rot.z, &mat_rot);
|
||||
mat4_rotate(&rot, &mat_rot);
|
||||
|
||||
vec3 trans = translation;
|
||||
mat4_translate(trans.x, trans.y, trans.z, &mat);
|
||||
mat4_translate(&translation, &mat);
|
||||
}
|
||||
|
||||
vec3 scale;
|
||||
vec3_mult_scalar(this->scale, scale_all, scale);
|
||||
vec3 scale = this->scale * scale_all;
|
||||
|
||||
mat4_rotate_mult(&mat, rot.x, rot.y, rot.z, &mat);
|
||||
mat4_scale_rot(&mat, scale.x, scale.y, scale.z, &this->mat);
|
||||
mat4_rotate_mult(&mat, &rot, &mat);
|
||||
mat4_scale_rot(&mat, &scale, &this->mat);
|
||||
|
||||
for (XEmitterInst*& i : emitters)
|
||||
if (i)
|
||||
@@ -842,13 +841,12 @@ namespace Glitter {
|
||||
|
||||
vec3 trans = translation;
|
||||
vec3 rot = rotation;
|
||||
vec3 scale;
|
||||
vec3_mult_scalar(this->scale, scale_all, scale);
|
||||
vec3 scale = this->scale * scale_all;
|
||||
|
||||
mat4 mat;
|
||||
mat4_translate(trans.x, trans.y, trans.z, &mat);
|
||||
mat4_rotate_mult(&mat, rot.x, rot.y, rot.z, &mat);
|
||||
mat4_scale_rot(&mat, scale.x, scale.y, scale.z, &mat);
|
||||
mat4_translate(&trans, &mat);
|
||||
mat4_rotate_mult(&mat, &rot, &mat);
|
||||
mat4_scale_rot(&mat, &scale, &mat);
|
||||
for (XEmitterInst*& i : emitters)
|
||||
if (i)
|
||||
i->CtrlInit(this, delta_frame);
|
||||
@@ -880,13 +878,12 @@ namespace Glitter {
|
||||
|
||||
vec3 trans = translation;
|
||||
vec3 rot = rotation;
|
||||
vec3 scale;
|
||||
vec3_mult_scalar(this->scale, scale_all, scale);
|
||||
vec3 scale = this->scale * scale_all;
|
||||
|
||||
mat4 mat;
|
||||
mat4_translate(trans.x, trans.y, trans.z, &mat);
|
||||
mat4_rotate_mult(&mat, rot.x, rot.y, rot.z, &mat);
|
||||
mat4_scale_rot(&mat, scale.x, scale.y, scale.z, &mat);
|
||||
mat4_translate(&trans, &mat);
|
||||
mat4_rotate_mult(&mat, &rot, &mat);
|
||||
mat4_scale_rot(&mat, &scale, &mat);
|
||||
this->mat = mat;
|
||||
|
||||
for (XEmitterInst*& i : emitters)
|
||||
@@ -928,11 +925,11 @@ namespace Glitter {
|
||||
|
||||
vec3 scale;
|
||||
mat4_get_scale(mat, &scale);
|
||||
vec3_sub_scalar(scale, 1.0f, ext_anim_scale);
|
||||
ext_anim_scale = scale - 1.0f;
|
||||
ext_anim_scale.z = 0.0f;
|
||||
enum_or(flags, EFFECT_INST_HAS_EXT_ANIM_SCALE);
|
||||
|
||||
if (rob_chr->data.field_0 & 0x01 || ~data.ext_anim_x->flags & EFFECT_EXT_ANIM_NO_DRAW_IF_NO_DATA)
|
||||
if (rob_chr->get_visibility() || !(data.ext_anim_x->flags & EFFECT_EXT_ANIM_NO_DRAW_IF_NO_DATA))
|
||||
set_flags = true;
|
||||
else
|
||||
set_flags = false;
|
||||
@@ -977,7 +974,7 @@ namespace Glitter {
|
||||
|
||||
vec3 scale;
|
||||
mat4_get_scale(mat, &scale);
|
||||
vec3_sub_scalar(scale, 1.0f, ext_anim_scale);
|
||||
ext_anim_scale = scale - 1.0f;
|
||||
ext_anim_scale.z = 0.0f;
|
||||
enum_or(flags, EFFECT_INST_HAS_EXT_ANIM_SCALE);
|
||||
}
|
||||
@@ -1025,8 +1022,7 @@ namespace Glitter {
|
||||
if (!(flags & EFFECT_INST_HAS_EXT_ANIM_TRANS) || !ext_anim)
|
||||
return false;
|
||||
|
||||
vec3 trans = ext_anim->translation;
|
||||
mat4_translate_mult(&ext_anim->mat, trans.x, trans.y, trans.z, mat);
|
||||
mat4_translate_mult(&ext_anim->mat, &ext_anim->translation, mat);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,4 +39,21 @@ namespace Glitter {
|
||||
for (Particle*& i : particles)
|
||||
delete i;
|
||||
}
|
||||
|
||||
Emitter& Emitter::operator=(const Emitter& emit) {
|
||||
data = emit.data;
|
||||
version = emit.version;
|
||||
|
||||
for (Particle*& i : particles)
|
||||
delete i;
|
||||
particles.clear();
|
||||
|
||||
particles.reserve(emit.particles.size());
|
||||
for (Particle* i : emit.particles) {
|
||||
Particle* ptcl = new Particle(i->version > 0x03 ? Glitter::X : Glitter::F2);
|
||||
*ptcl = *i;
|
||||
particles.push_back(ptcl);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,9 +104,7 @@ namespace Glitter {
|
||||
frame -= data.loop_end_time - data.loop_start_time;
|
||||
|
||||
GetValue(GLT_VAL);
|
||||
vec3 rotation_add;
|
||||
vec3_mult_scalar(data.rotation_add, delta_frame, rotation_add);
|
||||
vec3_add(rotation, rotation_add, rotation);
|
||||
rotation += data.rotation_add * delta_frame;
|
||||
CtrlMat(GPM_VAL, GLT_VAL, eff_inst);
|
||||
}
|
||||
|
||||
@@ -127,17 +125,14 @@ namespace Glitter {
|
||||
return;
|
||||
|
||||
GetValue(GLT_VAL);
|
||||
vec3 rotation_add;
|
||||
vec3_mult_scalar(data.rotation_add, delta_frame, rotation_add);
|
||||
vec3_add(rotation, rotation_add, rotation);
|
||||
rotation += data.rotation_add * delta_frame;
|
||||
CtrlMat(GPM_VAL, GLT_VAL, eff_inst);
|
||||
}
|
||||
|
||||
void F2EmitterInst::CtrlMat(GPM, GLT, F2EffectInst* eff_inst) {
|
||||
vec3 trans = translation;
|
||||
vec3 rot = rotation;
|
||||
vec3 scale;
|
||||
vec3_mult_scalar(this->scale, scale_all, scale);
|
||||
vec3 scale = this->scale * scale_all;
|
||||
|
||||
bool mult = true;
|
||||
mat4 dir_mat;
|
||||
@@ -165,13 +160,14 @@ namespace Glitter {
|
||||
}
|
||||
|
||||
mat4 mat;
|
||||
mat4_translate_mult(&eff_inst->mat, trans.x, trans.y, trans.z, &mat);
|
||||
mat4_translate_mult(&eff_inst->mat, &trans, &mat);
|
||||
mat4_normalize_rotation(&mat, &mat);
|
||||
if (mult)
|
||||
mat4_mult(&dir_mat, &mat, &mat);
|
||||
mat4_rotate_mult(&mat, rot.x, rot.y, rot.z, &mat);
|
||||
mat4_rotate_mult(&mat, &rot, &mat);
|
||||
mat4_clear_trans(&mat, &mat_rot);
|
||||
mat4_scale_rot(&mat, scale.x, scale.y, scale.z, &this->mat);
|
||||
mat4_scale_rot(&mat, &scale, &mat);
|
||||
this->mat = mat;
|
||||
}
|
||||
|
||||
void F2EmitterInst::Emit(GPM, GLT, float_t delta_frame, float_t emission) {
|
||||
@@ -304,14 +300,11 @@ namespace Glitter {
|
||||
return true;
|
||||
}
|
||||
|
||||
void F2EmitterInst::InitMesh(GLT, int32_t index, vec3& scale,
|
||||
void F2EmitterInst::InitMesh(GLT, int32_t index, const vec3& scale,
|
||||
vec3& position, vec3& direction, Random* random) {
|
||||
switch (data.type) {
|
||||
case EMITTER_BOX: {
|
||||
vec3 dir;
|
||||
vec3_mult(data.box.size, scale, dir);
|
||||
vec3_mult_scalar(dir, 0.5f, dir);
|
||||
random->F2GetVec3(GLT_VAL, dir, position);
|
||||
position = random->F2GetVec3(GLT_VAL, data.box.size * scale * 0.5f);
|
||||
} break;
|
||||
case EMITTER_CYLINDER: {
|
||||
float_t radius = data.cylinder.radius * scale.x;
|
||||
@@ -333,7 +326,7 @@ namespace Glitter {
|
||||
direction = dir;
|
||||
else if (data.cylinder.direction == EMITTER_EMISSION_DIRECTION_INWARD) {
|
||||
const vec3 reverse_xz_dir = { -0.0f, 0.0f, -0.0f };
|
||||
vec3_xor(dir, reverse_xz_dir, direction);
|
||||
direction = dir ^ reverse_xz_dir;
|
||||
}
|
||||
} break;
|
||||
case EMITTER_SPHERE: {
|
||||
@@ -349,11 +342,11 @@ namespace Glitter {
|
||||
dir.y = sinf(latitude);
|
||||
dir.z = cosf(longitude) * cosf(latitude);
|
||||
|
||||
vec3_mult_scalar(dir, radius, position);
|
||||
position = dir * radius;
|
||||
if (data.sphere.direction == EMITTER_EMISSION_DIRECTION_OUTWARD)
|
||||
direction = dir;
|
||||
else if (data.sphere.direction == EMITTER_EMISSION_DIRECTION_INWARD)
|
||||
vec3_negate(dir, direction);
|
||||
direction = -dir;
|
||||
} break;
|
||||
case EMITTER_POLYGON: {
|
||||
float_t radius = data.polygon.size * scale.x;
|
||||
@@ -381,76 +374,6 @@ namespace Glitter {
|
||||
i->Reset();
|
||||
}
|
||||
|
||||
void XEmitterInst::InitMesh(int32_t index, vec3& scale,
|
||||
vec3& position, vec3& direction, Random* random) {
|
||||
switch (emitter->data.type) {
|
||||
case EMITTER_BOX: {
|
||||
vec3 dir;
|
||||
vec3_mult(data.box.size, scale, dir);
|
||||
vec3_mult_scalar(dir, 0.5f, dir);
|
||||
random->XGetVec3(dir, position);
|
||||
} break;
|
||||
case EMITTER_CYLINDER: {
|
||||
float_t radius = data.cylinder.radius * scale.x;
|
||||
if (!data.cylinder.on_edge)
|
||||
radius = random->XGetFloat(0.0f, radius);
|
||||
|
||||
float_t angle = random->XGetFloat(data.cylinder.start_angle, data.cylinder.end_angle);
|
||||
|
||||
vec3 dir;
|
||||
dir.x = cosf(angle);
|
||||
dir.y = 0.0f;
|
||||
dir.z = sinf(angle);
|
||||
|
||||
position.x = dir.x * radius;
|
||||
position.y = random->XGetFloat(data.cylinder.height * scale.y * 0.5f);
|
||||
position.z = dir.z * radius;
|
||||
|
||||
if (data.cylinder.direction == EMITTER_EMISSION_DIRECTION_OUTWARD)
|
||||
direction = dir;
|
||||
else if (data.cylinder.direction == EMITTER_EMISSION_DIRECTION_INWARD) {
|
||||
const vec3 reverse_xz_dir = { -0.0f, 0.0f, -0.0f };
|
||||
vec3_xor(dir, reverse_xz_dir, direction);
|
||||
}
|
||||
} break;
|
||||
case EMITTER_SPHERE: {
|
||||
float_t radius = data.sphere.radius * scale.x;
|
||||
if (!data.sphere.on_edge)
|
||||
radius = random->XGetFloat(0.0f, radius);
|
||||
|
||||
float_t longitude = random->XGetFloat(data.sphere.longitude * 0.5f);
|
||||
float_t latitude = (float_t)M_PI_2 - random->XGetFloat(0.0f, data.sphere.latitude);
|
||||
|
||||
vec3 dir;
|
||||
dir.x = sinf(longitude) * cosf(latitude);
|
||||
dir.y = sinf(latitude);
|
||||
dir.z = cosf(longitude) * cosf(latitude);
|
||||
|
||||
vec3_mult_scalar(dir, radius, position);
|
||||
if (data.sphere.direction == EMITTER_EMISSION_DIRECTION_OUTWARD)
|
||||
direction = dir;
|
||||
else if (data.sphere.direction == EMITTER_EMISSION_DIRECTION_INWARD)
|
||||
vec3_negate(dir, direction);
|
||||
} break;
|
||||
case EMITTER_POLYGON: {
|
||||
float_t radius = data.polygon.size * scale.x;
|
||||
float_t angle = ((float_t)index * 360.0f
|
||||
/ (float_t)data.polygon.count + 90.0f) * DEG_TO_RAD_FLOAT;
|
||||
|
||||
vec3 dir;
|
||||
dir.x = cosf(angle);
|
||||
dir.y = 0.0f;
|
||||
dir.z = sinf(angle);
|
||||
|
||||
vec3_mult_scalar(dir, radius, position);
|
||||
if (data.sphere.direction == EMITTER_EMISSION_DIRECTION_OUTWARD)
|
||||
direction = dir;
|
||||
else if (data.sphere.direction == EMITTER_EMISSION_DIRECTION_INWARD)
|
||||
vec3_negate(dir, direction);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
XEmitterInst::XEmitterInst(Emitter* emit,
|
||||
XEffectInst* eff_inst, float_t emission) : EmitterInst(emit, &eff_inst->random_shared) {
|
||||
counter = 0;
|
||||
@@ -548,11 +471,9 @@ namespace Glitter {
|
||||
|
||||
GetValue();
|
||||
|
||||
vec3 rotation_add;
|
||||
vec3_mult_scalar(data.rotation_add, delta_frame, rotation_add);
|
||||
vec3_add(rotation, rotation_add, rotation);
|
||||
rotation += data.rotation_add * delta_frame;
|
||||
|
||||
vec3 trans_prev = vec3_null;
|
||||
vec3 trans_prev = {};
|
||||
bool has_dist = false;
|
||||
if (data.timer == EMITTER_TIMER_BY_DISTANCE && flags & EMITTER_INST_HAS_DISTANCE) {
|
||||
mat4_get_translation(&mat, &trans_prev);
|
||||
@@ -561,11 +482,10 @@ namespace Glitter {
|
||||
|
||||
vec3 trans = translation;
|
||||
vec3 rot = rotation;
|
||||
vec3 scale;
|
||||
vec3_mult_scalar(this->scale, scale_all, scale);
|
||||
vec3 scale = this->scale * scale_all;
|
||||
|
||||
mat4 mat = eff_inst->mat;
|
||||
mat4_translate_mult(&mat, trans.x, trans.y, trans.z, &mat);
|
||||
mat4_translate_mult(&mat, &trans, &mat);
|
||||
mat4 mat_rot;
|
||||
if (data.direction == DIRECTION_EFFECT_ROTATION) {
|
||||
mat4_normalize_rotation(&mat, &mat);
|
||||
@@ -610,19 +530,16 @@ namespace Glitter {
|
||||
mat4_mult(&dir_mat, &mat_rot, &mat_rot);
|
||||
}
|
||||
|
||||
mat4_rotate_mult(&mat, rot.x, rot.y, rot.z, &mat);
|
||||
mat4_rotate_mult(&mat_rot, rot.x, rot.y, rot.z, &mat_rot);
|
||||
mat4_scale_rot(&mat, scale.x, scale.y, scale.z, &mat);
|
||||
mat4_rotate_mult(&mat, &rot, &mat);
|
||||
mat4_rotate_mult(&mat_rot, &rot, &mat_rot);
|
||||
mat4_scale_rot(&mat, &scale, &mat);
|
||||
this->mat = mat;
|
||||
this->mat_rot = mat_rot;
|
||||
|
||||
if (has_dist) {
|
||||
vec3 trans;
|
||||
mat4_get_translation(&mat, &trans);
|
||||
|
||||
float_t trans_dist;
|
||||
vec3_distance(trans, trans_prev, trans_dist);
|
||||
emission_timer -= trans_dist;
|
||||
emission_timer -= vec3::distance(trans, trans_prev);
|
||||
}
|
||||
|
||||
if (~flags & EMITTER_INST_HAS_DISTANCE)
|
||||
@@ -660,9 +577,8 @@ namespace Glitter {
|
||||
|
||||
GetValue();
|
||||
|
||||
vec3 rotation_add;
|
||||
vec3_mult_scalar(data.rotation_add, delta_frame, rotation_add);
|
||||
vec3_add(rotation, rotation_add, rotation);
|
||||
rotation += data.rotation_add * delta_frame;
|
||||
|
||||
if (data.timer == EMITTER_TIMER_BY_DISTANCE && flags & EMITTER_INST_HAS_DISTANCE) {
|
||||
vec3 trans_prev;
|
||||
mat4 mat;
|
||||
@@ -677,16 +593,14 @@ namespace Glitter {
|
||||
vec3 trans = translation;
|
||||
vec3 rot = rotation;
|
||||
mat = eff_inst->mat;
|
||||
mat4_translate_mult(&mat, trans.x, trans.y, trans.z, &mat);
|
||||
mat4_rotate_mult(&mat, rot.x, rot.y, rot.z, &mat);
|
||||
mat4_rotate_mult(&mat_rot, rot.x, rot.y, rot.z, &mat_rot);
|
||||
mat4_translate_mult(&mat, &trans, &mat);
|
||||
mat4_rotate_mult(&mat, &rot, &mat);
|
||||
mat4_rotate_mult(&mat_rot, &rot, &mat_rot);
|
||||
this->mat = mat;
|
||||
this->mat_rot = mat_rot;
|
||||
|
||||
float_t trans_dist;
|
||||
mat4_get_translation(&mat, &trans);
|
||||
vec3_distance(trans, trans_prev, trans_dist);
|
||||
emission_timer -= trans_dist;
|
||||
emission_timer -= vec3::distance(trans, trans_prev);
|
||||
}
|
||||
enum_or(flags, EMITTER_INST_HAS_DISTANCE);
|
||||
}
|
||||
@@ -694,11 +608,10 @@ namespace Glitter {
|
||||
void XEmitterInst::CtrlMat(GPM, XEffectInst* eff_inst) {
|
||||
vec3 trans = translation;
|
||||
vec3 rot = rotation;
|
||||
vec3 scale;
|
||||
vec3_mult_scalar(this->scale, scale_all, scale);
|
||||
vec3 scale = this->scale * scale_all;
|
||||
|
||||
mat4 mat = eff_inst->mat;
|
||||
mat4_translate_mult(&mat, trans.x, trans.y, trans.z, &mat);
|
||||
mat4_translate_mult(&mat, &trans, &mat);
|
||||
mat4 mat_rot;
|
||||
if (data.direction == DIRECTION_EFFECT_ROTATION) {
|
||||
mat4_normalize_rotation(&mat, &mat);
|
||||
@@ -734,9 +647,9 @@ namespace Glitter {
|
||||
mat4_mult(&dir_mat, &mat_rot, &mat_rot);
|
||||
}
|
||||
|
||||
mat4_rotate_mult(&mat, rot.x, rot.y, rot.z, &mat);
|
||||
mat4_rotate_mult(&mat_rot, rot.x, rot.y, rot.z, &mat_rot);
|
||||
mat4_scale_rot(&mat, scale.x, scale.y, scale.z, &mat);
|
||||
mat4_rotate_mult(&mat, &rot, &mat);
|
||||
mat4_rotate_mult(&mat_rot, &rot, &mat_rot);
|
||||
mat4_scale_rot(&mat, &scale, &mat);
|
||||
this->mat = mat;
|
||||
this->mat_rot = mat_rot;
|
||||
}
|
||||
@@ -887,6 +800,73 @@ namespace Glitter {
|
||||
return true;
|
||||
}
|
||||
|
||||
void XEmitterInst::InitMesh(int32_t index, const vec3& scale,
|
||||
vec3& position, vec3& direction, Random* random) {
|
||||
switch (emitter->data.type) {
|
||||
case EMITTER_BOX: {
|
||||
position = random->XGetVec3(data.box.size * scale * 0.5f);
|
||||
} break;
|
||||
case EMITTER_CYLINDER: {
|
||||
float_t radius = data.cylinder.radius * scale.x;
|
||||
if (!data.cylinder.on_edge)
|
||||
radius = random->XGetFloat(0.0f, radius);
|
||||
|
||||
float_t angle = random->XGetFloat(data.cylinder.start_angle, data.cylinder.end_angle);
|
||||
|
||||
vec3 dir;
|
||||
dir.x = cosf(angle);
|
||||
dir.y = 0.0f;
|
||||
dir.z = sinf(angle);
|
||||
|
||||
position.x = dir.x * radius;
|
||||
position.y = random->XGetFloat(data.cylinder.height * scale.y * 0.5f);
|
||||
position.z = dir.z * radius;
|
||||
|
||||
if (data.cylinder.direction == EMITTER_EMISSION_DIRECTION_OUTWARD)
|
||||
direction = dir;
|
||||
else if (data.cylinder.direction == EMITTER_EMISSION_DIRECTION_INWARD) {
|
||||
const vec3 reverse_xz_dir = { -0.0f, 0.0f, -0.0f };
|
||||
direction = dir ^ reverse_xz_dir;
|
||||
}
|
||||
} break;
|
||||
case EMITTER_SPHERE: {
|
||||
float_t radius = data.sphere.radius * scale.x;
|
||||
if (!data.sphere.on_edge)
|
||||
radius = random->XGetFloat(0.0f, radius);
|
||||
|
||||
float_t longitude = random->XGetFloat(data.sphere.longitude * 0.5f);
|
||||
float_t latitude = (float_t)M_PI_2 - random->XGetFloat(0.0f, data.sphere.latitude);
|
||||
|
||||
vec3 dir;
|
||||
dir.x = sinf(longitude) * cosf(latitude);
|
||||
dir.y = sinf(latitude);
|
||||
dir.z = cosf(longitude) * cosf(latitude);
|
||||
|
||||
position = dir * radius;
|
||||
if (data.sphere.direction == EMITTER_EMISSION_DIRECTION_OUTWARD)
|
||||
direction = dir;
|
||||
else if (data.sphere.direction == EMITTER_EMISSION_DIRECTION_INWARD)
|
||||
direction = -dir;
|
||||
} break;
|
||||
case EMITTER_POLYGON: {
|
||||
float_t radius = data.polygon.size * scale.x;
|
||||
float_t angle = ((float_t)index * 360.0f
|
||||
/ (float_t)data.polygon.count + 90.0f) * DEG_TO_RAD_FLOAT;
|
||||
|
||||
vec3 dir;
|
||||
dir.x = cosf(angle);
|
||||
dir.y = 0.0f;
|
||||
dir.z = sinf(angle);
|
||||
|
||||
position = dir * radius;
|
||||
if (data.sphere.direction == EMITTER_EMISSION_DIRECTION_OUTWARD)
|
||||
direction = dir;
|
||||
else if (data.sphere.direction == EMITTER_EMISSION_DIRECTION_INWARD)
|
||||
direction = -dir;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t XEmitterInst::RandomGetStep() {
|
||||
step = (step + 2) % 60;
|
||||
return step;
|
||||
|
||||
@@ -834,7 +834,7 @@ namespace Glitter {
|
||||
int32_t efct_version, bool big_endian, object_database* obj_db) {
|
||||
eff->version = efct_version;
|
||||
if (type == Glitter::X) {
|
||||
eff->scale = vec3_identity;
|
||||
eff->scale = 1.0f;
|
||||
eff->data.start_time = 0;
|
||||
eff->data.ext_anim_x = 0;
|
||||
eff->data.flags = (EffectFlag)0;
|
||||
@@ -1010,7 +1010,7 @@ namespace Glitter {
|
||||
}
|
||||
}
|
||||
else {
|
||||
eff->scale = vec3_identity;
|
||||
eff->scale = 1.0f;
|
||||
eff->data.start_time = 0;
|
||||
eff->data.ext_anim = 0;
|
||||
eff->data.flags = (EffectFlag)0;
|
||||
@@ -1532,8 +1532,8 @@ namespace Glitter {
|
||||
d += 256;
|
||||
|
||||
if (ptcl->version == 4) {
|
||||
vec3_mult_scalar(ptcl->data.direction, 10.0f, ptcl->data.direction);
|
||||
vec3_mult_scalar(ptcl->data.direction_random, 10.0f, ptcl->data.direction_random);
|
||||
ptcl->data.direction *= 10.0f;
|
||||
ptcl->data.direction_random *= 10.0f;
|
||||
}
|
||||
|
||||
if (ptcl->data.emission >= min_emission)
|
||||
|
||||
@@ -1249,37 +1249,52 @@ namespace Glitter {
|
||||
|
||||
farc f;
|
||||
{
|
||||
f2_struct st;
|
||||
if (fr.UnparseDivaEffect(eff_group, &st, big_endian)) {
|
||||
f.add_file();
|
||||
farc_file& ff_drs = f.files.back();
|
||||
st.write(&ff_drs.data, &ff_drs.size);
|
||||
ff_drs.name = std::string(file) + ".dve";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
f2_struct st;
|
||||
if (fr.UnparseDivaResource(eff_group, &st)) {
|
||||
f.add_file();
|
||||
farc_file& ff_dve = f.files.back();
|
||||
st.write(&ff_dve.data, &ff_dve.size);
|
||||
ff_dve.name = std::string(file) + ".drs";
|
||||
}
|
||||
else
|
||||
size_t file_len = utf8_length(file);
|
||||
char* temp = force_malloc_s(char, file_len + 5);
|
||||
if (!temp)
|
||||
return;
|
||||
}
|
||||
|
||||
if (fr.type == Glitter::FT) {
|
||||
f2_struct st;
|
||||
if (fr.UnparseDivaList(eff_group, &st, big_endian)) {
|
||||
f.add_file();
|
||||
farc_file& ff_lst = f.files.back();
|
||||
st.write(&ff_lst.data, &ff_lst.size);
|
||||
ff_lst.name = std::string(file) + ".lst";
|
||||
memcpy(temp, file, file_len);
|
||||
temp[file_len] = 0;
|
||||
|
||||
{
|
||||
f2_struct dve_st;
|
||||
if (fr.UnparseDivaEffect(eff_group, &dve_st, big_endian)) {
|
||||
memcpy(&temp[file_len], ".dve", 4);
|
||||
temp[file_len + 4] = 0;
|
||||
farc_file* ff_dve = f.add_file(temp);
|
||||
dve_st.write(&ff_dve->data, &ff_dve->size);
|
||||
}
|
||||
else {
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
{
|
||||
f2_struct drs_st;
|
||||
if (fr.UnparseDivaResource(eff_group, &drs_st)) {
|
||||
memcpy(&temp[file_len], ".drs", 4);
|
||||
temp[file_len + 4] = 0;
|
||||
farc_file* ff_drs = f.add_file(temp);
|
||||
drs_st.write(&ff_drs->data, &ff_drs->size);
|
||||
}
|
||||
}
|
||||
|
||||
if (fr.type == Glitter::FT) {
|
||||
f2_struct lst_st;
|
||||
if (fr.UnparseDivaList(eff_group, &lst_st, big_endian)) {
|
||||
memcpy(&temp[file_len], ".lst", 4);
|
||||
temp[file_len + 4] = 0;
|
||||
farc_file* ff_lst = f.add_file(temp);
|
||||
lst_st.write(&ff_lst->data, &ff_lst->size);
|
||||
}
|
||||
else {
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
free(temp);
|
||||
}
|
||||
|
||||
farc_compress_mode mode;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "../../KKdLib/database/object.hpp"
|
||||
@@ -482,6 +481,8 @@ namespace Glitter {
|
||||
#if defined(CRE_DEV) || defined(ReDIVA_DEV)
|
||||
void AddValue(GLT, float_t val, CurveTypeFlags flags);
|
||||
#endif
|
||||
|
||||
Animation& operator=(const Animation& anim);
|
||||
};
|
||||
|
||||
struct Buffer {
|
||||
@@ -560,6 +561,8 @@ namespace Glitter {
|
||||
|
||||
ItemBase();
|
||||
virtual ~ItemBase();
|
||||
|
||||
ItemBase& operator=(const ItemBase& item_base);
|
||||
};
|
||||
|
||||
class Node : public ItemBase {
|
||||
@@ -571,6 +574,8 @@ namespace Glitter {
|
||||
|
||||
Node();
|
||||
virtual ~Node() override;
|
||||
|
||||
Node& operator=(const Node& node);
|
||||
};
|
||||
|
||||
class Effect : public Node {
|
||||
@@ -614,6 +619,7 @@ namespace Glitter {
|
||||
int32_t life_time;
|
||||
int32_t start_time;
|
||||
vec4u8 color;
|
||||
bool ext_anim_is_x;
|
||||
union {
|
||||
Effect::ExtAnim * ext_anim;
|
||||
Effect::ExtAnimX* ext_anim_x;
|
||||
@@ -631,6 +637,8 @@ namespace Glitter {
|
||||
|
||||
Effect(GLT);
|
||||
virtual ~Effect() override;
|
||||
|
||||
Effect& operator=(const Effect& eff);
|
||||
};
|
||||
|
||||
struct EffectGroup {
|
||||
@@ -673,7 +681,7 @@ namespace Glitter {
|
||||
float_t F2GetFloat(GLT, float_t min, float_t max);
|
||||
int32_t F2GetInt(GLT, int32_t value);
|
||||
int32_t F2GetInt(GLT, int32_t min, int32_t max);
|
||||
void F2GetVec3(GLT, vec3& src, vec3& dst);
|
||||
vec3 F2GetVec3(GLT, const vec3& value);
|
||||
void F2StepValue();
|
||||
int32_t GetValue();
|
||||
void SetValue(int32_t value);
|
||||
@@ -681,7 +689,7 @@ namespace Glitter {
|
||||
float_t XGetFloat(float_t min, float_t max);
|
||||
int32_t XGetInt(int32_t value);
|
||||
int32_t XGetInt(int32_t min, int32_t max);
|
||||
void XGetVec3(vec3& src, vec3& dst);
|
||||
vec3 XGetVec3(const vec3& value);
|
||||
void XReset();
|
||||
void XSetStep(uint8_t step);
|
||||
void XStepValue();
|
||||
@@ -746,9 +754,9 @@ namespace Glitter {
|
||||
size_t GetDispCount(ParticleType type);
|
||||
|
||||
static void CalcDispLocusSetPivot(Pivot pivot,
|
||||
float_t w, float_t* v00, float_t* v01);
|
||||
float_t w, float_t& v00, float_t& v01);
|
||||
static void CalcDispQuadSetPivot(Pivot pivot,
|
||||
float_t w, float_t h, float_t* v00, float_t* v01, float_t* v10, float_t* v11);
|
||||
float_t w, float_t h, float_t& v00, float_t& v01, float_t& v10, float_t& v11);
|
||||
};
|
||||
|
||||
class F2RenderScene : public RenderScene {
|
||||
@@ -831,6 +839,7 @@ namespace Glitter {
|
||||
virtual bool HasEnded(bool a2) = 0;
|
||||
virtual void Reset(GPM, GLT, float_t emission) = 0;
|
||||
|
||||
bool GetExtAnimScale(vec3* ext_anim_scale, float_t* some_scale);
|
||||
void SetExtColor(bool set, float_t r, float_t g, float_t b, float_t a);
|
||||
|
||||
static int32_t GetExtAnimBoneIndex(GPM, EffectExtAnimCharaNode node);
|
||||
@@ -1009,6 +1018,8 @@ namespace Glitter {
|
||||
|
||||
Emitter(GLT);
|
||||
virtual ~Emitter() override;
|
||||
|
||||
Emitter& operator=(const Emitter& emit);
|
||||
};
|
||||
|
||||
class EmitterInst {
|
||||
@@ -1051,7 +1062,7 @@ namespace Glitter {
|
||||
void Free(GPM, GLT, float_t emission, bool free);
|
||||
void GetValue(GLT);
|
||||
bool HasEnded(bool a2);
|
||||
void InitMesh(GLT, int32_t index, vec3& scale,
|
||||
void InitMesh(GLT, int32_t index, const vec3& scale,
|
||||
vec3& position, vec3& direction, Random* random);
|
||||
void Reset();
|
||||
};
|
||||
@@ -1074,7 +1085,7 @@ namespace Glitter {
|
||||
void Free(float_t emission, bool free);
|
||||
void GetValue();
|
||||
bool HasEnded(bool a2);
|
||||
void InitMesh(int32_t index, vec3& scale,
|
||||
void InitMesh(int32_t index, const vec3& scale,
|
||||
vec3& position, vec3& direction, Random* random);
|
||||
uint8_t RandomGetStep();
|
||||
void RandomStepValue();
|
||||
@@ -1288,6 +1299,7 @@ namespace Glitter {
|
||||
void EmitParticle(GPM, GLT, RenderElement* rend_elem, F2EmitterInst* emit_inst,
|
||||
F2ParticleInst::Data* ptcl_inst_data, int32_t index, Random* random);
|
||||
void GetColor(RenderElement* rend_elem);
|
||||
bool GetExtAnimScale(vec3* ext_anim_scale, float_t* some_scale);
|
||||
void GetExtColor(float_t& r, float_t& g, float_t& b, float_t& a);
|
||||
bool GetValue(GLT, RenderElement* rend_elem, float_t frame, Random* random);
|
||||
void Free(bool free);
|
||||
@@ -1325,6 +1337,7 @@ namespace Glitter {
|
||||
void EmitParticle(RenderElement* rend_elem, XEmitterInst* emit_inst,
|
||||
XParticleInst::Data* ptcl_inst_data, int32_t index, uint8_t step, Random* random);
|
||||
void GetColor(RenderElement* rend_elem, float_t color_scale);
|
||||
bool GetExtAnimScale(vec3* ext_anim_scale, float_t* some_scale);
|
||||
void GetExtColor(float_t& r, float_t& g, float_t& b, float_t& a);
|
||||
bool GetValue(RenderElement* rend_elem, float_t frame, Random* random, float_t* color_scale);
|
||||
void Free(bool free);
|
||||
@@ -1412,6 +1425,8 @@ namespace Glitter {
|
||||
vec3 scale;
|
||||
vec3 rotation;
|
||||
vec3 rotation_add;
|
||||
float_t rot_z_cos;
|
||||
float_t rot_z_sin;
|
||||
float_t scale_all;
|
||||
vec2 uv_scroll;
|
||||
vec2 uv_scroll_2nd;
|
||||
@@ -1595,4 +1610,3 @@ namespace Glitter {
|
||||
extern bool glt_particle_manager_free_task();
|
||||
extern void glt_particle_manager_free();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,4 +13,10 @@ namespace Glitter {
|
||||
ItemBase::~ItemBase() {
|
||||
|
||||
}
|
||||
|
||||
ItemBase& ItemBase::operator=(const ItemBase& item_base) {
|
||||
name.assign(item_base.name);
|
||||
animation = item_base.animation;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,19 @@
|
||||
|
||||
namespace Glitter {
|
||||
Node::Node() : translation(), rotation() {
|
||||
scale = vec3_identity;
|
||||
scale = 1.0f;
|
||||
scale_all = 1.0f;
|
||||
}
|
||||
|
||||
Node::~Node() {
|
||||
|
||||
}
|
||||
|
||||
Node& Node::operator=(const Node& node) {
|
||||
translation = node.translation;
|
||||
rotation = node.rotation;
|
||||
scale = node.scale;
|
||||
scale_all = node.scale_all;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,15 +19,15 @@ namespace Glitter {
|
||||
Particle::Particle(GLT) : data() {
|
||||
version = GLT_VAL == Glitter::X ? 0x05 : 0x03;
|
||||
data.pivot = PIVOT_MIDDLE_CENTER;
|
||||
data.scale = vec3_identity;
|
||||
data.scale = 1.0f;
|
||||
data.reflection_coeff = 1.0f;
|
||||
data.color = vec4_identity;
|
||||
data.color = 1.0f;
|
||||
data.uv_index = 0;
|
||||
data.uv_index_start = 0;
|
||||
data.uv_index_end = 1;
|
||||
data.uv_scroll_add_scale = 1.0f;
|
||||
data.uv_scroll_2nd_add_scale = 1.0f;
|
||||
data.split_uv = vec2_identity;
|
||||
data.split_uv = 1.0f;
|
||||
data.split_u = 1;
|
||||
data.split_v = 1;
|
||||
data.sub_flags = PARTICLE_SUB_USE_CURVE;
|
||||
|
||||
@@ -106,30 +106,24 @@ namespace Glitter {
|
||||
float_t delta_time = delta_frame * (float_t)(1.0 / 60.0);
|
||||
float_t diff_time = time - rend_elem->rebound_time - delta_time;
|
||||
|
||||
vec3 acceleration;
|
||||
vec3_mult_scalar(rend_elem->acceleration, delta_time * (delta_time * 0.5f + diff_time), acceleration);
|
||||
float_t speed = rend_elem->deceleration * delta_time * (delta_time * 0.5f - diff_time) + rend_elem->speed;
|
||||
if (speed >= 0.01f) {
|
||||
vec3 direction;
|
||||
vec3_mult_scalar(rend_elem->direction, speed * delta_time, direction);
|
||||
vec3_add(acceleration, direction, acceleration);
|
||||
}
|
||||
vec3 acceleration = rend_elem->acceleration * (delta_time * (delta_time * 0.5f + diff_time));
|
||||
float_t speed = rend_elem->deceleration * (delta_time * (delta_time * 0.5f - diff_time)) + rend_elem->speed;
|
||||
if (speed >= 0.01f)
|
||||
acceleration += rend_elem->direction * (speed * delta_time);
|
||||
|
||||
vec3_add(rend_elem->translation, acceleration, rend_elem->translation);
|
||||
vec3_add(rend_elem->base_translation, acceleration, rend_elem->base_translation);
|
||||
rend_elem->translation += acceleration;
|
||||
rend_elem->base_translation += acceleration;
|
||||
|
||||
if (data.data.flags & PARTICLE_REBOUND_PLANE
|
||||
&& rend_elem->translation_prev.y > data.data.rebound_plane_y
|
||||
&& rend_elem->translation.y <= data.data.rebound_plane_y) {
|
||||
float_t reflection_coeff = random->F2GetFloat(GLT_VAL,
|
||||
data.data.reflection_coeff_random) + data.data.reflection_coeff;
|
||||
float_t reflection_coeff = (random->F2GetFloat(GLT_VAL,
|
||||
data.data.reflection_coeff_random) + data.data.reflection_coeff) * 60.0f;
|
||||
rend_elem->rebound_time = time;
|
||||
|
||||
vec3 direction;
|
||||
vec3_sub(rend_elem->translation, rend_elem->translation_prev, direction);
|
||||
vec3_mult_scalar(direction, reflection_coeff * 60.0f, direction);
|
||||
vec3 direction = rend_elem->translation - rend_elem->translation_prev;
|
||||
const vec3 reverse_y_dir = { 0.0f, -0.0f, 0.0f };
|
||||
vec3_xor(direction, reverse_y_dir, rend_elem->direction);
|
||||
rend_elem->direction = (direction * reflection_coeff) ^ reverse_y_dir;
|
||||
|
||||
rend_elem->translation.y = rend_elem->translation_prev.y;
|
||||
}
|
||||
@@ -184,7 +178,7 @@ namespace Glitter {
|
||||
rend_elem->random = random->F2GetInt(GLT_VAL, Random::F2GetMax(GLT_VAL));
|
||||
rend_elem->frame = 0.0f;
|
||||
rend_elem->rebound_time = 0.0f;
|
||||
rend_elem->uv = vec2_null;
|
||||
rend_elem->uv = 0.0f;
|
||||
rend_elem->uv_index = ptcl_inst_data->data.uv_index;
|
||||
|
||||
rend_elem->fade_in_frames = 0.0f;
|
||||
@@ -208,13 +202,15 @@ namespace Glitter {
|
||||
rend_elem->rotation_add.x = 0.0f;
|
||||
rend_elem->rotation_add.y = 0.0f;
|
||||
}
|
||||
rend_elem->rot_z_cos = 1.0f;
|
||||
rend_elem->rot_z_sin = 0.0f;
|
||||
rend_elem->rotation.z = random->F2GetFloat(GLT_VAL, ptcl_inst_data->data.rotation_random.z)
|
||||
+ ptcl_inst_data->data.rotation.z;
|
||||
rend_elem->rotation_add.z = random->F2GetFloat(GLT_VAL,
|
||||
ptcl_inst_data->data.rotation_add_random.z) + ptcl_inst_data->data.rotation_add.z;
|
||||
rend_elem->uv_scroll = vec2_null;
|
||||
rend_elem->uv_scroll_2nd = vec2_null;
|
||||
rend_elem->scale = vec3_identity;
|
||||
rend_elem->uv_scroll = 0.0f;
|
||||
rend_elem->uv_scroll_2nd = 0.0f;
|
||||
rend_elem->scale = 1.0f;
|
||||
rend_elem->scale_all = 1.0f;
|
||||
rend_elem->frame_step_uv = (float_t)ptcl_inst_data->data.frame_step_uv;
|
||||
|
||||
@@ -250,20 +246,14 @@ namespace Glitter {
|
||||
|| ptcl_inst_data->data.draw_type == DIRECTION_EMITTER_ROTATION) {
|
||||
switch (emit_inst->data.type) {
|
||||
case EMITTER_CYLINDER:
|
||||
if (emit_inst->data.cylinder.direction != EMITTER_EMISSION_DIRECTION_NONE) {
|
||||
float_t length;
|
||||
vec3_length(rend_elem->direction, length);
|
||||
copy_mat = length <= 0.000001f;
|
||||
}
|
||||
if (emit_inst->data.cylinder.direction != EMITTER_EMISSION_DIRECTION_NONE)
|
||||
copy_mat = vec3::length(rend_elem->direction) <= 0.000001f;
|
||||
else
|
||||
copy_mat = true;
|
||||
break;
|
||||
case EMITTER_SPHERE:
|
||||
if (emit_inst->data.sphere.direction != EMITTER_EMISSION_DIRECTION_NONE) {
|
||||
float_t length;
|
||||
vec3_length(rend_elem->direction, length);
|
||||
copy_mat = length <= 0.000001f;
|
||||
}
|
||||
if (emit_inst->data.sphere.direction != EMITTER_EMISSION_DIRECTION_NONE)
|
||||
copy_mat = vec3::length(rend_elem->direction) <= 0.000001f;
|
||||
else
|
||||
copy_mat = true;
|
||||
break;
|
||||
@@ -322,6 +312,15 @@ namespace Glitter {
|
||||
rend_elem->disp = false;
|
||||
}
|
||||
|
||||
bool F2ParticleInst::GetExtAnimScale(vec3* ext_anim_scale, float_t* some_scale) {
|
||||
if (data.effect)
|
||||
return data.effect->GetExtAnimScale(ext_anim_scale, some_scale);
|
||||
else if (data.parent && data.parent->data.effect)
|
||||
return data.parent->data.effect->GetExtAnimScale(ext_anim_scale, some_scale);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void F2ParticleInst::GetExtColor(float_t& r, float_t& g, float_t& b, float_t& a) {
|
||||
if (data.effect)
|
||||
data.effect->GetExtColor(r, g, b, a);
|
||||
@@ -332,7 +331,7 @@ namespace Glitter {
|
||||
bool F2ParticleInst::GetValue(GLT, RenderElement* rend_elem, float_t frame, Random* random) {
|
||||
float_t value = 0.0f;
|
||||
bool has_translation = false;
|
||||
vec3 translation = vec3_null;
|
||||
vec3 translation = 0.0f;
|
||||
|
||||
Animation* anim = &particle->animation;
|
||||
size_t length = anim->curves.size();
|
||||
@@ -402,7 +401,7 @@ namespace Glitter {
|
||||
}
|
||||
|
||||
if (data.data.flags & PARTICLE_ROTATE_BY_EMITTER || has_translation) {
|
||||
vec3_add(translation, rend_elem->base_translation, translation);
|
||||
translation += rend_elem->base_translation;
|
||||
if (data.data.flags & PARTICLE_ROTATE_BY_EMITTER)
|
||||
mat4_mult_vec3_trans(&rend_elem->mat, &translation, &translation);
|
||||
rend_elem->translation = translation;
|
||||
@@ -561,32 +560,25 @@ namespace Glitter {
|
||||
float_t speed = rend_elem->speed * delta_frame;
|
||||
diff_time = max_def(diff_time, 0.0f) * (float_t)(1.0 / 60.0);
|
||||
|
||||
vec3 acceleration;
|
||||
vec3_mult_scalar(rend_elem->acceleration,
|
||||
(diff_time + (float_t)(1.0 / 7200.0)) * delta_frame, acceleration);
|
||||
if (speed > 0.0f) {
|
||||
vec3 direction;
|
||||
vec3_mult_scalar(rend_elem->direction, speed, direction);
|
||||
vec3_add(acceleration, direction, acceleration);
|
||||
}
|
||||
vec3 acceleration = rend_elem->acceleration * ((diff_time + (float_t)(1.0 / 7200.0)) * delta_frame);
|
||||
if (speed > 0.0f)
|
||||
acceleration += rend_elem->direction * speed;
|
||||
|
||||
vec3_add(rend_elem->translation, acceleration, rend_elem->translation);
|
||||
vec3_add(rend_elem->base_translation, acceleration, rend_elem->base_translation);
|
||||
rend_elem->translation += acceleration;
|
||||
rend_elem->base_translation += acceleration;
|
||||
|
||||
if (data.data.flags & PARTICLE_REBOUND_PLANE
|
||||
&& rend_elem->translation_prev.y > data.data.rebound_plane_y
|
||||
&& rend_elem->translation.y <= data.data.rebound_plane_y) {
|
||||
float_t reflection_coeff = random->XGetFloat(
|
||||
data.data.reflection_coeff_random) + data.data.reflection_coeff;
|
||||
float_t reflection_coeff = (random->XGetFloat(
|
||||
data.data.reflection_coeff_random) + data.data.reflection_coeff) / rend_elem->speed;
|
||||
rend_elem->rebound_time = time;
|
||||
|
||||
vec3 direction;
|
||||
vec3_sub(rend_elem->translation, rend_elem->translation_prev, direction);
|
||||
vec3 direction = rend_elem->translation - rend_elem->translation_prev;
|
||||
if (delta_frame > 0.0f)
|
||||
vec3_div_scalar(direction, delta_frame, direction);
|
||||
vec3_mult_scalar(direction, reflection_coeff / rend_elem->speed, direction);
|
||||
direction /= delta_frame;
|
||||
const vec3 reverse_y_dir = { 0.0f, -0.0f, 0.0f };
|
||||
vec3_xor(direction, reverse_y_dir, rend_elem->direction);
|
||||
rend_elem->direction = (direction * reflection_coeff) ^ reverse_y_dir;
|
||||
|
||||
rend_elem->translation.y = rend_elem->translation_prev.y;
|
||||
}
|
||||
@@ -642,7 +634,7 @@ namespace Glitter {
|
||||
rend_elem->random = random->GetValue();
|
||||
rend_elem->frame = 0.0f;
|
||||
rend_elem->rebound_time = 0.0f;
|
||||
rend_elem->uv = vec2_null;
|
||||
rend_elem->uv = 0.0f;
|
||||
rend_elem->uv_index = ptcl_inst_data->data.uv_index;
|
||||
|
||||
rend_elem->step = step;
|
||||
@@ -681,13 +673,15 @@ namespace Glitter {
|
||||
rend_elem->rotation_add.x = 0.0f;
|
||||
rend_elem->rotation_add.y = 0.0f;
|
||||
}
|
||||
rend_elem->rot_z_cos = 1.0f;
|
||||
rend_elem->rot_z_sin = 0.0f;
|
||||
rend_elem->rotation.z = random->XGetFloat(ptcl_inst_data->data.rotation_random.z)
|
||||
+ ptcl_inst_data->data.rotation.z;
|
||||
rend_elem->rotation_add.z = random->XGetFloat(ptcl_inst_data->data.rotation_add_random.z)
|
||||
+ ptcl_inst_data->data.rotation_add.z;
|
||||
rend_elem->uv_scroll = vec2_null;
|
||||
rend_elem->uv_scroll_2nd = vec2_null;
|
||||
rend_elem->scale = vec3_identity;
|
||||
rend_elem->uv_scroll = 0.0f;
|
||||
rend_elem->uv_scroll_2nd = 0.0f;
|
||||
rend_elem->scale = 1.0f;
|
||||
rend_elem->scale_all = 1.0f;
|
||||
rend_elem->frame_step_uv = (float_t)ptcl_inst_data->data.frame_step_uv;
|
||||
|
||||
@@ -725,20 +719,14 @@ namespace Glitter {
|
||||
|| ptcl_inst_data->data.draw_type == DIRECTION_EMITTER_ROTATION) {
|
||||
switch (emit_inst->data.type) {
|
||||
case EMITTER_CYLINDER:
|
||||
if (emit_inst->data.cylinder.direction != EMITTER_EMISSION_DIRECTION_NONE) {
|
||||
float_t length;
|
||||
vec3_length(rend_elem->direction, length);
|
||||
copy_mat = length <= 0.000001f;
|
||||
}
|
||||
if (emit_inst->data.cylinder.direction != EMITTER_EMISSION_DIRECTION_NONE)
|
||||
copy_mat = vec3::length(rend_elem->direction) <= 0.000001f;
|
||||
else
|
||||
copy_mat = true;
|
||||
break;
|
||||
case EMITTER_SPHERE:
|
||||
if (emit_inst->data.sphere.direction != EMITTER_EMISSION_DIRECTION_NONE) {
|
||||
float_t length;
|
||||
vec3_length(rend_elem->direction, length);
|
||||
copy_mat = length <= 0.000001f;
|
||||
}
|
||||
if (emit_inst->data.sphere.direction != EMITTER_EMISSION_DIRECTION_NONE)
|
||||
copy_mat = vec3::length(rend_elem->direction) <= 0.000001f;
|
||||
else
|
||||
copy_mat = true;
|
||||
break;
|
||||
@@ -806,6 +794,15 @@ namespace Glitter {
|
||||
rend_elem->disp = false;
|
||||
}
|
||||
|
||||
bool XParticleInst::GetExtAnimScale(vec3* ext_anim_scale, float_t* some_scale) {
|
||||
if (data.effect)
|
||||
return data.effect->GetExtAnimScale(ext_anim_scale, some_scale);
|
||||
else if (data.parent && data.parent->data.effect)
|
||||
return data.parent->data.effect->GetExtAnimScale(ext_anim_scale, some_scale);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void XParticleInst::GetExtColor(float_t& r, float_t& g, float_t& b, float_t& a) {
|
||||
if (data.effect)
|
||||
data.effect->GetExtColor(r, g, b, a);
|
||||
@@ -815,7 +812,7 @@ namespace Glitter {
|
||||
|
||||
bool XParticleInst::GetValue(RenderElement* rend_elem, float_t frame, Random* random, float_t* color_scale) {
|
||||
float_t value = 0.0f;
|
||||
vec3 translation = vec3_null;
|
||||
vec3 translation = 0.0f;
|
||||
bool has_translation = false;
|
||||
|
||||
Animation* anim = &particle->animation;
|
||||
@@ -910,7 +907,7 @@ namespace Glitter {
|
||||
}
|
||||
|
||||
if (data.data.flags & PARTICLE_ROTATE_BY_EMITTER || has_translation) {
|
||||
vec3_add(translation, rend_elem->base_translation, translation);
|
||||
translation += rend_elem->base_translation;
|
||||
if (data.data.flags & PARTICLE_ROTATE_BY_EMITTER)
|
||||
mat4_mult_vec3_trans(&rend_elem->mat, &translation, &translation);
|
||||
rend_elem->translation = translation;
|
||||
|
||||
+16
-24
@@ -1298,26 +1298,22 @@ namespace Glitter {
|
||||
return val % (max - min) + min;
|
||||
}
|
||||
|
||||
void Random::F2GetVec3(GLT, vec3& src, vec3& dst) {
|
||||
vec3 Random::F2GetVec3(GLT, const vec3& value) {
|
||||
vec3 val;
|
||||
switch (GLT_VAL) {
|
||||
default:
|
||||
case Glitter::FT:
|
||||
val.x = *(float_t*)&full_float_table[value++ % 0x1000];
|
||||
val.y = *(float_t*)&full_float_table[value++ % 0x1000];
|
||||
val.z = *(float_t*)&full_float_table[value++ % 0x1000];
|
||||
val.x = *(float_t*)&full_float_table[this->value++ % 0x1000];
|
||||
val.y = *(float_t*)&full_float_table[this->value++ % 0x1000];
|
||||
val.z = *(float_t*)&full_float_table[this->value++ % 0x1000];
|
||||
break;
|
||||
case Glitter::F2:
|
||||
val.x = *(float_t*)&short_float_table[value++ % 0x100];
|
||||
val.y = *(float_t*)&short_float_table[value++ % 0x100];
|
||||
val.z = *(float_t*)&short_float_table[value++ % 0x100];
|
||||
val.x = *(float_t*)&short_float_table[this->value++ % 0x100];
|
||||
val.y = *(float_t*)&short_float_table[this->value++ % 0x100];
|
||||
val.z = *(float_t*)&short_float_table[this->value++ % 0x100];
|
||||
break;
|
||||
}
|
||||
|
||||
vec3 t;
|
||||
vec3_add(src, src, t);
|
||||
vec3_mult(val, t, val);
|
||||
vec3_sub(val, src, dst);
|
||||
return val * (value + value) - value;
|
||||
}
|
||||
|
||||
void Random::F2StepValue() {
|
||||
@@ -1358,19 +1354,15 @@ namespace Glitter {
|
||||
return val % (max - min) + min;
|
||||
}
|
||||
|
||||
void Random::XGetVec3(vec3& src, vec3& dst) {
|
||||
vec3 Random::XGetVec3(const vec3& value) {
|
||||
vec3 val;
|
||||
val.x = *(float_t*)&x_float_table[value % 0x169];
|
||||
value += step;
|
||||
val.y = *(float_t*)&x_float_table[value % 0x169];
|
||||
value += step;
|
||||
val.z = *(float_t*)&x_float_table[value % 0x169];
|
||||
value += step;
|
||||
|
||||
vec3 t;
|
||||
vec3_add(src, src, t);
|
||||
vec3_mult(val, t, val);
|
||||
vec3_sub(val, src, dst);
|
||||
val.x = *(float_t*)&x_float_table[this->value % 0x169];
|
||||
this->value += step;
|
||||
val.y = *(float_t*)&x_float_table[this->value % 0x169];
|
||||
this->value += step;
|
||||
val.z = *(float_t*)&x_float_table[this->value % 0x169];
|
||||
this->value += step;
|
||||
return val * (value + value) - value;
|
||||
}
|
||||
|
||||
void Random::XReset() {
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include "glitter.hpp"
|
||||
|
||||
namespace Glitter {
|
||||
RenderElement::RenderElement() : alive(), uv_index(), disp(), frame(), life_time(),
|
||||
rebound_time(), frame_step_uv(), base_speed(), speed(), deceleration(),
|
||||
RenderElement::RenderElement() : alive(), uv_index(), disp(), frame(), life_time(), rebound_time(),
|
||||
frame_step_uv(), base_speed(), speed(), deceleration(), rot_z_cos(), rot_z_sin(),
|
||||
scale_all(), fade_out_frames(), fade_in_frames(), locus_history(), random(), step() {
|
||||
|
||||
}
|
||||
@@ -39,31 +39,29 @@ namespace Glitter {
|
||||
void RenderElement::InitMesh(GLT, F2EmitterInst* emit_inst,
|
||||
F2ParticleInst::Data* ptcl_inst_data, int32_t index, Random* random) {
|
||||
if (ptcl_inst_data->data.flags & (PARTICLE_EMITTER_LOCAL | PARTICLE_ROTATE_BY_EMITTER))
|
||||
base_translation = vec3_null;
|
||||
base_translation = 0.0f;
|
||||
else
|
||||
mat4_get_translation(&emit_inst->mat, &base_translation);
|
||||
|
||||
vec3 direction = ptcl_inst_data->data.direction;
|
||||
vec3 scale;
|
||||
if (ptcl_inst_data->data.flags & PARTICLE_EMITTER_LOCAL)
|
||||
scale = vec3_identity;
|
||||
scale = 1.0f;
|
||||
else
|
||||
vec3_mult_scalar(emit_inst->scale, emit_inst->scale_all, scale);
|
||||
scale = emit_inst->scale * emit_inst->scale_all;
|
||||
|
||||
vec3 position = vec3_null;
|
||||
vec3 position = 0.0f;
|
||||
emit_inst->InitMesh(GLT_VAL, index, scale, position, direction, random);
|
||||
|
||||
if (~ptcl_inst_data->data.flags & PARTICLE_EMITTER_LOCAL)
|
||||
mat4_mult_vec3(&emit_inst->mat_rot, &position, &position);
|
||||
|
||||
vec3_add(base_translation, position, base_translation);
|
||||
base_translation += position;
|
||||
translation = base_translation;
|
||||
translation_prev = base_translation;
|
||||
|
||||
vec3 direction_random;
|
||||
random->F2GetVec3(GLT_VAL, ptcl_inst_data->data.direction_random, direction_random);
|
||||
vec3_add(direction, direction_random, direction);
|
||||
vec3_normalize(direction, direction);
|
||||
direction = vec3::normalize(direction
|
||||
+ random->F2GetVec3(GLT_VAL, ptcl_inst_data->data.direction_random));
|
||||
|
||||
if (~ptcl_inst_data->data.flags & PARTICLE_EMITTER_LOCAL)
|
||||
mat4_mult_vec3(&emit_inst->mat_rot, &direction, &direction);
|
||||
@@ -77,40 +75,36 @@ namespace Glitter {
|
||||
this->speed = speed * 60.0f;
|
||||
this->deceleration = max_def(deceleration * 60.0f, 0.0f);
|
||||
|
||||
vec3 acceleration;
|
||||
random->F2GetVec3(GLT_VAL, ptcl_inst_data->data.acceleration_random, acceleration);
|
||||
vec3_add(acceleration, ptcl_inst_data->data.acceleration, acceleration);
|
||||
vec3_add(acceleration, ptcl_inst_data->data.gravity, this->acceleration);
|
||||
this->acceleration = ptcl_inst_data->data.acceleration + ptcl_inst_data->data.gravity
|
||||
+ random->F2GetVec3(GLT_VAL, ptcl_inst_data->data.acceleration_random);
|
||||
}
|
||||
|
||||
void RenderElement::InitMesh(XEmitterInst* emit_inst,
|
||||
XParticleInst::Data* ptcl_inst_data, int32_t index, Random* random) {
|
||||
if (ptcl_inst_data->data.flags & (PARTICLE_EMITTER_LOCAL | PARTICLE_ROTATE_BY_EMITTER))
|
||||
base_translation = vec3_null;
|
||||
base_translation = 0.0f;
|
||||
else
|
||||
mat4_get_translation(&emit_inst->mat, &base_translation);
|
||||
|
||||
vec3 direction = ptcl_inst_data->data.direction;
|
||||
vec3 scale;
|
||||
if (ptcl_inst_data->data.flags & PARTICLE_EMITTER_LOCAL)
|
||||
scale = vec3_identity;
|
||||
scale = 1.0f;
|
||||
else
|
||||
vec3_mult_scalar(emit_inst->scale, emit_inst->scale_all, scale);
|
||||
scale = emit_inst->scale * emit_inst->scale_all;
|
||||
|
||||
vec3 position = vec3_null;
|
||||
vec3 position = 0.0f;
|
||||
emit_inst->InitMesh(index, scale, position, direction, random);
|
||||
|
||||
if (~ptcl_inst_data->data.flags & PARTICLE_EMITTER_LOCAL)
|
||||
mat4_mult_vec3(&emit_inst->mat_rot, &position, &position);
|
||||
|
||||
vec3_add(base_translation, position, base_translation);
|
||||
base_translation += position;
|
||||
translation = base_translation;
|
||||
translation_prev = base_translation;
|
||||
|
||||
vec3 direction_random;
|
||||
random->XGetVec3(ptcl_inst_data->data.direction_random, direction_random);
|
||||
vec3_add(direction, direction_random, direction);
|
||||
vec3_normalize(direction, direction);
|
||||
direction = vec3::normalize(direction
|
||||
+ random->XGetVec3(ptcl_inst_data->data.direction_random));
|
||||
|
||||
if (~ptcl_inst_data->data.flags & PARTICLE_EMITTER_LOCAL)
|
||||
mat4_mult_vec3(&emit_inst->mat_rot, &direction, &direction);
|
||||
@@ -125,9 +119,7 @@ namespace Glitter {
|
||||
this->speed = speed;
|
||||
this->deceleration = max_def(deceleration, 0.0f);
|
||||
|
||||
vec3 acceleration;
|
||||
random->XGetVec3(ptcl_inst_data->data.acceleration_random, acceleration);
|
||||
vec3_add(acceleration, ptcl_inst_data->data.acceleration, acceleration);
|
||||
vec3_add(acceleration, ptcl_inst_data->data.gravity, this->acceleration);
|
||||
this->acceleration = ptcl_inst_data->data.acceleration + ptcl_inst_data->data.gravity
|
||||
+ random->XGetVec3(ptcl_inst_data->data.acceleration_random);
|
||||
}
|
||||
}
|
||||
|
||||
+128
-139
@@ -12,7 +12,7 @@ namespace Glitter {
|
||||
elements(), max_count(), random_ptr(), disp_type(), fog_type(), vao(), vbo(), ebo() {
|
||||
split_u = 1;
|
||||
split_v = 1;
|
||||
split_uv = vec2_identity;
|
||||
split_uv = 1.0f;
|
||||
mat = mat4_identity;
|
||||
mat_rot = mat4_identity;
|
||||
mat_draw = mat4_identity;
|
||||
@@ -80,38 +80,49 @@ namespace Glitter {
|
||||
bool is_quad = a1->data.data.type == PARTICLE_QUAD;
|
||||
|
||||
glGenVertexArrays(1, &vao);
|
||||
gl_state_bind_vertex_array(vao);
|
||||
gl_state_bind_vertex_array(vao, true);
|
||||
|
||||
glGenBuffers(1, &vbo);
|
||||
gl_state_bind_array_buffer(vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(sizeof(Buffer) * max_count), 0, GL_DYNAMIC_DRAW);
|
||||
gl_state_bind_array_buffer(vbo, true);
|
||||
|
||||
static const GLsizei buffer_size = sizeof(Buffer);
|
||||
|
||||
if (GLAD_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ARRAY_BUFFER,
|
||||
(GLsizeiptr)(buffer_size * max_count), 0, GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT);
|
||||
else
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
(GLsizeiptr)(buffer_size * max_count), 0, GL_DYNAMIC_DRAW);
|
||||
|
||||
if (is_quad) {
|
||||
size_t count = max_count / 4 * 6;
|
||||
int32_t* ebo_data = force_malloc_s(int32_t, count);
|
||||
for (size_t i = 0, j = 0; i < count; i += 6, j += 4) {
|
||||
ebo_data[i] = (int32_t)j;
|
||||
ebo_data[i + 1] = (int32_t)(j + 1);
|
||||
ebo_data[i + 2] = (int32_t)(j + 2);
|
||||
ebo_data[i + 3] = (int32_t)(j + 0);
|
||||
ebo_data[i + 4] = (int32_t)(j + 2);
|
||||
ebo_data[i + 5] = (int32_t)(j + 3);
|
||||
size_t count = max_count / 4 * 5;
|
||||
uint32_t* ebo_data = force_malloc_s(uint32_t, count - 1);
|
||||
for (size_t i = 0, j = 0, k = count / 5 - 1; i < count; i += 5, j += 4, k--) {
|
||||
ebo_data[i + 0] = (uint32_t)(j + 0);
|
||||
ebo_data[i + 1] = (uint32_t)(j + 1);
|
||||
ebo_data[i + 2] = (uint32_t)(j + 3);
|
||||
ebo_data[i + 3] = (uint32_t)(j + 2);
|
||||
if (k)
|
||||
ebo_data[i + 4] = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
glGenBuffers(1, &ebo);
|
||||
gl_state_bind_element_array_buffer(ebo);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(int32_t) * count, ebo_data, GL_STATIC_DRAW);
|
||||
gl_state_bind_element_array_buffer(ebo, true);
|
||||
if (GLAD_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ELEMENT_ARRAY_BUFFER,
|
||||
(GLsizeiptr)(sizeof(uint32_t) * (count - 1)), ebo_data, 0);
|
||||
else
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
|
||||
(GLsizeiptr)(sizeof(uint32_t) * (count - 1)), ebo_data, GL_STATIC_DRAW);
|
||||
free_def(ebo_data);
|
||||
}
|
||||
|
||||
static const GLsizei buffer_size = sizeof(Buffer);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, position)); // Pos
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, color)); // Color
|
||||
(void*)offsetof(Buffer, color)); // Color0
|
||||
glEnableVertexAttribArray(8);
|
||||
glVertexAttribPointer(8, 2, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, uv)); // TexCoord0
|
||||
@@ -230,6 +241,16 @@ namespace Glitter {
|
||||
if (particle->data.data.sub_flags & PARTICLE_SUB_USE_CURVE)
|
||||
disp = particle->GetValue(GLT_VAL, rend_elem, rend_elem->frame, random_ptr);
|
||||
|
||||
if (particle->data.data.draw_type == DIRECTION_PARTICLE_ROTATION
|
||||
|| fabsf(rend_elem->rotation.z) <= 0.000001f) {
|
||||
rend_elem->rot_z_cos = 1.0f;
|
||||
rend_elem->rot_z_sin = 0.0f;
|
||||
}
|
||||
else {
|
||||
rend_elem->rot_z_cos = cosf(rend_elem->rotation.z);
|
||||
rend_elem->rot_z_sin = sinf(rend_elem->rotation.z);
|
||||
}
|
||||
|
||||
if (disp)
|
||||
particle->GetColor(rend_elem);
|
||||
|
||||
@@ -306,29 +327,9 @@ namespace Glitter {
|
||||
}
|
||||
|
||||
bool F2RenderGroup::GetExtAnimScale(vec3* ext_anim_scale, float_t* some_scale) {
|
||||
if (!particle)
|
||||
return false;
|
||||
|
||||
F2EffectInst* effect_inst;
|
||||
if (particle->data.effect)
|
||||
effect_inst = particle->data.effect;
|
||||
else {
|
||||
if (!particle->data.parent)
|
||||
return false;
|
||||
|
||||
effect_inst = particle->data.parent->data.effect;
|
||||
if (!effect_inst)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (~effect_inst->flags & EFFECT_INST_HAS_EXT_ANIM_SCALE)
|
||||
return false;
|
||||
|
||||
if (ext_anim_scale)
|
||||
*ext_anim_scale = effect_inst->ext_anim_scale;
|
||||
if (some_scale)
|
||||
*some_scale = effect_inst->some_scale;
|
||||
return true;
|
||||
if (particle)
|
||||
particle->GetExtAnimScale(ext_anim_scale, some_scale);
|
||||
return false;
|
||||
}
|
||||
|
||||
mat4 F2RenderGroup::RotateToEmitPosition(F2RenderGroup* rend_group,
|
||||
@@ -338,9 +339,9 @@ namespace Glitter {
|
||||
vec2 = rend_elem->translation;
|
||||
else {
|
||||
mat4_get_translation(&rend_group->mat, &vec2);
|
||||
vec3_sub(vec2, rend_elem->translation, vec2);
|
||||
vec2 -= rend_elem->translation;
|
||||
}
|
||||
vec3_normalize(vec2, vec2);
|
||||
vec2 = vec3::normalize(vec2);
|
||||
|
||||
mat4 mat;
|
||||
if (fabsf(vec2.y) >= 0.000001f) {
|
||||
@@ -359,14 +360,12 @@ namespace Glitter {
|
||||
|
||||
mat4 F2RenderGroup::RotateToPrevPosition(F2RenderGroup* rend_group,
|
||||
RenderElement* rend_elem, vec3* vec) {
|
||||
vec3 vec2;
|
||||
vec3_sub(rend_elem->translation, rend_elem->translation_prev, vec2);
|
||||
vec3 vec2 = rend_elem->translation - rend_elem->translation_prev;
|
||||
|
||||
float_t length;
|
||||
vec3_length_squared(vec2, length);
|
||||
if (length < 0.000001f)
|
||||
vec2 = rend_elem->translation;
|
||||
vec3_normalize(vec2, vec2);
|
||||
if (vec3::length_squared(vec2) < 0.000001f)
|
||||
vec2 = vec3::normalize(rend_elem->translation);
|
||||
else
|
||||
vec2 = vec3::normalize(vec2);
|
||||
|
||||
mat4 mat;
|
||||
mat4_rotate_z((float_t)M_PI, &mat);
|
||||
@@ -421,60 +420,66 @@ namespace Glitter {
|
||||
}
|
||||
|
||||
memset(elements, 0, sizeof(RenderElement) * count);
|
||||
if (!max_count)
|
||||
if (!max_count || a1->data.data.type == PARTICLE_MESH)
|
||||
return;
|
||||
|
||||
bool is_quad = a1->data.data.type == PARTICLE_QUAD;
|
||||
bool is_mesh = a1->data.data.type == PARTICLE_MESH;
|
||||
|
||||
if (!is_mesh) {
|
||||
glGenVertexArrays(1, &vao);
|
||||
gl_state_bind_vertex_array(vao);
|
||||
glGenVertexArrays(1, &vao);
|
||||
gl_state_bind_vertex_array(vao, true);
|
||||
|
||||
glGenBuffers(1, &vbo);
|
||||
gl_state_bind_array_buffer(vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(sizeof(Buffer) * max_count), 0, GL_DYNAMIC_DRAW);
|
||||
}
|
||||
glGenBuffers(1, &vbo);
|
||||
gl_state_bind_array_buffer(vbo, true);
|
||||
|
||||
static const GLsizei buffer_size = sizeof(Buffer);
|
||||
|
||||
if (GLAD_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ARRAY_BUFFER,
|
||||
(GLsizeiptr)(buffer_size * max_count), 0, GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT);
|
||||
else
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
(GLsizeiptr)(buffer_size * max_count), 0, GL_DYNAMIC_DRAW);
|
||||
|
||||
if (is_quad) {
|
||||
size_t count = max_count / 4 * 6;
|
||||
int32_t* ebo_data = force_malloc_s(int32_t, count);
|
||||
for (size_t i = 0, j = 0; i < count; i += 6, j += 4) {
|
||||
ebo_data[i] = (int32_t)j;
|
||||
ebo_data[i + 1] = (int32_t)(j + 1);
|
||||
ebo_data[i + 2] = (int32_t)(j + 2);
|
||||
ebo_data[i + 3] = (int32_t)(j + 0);
|
||||
ebo_data[i + 4] = (int32_t)(j + 2);
|
||||
ebo_data[i + 5] = (int32_t)(j + 3);
|
||||
size_t count = max_count / 4 * 5;
|
||||
uint32_t* ebo_data = force_malloc_s(uint32_t, count - 1);
|
||||
for (size_t i = 0, j = 0, k = count / 5 - 1; i < count; i += 5, j += 4, k--) {
|
||||
ebo_data[i + 0] = (uint32_t)(j + 0);
|
||||
ebo_data[i + 1] = (uint32_t)(j + 1);
|
||||
ebo_data[i + 2] = (uint32_t)(j + 3);
|
||||
ebo_data[i + 3] = (uint32_t)(j + 2);
|
||||
if (k)
|
||||
ebo_data[i + 4] = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
glGenBuffers(1, &ebo);
|
||||
gl_state_bind_element_array_buffer(ebo);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(int32_t) * count, ebo_data, GL_STATIC_DRAW);
|
||||
gl_state_bind_element_array_buffer(ebo, true);
|
||||
if (GLAD_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ELEMENT_ARRAY_BUFFER,
|
||||
(GLsizeiptr)(sizeof(uint32_t) * (count - 1)), ebo_data, 0);
|
||||
else
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
|
||||
(GLsizeiptr)(sizeof(uint32_t) * (count - 1)), ebo_data, GL_STATIC_DRAW);
|
||||
free_def(ebo_data);
|
||||
}
|
||||
|
||||
if (!is_mesh) {
|
||||
static const GLsizei buffer_size = sizeof(Buffer);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, position)); // Pos
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, color)); // Color0
|
||||
glEnableVertexAttribArray(8);
|
||||
glVertexAttribPointer(8, 2, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, uv)); // TexCoord0
|
||||
glEnableVertexAttribArray(9);
|
||||
glVertexAttribPointer(9, 2, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, uv)); // TexCoord1
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, position)); // Pos
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, color)); // Color
|
||||
glEnableVertexAttribArray(8);
|
||||
glVertexAttribPointer(8, 2, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, uv)); // TexCoord0
|
||||
glEnableVertexAttribArray(9);
|
||||
glVertexAttribPointer(9, 2, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, uv)); // TexCoord1
|
||||
|
||||
gl_state_bind_array_buffer(0);
|
||||
gl_state_bind_vertex_array(0);
|
||||
if (is_quad)
|
||||
gl_state_bind_element_array_buffer(0);
|
||||
}
|
||||
gl_state_bind_array_buffer(0);
|
||||
gl_state_bind_vertex_array(0);
|
||||
if (is_quad)
|
||||
gl_state_bind_element_array_buffer(0);
|
||||
|
||||
if (!is_quad)
|
||||
draw_list.reserve(count);
|
||||
@@ -603,6 +608,16 @@ namespace Glitter {
|
||||
if (particle->data.data.sub_flags & PARTICLE_SUB_USE_CURVE)
|
||||
disp = particle->GetValue(rend_elem, rend_elem->frame, random_ptr, &color_scale);
|
||||
|
||||
if (particle->data.data.draw_type == DIRECTION_PARTICLE_ROTATION
|
||||
|| fabsf(rend_elem->rotation.z) <= 0.000001f) {
|
||||
rend_elem->rot_z_cos = 1.0f;
|
||||
rend_elem->rot_z_sin = 0.0f;
|
||||
}
|
||||
else {
|
||||
rend_elem->rot_z_cos = cosf(rend_elem->rotation.z);
|
||||
rend_elem->rot_z_sin = sinf(rend_elem->rotation.z);
|
||||
}
|
||||
|
||||
if (disp)
|
||||
particle->GetColor(rend_elem, color_scale);
|
||||
|
||||
@@ -686,39 +701,19 @@ namespace Glitter {
|
||||
if (particle) {
|
||||
Glitter::EmitterInst* emit_inst = particle->data.emitter;
|
||||
if (emit_inst) {
|
||||
vec3_mult_scalar(emit_inst->scale, emit_inst->scale_all, emitter_scale);
|
||||
emitter_scale = emit_inst->scale * emit_inst->scale_all;
|
||||
return emitter_scale.x > 0.000001f || emitter_scale.y > 0.000001f || emitter_scale.z > 0.000001f;
|
||||
}
|
||||
}
|
||||
|
||||
emitter_scale = vec3_identity;
|
||||
emitter_scale = 1.0f;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool XRenderGroup::GetExtAnimScale(vec3* ext_anim_scale, float_t* some_scale) {
|
||||
if (!particle)
|
||||
return false;
|
||||
|
||||
XEffectInst* effect_inst;
|
||||
if (particle->data.effect)
|
||||
effect_inst = particle->data.effect;
|
||||
else {
|
||||
if (!particle->data.parent)
|
||||
return false;
|
||||
|
||||
effect_inst = particle->data.parent->data.effect;
|
||||
if (!effect_inst)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (~effect_inst->flags & EFFECT_INST_HAS_EXT_ANIM_SCALE)
|
||||
return false;
|
||||
|
||||
if (ext_anim_scale)
|
||||
*ext_anim_scale = effect_inst->ext_anim_scale;
|
||||
if (some_scale)
|
||||
*some_scale = effect_inst->some_scale;
|
||||
return true;
|
||||
if (particle)
|
||||
particle->GetExtAnimScale(ext_anim_scale, some_scale);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool XRenderGroup::HasEnded() {
|
||||
@@ -731,13 +726,12 @@ namespace Glitter {
|
||||
RenderElement* rend_elem, vec3* vec, vec3* trans) {
|
||||
vec3 vec2;
|
||||
mat4_get_translation(&rend_group->mat, &vec2);
|
||||
vec3_sub(vec2, *trans, vec2);
|
||||
vec2 -= *trans;
|
||||
|
||||
float_t length;
|
||||
vec3_length_squared(vec2, length);
|
||||
if (length < 0.000001f)
|
||||
if (vec3::length_squared(vec2) < 0.000001f)
|
||||
vec2 = { 0.0f, 1.0f, 0.0f };
|
||||
vec3_normalize(vec2, vec2);
|
||||
else
|
||||
vec2 = vec3::normalize(vec2);
|
||||
|
||||
vec3 vec1 = *vec;
|
||||
|
||||
@@ -752,14 +746,12 @@ namespace Glitter {
|
||||
|
||||
mat4 XRenderGroup::RotateMeshToPrevPosition(XRenderGroup* rend_group,
|
||||
RenderElement* rend_elem, vec3* vec, vec3* trans) {
|
||||
vec3 vec2;
|
||||
vec3_sub(rend_elem->translation, rend_elem->translation_prev, vec2);
|
||||
vec3 vec2 = rend_elem->translation - rend_elem->translation_prev;
|
||||
|
||||
float_t length;
|
||||
vec3_length_squared(vec2, length);
|
||||
if (length < 0.000001f)
|
||||
vec2 = rend_elem->base_direction;
|
||||
vec3_normalize(vec2, vec2);
|
||||
if (vec3::length_squared(vec2) < 0.000001f)
|
||||
vec2 = vec3::normalize(rend_elem->base_direction);
|
||||
else
|
||||
vec2 = vec3::normalize(vec2);
|
||||
|
||||
vec3 vec1 = *vec;
|
||||
|
||||
@@ -776,13 +768,12 @@ namespace Glitter {
|
||||
RenderElement* rend_elem, vec3* vec) {
|
||||
vec3 vec2;
|
||||
mat4_get_translation(&rend_elem->mat, &vec2);
|
||||
vec3_sub(vec2, rend_elem->translation, vec2);
|
||||
vec2 -= rend_elem->translation;
|
||||
|
||||
float_t length;
|
||||
vec3_length_squared(vec2, length);
|
||||
if (length < 0.000001f)
|
||||
if (vec3::length_squared(vec2) < 0.000001f)
|
||||
vec2 = { 0.0f, 1.0f, 0.0f };
|
||||
vec3_normalize(vec2, vec2);
|
||||
else
|
||||
vec3::normalize(vec2);
|
||||
|
||||
vec3 vec1 = *vec;
|
||||
|
||||
@@ -797,14 +788,12 @@ namespace Glitter {
|
||||
|
||||
mat4 XRenderGroup::RotateToPrevPosition(XRenderGroup* rend_group,
|
||||
RenderElement* rend_elem, vec3* vec) {
|
||||
vec3 vec2;
|
||||
vec3_sub(rend_elem->translation, rend_elem->translation_prev, vec2);
|
||||
vec3 vec2 = rend_elem->translation - rend_elem->translation_prev;
|
||||
|
||||
float_t length;
|
||||
vec3_length_squared(vec2, length);
|
||||
if (length < 0.000001f)
|
||||
vec2 = rend_elem->base_direction;
|
||||
vec3_normalize(vec2, vec2);
|
||||
if (vec3::length_squared(vec2) < 0.000001f)
|
||||
vec2 = vec3::normalize(rend_elem->base_direction);
|
||||
else
|
||||
vec2 = vec3::normalize(vec2);
|
||||
|
||||
vec3 vec1 = *vec;
|
||||
|
||||
|
||||
+412
-333
File diff suppressed because it is too large
Load Diff
+2521
-656
File diff suppressed because it is too large
Load Diff
+170
-40
@@ -48,21 +48,6 @@ enum auth_3d_ep_type {
|
||||
AUTH_3D_EP_CYCLE_OFFSET = 3,
|
||||
}; // Pre/Post Infinity
|
||||
|
||||
enum auth_3d_event_type {
|
||||
AUTH_3D_EVENT_MISC = 0x00,
|
||||
AUTH_3D_EVENT_FILT = 0x01,
|
||||
AUTH_3D_EVENT_FX = 0x02,
|
||||
AUTH_3D_EVENT_SND = 0x03,
|
||||
AUTH_3D_EVENT_MOT = 0x04,
|
||||
AUTH_3D_EVENT_A2D = 0x05,
|
||||
};
|
||||
|
||||
enum auth_3d_event_filter_fade_type {
|
||||
AUTH_3D_EVENT_FILTER_FADE_NONE = -1,
|
||||
AUTH_3D_EVENT_FILTER_FADE_OUT = 0,
|
||||
AUTH_3D_EVENT_FILTER_FADE_IN = 1,
|
||||
};
|
||||
|
||||
enum auth_3d_fog_flags {
|
||||
AUTH_3D_FOG_COLOR = 0x01,
|
||||
AUTH_3D_FOG_DENSITY = 0x02,
|
||||
@@ -156,6 +141,7 @@ enum auth_3d_rgba_flags {
|
||||
AUTH_3D_RGBA_A = 0x08,
|
||||
};
|
||||
|
||||
struct auth_3d;
|
||||
struct auth_3d_ambient;
|
||||
struct auth_3d_camera_auxiliary;
|
||||
struct auth_3d_camera_root;
|
||||
@@ -184,6 +170,128 @@ struct auth_3d_post_process;
|
||||
struct auth_3d_rgba;
|
||||
struct auth_3d_vec3;
|
||||
|
||||
namespace auth_3d_detail {
|
||||
class Event {
|
||||
public:
|
||||
enum Type {
|
||||
MISC = 0x00,
|
||||
FILT = 0x01,
|
||||
FX = 0x02,
|
||||
SND = 0x03,
|
||||
MOT = 0x04,
|
||||
A2D = 0x05,
|
||||
};
|
||||
|
||||
bool active;
|
||||
Type type;
|
||||
std::string name;
|
||||
float_t begin;
|
||||
float_t end;
|
||||
std::string param1;
|
||||
std::string ref;
|
||||
size_t index;
|
||||
|
||||
Event(a3da_event* e);
|
||||
virtual ~Event();
|
||||
|
||||
virtual void Load(auth_3d* auth);
|
||||
virtual void Begin(auth_3d* auth, int32_t flags, render_context* rctx);
|
||||
virtual void End(auth_3d* auth, int32_t flags, render_context* rctx);
|
||||
virtual void Ctrl(auth_3d* auth, int32_t flags, render_context* rctx);
|
||||
virtual void Disp(auth_3d* auth, const mat4* mat, render_context* rctx);
|
||||
};
|
||||
|
||||
struct EventA2d : public Event {
|
||||
public:
|
||||
//std::pair<AetObjInitData, int32_t> aet_init_data;
|
||||
|
||||
EventA2d(a3da_event* e);
|
||||
virtual ~EventA2d();
|
||||
|
||||
virtual void Begin(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void End(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void Ctrl(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void Disp(auth_3d* auth, const mat4* mat, render_context* rctx) override;
|
||||
};
|
||||
|
||||
struct EventFX : public Event {
|
||||
public:
|
||||
EventFX(a3da_event* e);
|
||||
virtual ~EventFX();
|
||||
|
||||
virtual void Load(auth_3d* auth) override;
|
||||
virtual void Begin(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void Ctrl(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
};
|
||||
|
||||
struct EventFXSmoothCut : public Event {
|
||||
public:
|
||||
bool cam;
|
||||
|
||||
EventFXSmoothCut(a3da_event* e);
|
||||
virtual ~EventFXSmoothCut();
|
||||
|
||||
virtual void Load(auth_3d* auth) override;
|
||||
virtual void Begin(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void End(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void Disp(auth_3d* auth, const mat4* mat, render_context* rctx) override;
|
||||
};
|
||||
|
||||
struct EventFilterFade : public Event {
|
||||
public:
|
||||
enum Type {
|
||||
FADE_NONE = -1,
|
||||
FADE_OUT = 0,
|
||||
FADE_IN = 1,
|
||||
};
|
||||
|
||||
Type type;
|
||||
vec3 color;
|
||||
|
||||
EventFilterFade(a3da_event* e);
|
||||
virtual ~EventFilterFade();
|
||||
|
||||
virtual void Begin(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void End(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void Disp(auth_3d* auth, const mat4* mat, render_context* rctx) override;
|
||||
};
|
||||
|
||||
struct EventFilterTimeStop : public Event {
|
||||
public:
|
||||
EventFilterTimeStop(a3da_event* e);
|
||||
virtual ~EventFilterTimeStop();
|
||||
|
||||
virtual void Begin(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void End(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void Disp(auth_3d* auth, const mat4* mat, render_context* rctx) override;
|
||||
};
|
||||
|
||||
struct EventMot : public Event {
|
||||
public:
|
||||
EventMot(a3da_event* e);
|
||||
virtual ~EventMot();
|
||||
|
||||
virtual void Load(auth_3d* auth) override;
|
||||
virtual void Begin(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void End(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void Ctrl(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void Disp(auth_3d* auth, const mat4* mat, render_context* rctx) override;
|
||||
};
|
||||
|
||||
struct EventSnd : public Event {
|
||||
public:
|
||||
bool field_190;
|
||||
|
||||
EventSnd(a3da_event* e);
|
||||
virtual ~EventSnd();
|
||||
|
||||
virtual void Load(auth_3d* auth) override;
|
||||
virtual void Begin(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void End(auth_3d* auth, int32_t flags, render_context* rctx) override;
|
||||
virtual void Disp(auth_3d* auth, const mat4* mat, render_context* rctx) override;
|
||||
};
|
||||
}
|
||||
|
||||
struct auth_3d_key {
|
||||
auth_3d_key_type type;
|
||||
float_t value;
|
||||
@@ -205,6 +313,8 @@ struct auth_3d_key {
|
||||
|
||||
float_t interpolate(float_t frame);
|
||||
void reset();
|
||||
|
||||
auth_3d_key& operator=(const auth_3d_key& k);
|
||||
};
|
||||
|
||||
struct auth_3d_rgba {
|
||||
@@ -252,6 +362,7 @@ struct auth_3d_model_transform {
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
void set_mat(const mat4* parent_mat);
|
||||
};
|
||||
|
||||
struct auth_3d_ambient {
|
||||
@@ -263,6 +374,7 @@ struct auth_3d_ambient {
|
||||
auth_3d_ambient();
|
||||
~auth_3d_ambient();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -285,6 +397,7 @@ struct auth_3d_camera_auxiliary {
|
||||
auth_3d_camera_auxiliary();
|
||||
~auth_3d_camera_auxiliary();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -318,16 +431,19 @@ struct auth_3d_camera_root {
|
||||
auth_3d_camera_root();
|
||||
~auth_3d_camera_root();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
struct auth_3d_chara {
|
||||
auth_3d_model_transform model_transform;
|
||||
std::string name;
|
||||
int32_t index;
|
||||
|
||||
auth_3d_chara();
|
||||
~auth_3d_chara();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -339,6 +455,7 @@ struct auth_3d_curve {
|
||||
auth_3d_curve();
|
||||
~auth_3d_curve();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -349,23 +466,7 @@ struct auth_3d_dof {
|
||||
auth_3d_dof();
|
||||
~auth_3d_dof();
|
||||
|
||||
void reset();
|
||||
};
|
||||
|
||||
struct auth_3d_event {
|
||||
float_t begin;
|
||||
float_t clip_begin;
|
||||
float_t clip_end;
|
||||
float_t end;
|
||||
std::string name;
|
||||
std::string param_1;
|
||||
std::string ref;
|
||||
float_t time_ref_scale;
|
||||
auth_3d_event_type type;
|
||||
|
||||
auth_3d_event();
|
||||
~auth_3d_event();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -390,6 +491,7 @@ struct auth_3d_fog {
|
||||
auth_3d_fog();
|
||||
~auth_3d_fog();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -435,6 +537,7 @@ struct auth_3d_light {
|
||||
auth_3d_light();
|
||||
~auth_3d_light();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -460,6 +563,8 @@ struct auth_3d_object_model_transform {
|
||||
auth_3d_object_model_transform();
|
||||
~auth_3d_object_model_transform();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void mat_mult(const mat4* mat);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -472,6 +577,8 @@ struct auth_3d_m_object_hrc {
|
||||
auth_3d_m_object_hrc();
|
||||
~auth_3d_m_object_hrc();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void list_ctrl(const mat4* parent_mat);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -488,6 +595,7 @@ struct auth_3d_material_list {
|
||||
auth_3d_material_list();
|
||||
~auth_3d_material_list();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -500,6 +608,7 @@ struct auth_3d_object_curve {
|
||||
auth_3d_object_curve();
|
||||
~auth_3d_object_curve();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -523,14 +632,16 @@ struct auth_3d_object {
|
||||
auth_3d_object();
|
||||
~auth_3d_object();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void list_ctrl(const mat4* parent_mat);
|
||||
void reset();
|
||||
};
|
||||
|
||||
struct auth_3d_object_hrc {
|
||||
std::vector<auth_3d_object*> children_object;
|
||||
std::vector<auth_3d_object_hrc*> children_object_hrc;
|
||||
std::vector<int32_t> childer_object_hrc_parent_node;
|
||||
std::vector<int32_t> childer_object_parent_node;
|
||||
std::vector<int32_t> children_object_parent_node;
|
||||
std::vector<int32_t> children_object_hrc_parent_node;
|
||||
std::vector<mat4> mats;
|
||||
std::string name;
|
||||
std::vector<auth_3d_object_node> node;
|
||||
@@ -546,6 +657,9 @@ struct auth_3d_object_hrc {
|
||||
auth_3d_object_hrc();
|
||||
~auth_3d_object_hrc();
|
||||
|
||||
int32_t get_node_index(const char* node);
|
||||
void interpolate(float_t frame);
|
||||
void list_ctrl(const mat4* parent_mat);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -562,6 +676,7 @@ struct auth_3d_object_instance {
|
||||
auth_3d_object_instance();
|
||||
~auth_3d_object_instance();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -578,6 +693,7 @@ struct auth_3d_object_node {
|
||||
auth_3d_object_node();
|
||||
~auth_3d_object_node();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -589,6 +705,7 @@ struct auth_3d_object_texture_pattern {
|
||||
auth_3d_object_texture_pattern();
|
||||
~auth_3d_object_texture_pattern();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -611,6 +728,7 @@ struct auth_3d_object_texture_transform {
|
||||
auth_3d_object_texture_transform();
|
||||
~auth_3d_object_texture_transform();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -635,6 +753,7 @@ struct auth_3d_point {
|
||||
auth_3d_point();
|
||||
~auth_3d_point();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -662,9 +781,16 @@ struct auth_3d_post_process {
|
||||
auth_3d_post_process();
|
||||
~auth_3d_post_process();
|
||||
|
||||
void interpolate(float_t frame);
|
||||
void reset();
|
||||
};
|
||||
|
||||
struct auth_3d_time_event {
|
||||
float_t frame;
|
||||
int32_t type;
|
||||
size_t event_index;
|
||||
};
|
||||
|
||||
struct auth_3d {
|
||||
int32_t uid;
|
||||
int32_t id;
|
||||
@@ -679,6 +805,7 @@ struct auth_3d {
|
||||
float_t alpha;
|
||||
draw_task_flags draw_task_flags;
|
||||
int32_t chara_id;
|
||||
bool chara_item;
|
||||
bool shadow;
|
||||
int32_t src_chara;
|
||||
int32_t dst_chara;
|
||||
@@ -698,7 +825,9 @@ struct auth_3d {
|
||||
std::vector<auth_3d_chara> chara;
|
||||
std::vector<auth_3d_curve> curve;
|
||||
auth_3d_dof dof;
|
||||
std::vector<auth_3d_event> event;
|
||||
std::vector<auth_3d_detail::Event*> event;
|
||||
std::vector<auth_3d_time_event> event_time;
|
||||
auth_3d_time_event* event_time_next;
|
||||
std::vector<auth_3d_fog> fog;
|
||||
std::vector<auth_3d_light> light;
|
||||
std::vector<auth_3d_m_object_hrc> m_object_hrc;
|
||||
@@ -833,11 +962,11 @@ public:
|
||||
} window;
|
||||
|
||||
Auth3dTestTask();
|
||||
virtual ~Auth3dTestTask();
|
||||
virtual ~Auth3dTestTask() override;
|
||||
|
||||
virtual bool Init();
|
||||
virtual bool Ctrl();
|
||||
virtual bool Dest();
|
||||
virtual bool Init() override;
|
||||
virtual bool Ctrl() override;
|
||||
virtual bool Dest() override;
|
||||
};
|
||||
|
||||
extern auth_3d_data_struct* auth_3d_data;
|
||||
@@ -880,12 +1009,13 @@ extern void auth_3d_data_read_file(int32_t* id, auth_3d_database* auth_3d_db);
|
||||
extern void auth_3d_data_read_file_modern(int32_t* id);
|
||||
extern void auth_3d_data_set_camera_root_update(int32_t* id, bool value);
|
||||
extern void auth_3d_data_set_chara_id(int32_t* id, int32_t value);
|
||||
extern void auth_3d_data_set_chara_item(int32_t* id, bool value);
|
||||
extern void auth_3d_data_set_draw_task_flags_alpha(int32_t* id, draw_task_flags draw_task_flags, float_t alpha);
|
||||
extern void auth_3d_data_set_enable(int32_t* id, bool value);
|
||||
extern void auth_3d_data_set_frame_rate(int32_t* id, FrameRateControl* value);
|
||||
extern void auth_3d_data_set_last_frame(int32_t* id, float_t value);
|
||||
extern void auth_3d_data_set_left_right_reverse(int32_t* id, bool value);
|
||||
extern void auth_3d_data_set_mat(int32_t* id, mat4* value);
|
||||
extern void auth_3d_data_set_mat(int32_t* id, const mat4* value);
|
||||
extern void auth_3d_data_set_max_frame(int32_t* id, float_t value);
|
||||
extern void auth_3d_data_set_paused(int32_t* id, bool value);
|
||||
extern void auth_3d_data_set_repeat(int32_t* id, bool value);
|
||||
|
||||
+10
-10
@@ -54,7 +54,7 @@ void camera::initialize(double_t aspect, int32_t render_width,
|
||||
set_roll(0.0);
|
||||
set_fov(32.2673416137695);
|
||||
camera_calculate_forward(this);
|
||||
set_position(vec3_null);
|
||||
set_position(0.0f);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -147,14 +147,14 @@ void camera::get_view_point(vec3& value) {
|
||||
}
|
||||
|
||||
void camera::set_view_point(const vec3& value) {
|
||||
if (memcmp(&value, &view_point, sizeof(vec3))) {
|
||||
if (value != view_point) {
|
||||
view_point = value;
|
||||
changed_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
void camera::set_view_point(const vec3&& value) {
|
||||
if (memcmp(&value, &view_point, sizeof(vec3))) {
|
||||
if (value != view_point) {
|
||||
view_point = value;
|
||||
changed_view = true;
|
||||
}
|
||||
@@ -165,14 +165,14 @@ void camera::get_interest(vec3& value) {
|
||||
}
|
||||
|
||||
void camera::set_interest(const vec3& value) {
|
||||
if (memcmp(&value, &interest, sizeof(vec3))) {
|
||||
if (value != interest) {
|
||||
interest = value;
|
||||
changed_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
void camera::set_interest(const vec3&& value) {
|
||||
if (memcmp(&value, &interest, sizeof(vec3))) {
|
||||
if (value != interest) {
|
||||
interest = value;
|
||||
changed_view = true;
|
||||
}
|
||||
@@ -222,7 +222,7 @@ void camera::reset() {
|
||||
fast_change_hist0 = false;
|
||||
fast_change_hist1 = false;
|
||||
camera_calculate_forward(this);
|
||||
set_position(vec3_null);
|
||||
set_position(0.0f);
|
||||
update_data();
|
||||
}
|
||||
|
||||
@@ -264,9 +264,9 @@ void camera::set(const vec3& view_point, const vec3& interest,
|
||||
_fov = fov;
|
||||
|
||||
mat4 cam;
|
||||
mat4_translate(trans.x, trans.y, trans.z, &cam);
|
||||
mat4_rotate_mult(&cam, rot.x, rot.y, rot.z, &cam);
|
||||
mat4_scale_rot(&cam, scale.x, scale.y, scale.z, &cam);
|
||||
mat4_translate(&trans, &cam);
|
||||
mat4_rotate_mult(&cam, &rot, &cam);
|
||||
mat4_scale_rot(&cam, &scale, &cam);
|
||||
mat4_mult_vec3_trans(&cam, &_vp, &_vp);
|
||||
mat4_mult_vec3_trans(&cam, &_int, &_int);
|
||||
|
||||
@@ -404,7 +404,7 @@ static void camera_calculate_view(camera* c) {
|
||||
mat4_rotate_z(rotation.z, &c->view);
|
||||
mat4_rotate_x_mult(&c->view, rotation.x, &c->view);
|
||||
mat4_rotate_y_mult(&c->view, rotation.y, &c->view);
|
||||
mat4_translate_mult(&c->view, view_point.x, view_point.y, view_point.z, &c->view);
|
||||
mat4_translate_mult(&c->view, &view_point, &c->view);
|
||||
|
||||
mat4_inverse(&c->view, &c->inv_view);
|
||||
mat3_from_mat4(&c->view, &c->view_mat3);
|
||||
|
||||
@@ -23,3 +23,13 @@ const vec4u8 color_grey = { 0x7F, 0x7F, 0x7F, 0xFF };
|
||||
|
||||
vec4u8 clear_color;
|
||||
bool set_clear_color;
|
||||
|
||||
vec4 get_clear_color() {
|
||||
if (!set_clear_color)
|
||||
return 0.0f;
|
||||
|
||||
vec4 _clear_color;
|
||||
vec4u8_to_vec4(clear_color, _clear_color);
|
||||
return _clear_color * (float_t)(1.0 / 255.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,3 +26,5 @@ extern const vec4u8 color_grey;
|
||||
|
||||
extern vec4u8 clear_color;
|
||||
extern bool set_clear_color;
|
||||
|
||||
extern vec4 get_clear_color();
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ struct data_struct {
|
||||
#endif
|
||||
|
||||
data_struct();
|
||||
virtual ~data_struct();
|
||||
~data_struct();
|
||||
|
||||
bool check_directory_exists(const char* dir);
|
||||
bool check_file_exists(const char* path);
|
||||
|
||||
+58
-46
@@ -37,6 +37,10 @@ texture_data_struct::texture_data_struct() : field_0() {
|
||||
|
||||
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) {
|
||||
GLuint vao = rctx->object_data.get_vertex_array(draw);
|
||||
if (!vao)
|
||||
return;
|
||||
|
||||
if (draw->mats) {
|
||||
mat4* mats = draw->mats;
|
||||
if (draw->mat_count == 2)
|
||||
@@ -66,7 +70,7 @@ void draw_object_draw(render_context* rctx, draw_object* draw, mat4* model,
|
||||
|
||||
|
||||
if (!show_vector) {
|
||||
gl_state_bind_vertex_array(rctx->object_data.get_vertex_array(draw));
|
||||
gl_state_bind_vertex_array(vao);
|
||||
draw_object_func(rctx, draw);
|
||||
}
|
||||
uniform_value[U_BONE_MAT] = 0;
|
||||
@@ -75,21 +79,23 @@ void draw_object_draw(render_context* rctx, draw_object* draw, mat4* model,
|
||||
void draw_object_draw_default(render_context* rctx, draw_object* draw) {
|
||||
if (draw->set_blend_color) {
|
||||
shaders_ft.env_vert_set(3, draw->blend_color);
|
||||
shaders_ft.env_vert_set(4, vec4_null);
|
||||
shaders_ft.env_vert_set(4, 0.0f);
|
||||
}
|
||||
|
||||
if (!draw->draw_object_func)
|
||||
draw_object_vertex_attrib_set_default(draw);
|
||||
|
||||
draw_object_material_set_default(rctx, draw, rctx->draw_state.shader);
|
||||
|
||||
obj_sub_mesh* sub_mesh = draw->sub_mesh;
|
||||
if (!draw->instances_count)
|
||||
obj_sub_mesh_draw(rctx,
|
||||
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);
|
||||
sub_mesh->primitive_type,
|
||||
sub_mesh->num_index,
|
||||
sub_mesh->first_index,
|
||||
sub_mesh->last_index,
|
||||
sub_mesh->index_format,
|
||||
sub_mesh->index_offset);
|
||||
else {
|
||||
mat4 mat;
|
||||
for (int32_t i = 0; i < draw->instances_count; i++) {
|
||||
@@ -99,12 +105,12 @@ void draw_object_draw_default(render_context* rctx, draw_object* draw) {
|
||||
glVertexAttrib4fv(14, (const GLfloat*)&mat.row2);
|
||||
glVertexAttrib4fv(15, (const GLfloat*)&mat.row3);
|
||||
obj_sub_mesh_draw(rctx,
|
||||
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);
|
||||
sub_mesh->primitive_type,
|
||||
sub_mesh->num_index,
|
||||
sub_mesh->first_index,
|
||||
sub_mesh->last_index,
|
||||
sub_mesh->index_format,
|
||||
sub_mesh->index_offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,8 +119,8 @@ void draw_object_draw_default(render_context* rctx, draw_object* draw) {
|
||||
draw_object_vertex_attrib_reset_default(draw);
|
||||
|
||||
if (draw->set_blend_color) {
|
||||
shaders_ft.env_vert_set(3, vec4_identity);
|
||||
shaders_ft.env_vert_set(4, vec4_null);
|
||||
shaders_ft.env_vert_set(3, 1.0f);
|
||||
shaders_ft.env_vert_set(4, 0.0f);
|
||||
}
|
||||
|
||||
rctx->draw_state.stats.object_draw_count++;
|
||||
@@ -174,11 +180,11 @@ void draw_object_draw_reflect(render_context* rctx, draw_object* draw) {
|
||||
if (sub_mesh->index_format != OBJ_INDEX_U8)
|
||||
obj_sub_mesh_draw(rctx,
|
||||
sub_mesh->primitive_type,
|
||||
sub_mesh->indices_count,
|
||||
sub_mesh->num_index,
|
||||
sub_mesh->first_index,
|
||||
sub_mesh->last_index,
|
||||
sub_mesh->index_format,
|
||||
sub_mesh->indices_offset);
|
||||
sub_mesh->index_offset);
|
||||
|
||||
draw_object_material_reset_reflect();
|
||||
draw_object_vertex_attrib_reset_reflect(draw);
|
||||
@@ -195,11 +201,11 @@ void draw_object_draw_reflect_reflect_map(render_context* rctx, draw_object* dra
|
||||
if (sub_mesh->index_format != OBJ_INDEX_U8)
|
||||
obj_sub_mesh_draw(rctx,
|
||||
sub_mesh->primitive_type,
|
||||
sub_mesh->indices_count,
|
||||
sub_mesh->num_index,
|
||||
sub_mesh->first_index,
|
||||
sub_mesh->last_index,
|
||||
sub_mesh->index_format,
|
||||
sub_mesh->indices_offset);
|
||||
sub_mesh->index_offset);
|
||||
|
||||
draw_object_material_reset_reflect();
|
||||
draw_object_vertex_attrib_reset_reflect(draw);
|
||||
@@ -287,11 +293,11 @@ void draw_object_draw_translucent(render_context* rctx, draw_object* draw) {
|
||||
if (sub_mesh->index_format != OBJ_INDEX_U8)
|
||||
obj_sub_mesh_draw(rctx,
|
||||
sub_mesh->primitive_type,
|
||||
sub_mesh->indices_count,
|
||||
sub_mesh->num_index,
|
||||
sub_mesh->first_index,
|
||||
sub_mesh->last_index,
|
||||
sub_mesh->index_format,
|
||||
sub_mesh->indices_offset);
|
||||
sub_mesh->index_offset);
|
||||
|
||||
if (tex_id != -1)
|
||||
gl_state_active_bind_texture_2d(tex_index, 0);
|
||||
@@ -362,11 +368,11 @@ void obj_sub_mesh_draw(render_context* rctx, obj_primitive_type primitive_type,
|
||||
};
|
||||
|
||||
if (primitive_type == OBJ_PRIMITIVE_TRIANGLE_STRIP && index_format == OBJ_INDEX_U16) {
|
||||
gl_state_enable_primitive_restart();
|
||||
glPrimitiveRestartIndex(0xFFFF);
|
||||
shaders_ft.enable_primitive_restart();
|
||||
shaders_ft.set_primitive_restart_index(0xFFFF);
|
||||
shaders_ft.draw_range_elements(GL_TRIANGLE_STRIP,
|
||||
start, end, count, GL_UNSIGNED_SHORT, (void*)indices);
|
||||
gl_state_disable_primitive_restart();
|
||||
shaders_ft.disable_primitive_restart();
|
||||
}
|
||||
else
|
||||
shaders_ft.draw_elements(mesh_draw_mode[primitive_type],
|
||||
@@ -543,28 +549,32 @@ static void draw_object_material_set_default(render_context* rctx, draw_object*
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tex_type == OBJ_MATERIAL_TEXTURE_ENVIRONMENT_CUBE)
|
||||
if (tex_type == OBJ_MATERIAL_TEXTURE_ENVIRONMENT_CUBE) {
|
||||
gl_state_active_bind_texture_cube_map(tex_index, tex_id);
|
||||
gl_state_bind_sampler(tex_index, 0);
|
||||
}
|
||||
else {
|
||||
gl_state_active_bind_texture_2d(tex_index, tex_id);
|
||||
|
||||
GLenum wrap_s;
|
||||
int32_t wrap_s;
|
||||
if (texdata->attrib.m.mirror_u)
|
||||
wrap_s = GL_MIRRORED_REPEAT;
|
||||
wrap_s = 2;
|
||||
else if (texdata->attrib.m.repeat_u)
|
||||
wrap_s = GL_REPEAT;
|
||||
wrap_s = 1;
|
||||
else
|
||||
wrap_s = GL_CLAMP_TO_EDGE;
|
||||
wrap_s = 0;
|
||||
|
||||
GLenum wrap_t;
|
||||
int32_t wrap_t;
|
||||
if (texdata->attrib.m.mirror_v)
|
||||
wrap_t = GL_MIRRORED_REPEAT;
|
||||
wrap_t = 2;
|
||||
else if (texdata->attrib.m.repeat_v)
|
||||
wrap_t = GL_REPEAT;
|
||||
wrap_t = 1;
|
||||
else
|
||||
wrap_t = GL_CLAMP_TO_EDGE;
|
||||
wrap_t = 0;
|
||||
|
||||
texture_storage_set_texture_wrap(tex_id, wrap_s, wrap_t);
|
||||
texture* tex = texture_storage_get_texture(::texture_id(0, texture_id));
|
||||
gl_state_bind_sampler(tex_index, rctx->draw_pass.samplers[(wrap_t * 3
|
||||
+ wrap_s) * 2 + (tex->max_mipmap_level > 0 ? 1 : 0)]);
|
||||
}
|
||||
|
||||
if (material->material.shader.index == SHADER_FT_SKY) {
|
||||
@@ -764,23 +774,25 @@ static void draw_object_material_set_reflect(render_context* rctx, draw_object*
|
||||
|
||||
gl_state_active_bind_texture_2d(i, tex_id);
|
||||
|
||||
GLenum wrap_s;
|
||||
int32_t wrap_s;
|
||||
if (texdata->attrib.m.mirror_u)
|
||||
wrap_s = GL_MIRRORED_REPEAT;
|
||||
wrap_s = 2;
|
||||
else if (texdata->attrib.m.repeat_u)
|
||||
wrap_s = GL_REPEAT;
|
||||
wrap_s = 1;
|
||||
else
|
||||
wrap_s = GL_CLAMP_TO_EDGE;
|
||||
wrap_s = 0;
|
||||
|
||||
GLenum wrap_t;
|
||||
int32_t wrap_t;
|
||||
if (texdata->attrib.m.mirror_v)
|
||||
wrap_t = GL_MIRRORED_REPEAT;
|
||||
wrap_t = 2;
|
||||
else if (texdata->attrib.m.repeat_v)
|
||||
wrap_t = GL_REPEAT;
|
||||
wrap_t = 1;
|
||||
else
|
||||
wrap_t = GL_CLAMP_TO_EDGE;
|
||||
wrap_t = 0;
|
||||
|
||||
texture_storage_set_texture_wrap(tex_id, wrap_s, wrap_t);
|
||||
texture* tex = texture_storage_get_texture(::texture_id(0, texture_id));
|
||||
gl_state_bind_sampler(i, rctx->draw_pass.samplers[(wrap_t * 3
|
||||
+ wrap_s) * 2 + (tex->max_mipmap_level > 0 ? 1 : 0)]);
|
||||
}
|
||||
|
||||
vec4 ambient;
|
||||
@@ -788,9 +800,9 @@ static void draw_object_material_set_reflect(render_context* rctx, draw_object*
|
||||
vec4 emission;
|
||||
vec4 specular;
|
||||
if (material->material.shader.index == -1) {
|
||||
ambient = vec4_identity;
|
||||
ambient = 1.0f;
|
||||
diffuse = material->material.color.diffuse;
|
||||
emission = vec4_identity;
|
||||
emission = 1.0f;
|
||||
specular = material->material.color.specular;
|
||||
}
|
||||
else {
|
||||
|
||||
+239
-115
@@ -15,14 +15,9 @@
|
||||
#include "shader_ft.hpp"
|
||||
#include "shader_glsl.hpp"
|
||||
#include "static_var.hpp"
|
||||
#include "task_effect.hpp"
|
||||
#include "texture.hpp"
|
||||
|
||||
struct draw_preprocess {
|
||||
int32_t field_0;
|
||||
void(*draw_func)(void*);
|
||||
void* data;
|
||||
};
|
||||
|
||||
struct texture_param {
|
||||
GLint width;
|
||||
GLint height;
|
||||
@@ -39,8 +34,11 @@ static void draw_pass_sss_contour(render_context* rctx, post_process* pp);
|
||||
static void draw_pass_sss_filter(render_context* rctx, sss_data* a1);
|
||||
static void draw_pass_reflect(render_context* rctx, draw_pass* a1);
|
||||
static void draw_pass_refract(render_context* rctx, draw_pass* a1);
|
||||
static void draw_pass_pre_process(render_context* rctx, draw_pass* a1);
|
||||
static void draw_pass_preprocess(render_context* rctx, draw_pass* a1);
|
||||
static void draw_pass_clear(render_context* rctx, draw_pass* a1);
|
||||
static void draw_pass_pre_sprite(render_context* rctx, draw_pass* a1);
|
||||
static void draw_pass_3d(render_context* rctx, draw_pass* a1);
|
||||
static void draw_pass_3d_contour(render_context* rctx, draw_pass* a1);
|
||||
static int32_t draw_pass_3d_get_translucent_count(render_context* rctx);
|
||||
static void draw_pass_3d_shadow_reset(render_context* rctx);
|
||||
static void draw_pass_3d_shadow_set(shadow* shad, render_context* rctx);
|
||||
@@ -57,7 +55,7 @@ static void texture_params_restore(texture_param* tex_0_param,
|
||||
|
||||
extern bool draw_grid_3d;
|
||||
extern shader_glsl* grid_shader;
|
||||
extern GLuint grid_vbo;
|
||||
extern GLuint grid_vao;
|
||||
extern size_t grid_vertex_count;
|
||||
extern light_param_data_storage* light_param_data_storage_data;
|
||||
|
||||
@@ -105,24 +103,13 @@ void draw_pass_main(render_context* rctx) {
|
||||
draw_pass_refract(rctx, &rctx->draw_pass);
|
||||
break;
|
||||
case DRAW_PASS_PRE_PROCESS:
|
||||
draw_pass_pre_process(rctx, &rctx->draw_pass);
|
||||
draw_pass_preprocess(rctx, &rctx->draw_pass);
|
||||
break;
|
||||
case DRAW_PASS_CLEAR:
|
||||
draw_pass_clear(rctx, &rctx->draw_pass);
|
||||
break;
|
||||
case DRAW_PASS_CLEAR: {
|
||||
rctx->post_process.rend_texture.bind();
|
||||
if (set_clear_color) {
|
||||
vec4 _clear_color;
|
||||
vec4u8_to_vec4(clear_color, _clear_color);
|
||||
_clear_color *= (float_t)(1.0 / 255.0);
|
||||
glClearBufferfv(GL_COLOR, 0, (GLfloat*)&_clear_color);
|
||||
}
|
||||
else {
|
||||
vec4 _clear_color = {};
|
||||
glClearBufferfv(GL_COLOR, 0, (GLfloat*)&_clear_color);
|
||||
}
|
||||
//sub_140501470(rctx, &rctx->draw_pass);
|
||||
} break;
|
||||
case DRAW_PASS_PRE_SPRITE:
|
||||
//sub_140501600(rctx, &rctx->draw_pass);
|
||||
draw_pass_pre_sprite(rctx, &rctx->draw_pass);
|
||||
break;
|
||||
case DRAW_PASS_3D:
|
||||
draw_pass_3d(rctx, &rctx->draw_pass);
|
||||
@@ -142,6 +129,7 @@ void draw_pass_main(render_context* rctx) {
|
||||
}
|
||||
rctx->object_data.check_vertex_arrays();
|
||||
gl_state_bind_vertex_array(0);
|
||||
gl_state_disable_primitive_restart();
|
||||
}
|
||||
|
||||
inline static void draw_pass_begin(draw_pass* a1) {
|
||||
@@ -154,9 +142,9 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
|
||||
rctx->camera->update_data();
|
||||
rctx->view_mat = rctx->camera->view;
|
||||
if (rctx->litproj->set(rctx)) {
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_OPAQUE, 0, 0, true, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSPARENT, 0, 0, true, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSLUCENT, 0, 0, true, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_OPAQUE);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSPARENT);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSLUCENT);
|
||||
|
||||
rctx->draw_state.shader_index = -1;
|
||||
uniform_value[U0A] = 0;
|
||||
@@ -167,12 +155,12 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
|
||||
draw_pass_set_camera(rctx->camera);
|
||||
for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++)
|
||||
rctx->light_set[i].data_set(rctx->face, (light_set_id)i);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_OPAQUE, 0, 0, true, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSPARENT, 0, 0, true, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_OPAQUE);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSPARENT);
|
||||
draw_task_sort(rctx, DRAW_OBJECT_TRANSLUCENT, 1);
|
||||
gl_state_set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
gl_state_enable_blend();
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSLUCENT, 0, 0, true, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSLUCENT);
|
||||
gl_state_disable_blend();
|
||||
rctx->draw_state.shader_index = -1;
|
||||
gl_state_bind_framebuffer(0);
|
||||
@@ -247,10 +235,10 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
|
||||
rctx->draw_state.shader_index = SHADER_FT_SIL;
|
||||
uniform_value[U0A] = 0;
|
||||
|
||||
draw_task_draw_objects_by_type(rctx, (draw_object_type)(DRAW_OBJECT_SHADOW_CHARA + v11[i]), 0, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, (draw_object_type)(DRAW_OBJECT_SHADOW_CHARA + v11[i]));
|
||||
if (draw_task_get_count(rctx, (draw_object_type)(DRAW_OBJECT_SHADOW_OBJECT_CHARA + v11[i])) > 0) {
|
||||
glColorMask(a1->field_2F8 != 0 ? GL_TRUE : GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
draw_task_draw_objects_by_type(rctx, (draw_object_type)v8, 0, 0, true, -1);
|
||||
draw_task_draw_objects_by_type(rctx, (draw_object_type)v8);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
}
|
||||
gl_state_disable_depth_test();
|
||||
@@ -268,8 +256,9 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
|
||||
texture_param tex_params[3];
|
||||
texture_params_get(v5, &tex_params[0], v7, &tex_params[1], v6, &tex_params[2]);
|
||||
shad->field_8[6].bind();
|
||||
uniform_value[U_ESM_FILTER] = 0;
|
||||
shaders_ft.set(SHADER_FT_ESMFILT);
|
||||
//uniform_value[U_ESM_FILTER] = 0;
|
||||
//shaders_ft.set(SHADER_FT_ESMFILT);
|
||||
shaders_ft.set(SHADER_FT_ESMFILT_MIN);
|
||||
shaders_ft.local_frag_set(0, 1.0f / (float_t)tex_params[1].width,
|
||||
1.0f / (float_t)tex_params[1].height, 0.0f, 0.0f);
|
||||
gl_state_active_bind_texture_2d(0, v7);
|
||||
@@ -277,8 +266,9 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
|
||||
render_texture::draw_custom(&shaders_ft);
|
||||
|
||||
shad->field_8[5].bind();
|
||||
uniform_value[U_ESM_FILTER] = 1;
|
||||
shaders_ft.set(SHADER_FT_ESMFILT);
|
||||
//uniform_value[U_ESM_FILTER] = 1;
|
||||
//shaders_ft.set(SHADER_FT_ESMFILT);
|
||||
shaders_ft.set(SHADER_FT_ESMFILT_EROSION);
|
||||
shaders_ft.local_frag_set(0, 0.75f / (float_t)tex_params[2].width,
|
||||
0.75f / (float_t)tex_params[2].height, 0.0f, 0.0f);
|
||||
gl_state_active_bind_texture_2d(0, v6);
|
||||
@@ -298,7 +288,7 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
|
||||
texture_params_get(v11, &tex_params[0], v12, &tex_params[1], 0, 0);
|
||||
uniform_value[U_IMAGE_FILTER] = 5;
|
||||
shaders_ft.set(SHADER_FT_IMGFILT);
|
||||
shaders_ft.local_frag_set(0, vec4_identity);
|
||||
shaders_ft.local_frag_set(0, 1.0f);
|
||||
shaders_ft.state_matrix_set_texture(0, mat4_identity);
|
||||
shaders_ft.state_matrix_set_texture(1, mat4_identity);
|
||||
shaders_ft.state_matrix_set_texture(2, mat4_identity);
|
||||
@@ -422,13 +412,14 @@ static bool draw_pass_shadow_litproj(render_context* rctx, light_proj* litproj)
|
||||
return false;
|
||||
}
|
||||
|
||||
static const vec4 border_color = 0.0f;
|
||||
rctx->draw_state.shader_index = SHADER_FT_LITPROJ;
|
||||
gl_state_active_bind_texture_2d(17, tex->tex);
|
||||
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, (GLfloat*)&vec4_null);
|
||||
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, (GLfloat*)&border_color);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||
gl_state_active_bind_texture_2d(18, litproj->shadow_texture[0].color_texture->tex);
|
||||
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, (GLfloat*)&vec4_null);
|
||||
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, (GLfloat*)&border_color);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||
gl_state_active_texture(0);
|
||||
@@ -476,7 +467,7 @@ static void draw_pass_sss(render_context* rctx, draw_pass* a1) {
|
||||
gl_state_enable_depth_test();
|
||||
gl_state_set_depth_func(GL_LEQUAL);
|
||||
gl_state_set_depth_mask(GL_TRUE);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_SSS, 0, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_SSS);
|
||||
gl_state_disable_depth_test();
|
||||
rctx->draw_state.shader_index = -1;
|
||||
draw_pass_3d_shadow_reset(rctx);
|
||||
@@ -494,7 +485,7 @@ static void draw_pass_sss(render_context* rctx, draw_pass* a1) {
|
||||
rctx->draw_state.shader_index = SHADER_FT_SSS_SKIN;
|
||||
gl_state_enable_depth_test();
|
||||
gl_state_set_depth_mask(GL_TRUE);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_SSS, 1, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_SSS, 1);
|
||||
gl_state_disable_depth_test();
|
||||
rctx->draw_state.shader_index = -1;
|
||||
gl_state_bind_framebuffer(0);
|
||||
@@ -508,9 +499,9 @@ static void draw_pass_sss(render_context* rctx, draw_pass* a1) {
|
||||
|
||||
static void draw_pass_sss_contour(render_context* rctx, post_process* pp) {
|
||||
pp->sss_contour_texture.bind();
|
||||
shaders_ft.state_matrix_set_modelview(0, mat4_identity, false);
|
||||
shaders_ft.state_matrix_set_projection(mat4_identity, true);
|
||||
shaders_ft.state_matrix_set_mvp(mat4_identity, mat4_identity);
|
||||
gl_state_enable_depth_test();
|
||||
gl_state_set_depth_func(GL_ALWAYS);
|
||||
gl_state_set_depth_mask(GL_TRUE);
|
||||
glViewport(0, 0, pp->render_width, pp->render_height);
|
||||
gl_state_active_bind_texture_2d(0, pp->rend_texture.color_texture->tex);
|
||||
@@ -532,7 +523,7 @@ static void draw_pass_sss_contour(render_context* rctx, post_process* pp) {
|
||||
vec3 direction = cam->interest - cam->view_point;
|
||||
float_t length = vec3::length(direction);
|
||||
float_t v7 = direction.y;
|
||||
if (length != 0.0)
|
||||
if (length != 0.0f)
|
||||
v7 /= length;
|
||||
|
||||
float_t v9 = fabsf(v7) - 0.1f;
|
||||
@@ -548,8 +539,7 @@ static void draw_pass_sss_filter_calc_coef(double_t a1, size_t a2, double_t a3,
|
||||
if (a2 > 8)
|
||||
return;
|
||||
|
||||
vec4 params[64];
|
||||
memset(params, 0, sizeof(vec4) * 64);
|
||||
vec4 params[64] = {};
|
||||
|
||||
for (size_t i = a4; i; i--) {
|
||||
float_t* v20 = (float_t*)params;
|
||||
@@ -599,8 +589,8 @@ static void draw_pass_sss_filter(render_context* rctx, sss_data* a1) {
|
||||
vec3 view_point = rctx->camera->view_point;
|
||||
|
||||
vec3 chara_position[2];
|
||||
chara_position[0] = vec3_null;
|
||||
chara_position[1] = vec3_null;
|
||||
chara_position[0] = 0.0f;
|
||||
chara_position[1] = 0.0f;
|
||||
float_t chara_distance[2];
|
||||
for (int32_t i = 0; i < 2; i++) {
|
||||
chara_position[i] = interest;
|
||||
@@ -645,12 +635,11 @@ static void draw_pass_sss_filter(render_context* rctx, sss_data* a1) {
|
||||
|
||||
shaders_ft.env_frag_set(25, v33, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
shaders_ft.state_matrix_set_projection(mat4_identity, false);
|
||||
shaders_ft.state_matrix_set_modelview(0, mat4_identity, true);
|
||||
shaders_ft.state_matrix_set_mvp(mat4_identity, mat4_identity);
|
||||
|
||||
gl_state_active_texture(0);
|
||||
if (a1->npr_contour) {
|
||||
a1->textures->bind();
|
||||
a1->textures[0].bind();
|
||||
glViewport(0, 0, 640, 360);
|
||||
post_process* pp = &rctx->post_process;
|
||||
gl_state_bind_texture_2d(pp->rend_texture.color_texture->tex);
|
||||
@@ -663,12 +652,14 @@ static void draw_pass_sss_filter(render_context* rctx, sss_data* a1) {
|
||||
a1->textures[2].bind();
|
||||
glViewport(0, 0, 320, 180);
|
||||
gl_state_bind_texture_2d(a1->textures[0].color_texture->tex);
|
||||
uniform_value[U_SSS_FILTER] = 0;
|
||||
shaders_ft.set(SHADER_FT_SSS_FILT);
|
||||
//uniform_value[U_SSS_FILTER] = 0;
|
||||
//shaders_ft.set(SHADER_FT_SSS_FILT);
|
||||
shaders_ft.set(SHADER_FT_SSS_FILT_MIN);
|
||||
render_texture::draw_params(&shaders_ft, 640, 360, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f);
|
||||
a1->textures[1].bind();
|
||||
uniform_value[U_SSS_FILTER] = 3;
|
||||
shaders_ft.set(SHADER_FT_SSS_FILT);
|
||||
//uniform_value[U_SSS_FILTER] = 3;
|
||||
//shaders_ft.set(SHADER_FT_SSS_FILT);
|
||||
shaders_ft.set(SHADER_FT_SSS_FILT_GAUSS_2D);
|
||||
shaders_ft.local_frag_set(1, 5.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
double_t a5[3];
|
||||
@@ -697,7 +688,7 @@ static void draw_pass_sss_filter(render_context* rctx, sss_data* a1) {
|
||||
}
|
||||
|
||||
static void draw_pass_reflect(render_context* rctx, draw_pass* a1) {
|
||||
render_texture& reflect_texture = rctx->draw_pass.reflect_texture;
|
||||
render_texture& reflect_texture = rctx->draw_pass.get_render_texture(0);
|
||||
reflect_texture.bind();
|
||||
if (draw_task_get_count(rctx, DRAW_OBJECT_REFLECT_OPAQUE)
|
||||
|| draw_task_get_count(rctx, DRAW_OBJECT_REFLECT_TRANSPARENT)
|
||||
@@ -729,19 +720,19 @@ static void draw_pass_reflect(render_context* rctx, draw_pass* a1) {
|
||||
gl_state_enable_depth_test();
|
||||
gl_state_set_depth_func(GL_LEQUAL);
|
||||
gl_state_set_depth_mask(GL_TRUE);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_REFLECT_OPAQUE, 0, 0, a1->field_31D, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_REFLECT_OPAQUE, 0, 0, a1->field_31D);
|
||||
if (a1->reflect_type == STAGE_DATA_REFLECT_REFLECT_MAP) {
|
||||
gl_state_enable_blend();
|
||||
gl_state_set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
gl_state_set_blend_equation(GL_FUNC_ADD);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_REFLECT_TRANSLUCENT, 0, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_REFLECT_TRANSLUCENT);
|
||||
gl_state_disable_blend();
|
||||
}
|
||||
|
||||
if (a1->reflect_type == STAGE_DATA_REFLECT_REFLECT_MAP) {
|
||||
uniform_value[U_REFLECT] = a1->field_31E;
|
||||
uniform_value[U_CLIP_PLANE] = clip_plane.data[0];
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_REFLECT_CHARA_OPAQUE, 0, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_REFLECT_CHARA_OPAQUE);
|
||||
}
|
||||
gl_state_disable_depth_test();
|
||||
uniform_value[U_REFLECT] = 0;
|
||||
@@ -762,7 +753,7 @@ static void draw_pass_reflect(render_context* rctx, draw_pass* a1) {
|
||||
}
|
||||
|
||||
static void draw_pass_refract(render_context* rctx, draw_pass* a1) {
|
||||
render_texture& refract_texture = rctx->draw_pass.refract_texture;
|
||||
render_texture& refract_texture = rctx->draw_pass.get_render_texture(1);
|
||||
refract_texture.bind();
|
||||
if (draw_task_get_count(rctx, DRAW_OBJECT_REFRACT_OPAQUE)
|
||||
|| draw_task_get_count(rctx, DRAW_OBJECT_REFRACT_TRANSPARENT)
|
||||
@@ -787,30 +778,111 @@ static void draw_pass_refract(render_context* rctx, draw_pass* a1) {
|
||||
gl_state_enable_depth_test();
|
||||
gl_state_set_depth_func(GL_LEQUAL);
|
||||
gl_state_set_depth_mask(GL_TRUE);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_REFRACT_OPAQUE, 0, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_REFRACT_TRANSPARENT, 0, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_REFRACT_TRANSLUCENT, 0, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_REFRACT_OPAQUE);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_REFRACT_TRANSPARENT);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_REFRACT_TRANSLUCENT);
|
||||
gl_state_disable_depth_test();
|
||||
rctx->draw_state.shader_index = -1;
|
||||
}
|
||||
else {
|
||||
vec4 clear_color;
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, (GLfloat*)&clear_color);
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_pass_pre_process(render_context* rctx, draw_pass* a1) {
|
||||
static void draw_pass_preprocess(render_context* rctx, draw_pass* a1) {
|
||||
for (draw_preprocess& i : a1->preprocess)
|
||||
if (i.func)
|
||||
i.func(i.data);
|
||||
}
|
||||
|
||||
void sub_1404A9350(post_process* a1, bool a2) {
|
||||
if (a2) {
|
||||
a1->aet_back_texture.bind();
|
||||
a1->aet_back = 1;
|
||||
}
|
||||
else
|
||||
a1->rend_texture.bind();
|
||||
glViewport(0, 0, a1->render_width, a1->render_height);
|
||||
}
|
||||
|
||||
static void draw_pass_clear(render_context* rctx, draw_pass* a1) {
|
||||
if (true/*a1->field_128*/) {
|
||||
vec4 clear_color = get_clear_color();
|
||||
glClearBufferfv(GL_COLOR, 0, (GLfloat*)&clear_color);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
post_process* pp = &rctx->post_process;
|
||||
if (!a1->sss_data.enable || !a1->sss_data.npr_contour) {
|
||||
pp->set_render_texture();
|
||||
|
||||
if (false/*sub_14063FA90(2)*/) {
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClearDepth(1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
else {
|
||||
vec4 clear_color = get_clear_color();
|
||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||
glClearDepth(1.0f);
|
||||
if (true/*a1->field_128*/)
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
else
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
gl_state_bind_framebuffer(0);
|
||||
}
|
||||
else {
|
||||
if (false/*sub_14063FA90(2)*/) {
|
||||
pp->set_render_texture();
|
||||
|
||||
vec4 clear_color = 0.0f;
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
gl_state_bind_framebuffer(0);
|
||||
}
|
||||
else if (false/*a1->field_128*/) {
|
||||
pp->set_render_texture();
|
||||
|
||||
vec4 clear_color = get_clear_color();
|
||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
gl_state_bind_framebuffer(0);
|
||||
}
|
||||
}
|
||||
glGetError();
|
||||
}
|
||||
|
||||
static void draw_pass_pre_sprite(render_context* rctx, draw_pass* a1) {
|
||||
if (!(false/*sub_14063FA90(2)*/))
|
||||
return;
|
||||
|
||||
post_process* pp = &rctx->post_process;
|
||||
pp->set_render_texture(true);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
shaders_ft.state_matrix_set_mvp(mat4_identity, rctx->camera->projection_aet_3d);
|
||||
gl_state_set_depth_mask(GL_FALSE);
|
||||
gl_state_disable_depth_test();
|
||||
gl_state_enable_blend();
|
||||
gl_state_disable_cull_face();
|
||||
//sub_14063F870(2, 1, pp->aa->mlaa_buffer[1].color_texture->tex);
|
||||
gl_state_enable_cull_face();
|
||||
gl_state_disable_blend();
|
||||
gl_state_enable_depth_test();
|
||||
gl_state_set_depth_mask(GL_TRUE);
|
||||
gl_state_bind_framebuffer(0);
|
||||
glGetError();
|
||||
}
|
||||
|
||||
static void draw_pass_3d(render_context* rctx, draw_pass* a1) {
|
||||
rctx->camera->update_data();
|
||||
rctx->view_mat = rctx->camera->view;
|
||||
rctx->post_process.rend_texture.bind();
|
||||
glViewport(0, 0, rctx->post_process.render_width, rctx->post_process.render_height);
|
||||
rctx->post_process.set_render_texture();
|
||||
draw_pass_set_camera(rctx->camera);
|
||||
if (!a1->sss_data.enable || !a1->sss_data.npr_contour || draw_pass_3d_get_translucent_count(rctx))
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
@@ -827,15 +899,18 @@ static void draw_pass_3d(render_context* rctx, draw_pass* a1) {
|
||||
else
|
||||
draw_pass_3d_shadow_reset(rctx);
|
||||
|
||||
if (a1->enable[DRAW_PASS_REFLECT] && a1->reflect && a1->reflect_texture.color_texture) {
|
||||
gl_state_active_bind_texture_2d(15, a1->reflect_texture.color_texture->tex);
|
||||
if (a1->enable[DRAW_PASS_REFLECT] && a1->reflect) {
|
||||
render_texture& reflect_texture = a1->get_render_texture(0);
|
||||
gl_state_active_bind_texture_2d(15, reflect_texture.color_texture->tex);
|
||||
uniform_value[U_WATER_REFLECT] = 1;
|
||||
}
|
||||
else
|
||||
uniform_value[U_WATER_REFLECT] = 0;
|
||||
|
||||
if (a1->sss_texture)
|
||||
gl_state_active_bind_texture_2d(14, a1->sss_texture->tex);
|
||||
uniform_value[U12] = a1->field_320 ? 1 : 0;
|
||||
|
||||
if (a1->effect_texture)
|
||||
gl_state_active_bind_texture_2d(14, a1->effect_texture->tex);
|
||||
|
||||
gl_state_active_bind_texture_2d(16, a1->sss_data.textures[1].color_texture->tex);
|
||||
gl_state_active_texture(0);
|
||||
@@ -854,7 +929,7 @@ static void draw_pass_3d(render_context* rctx, draw_pass* a1) {
|
||||
if (a1->draw_pass_3d[DRAW_PASS_3D_OPAQUE]) {
|
||||
gl_state_enable_depth_test();
|
||||
gl_state_set_depth_mask(GL_TRUE);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_OPAQUE, 0, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_OPAQUE);
|
||||
gl_state_disable_depth_test();
|
||||
}
|
||||
|
||||
@@ -866,14 +941,17 @@ static void draw_pass_3d(render_context* rctx, draw_pass* a1) {
|
||||
gl_state_enable_depth_test();
|
||||
gl_state_set_depth_mask(GL_TRUE);
|
||||
if (a1->draw_pass_3d[DRAW_PASS_3D_TRANSPARENT])
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSPARENT, 0, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSPARENT);
|
||||
/*if (rctx->draw_pass.field_120)
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TYPE_7, 0, 0, 1, -1);*/
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TYPE_7);*/
|
||||
|
||||
rctx->post_process.exposure->get_exposure_chara_data(&rctx->post_process, rctx->camera);
|
||||
|
||||
//post_process_draw_lens_flare(a1->post_process);
|
||||
//draw_stars(&stars);
|
||||
if (a1->npr_param == 1)
|
||||
draw_pass_3d_contour(rctx, a1);
|
||||
|
||||
//post_process_draw_lens_flare(pp);
|
||||
//star_catalog_data.draw();
|
||||
|
||||
draw_task_draw_objects_by_type_translucent(rctx,
|
||||
a1->draw_pass_3d[DRAW_PASS_3D_OPAQUE],
|
||||
@@ -883,22 +961,22 @@ static void draw_pass_3d(render_context* rctx, draw_pass* a1) {
|
||||
DRAW_OBJECT_TRANSPARENT_ALPHA_ORDER_3,
|
||||
DRAW_OBJECT_TRANSLUCENT_ALPHA_ORDER_3);
|
||||
|
||||
//draw_snow_particle();
|
||||
//draw_rain();
|
||||
//draw_leaf_particle();
|
||||
//draw_particle();
|
||||
snow_particle_draw();
|
||||
rain_particle_draw();
|
||||
leaf_particle_draw();
|
||||
particle_draw();
|
||||
gl_state_disable_depth_test();
|
||||
|
||||
gl_state_set_color_mask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
|
||||
Glitter::glt_particle_manager->DispScenes(Glitter::DISP_ALPHA);
|
||||
gl_state_set_color_mask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
|
||||
if (a1->npr_param == 1) {
|
||||
/*if (a1->npr_param == 1) {
|
||||
gl_state_set_color_mask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
gl_state_set_color_mask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
}
|
||||
}*/
|
||||
|
||||
gl_state_enable_depth_test();
|
||||
|
||||
@@ -906,8 +984,8 @@ static void draw_pass_3d(render_context* rctx, draw_pass* a1) {
|
||||
gl_state_enable_blend();
|
||||
gl_state_set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
gl_state_set_depth_mask(GL_FALSE);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSLUCENT_NO_SHADOW, 0, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSLUCENT, 0, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSLUCENT_NO_SHADOW);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSLUCENT);
|
||||
gl_state_disable_blend();
|
||||
}
|
||||
|
||||
@@ -945,10 +1023,10 @@ static void draw_pass_3d(render_context* rctx, draw_pass* a1) {
|
||||
cam->set_fov(32.2673416137695);
|
||||
draw_pass_set_camera(cam);
|
||||
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_OPAQUE_LOCAL, 0, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSPARENT_LOCAL, 0, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_OPAQUE_LOCAL);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSPARENT_LOCAL);
|
||||
gl_state_enable_blend();
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSLUCENT_LOCAL, 0, 0, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSLUCENT_LOCAL);
|
||||
gl_state_disable_blend();
|
||||
|
||||
draw_task_draw_objects_by_type_translucent(rctx,
|
||||
@@ -966,7 +1044,7 @@ static void draw_pass_3d(render_context* rctx, draw_pass* a1) {
|
||||
draw_pass_set_camera(cam);
|
||||
}
|
||||
|
||||
if (a1->sss_texture)
|
||||
if (a1->effect_texture)
|
||||
gl_state_active_bind_texture_2d(14, 0);
|
||||
|
||||
gl_state_disable_depth_test();
|
||||
@@ -978,6 +1056,36 @@ static void draw_pass_3d(render_context* rctx, draw_pass* a1) {
|
||||
shader::unbind();
|
||||
}
|
||||
|
||||
static void draw_pass_3d_contour(render_context* rctx, draw_pass* a1) {
|
||||
render_texture* rt = &rctx->post_process.rend_texture;
|
||||
render_texture* contour_rt = &rctx->post_process.sss_contour_texture;
|
||||
|
||||
gl_state_enable_blend();
|
||||
gl_state_set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
gl_state_set_blend_equation(GL_FUNC_ADD);
|
||||
gl_state_disable_depth_test();
|
||||
|
||||
shaders_ft.set(SHADER_FT_CONTOUR_NPR);
|
||||
shaders_ft.state_matrix_set_mvp(mat4_identity, mat4_identity);
|
||||
gl_state_active_bind_texture_2d(16, contour_rt->color_texture->tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
gl_state_active_bind_texture_2d(17, contour_rt->depth_texture->tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
gl_state_active_bind_texture_2d(14, rt->depth_texture->tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
render_texture::draw_custom(&shaders_ft);
|
||||
|
||||
draw_pass_set_camera(rctx->camera);
|
||||
|
||||
if (a1->effect_texture)
|
||||
gl_state_active_bind_texture_2d(14, a1->effect_texture->tex);
|
||||
gl_state_enable_depth_test();
|
||||
gl_state_disable_blend();
|
||||
}
|
||||
|
||||
static int32_t draw_pass_3d_get_translucent_count(render_context* rctx) {
|
||||
int32_t count = 0;
|
||||
count += draw_task_get_count(rctx, DRAW_OBJECT_OPAQUE_ALPHA_ORDER_1);
|
||||
@@ -1023,9 +1131,7 @@ static void draw_pass_3d_shadow_set(shadow* shad, render_context* rctx) {
|
||||
vec3* interest;
|
||||
vec3* view_point;
|
||||
if (shad->field_2F5) {
|
||||
v6 = -0.5f;
|
||||
if (i)
|
||||
v6 = 0.5f;
|
||||
v6 = i ? 0.5f : -0.5f;
|
||||
|
||||
interest = &shad->interest[i];
|
||||
view_point = &shad->view_point[i];
|
||||
@@ -1082,8 +1188,8 @@ static void draw_pass_3d_shadow_set(shadow* shad, render_context* rctx) {
|
||||
gl_state_active_bind_texture_2d(6 + i, shad->field_158[1 + i]->color_texture->tex);
|
||||
gl_state_active_texture(0);
|
||||
|
||||
shaders_ft.env_frag_set(12, vec4_identity);
|
||||
shaders_ft.env_frag_set(13, vec4_null);
|
||||
shaders_ft.env_frag_set(12, 1.0f);
|
||||
shaders_ft.env_frag_set(13, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1093,8 +1199,7 @@ static void draw_pass_show_vector(render_context* rctx, draw_pass* a1) {
|
||||
|
||||
rctx->camera->update_data();
|
||||
rctx->view_mat = rctx->camera->view;
|
||||
rctx->post_process.rend_texture.bind();
|
||||
glViewport(0, 0, rctx->post_process.render_width, rctx->post_process.render_height);
|
||||
rctx->post_process.set_render_texture();
|
||||
draw_pass_set_camera(rctx->camera);
|
||||
|
||||
shaders_ft.env_vert_set(20, a1->show_vector_length, a1->show_vector_z_offset, 0.0f, 0.0f);
|
||||
@@ -1103,12 +1208,12 @@ static void draw_pass_show_vector(render_context* rctx, draw_pass* a1) {
|
||||
continue;
|
||||
|
||||
if (a1->draw_pass_3d[DRAW_PASS_3D_OPAQUE])
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_OPAQUE, 0, i, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_OPAQUE, 0, i, true);
|
||||
if (a1->draw_pass_3d[DRAW_PASS_3D_TRANSPARENT])
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSPARENT, 0, i, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSPARENT, 0, i, true);
|
||||
if (a1->draw_pass_3d[DRAW_PASS_3D_TRANSLUCENT]) {
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSLUCENT_NO_SHADOW, 0, i, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSLUCENT, 0, i, 1, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSLUCENT_NO_SHADOW, 0, i, true);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSLUCENT, 0, i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1129,6 +1234,34 @@ static void draw_pass_post_process(render_context* rctx, draw_pass* a1) {
|
||||
}
|
||||
|
||||
static void draw_pass_sprite(render_context* rctx, draw_pass* a1) {
|
||||
post_process* pp = &rctx->post_process;
|
||||
|
||||
if (a1->multisample && a1->multisample_framebuffer) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, a1->multisample_framebuffer);
|
||||
gl_state_enable_multisample();
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
shaders_ft.state_matrix_set_mvp(mat4_identity, rctx->camera->projection_aet_2d);
|
||||
|
||||
gl_state_disable_depth_test();
|
||||
gl_state_enable_blend();
|
||||
gl_state_disable_cull_face();
|
||||
//sub_14063F870(0, 1, pp->aa->mlaa_buffer[1].color_texture->tex);
|
||||
gl_state_enable_cull_face();
|
||||
gl_state_disable_blend();
|
||||
gl_state_enable_depth_test();
|
||||
|
||||
if (a1->multisample && a1->multisample_framebuffer) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
gl_state_disable_multisample();
|
||||
gl_state_bind_read_framebuffer(a1->multisample_framebuffer);
|
||||
glBlitFramebuffer(0, 0, pp->sprite_width, pp->sprite_height,
|
||||
0, 0, pp->sprite_width, pp->sprite_height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
gl_state_bind_read_framebuffer(0);
|
||||
}
|
||||
glGetError();
|
||||
}
|
||||
|
||||
inline static void draw_pass_end(draw_pass* pass, draw_pass_type type) {
|
||||
@@ -1153,17 +1286,8 @@ static void draw_pass_3d_grid(render_context* rctx) {
|
||||
|
||||
grid_shader->use();
|
||||
grid_shader->set("vp", false, rctx->camera->view_projection);
|
||||
gl_state_bind_array_buffer(grid_vbo);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE,
|
||||
sizeof(float_t) * 3, (void*)0); // Pos
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribIPointer(1, 1, GL_INT,
|
||||
sizeof(float_t) * 3, (void*)(sizeof(float_t) * 2)); // Color
|
||||
gl_state_bind_array_buffer(0);
|
||||
gl_state_bind_vertex_array(grid_vao);
|
||||
glDrawArrays(GL_LINES, 0, (GLsizei)grid_vertex_count);
|
||||
glDisableVertexAttribArray(0);
|
||||
glDisableVertexAttribArray(1);
|
||||
gl_state_use_program(0);
|
||||
|
||||
gl_state_disable_depth_test();
|
||||
@@ -1173,13 +1297,14 @@ static void draw_pass_3d_grid(render_context* rctx) {
|
||||
|
||||
static void draw_pass_set_camera(camera* cam) {
|
||||
cam->update_data();
|
||||
shaders_ft.state_matrix_set_modelview(0, cam->view, false);
|
||||
shaders_ft.state_matrix_set_projection(cam->projection, true);
|
||||
shaders_ft.state_matrix_set_mvp(cam->view, cam->projection);
|
||||
shaders_ft.state_matrix_set_program(5, cam->view);
|
||||
|
||||
double_t fov_horizontal_rad = tan(cam->fov_rad * 0.5);
|
||||
|
||||
shaders_ft.env_frag_set(20,
|
||||
(float_t)(0.5 / (cam->fov_rad * cam->aspect)),
|
||||
(float_t)(0.5 / cam->fov_rad),
|
||||
(float_t)(0.5 / (fov_horizontal_rad * cam->aspect)),
|
||||
(float_t)(0.5 / fov_horizontal_rad),
|
||||
0.0f, 0.0f);
|
||||
shaders_ft.env_frag_set(32,
|
||||
(float_t)(cam->max_distance / (cam->max_distance - cam->min_distance)),
|
||||
@@ -1225,8 +1350,7 @@ static void texture_params_get(GLuint tex_0, texture_param* tex_0_param,
|
||||
mat4 mat;
|
||||
mat4_ortho(0.0f, (float_t)tex_0_param->width,
|
||||
0.0f, (float_t)tex_0_param->height, -1.0f, 1.0f, &mat);
|
||||
shaders_ft.state_matrix_set_projection(mat, false);
|
||||
shaders_ft.state_matrix_set_modelview(0, mat4_identity, true);
|
||||
shaders_ft.state_matrix_set_mvp(mat4_identity, mat);
|
||||
glViewport(0, 0, tex_0_param->width, tex_0_param->height);
|
||||
}
|
||||
}
|
||||
|
||||
+60
-39
@@ -12,12 +12,14 @@
|
||||
#include "shader_ft.hpp"
|
||||
|
||||
static void draw_task_add(render_context* rctx, draw_object_type type, draw_task* task);
|
||||
static void draw_task_object_init(draw_task* task, object_data* object_data, mat4* mat,
|
||||
static void draw_task_preprocess_init(draw_task* task, const mat4* mat,
|
||||
void(*func)(render_context* rctx, void* data), void* data);
|
||||
static void draw_task_object_init(draw_task* task, object_data* object_data, const mat4* mat,
|
||||
float_t bounding_radius, obj_sub_mesh* sub_mesh, obj_mesh* mesh, obj_material_data* material,
|
||||
std::vector<GLuint>* textures, int32_t mat_count, mat4* mats, GLuint array_buffer,
|
||||
GLuint element_array_buffer, vec4* blend_color, vec4* emission, int32_t morph_array_buffer,
|
||||
int32_t instances_count, mat4* instances_mat, void(*draw_object_func)(draw_object*));
|
||||
static void draw_task_object_translucent_init(draw_task* task, mat4* mat,
|
||||
static void draw_task_object_translucent_init(draw_task* task, const mat4* mat,
|
||||
draw_task_object_translucent* object);
|
||||
static int draw_task_sort_quicksort_compare0(void const* src1, void const* src2);
|
||||
static int draw_task_sort_quicksort_compare1(void const* src1, void const* src2);
|
||||
@@ -41,7 +43,7 @@ void draw_task_draw_objects_by_type(render_context* rctx, draw_object_type type,
|
||||
gl_state_active_bind_texture_2d(i, 0);
|
||||
gl_state_active_texture(0);
|
||||
gl_state_set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glPrimitiveRestartIndex(0xFFFF);
|
||||
gl_state_set_primitive_restart_index(0xFFFF);
|
||||
uniform_value_reset();
|
||||
gl_state_get();
|
||||
|
||||
@@ -241,17 +243,17 @@ void draw_task_draw_objects_by_type_translucent(render_context* rctx, bool opaqu
|
||||
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
if (opaque_enable && draw_task_get_count(rctx, opaque))
|
||||
draw_task_draw_objects_by_type(rctx, opaque, 0, 0, 1, alpha);
|
||||
draw_task_draw_objects_by_type(rctx, opaque, 0, 0, true, alpha);
|
||||
if (transparent_enable && draw_task_get_count(rctx, transparent))
|
||||
draw_task_draw_objects_by_type(rctx, transparent, 0, 0, 1, alpha);
|
||||
draw_task_draw_objects_by_type(rctx, transparent, 0, 0, true, alpha);
|
||||
if (translucent_enable && draw_task_get_count(rctx, translucent)) {
|
||||
gl_state_enable_blend();
|
||||
draw_task_draw_objects_by_type(rctx, translucent, 0, 0, 1, alpha);
|
||||
draw_task_draw_objects_by_type(rctx, translucent, 0, 0, true, alpha);
|
||||
gl_state_disable_blend();
|
||||
}
|
||||
|
||||
pp->buf_texture.bind();
|
||||
render_texture::shader_set_glsl(&pp->alpha_layer_shader);
|
||||
pp->alpha_layer_shader.use();
|
||||
gl_state_active_bind_texture_2d(0, pp->alpha_layer_texture.color_texture->tex);
|
||||
gl_state_active_bind_texture_2d(1, pp->rend_texture.color_texture->tex);
|
||||
glUniform1f(0, (float_t)(alpha * (1.0 / 255.0)));
|
||||
@@ -269,7 +271,7 @@ inline int32_t draw_task_get_count(render_context* rctx, draw_object_type type)
|
||||
}
|
||||
|
||||
bool draw_task_add_draw_object(render_context* rctx, obj* object,
|
||||
obj_mesh_vertex_buffer* obj_vertex_buf, obj_mesh_index_buffer* obj_index_buf, mat4* mat,
|
||||
obj_mesh_vertex_buffer* obj_vertex_buf, obj_mesh_index_buffer* obj_index_buf, const mat4* mat,
|
||||
std::vector<GLuint>* textures, vec4* blend_color, mat4* bone_mat, obj* object_morph,
|
||||
obj_mesh_vertex_buffer* obj_morph_vertex_buf, int32_t instances_count,
|
||||
mat4* instances_mat, void(*draw_object_func)(draw_object*), bool enable_bone_mat, bool local) {
|
||||
@@ -357,22 +359,22 @@ bool draw_task_add_draw_object(render_context* rctx, obj* object,
|
||||
}
|
||||
object_data->passed.submesh_array++;
|
||||
|
||||
int32_t bone_indices_count = sub_mesh->bone_indices_count;
|
||||
uint16_t* bone_indices = sub_mesh->bone_indices;
|
||||
int32_t num_bone_index = sub_mesh->num_bone_index;
|
||||
uint16_t* bone_index = sub_mesh->bone_index_array;
|
||||
|
||||
mat4* mats;
|
||||
if (bone_indices_count && enable_bone_mat) {
|
||||
mats = object_data->buffer.add_mat4(bone_indices_count);
|
||||
if (num_bone_index && enable_bone_mat) {
|
||||
mats = object_data->buffer.add_mat4(num_bone_index);
|
||||
if (bone_mat)
|
||||
for (int32_t k = 0; k < bone_indices_count; k++)
|
||||
mats[k] = bone_mat[*bone_indices++];
|
||||
for (int32_t k = 0; k < num_bone_index; k++, bone_index++)
|
||||
mats[k] = bone_mat[*bone_index];
|
||||
else
|
||||
for (int32_t k = 0; k < bone_indices_count; k++)
|
||||
for (int32_t k = 0; k < num_bone_index; k++)
|
||||
mats[k] = mat4_identity;
|
||||
}
|
||||
else {
|
||||
mats = 0;
|
||||
bone_indices_count = 0;
|
||||
num_bone_index = 0;
|
||||
}
|
||||
|
||||
obj_material_data* material = &object->material_array[sub_mesh->material_index];
|
||||
@@ -401,8 +403,8 @@ bool draw_task_add_draw_object(render_context* rctx, obj* object,
|
||||
break;
|
||||
}
|
||||
|
||||
vec4 _blend_color = vec4_identity;
|
||||
vec4 _emission = vec4_null;
|
||||
vec4 _blend_color = 1.0f;
|
||||
vec4 _emission = 0.0f;
|
||||
|
||||
if (mat_list) {
|
||||
bool has_blend_color = false;
|
||||
@@ -464,7 +466,7 @@ bool draw_task_add_draw_object(render_context* rctx, obj* object,
|
||||
}
|
||||
|
||||
draw_task_object_init(task, object_data, mat, object->bounding_sphere.radius, sub_mesh,
|
||||
mesh, material, textures, bone_indices_count, mats, array_buffer, element_array_buffer,
|
||||
mesh, material, textures, num_bone_index, mats, array_buffer, element_array_buffer,
|
||||
&_blend_color, &_emission, morph_array_buffer, instances_count, instances_mat, draw_object_func);
|
||||
|
||||
if (draw_task_flags & DRAW_TASK_SHADOW_OBJECT) {
|
||||
@@ -627,8 +629,9 @@ bool draw_task_add_draw_object(render_context* rctx, obj* object,
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void draw_task_add_draw_object_by_obj(render_context* rctx, mat4* mat, obj* obj, std::vector<GLuint>* textures,
|
||||
obj_mesh_vertex_buffer* obj_vert_buf, obj_mesh_index_buffer* obj_index_buf, mat4* bone_mat, float_t alpha) {
|
||||
inline void draw_task_add_draw_object_by_obj(render_context* rctx, const mat4* mat,
|
||||
obj* obj, std::vector<GLuint>* textures, obj_mesh_vertex_buffer* obj_vert_buf,
|
||||
obj_mesh_index_buffer* obj_index_buf, mat4* bone_mat, float_t alpha) {
|
||||
if (!obj)
|
||||
return;
|
||||
|
||||
@@ -639,14 +642,14 @@ inline void draw_task_add_draw_object_by_obj(render_context* rctx, mat4* mat, ob
|
||||
bone_mat, 0, 0, 0, 0, 0, !!bone_mat);
|
||||
}
|
||||
|
||||
inline bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4* mat,
|
||||
inline bool draw_task_add_draw_object_by_object_info(render_context* rctx, const mat4* mat,
|
||||
object_info obj_info, mat4* bone_mat) {
|
||||
vec4 blend_color = vec4_identity;
|
||||
vec4 blend_color = 1.0f;
|
||||
return draw_task_add_draw_object_by_object_info(rctx,
|
||||
mat, obj_info, &blend_color, bone_mat, 0, 0, 0, true);
|
||||
}
|
||||
|
||||
bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4* mat,
|
||||
bool draw_task_add_draw_object_by_object_info(render_context* rctx, const mat4* mat,
|
||||
object_info obj_info, vec4* blend_color, mat4* bone_mat, int32_t instances_count,
|
||||
mat4* instances_mat, void(*draw_object_func)(draw_object*), bool enable_bone_mat, bool local) {
|
||||
if (obj_info.id == -1 && obj_info.set_id == -1)
|
||||
@@ -673,22 +676,22 @@ bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4* mat,
|
||||
instances_count, instances_mat, draw_object_func, enable_bone_mat, local);
|
||||
}
|
||||
|
||||
inline bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4* mat,
|
||||
inline bool draw_task_add_draw_object_by_object_info(render_context* rctx, const mat4* mat,
|
||||
object_info obj_info, float_t alpha, mat4* bone_mat) {
|
||||
vec4 blend_color = vec4_identity;
|
||||
vec4 blend_color = 1.0f;
|
||||
blend_color.w = alpha;
|
||||
return draw_task_add_draw_object_by_object_info(rctx,
|
||||
mat, obj_info, &blend_color, bone_mat, 0, 0, 0, true);
|
||||
}
|
||||
|
||||
inline bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4* mat,
|
||||
inline bool draw_task_add_draw_object_by_object_info(render_context* rctx, const mat4* mat,
|
||||
object_info obj_info, float_t r, float_t g, float_t b, float_t a, mat4* bone_mat, bool local) {
|
||||
vec4 blend_color = { r, g, b, a };
|
||||
return draw_task_add_draw_object_by_object_info(rctx,
|
||||
mat, obj_info, &blend_color, bone_mat, 0, 0, 0, true, local);
|
||||
}
|
||||
|
||||
inline bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4* mat,
|
||||
inline bool draw_task_add_draw_object_by_object_info(render_context* rctx, const mat4* mat,
|
||||
object_info obj_info, vec4* blend_color, mat4* bone_mat, bool local) {
|
||||
return draw_task_add_draw_object_by_object_info(rctx,
|
||||
mat, obj_info, blend_color, 0, 0, 0, 0, false, local);
|
||||
@@ -696,7 +699,7 @@ inline bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4*
|
||||
|
||||
void draw_task_add_draw_object_by_object_info_object_skin(render_context* rctx, object_info obj_info,
|
||||
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) {
|
||||
mat4* matrices, mat4* ex_data_matrices, const mat4* mat, mat4* global_mat) {
|
||||
obj_skin* skin = object_storage_get_obj_skin(obj_info);
|
||||
if (!skin)
|
||||
return;
|
||||
@@ -753,6 +756,16 @@ void draw_task_add_draw_object_by_object_info_object_skin(render_context* rctx,
|
||||
}
|
||||
}
|
||||
|
||||
void draw_task_add_draw_preprocess(render_context* rctx, const mat4* mat,
|
||||
void(*func)(render_context* rctx, void* data), void* data, draw_object_type type) {
|
||||
object_data* object_data = &rctx->object_data;
|
||||
draw_task* task = object_data->buffer.add_draw_task(DRAW_TASK_OBJECT_PREPROCESS);
|
||||
if (task) {
|
||||
draw_task_preprocess_init(task, mat, func, data);
|
||||
draw_task_add(rctx, type, task);
|
||||
}
|
||||
}
|
||||
|
||||
void draw_task_sort(render_context* rctx, draw_object_type type, int32_t compare_func) {
|
||||
std::vector<draw_task*>& vec = rctx->object_data.draw_task_array[type];
|
||||
if (vec.size() < 1)
|
||||
@@ -771,16 +784,16 @@ void draw_task_sort(render_context* rctx, draw_object_type type, int32_t compare
|
||||
model_mat_face_camera_position(&rctx->camera->view, &mat, &mat);
|
||||
|
||||
obj_sub_mesh* sub_mesh = task->data.object.sub_mesh;
|
||||
if (task->data.object.mat_count < 1 || !sub_mesh->bone_indices_count)
|
||||
if (task->data.object.mat_count < 1 || !sub_mesh->num_bone_index)
|
||||
mat4_mult_vec3_trans(&mat, &sub_mesh->bounding_sphere.center, ¢er);
|
||||
else {
|
||||
vec3 center_sum = vec3_null;
|
||||
for (uint32_t j = 0; j < sub_mesh->bone_indices_count; j++) {
|
||||
vec3 center_sum = 0.0f;
|
||||
for (uint32_t j = 0; j < sub_mesh->num_bone_index; j++) {
|
||||
center = sub_mesh->bounding_sphere.center;
|
||||
mat4_mult_vec3_trans(&task->data.object.mats[j], ¢er, ¢er);
|
||||
center_sum += center;
|
||||
}
|
||||
center_sum *= 1.0f / (float_t)sub_mesh->bone_indices_count;
|
||||
center_sum *= 1.0f / (float_t)sub_mesh->num_bone_index;
|
||||
}
|
||||
task->bounding_radius = task->data.object.mesh->bounding_sphere.radius;
|
||||
}
|
||||
@@ -806,7 +819,7 @@ void draw_task_sort(render_context* rctx, draw_object_type type, int32_t compare
|
||||
}
|
||||
|
||||
int32_t obj_axis_aligned_bounding_box_check_visibility(
|
||||
obj_axis_aligned_bounding_box* aabb, camera* cam, mat4* mat) {
|
||||
obj_axis_aligned_bounding_box* aabb, camera* cam, const mat4* mat) {
|
||||
vec3 points[8];
|
||||
points[0] = aabb->center + (aabb->size ^ vec3( 0.0f, 0.0f, 0.0f));
|
||||
points[1] = aabb->center + (aabb->size ^ vec3(-0.0f, -0.0f, -0.0f));
|
||||
@@ -849,7 +862,7 @@ int32_t obj_axis_aligned_bounding_box_check_visibility(
|
||||
}
|
||||
|
||||
int32_t object_bounding_sphere_check_visibility(obj_bounding_sphere* sphere,
|
||||
object_data* object_data, camera* cam, mat4* mat) {
|
||||
object_data* object_data, camera* cam, const mat4* mat) {
|
||||
if (object_data->object_bounding_sphere_check_func)
|
||||
return object_data->object_bounding_sphere_check_func(sphere, cam);
|
||||
|
||||
@@ -889,7 +902,15 @@ inline static void draw_task_add(render_context* rctx, draw_object_type type, dr
|
||||
rctx->object_data.draw_task_array[type].push_back(task);
|
||||
}
|
||||
|
||||
inline static void draw_task_object_init(draw_task* task, object_data* object_data, mat4* mat,
|
||||
inline static void draw_task_preprocess_init(draw_task* task, const mat4* mat,
|
||||
void(*func)(render_context* rctx, void* data), void* data) {
|
||||
task->type = DRAW_TASK_OBJECT_PREPROCESS;
|
||||
task->mat = *mat;
|
||||
task->data.preprocess.func = func;
|
||||
task->data.preprocess.data = data;
|
||||
}
|
||||
|
||||
inline static void draw_task_object_init(draw_task* task, object_data* object_data, const mat4* mat,
|
||||
float_t bounding_radius, obj_sub_mesh* sub_mesh, obj_mesh* mesh, obj_material_data* material,
|
||||
std::vector<GLuint>* textures, int32_t mat_count, mat4* mats, GLuint array_buffer,
|
||||
GLuint element_array_buffer, vec4* blend_color, vec4* emission, int32_t morph_array_buffer,
|
||||
@@ -917,13 +938,13 @@ inline static void draw_task_object_init(draw_task* task, object_data* object_da
|
||||
for (int32_t i = 0; i < object_data->texture_transform_count && i < TEXTURE_TRANSFORM_COUNT; i++)
|
||||
draw->texture_transform_array[i] = object_data->texture_transform_array[i];
|
||||
|
||||
if (blend_color && memcmp(blend_color, &vec4_identity, sizeof(vec4))) {
|
||||
if (blend_color && *blend_color != 1.0f) {
|
||||
draw->set_blend_color = true;
|
||||
draw->blend_color = *blend_color;
|
||||
}
|
||||
else {
|
||||
draw->set_blend_color = false;
|
||||
draw->blend_color = vec4_identity;
|
||||
draw->blend_color = 1.0f;
|
||||
}
|
||||
|
||||
draw->emission = *emission;
|
||||
@@ -943,7 +964,7 @@ inline static void draw_task_object_init(draw_task* task, object_data* object_da
|
||||
object_data->add_vertex_array(&task->data.object);
|
||||
}
|
||||
|
||||
inline static void draw_task_object_translucent_init(draw_task* task, mat4* mat,
|
||||
inline static void draw_task_object_translucent_init(draw_task* task, const mat4* mat,
|
||||
draw_task_object_translucent* object) {
|
||||
task->type = DRAW_TASK_OBJECT_TRANSLUCENT;
|
||||
task->mat = *mat;
|
||||
|
||||
+15
-12
@@ -12,34 +12,37 @@
|
||||
#include "draw_primitive.hpp"
|
||||
|
||||
extern void draw_task_draw_objects_by_type(render_context* rctx, draw_object_type type,
|
||||
int32_t a2, int32_t a3, bool a4, int32_t alpha);
|
||||
int32_t a2 = 0, int32_t a3 = 0, bool a4 = true, int32_t alpha = -1);
|
||||
extern void draw_task_draw_objects_by_type_translucent(render_context* rctx, bool opaque_enable,
|
||||
bool transparent_enable, bool translucent_enable, draw_object_type opaque,
|
||||
draw_object_type transparent, draw_object_type translucent);
|
||||
extern int32_t draw_task_get_count(render_context* rctx, draw_object_type type);
|
||||
extern bool draw_task_add_draw_object(render_context* rctx, obj* object,
|
||||
obj_mesh_vertex_buffer* obj_vertex_buf, obj_mesh_index_buffer* obj_index_buf, mat4* mat,
|
||||
obj_mesh_vertex_buffer* obj_vertex_buf, obj_mesh_index_buffer* obj_index_buf, const mat4* mat,
|
||||
std::vector<GLuint>* textures, vec4* blend_color, mat4* bone_mat, obj* object_morph,
|
||||
obj_mesh_vertex_buffer* obj_morph_vertex_buf, int32_t instances_count,
|
||||
mat4* instances_mat, void(*draw_object_func)(draw_object*), bool enable_bone_mat, bool local = false);
|
||||
extern void draw_task_add_draw_object_by_obj(render_context* rctx, mat4* mat, obj* obj, std::vector<GLuint>* textures,
|
||||
obj_mesh_vertex_buffer* obj_vert_buf, obj_mesh_index_buffer* obj_index_buf, mat4* bone_mat, float_t alpha);
|
||||
extern bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4* mat,
|
||||
extern void draw_task_add_draw_object_by_obj(render_context* rctx, const mat4* mat,
|
||||
obj* obj, std::vector<GLuint>* textures, obj_mesh_vertex_buffer* obj_vert_buf,
|
||||
obj_mesh_index_buffer* obj_index_buf, mat4* bone_mat, float_t alpha);
|
||||
extern bool draw_task_add_draw_object_by_object_info(render_context* rctx, const mat4* mat,
|
||||
object_info obj_info, mat4* bone_mat = 0);
|
||||
extern bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4* mat,
|
||||
extern bool draw_task_add_draw_object_by_object_info(render_context* rctx, const mat4* mat,
|
||||
object_info obj_info, vec4* blend_color, mat4* bone_mat, int32_t instances_count,
|
||||
mat4* instances_mat, void(*draw_object_func)(draw_object*), bool enable_bone_mat, bool local = false);
|
||||
extern bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4* mat,
|
||||
extern bool draw_task_add_draw_object_by_object_info(render_context* rctx, const mat4* mat,
|
||||
object_info obj_info, float_t alpha, mat4* bone_mat = 0);
|
||||
extern bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4* mat,
|
||||
extern bool draw_task_add_draw_object_by_object_info(render_context* rctx, const mat4* mat,
|
||||
object_info obj_info, float_t r, float_t g, float_t b, float_t a, mat4* bone_mat = 0, bool local = false);
|
||||
extern bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4* mat,
|
||||
extern bool draw_task_add_draw_object_by_object_info(render_context* rctx, const mat4* mat,
|
||||
object_info obj_info, vec4* blend_color, mat4* bone_mat = 0, bool local = false);
|
||||
extern void draw_task_add_draw_object_by_object_info_object_skin(render_context* rctx, object_info obj_info,
|
||||
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);
|
||||
mat4* matrices, mat4* ex_data_matrices, const mat4* mat, mat4* global_mat);
|
||||
extern void draw_task_add_draw_preprocess(render_context* rctx, const mat4* mat,
|
||||
void(*func)(render_context* rctx, void* data), void* data, draw_object_type type);
|
||||
extern void draw_task_sort(render_context* rctx, draw_object_type type, int32_t compare_func);
|
||||
extern int32_t obj_axis_aligned_bounding_box_check_visibility(
|
||||
obj_axis_aligned_bounding_box* aabb, camera* cam, mat4* mat);
|
||||
obj_axis_aligned_bounding_box* aabb, camera* cam, const mat4* mat);
|
||||
extern int32_t object_bounding_sphere_check_visibility(obj_bounding_sphere* sphere,
|
||||
object_data* object_data, camera* cam, mat4* mat);
|
||||
object_data* object_data, camera* cam, const mat4* mat);
|
||||
|
||||
+12
-10
@@ -16,7 +16,7 @@ struct farc_read_handler {
|
||||
farc* farc;
|
||||
|
||||
farc_read_handler();
|
||||
virtual ~farc_read_handler();
|
||||
~farc_read_handler();
|
||||
|
||||
size_t get_file_size(std::string& file);
|
||||
bool read(std::string& file_path, bool cache);
|
||||
@@ -41,7 +41,7 @@ struct file_handler_storage {
|
||||
int32_t field_74;
|
||||
|
||||
file_handler_storage();
|
||||
virtual ~file_handler_storage();
|
||||
~file_handler_storage();
|
||||
};
|
||||
|
||||
file_handler_storage* file_handler_storage_data;
|
||||
@@ -203,17 +203,19 @@ void file_handler_storage_ctrl() {
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> u_lock(file_handler_storage_data->mtx);
|
||||
if (!file_handler_storage_data->deque.size()) {
|
||||
for (file_handler*& i : file_handler_storage_data->list)
|
||||
std::list<file_handler*>& list = file_handler_storage_data->list;
|
||||
std::deque<file_handler*>& deque = file_handler_storage_data->deque;
|
||||
if (!deque.size()) {
|
||||
for (file_handler*& i : list)
|
||||
if (i->not_ready && !i->reading) {
|
||||
{
|
||||
std::unique_lock<std::mutex> u_lock(i->mtx);
|
||||
i->count++;
|
||||
}
|
||||
file_handler_storage_data->deque.push_back(i);
|
||||
deque.push_back(i);
|
||||
}
|
||||
|
||||
if (file_handler_storage_data->deque.size())
|
||||
if (deque.size())
|
||||
file_handler_storage_data->cnd.notify_all();
|
||||
}
|
||||
}
|
||||
@@ -293,12 +295,12 @@ static bool file_handler_load_farc_file(void* data, const char* dir, const char*
|
||||
}
|
||||
|
||||
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;
|
||||
std::list<file_handler*>& list = file_handler_storage_data->list;
|
||||
for (std::list<file_handler*>::iterator i = list.begin(); i != list.end();) {
|
||||
file_handler* pfhndl = *i;
|
||||
if (pfhndl->count == 1) {
|
||||
pfhndl->free_data_lock();
|
||||
i = file_handler_storage_data->list.erase(i);
|
||||
i = list.erase(i);
|
||||
}
|
||||
else {
|
||||
if (!pfhndl->not_ready && !pfhndl->callback[0].ready)
|
||||
|
||||
+82
-65
@@ -7,7 +7,7 @@
|
||||
|
||||
gl_state_struct gl_state;
|
||||
|
||||
inline void gl_state_active_bind_texture_2d(int32_t index, GLuint texture) {
|
||||
void gl_state_active_bind_texture_2d(int32_t index, GLuint texture) {
|
||||
if (gl_state.texture_binding_2d[index] != texture) {
|
||||
if (gl_state.active_texture_index != index) {
|
||||
glActiveTexture((GLenum)(GL_TEXTURE0 + index));
|
||||
@@ -19,7 +19,7 @@ inline void gl_state_active_bind_texture_2d(int32_t index, GLuint texture) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_active_bind_texture_cube_map(int32_t index, GLuint texture) {
|
||||
void gl_state_active_bind_texture_cube_map(int32_t index, GLuint texture) {
|
||||
if (gl_state.texture_binding_cube_map[index] != texture) {
|
||||
if (gl_state.active_texture_index != index) {
|
||||
glActiveTexture((GLenum)(GL_TEXTURE0 + index));
|
||||
@@ -31,7 +31,7 @@ inline void gl_state_active_bind_texture_cube_map(int32_t index, GLuint texture)
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_active_texture(size_t index) {
|
||||
void gl_state_active_texture(size_t index) {
|
||||
if (gl_state.active_texture_index != index) {
|
||||
glActiveTexture((GLenum)(GL_TEXTURE0 + index));
|
||||
gl_state.active_texture = (GLenum)(GL_TEXTURE0 + index);
|
||||
@@ -39,7 +39,7 @@ inline void gl_state_active_texture(size_t index) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_bind_framebuffer(GLuint framebuffer) {
|
||||
void gl_state_bind_framebuffer(GLuint framebuffer) {
|
||||
if (gl_state.read_framebuffer_binding != framebuffer
|
||||
|| gl_state.draw_framebuffer_binding != framebuffer) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
||||
@@ -48,49 +48,46 @@ inline void gl_state_bind_framebuffer(GLuint framebuffer) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_bind_read_framebuffer(GLuint framebuffer) {
|
||||
void gl_state_bind_read_framebuffer(GLuint framebuffer) {
|
||||
if (gl_state.read_framebuffer_binding != framebuffer) {
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
|
||||
gl_state.read_framebuffer_binding = framebuffer;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_bind_draw_framebuffer(GLuint framebuffer) {
|
||||
void gl_state_bind_draw_framebuffer(GLuint framebuffer) {
|
||||
if (gl_state.draw_framebuffer_binding != framebuffer) {
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
|
||||
gl_state.draw_framebuffer_binding = framebuffer;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_bind_vertex_array(GLuint array) {
|
||||
if (gl_state.vertex_array_binding != array) {
|
||||
void gl_state_bind_vertex_array(GLuint array, bool force) {
|
||||
if (gl_state.vertex_array_binding != array || force) {
|
||||
glBindVertexArray(array);
|
||||
gl_state.vertex_array_binding = array;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_bind_array_buffer(GLuint buffer) {
|
||||
if (gl_state.array_buffer_binding != buffer) {
|
||||
void gl_state_bind_array_buffer(GLuint buffer, bool force) {
|
||||
if (gl_state.array_buffer_binding != buffer || force) {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
gl_state.array_buffer_binding = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_bind_element_array_buffer(GLuint buffer) {
|
||||
if (gl_state.element_array_buffer_binding != buffer) {
|
||||
void gl_state_bind_element_array_buffer(GLuint buffer, bool force) {
|
||||
if (gl_state.element_array_buffer_binding != buffer || force) {
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
|
||||
gl_state.element_array_buffer_binding = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_bind_uniform_buffer(GLuint buffer) {
|
||||
if (gl_state.uniform_buffer_binding[gl_state.uniform_buffer_index] != buffer) {
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, buffer);
|
||||
gl_state.uniform_buffer_binding[gl_state.uniform_buffer_index] = buffer;
|
||||
}
|
||||
void gl_state_bind_uniform_buffer(GLuint buffer, bool force) {
|
||||
gl_state_bind_uniform_buffer_base(gl_state.uniform_buffer_index, buffer);
|
||||
}
|
||||
|
||||
inline void gl_state_bind_uniform_buffer_base(GLuint index, GLuint buffer) {
|
||||
void gl_state_bind_uniform_buffer_base(GLuint index, GLuint buffer, bool force) {
|
||||
if (gl_state.uniform_buffer_binding[index] != buffer) {
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, index, buffer);
|
||||
gl_state.uniform_buffer_binding[index] = buffer;
|
||||
@@ -100,8 +97,8 @@ inline void gl_state_bind_uniform_buffer_base(GLuint index, GLuint buffer) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_bind_uniform_buffer_range(GLuint index,
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size) {
|
||||
void gl_state_bind_uniform_buffer_range(GLuint index,
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size, bool force) {
|
||||
if (gl_state.uniform_buffer_binding[index] != buffer
|
||||
|| gl_state.uniform_buffer_offset[index] != offset
|
||||
|| gl_state.uniform_buffer_size[index] != size) {
|
||||
@@ -113,14 +110,11 @@ inline void gl_state_bind_uniform_buffer_range(GLuint index,
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_bind_shader_storage_buffer(GLuint buffer) {
|
||||
if (gl_state.shader_storage_buffer_binding[gl_state.shader_storage_buffer_index] != buffer) {
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer);
|
||||
gl_state.shader_storage_buffer_binding[gl_state.shader_storage_buffer_index] = buffer;
|
||||
}
|
||||
void gl_state_bind_shader_storage_buffer(GLuint buffer, bool force) {
|
||||
gl_state_bind_shader_storage_buffer_base(gl_state.shader_storage_buffer_index, buffer);
|
||||
}
|
||||
|
||||
inline void gl_state_bind_shader_storage_buffer_base(GLuint index, GLuint buffer) {
|
||||
void gl_state_bind_shader_storage_buffer_base(GLuint index, GLuint buffer, bool force) {
|
||||
if (gl_state.shader_storage_buffer_binding[index] != buffer) {
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, index, buffer);
|
||||
gl_state.shader_storage_buffer_binding[index] = buffer;
|
||||
@@ -130,8 +124,8 @@ inline void gl_state_bind_shader_storage_buffer_base(GLuint index, GLuint buffer
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_bind_shader_storage_buffer_range(GLuint index,
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size) {
|
||||
void gl_state_bind_shader_storage_buffer_range(GLuint index,
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size, bool force) {
|
||||
if (gl_state.shader_storage_buffer_binding[index] != buffer
|
||||
|| gl_state.shader_storage_buffer_offset[index] != offset
|
||||
|| gl_state.shader_storage_buffer_size[index] != size) {
|
||||
@@ -143,133 +137,147 @@ inline void gl_state_bind_shader_storage_buffer_range(GLuint index,
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_bind_texture_2d(GLuint texture) {
|
||||
void gl_state_bind_texture_2d(GLuint texture) {
|
||||
if (gl_state.texture_binding_2d[gl_state.active_texture_index] != texture) {
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
gl_state.texture_binding_2d[gl_state.active_texture_index] = texture;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_bind_texture_cube_map(GLuint texture) {
|
||||
void gl_state_bind_texture_cube_map(GLuint texture) {
|
||||
if (gl_state.texture_binding_cube_map[gl_state.active_texture_index] != texture) {
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
|
||||
gl_state.texture_binding_cube_map[gl_state.active_texture_index] = texture;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_bind_sampler(int32_t index, GLuint sampler) {
|
||||
void gl_state_bind_sampler(int32_t index, GLuint sampler) {
|
||||
if (gl_state.sampler_binding[index] != sampler) {
|
||||
glBindSampler(index, sampler);
|
||||
gl_state.sampler_binding[index] = sampler;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool gl_state_check_uniform_buffer_binding() {
|
||||
bool gl_state_check_uniform_buffer_binding() {
|
||||
return gl_state.uniform_buffer_binding[gl_state.uniform_buffer_index] != 0;
|
||||
}
|
||||
|
||||
inline bool gl_state_check_uniform_buffer_binding_base(size_t index) {
|
||||
bool gl_state_check_uniform_buffer_binding_base(size_t index) {
|
||||
return gl_state.uniform_buffer_binding[index] != 0;
|
||||
}
|
||||
|
||||
inline bool gl_state_check_shader_storage_buffer_binding() {
|
||||
bool gl_state_check_shader_storage_buffer_binding() {
|
||||
return gl_state.shader_storage_buffer_binding[gl_state.shader_storage_buffer_index] != 0;
|
||||
}
|
||||
|
||||
inline bool gl_state_check_shader_storage_buffer_binding_base(size_t index) {
|
||||
bool gl_state_check_shader_storage_buffer_binding_base(size_t index) {
|
||||
return gl_state.shader_storage_buffer_binding[index] != 0;
|
||||
}
|
||||
|
||||
inline bool gl_state_check_texture_binding_2d(size_t index) {
|
||||
bool gl_state_check_texture_binding_2d(size_t index) {
|
||||
return gl_state.texture_binding_2d[index] != 0;
|
||||
}
|
||||
|
||||
inline bool gl_state_check_texture_binding_cube_map(size_t index) {
|
||||
bool gl_state_check_texture_binding_cube_map(size_t index) {
|
||||
return gl_state.texture_binding_cube_map[index] != 0;
|
||||
}
|
||||
|
||||
inline bool gl_state_check_sampler_binding(int32_t index, GLuint sampler) {
|
||||
bool gl_state_check_sampler_binding(int32_t index, GLuint sampler) {
|
||||
return gl_state.sampler_binding[index] != 0;
|
||||
}
|
||||
|
||||
inline void gl_state_disable_blend() {
|
||||
void gl_state_disable_blend() {
|
||||
if (gl_state.blend) {
|
||||
glDisable(GL_BLEND);
|
||||
gl_state.blend = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_disable_cull_face() {
|
||||
void gl_state_disable_cull_face() {
|
||||
if (gl_state.cull_face) {
|
||||
glDisable(GL_CULL_FACE);
|
||||
gl_state.cull_face = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_disable_depth_test() {
|
||||
void gl_state_disable_depth_test() {
|
||||
if (gl_state.depth_test) {
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
gl_state.depth_test = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_disable_primitive_restart() {
|
||||
if (!gl_state.primitive_restart) {
|
||||
void gl_state_disable_multisample() {
|
||||
if (gl_state.multisample) {
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
gl_state.multisample = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_disable_primitive_restart() {
|
||||
if (gl_state.primitive_restart) {
|
||||
glDisable(GL_PRIMITIVE_RESTART);
|
||||
gl_state.primitive_restart = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_disable_scissor_test() {
|
||||
void gl_state_disable_scissor_test() {
|
||||
if (gl_state.scissor_test) {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
gl_state.scissor_test = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_disable_stencil_test() {
|
||||
void gl_state_disable_stencil_test() {
|
||||
if (gl_state.stencil_test) {
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
gl_state.stencil_test = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_enable_blend() {
|
||||
void gl_state_enable_blend() {
|
||||
if (!gl_state.blend) {
|
||||
glEnable(GL_BLEND);
|
||||
gl_state.blend = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_enable_cull_face() {
|
||||
void gl_state_enable_cull_face() {
|
||||
if (!gl_state.cull_face) {
|
||||
glEnable(GL_CULL_FACE);
|
||||
gl_state.cull_face = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_enable_depth_test() {
|
||||
void gl_state_enable_depth_test() {
|
||||
if (!gl_state.depth_test) {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
gl_state.depth_test = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_enable_primitive_restart() {
|
||||
void gl_state_enable_multisample() {
|
||||
if (!gl_state.multisample) {
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
gl_state.multisample = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_enable_primitive_restart() {
|
||||
if (!gl_state.primitive_restart) {
|
||||
glEnable(GL_PRIMITIVE_RESTART);
|
||||
gl_state.primitive_restart = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_enable_scissor_test() {
|
||||
void gl_state_enable_scissor_test() {
|
||||
if (!gl_state.scissor_test) {
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
gl_state.scissor_test = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_enable_stencil_test() {
|
||||
void gl_state_enable_stencil_test() {
|
||||
if (!gl_state.stencil_test) {
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
gl_state.stencil_test = GL_TRUE;
|
||||
@@ -328,7 +336,9 @@ void gl_state_get() {
|
||||
glGetBooleanv(GL_DEPTH_TEST, &gl_state.depth_test);
|
||||
glGetIntegerv(GL_DEPTH_FUNC, (GLint*)&gl_state.depth_func);
|
||||
glGetBooleanv(GL_DEPTH_WRITEMASK, &gl_state.depth_mask);
|
||||
glGetBooleanv(GL_MULTISAMPLE, &gl_state.multisample);
|
||||
glGetBooleanv(GL_PRIMITIVE_RESTART, &gl_state.primitive_restart);
|
||||
glGetIntegerv(GL_PRIMITIVE_RESTART_INDEX, (GLint*)&gl_state.primitive_restart_index);
|
||||
glGetBooleanv(GL_SCISSOR_TEST, &gl_state.scissor_test);
|
||||
glGetBooleanv(GL_STENCIL_TEST, &gl_state.stencil_test);
|
||||
glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint*)&gl_state.stencil_mask);
|
||||
@@ -338,17 +348,17 @@ void gl_state_get() {
|
||||
gl_state.polygon_back_face_mode = GL_FILL;
|
||||
}
|
||||
|
||||
inline void gl_state_get_all_gl_errors() {
|
||||
void gl_state_get_all_gl_errors() {
|
||||
GLenum error;
|
||||
while (error = glGetError())
|
||||
printf("GL Error: 0x%04X\n", error);
|
||||
printf_debug("GL Error: 0x%04X\n", error);
|
||||
}
|
||||
|
||||
inline GLuint gl_state_get_program() {
|
||||
GLuint gl_state_get_program() {
|
||||
return gl_state.program;
|
||||
}
|
||||
|
||||
inline void gl_state_set_blend_func(GLenum src, GLenum dst) {
|
||||
void gl_state_set_blend_func(GLenum src, GLenum dst) {
|
||||
if (gl_state.blend_src_rgb != src || gl_state.blend_dst_rgb != dst
|
||||
|| gl_state.blend_src_alpha != GL_ONE || gl_state.blend_dst_alpha != GL_ONE_MINUS_SRC_ALPHA) {
|
||||
glBlendFuncSeparate(src, dst, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -359,7 +369,7 @@ inline void gl_state_set_blend_func(GLenum src, GLenum dst) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_set_blend_func_separate(GLenum src_rgb, GLenum dst_rgb,
|
||||
void gl_state_set_blend_func_separate(GLenum src_rgb, GLenum dst_rgb,
|
||||
GLenum src_alpha, GLenum dst_alpha) {
|
||||
if (gl_state.blend_src_rgb != src_rgb || gl_state.blend_dst_rgb != dst_rgb
|
||||
|| gl_state.blend_src_alpha != src_alpha || gl_state.blend_dst_alpha != dst_alpha) {
|
||||
@@ -371,7 +381,7 @@ inline void gl_state_set_blend_func_separate(GLenum src_rgb, GLenum dst_rgb,
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_set_blend_equation(GLenum mode) {
|
||||
void gl_state_set_blend_equation(GLenum mode) {
|
||||
if (gl_state.blend_mode_rgb != mode || gl_state.blend_mode_alpha != mode) {
|
||||
glBlendEquationSeparate(mode, mode);
|
||||
gl_state.blend_mode_rgb = mode;
|
||||
@@ -379,7 +389,7 @@ inline void gl_state_set_blend_equation(GLenum mode) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_set_blend_equation_separate(GLenum mode_rgb, GLenum mode_alpha) {
|
||||
void gl_state_set_blend_equation_separate(GLenum mode_rgb, GLenum mode_alpha) {
|
||||
if (gl_state.blend_mode_rgb != mode_rgb || gl_state.blend_mode_alpha != mode_alpha) {
|
||||
glBlendEquationSeparate(mode_rgb, mode_alpha);
|
||||
gl_state.blend_mode_rgb = mode_rgb;
|
||||
@@ -387,7 +397,7 @@ inline void gl_state_set_blend_equation_separate(GLenum mode_rgb, GLenum mode_al
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_set_color_mask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
|
||||
void gl_state_set_color_mask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
|
||||
if (gl_state.color_mask[0] != red || gl_state.color_mask[1] != green
|
||||
|| gl_state.color_mask[2] != blue || gl_state.color_mask[3] != alpha) {
|
||||
glColorMask(red, green, blue, alpha);
|
||||
@@ -398,28 +408,28 @@ inline void gl_state_set_color_mask(GLboolean red, GLboolean green, GLboolean bl
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_set_cull_face_mode(GLenum mode) {
|
||||
void gl_state_set_cull_face_mode(GLenum mode) {
|
||||
if (gl_state.cull_face_mode != mode) {
|
||||
glCullFace(mode);
|
||||
gl_state.cull_face_mode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_set_depth_func(GLenum func) {
|
||||
void gl_state_set_depth_func(GLenum func) {
|
||||
if (gl_state.depth_func != func) {
|
||||
glDepthFunc(func);
|
||||
gl_state.depth_func = func;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_set_depth_mask(GLboolean flag) {
|
||||
void gl_state_set_depth_mask(GLboolean flag) {
|
||||
if (gl_state.depth_mask != flag) {
|
||||
glDepthMask(flag);
|
||||
gl_state.depth_mask = flag;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_set_polygon_mode(GLenum face, GLenum mode) {
|
||||
void gl_state_set_polygon_mode(GLenum face, GLenum mode) {
|
||||
switch (face) {
|
||||
case GL_FRONT:
|
||||
if (gl_state.polygon_front_face_mode != mode) {
|
||||
@@ -451,14 +461,21 @@ inline void gl_state_set_polygon_mode(GLenum face, GLenum mode) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_set_stencil_mask(GLuint mask) {
|
||||
void gl_state_set_primitive_restart_index(GLuint index) {
|
||||
if (gl_state.primitive_restart_index != index) {
|
||||
glPrimitiveRestartIndex(index);
|
||||
gl_state.primitive_restart_index = index;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_stencil_mask(GLuint mask) {
|
||||
if (gl_state.stencil_mask != mask) {
|
||||
glStencilMask(mask);
|
||||
gl_state.stencil_mask = mask;
|
||||
}
|
||||
}
|
||||
|
||||
inline void gl_state_use_program(GLuint program) {
|
||||
void gl_state_use_program(GLuint program) {
|
||||
if (gl_state.program != program) {
|
||||
glUseProgram(program);
|
||||
gl_state.program = program;
|
||||
|
||||
+14
-9
@@ -43,7 +43,9 @@ struct gl_state_struct {
|
||||
GLboolean depth_mask;
|
||||
GLenum polygon_front_face_mode;
|
||||
GLenum polygon_back_face_mode;
|
||||
GLboolean multisample;
|
||||
GLboolean primitive_restart;
|
||||
GLuint primitive_restart_index;
|
||||
GLboolean scissor_test;
|
||||
GLboolean stencil_test;
|
||||
GLuint stencil_mask;
|
||||
@@ -57,17 +59,17 @@ extern void gl_state_active_texture(size_t index);
|
||||
extern void gl_state_bind_framebuffer(GLuint framebuffer);
|
||||
extern void gl_state_bind_read_framebuffer(GLuint framebuffer);
|
||||
extern void gl_state_bind_draw_framebuffer(GLuint framebuffer);
|
||||
extern void gl_state_bind_vertex_array(GLuint array);
|
||||
extern void gl_state_bind_array_buffer(GLuint buffer);
|
||||
extern void gl_state_bind_element_array_buffer(GLuint buffer);
|
||||
extern void gl_state_bind_uniform_buffer(GLuint buffer);
|
||||
extern void gl_state_bind_uniform_buffer_base(GLuint index, GLuint buffer);
|
||||
extern void gl_state_bind_vertex_array(GLuint array, bool force = false);
|
||||
extern void gl_state_bind_array_buffer(GLuint buffer, bool force = false);
|
||||
extern void gl_state_bind_element_array_buffer(GLuint buffer, bool force = false);
|
||||
extern void gl_state_bind_uniform_buffer(GLuint buffer, bool force = false);
|
||||
extern void gl_state_bind_uniform_buffer_base(GLuint index, GLuint buffer, bool force = false);
|
||||
extern void gl_state_bind_uniform_buffer_range(GLuint index,
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size);
|
||||
extern void gl_state_bind_shader_storage_buffer(GLuint buffer);
|
||||
extern void gl_state_bind_shader_storage_buffer_base(GLuint index, GLuint buffer);
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size, bool force = false);
|
||||
extern void gl_state_bind_shader_storage_buffer(GLuint buffer, bool force = false);
|
||||
extern void gl_state_bind_shader_storage_buffer_base(GLuint index, GLuint buffer, bool force = false);
|
||||
extern void gl_state_bind_shader_storage_buffer_range(GLuint index,
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size);
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size, bool force = false);
|
||||
extern void gl_state_bind_texture_2d(GLuint texture);
|
||||
extern void gl_state_bind_texture_cube_map(GLuint texture);
|
||||
extern void gl_state_bind_sampler(int32_t index, GLuint sampler);
|
||||
@@ -81,12 +83,14 @@ extern bool gl_state_check_sampler_binding(int32_t index, GLuint sampler);
|
||||
extern void gl_state_disable_blend();
|
||||
extern void gl_state_disable_cull_face();
|
||||
extern void gl_state_disable_depth_test();
|
||||
extern void gl_state_disable_multisample();
|
||||
extern void gl_state_disable_primitive_restart();
|
||||
extern void gl_state_disable_scissor_test();
|
||||
extern void gl_state_disable_stencil_test();
|
||||
extern void gl_state_enable_blend();
|
||||
extern void gl_state_enable_cull_face();
|
||||
extern void gl_state_enable_depth_test();
|
||||
extern void gl_state_enable_multisample();
|
||||
extern void gl_state_enable_primitive_restart();
|
||||
extern void gl_state_enable_scissor_test();
|
||||
extern void gl_state_enable_stencil_test();
|
||||
@@ -103,5 +107,6 @@ extern void gl_state_set_cull_face_mode(GLenum mode);
|
||||
extern void gl_state_set_depth_func(GLenum func);
|
||||
extern void gl_state_set_depth_mask(GLboolean flag);
|
||||
extern void gl_state_set_polygon_mode(GLenum face, GLenum mode);
|
||||
extern void gl_state_set_primitive_restart_index(GLuint index);
|
||||
extern void gl_state_set_stencil_mask(GLuint mask);
|
||||
extern void gl_state_use_program(GLuint program);
|
||||
|
||||
@@ -60,7 +60,9 @@ bool item_table_array_load_file(void* data, const char* path, const char* file,
|
||||
if (t)
|
||||
file_len = t - file;
|
||||
|
||||
std::string s = path + std::string(file, file_len);
|
||||
std::string s;
|
||||
s.assign(path);
|
||||
s.append(file, file_len);
|
||||
|
||||
return item_table_array_read((data_struct*)data, s.c_str());
|
||||
}
|
||||
|
||||
+28
-56
@@ -10,16 +10,16 @@
|
||||
|
||||
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,
|
||||
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,
|
||||
light_param_data_storage_flags flags = LIGHT_PARAM_DATA_STORAGE_ALL);
|
||||
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 void light_param_storage_load_stages(light_param_data_storage* a1, std::vector<int32_t>& stage_indices);
|
||||
static void light_param_storage_load_stages(light_param_data_storage* a1,
|
||||
std::vector<uint32_t>* stage_hashes, stage_database* stage_data);
|
||||
std::vector<uint32_t>& stage_hashes, stage_database* stage_data);
|
||||
static int32_t light_param_storage_load_file(light_param_data_storage* a1, bool read_now);
|
||||
static void light_param_storage_reset(light_param_data_storage* a1);
|
||||
static void light_param_storage_set_default_light_param(light_param_data_storage* a1, int32_t stage_index);
|
||||
@@ -88,21 +88,21 @@ int32_t light_param_data_storage_data_load_file() {
|
||||
|
||||
void light_param_data_storage_data_load_stage(int32_t stage_index) {
|
||||
std::vector<int32_t> stage_indices = { stage_index };
|
||||
light_param_storage_load_stages(light_param_data_storage_data, &stage_indices);
|
||||
light_param_storage_load_stages(light_param_data_storage_data, stage_indices);
|
||||
}
|
||||
|
||||
void light_param_data_storage_data_load_stage(
|
||||
uint32_t stage_hash, stage_database* stage_data) {
|
||||
std::vector<uint32_t> stage_hashes = { stage_hash };
|
||||
light_param_storage_load_stages(light_param_data_storage_data, &stage_hashes, stage_data);
|
||||
light_param_storage_load_stages(light_param_data_storage_data, stage_hashes, stage_data);
|
||||
}
|
||||
|
||||
void light_param_data_storage_data_load_stages(std::vector<int32_t>* stage_indices) {
|
||||
void light_param_data_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_data_storage_data_load_stages(
|
||||
std::vector<uint32_t>* stage_hashes, stage_database* stage_data) {
|
||||
std::vector<uint32_t>& stage_hashes, stage_database* stage_data) {
|
||||
light_param_storage_load_stages(light_param_data_storage_data, stage_hashes, stage_data);
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ static int32_t light_param_storage_load_file(light_param_data_storage* a1, bool
|
||||
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);
|
||||
light_param_data_load_file_pv_cut(a1->pv_cut, &a1a, &a1->default_light_param, a1->pv_id);
|
||||
a1->state = 0;
|
||||
return 0;
|
||||
}
|
||||
@@ -202,13 +202,11 @@ static int32_t light_param_storage_load_file(light_param_data_storage* a1, bool
|
||||
|
||||
static void light_param_data_get_stage_name_string(std::string* str, int32_t stage_index) {
|
||||
str->clear();
|
||||
str->shrink_to_fit();
|
||||
|
||||
data_struct* aft_data = &data_list[DATA_AFT];
|
||||
stage_database* aft_stage_data = &aft_data->data_ft.stage_data;
|
||||
|
||||
const char* stage_name = stage_index < aft_stage_data->stage_data.size()
|
||||
? aft_stage_data->stage_data[stage_index].name.c_str() : 0;
|
||||
const char* stage_name = aft_stage_data->get_stage_name(stage_index);
|
||||
if (!stage_name)
|
||||
return;
|
||||
|
||||
@@ -216,40 +214,23 @@ static void light_param_data_get_stage_name_string(std::string* str, int32_t sta
|
||||
if (length <= 3)
|
||||
return;
|
||||
|
||||
stage_name += 3;
|
||||
length -= 3;
|
||||
|
||||
char* s = force_malloc_s(char, length + 1);
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
char c = stage_name[i];
|
||||
if (c == '_') {
|
||||
for (size_t i = 3; i < length; i++)
|
||||
if (stage_name[i] == '_') {
|
||||
length = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (c > 0x40 && c < 0x5B)
|
||||
str->assign(stage_name + 3, length - 3);
|
||||
for (char& c : *str)
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
c += 0x20;
|
||||
s[i] = c;
|
||||
}
|
||||
s[length] = '\0';
|
||||
|
||||
*str = std::string(s, length);
|
||||
free_def(s);
|
||||
}
|
||||
|
||||
static void light_param_data_get_stage_name_string(std::string* str,
|
||||
uint32_t stage_hash, stage_database* stage_data) {
|
||||
str->clear();
|
||||
str->shrink_to_fit();
|
||||
const char* stage_name = 0;
|
||||
for (stage_data_modern& i : stage_data->stage_modern) {
|
||||
if (i.hash != stage_hash)
|
||||
continue;
|
||||
|
||||
stage_name = i.name.c_str();
|
||||
break;
|
||||
}
|
||||
|
||||
const char* stage_name = stage_data->get_stage_name_modern(stage_hash);
|
||||
if (!stage_name)
|
||||
return;
|
||||
|
||||
@@ -257,25 +238,16 @@ static void light_param_data_get_stage_name_string(std::string* str,
|
||||
if (length <= 3)
|
||||
return;
|
||||
|
||||
stage_name += 3;
|
||||
length -= 3;
|
||||
|
||||
char* s = force_malloc_s(char, length + 1);
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
char c = stage_name[i];
|
||||
if (c == '_') {
|
||||
for (size_t i = 3; i < length; i++)
|
||||
if (stage_name[i] == '_') {
|
||||
length = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (c > 0x40 && c < 0x5B)
|
||||
str->assign(stage_name + 3, length - 3);
|
||||
for (char& c : *str)
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
c += 0x20;
|
||||
s[i] = c;
|
||||
}
|
||||
s[length] = '\0';
|
||||
|
||||
*str = std::string(s, length);
|
||||
free_def(s);
|
||||
}
|
||||
|
||||
static int32_t light_param_data_load_file(light_param_data* a1, p_file_handler* a2) {
|
||||
@@ -313,7 +285,7 @@ static int32_t light_param_data_load_file(light_param_data* a1, p_file_handler*
|
||||
| a1->glow.ready | a1->wind.ready | a1->face.ready) ? 1 : 0;
|
||||
}
|
||||
|
||||
static void light_param_data_load_file_pv_cut(std::map<int32_t, light_param_data>* tree,
|
||||
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) {
|
||||
char buf[0x100];
|
||||
|
||||
@@ -414,12 +386,12 @@ static void light_param_data_load_file_pv_cut(std::map<int32_t, light_param_data
|
||||
cut_id += (b[2] - '0') * 10;
|
||||
cut_id += b[3] - '0';
|
||||
|
||||
std::map<int32_t, light_param_data>::iterator elem = tree->find(cut_id);
|
||||
std::map<int32_t, light_param_data>::iterator elem = tree.find(cut_id);
|
||||
light_param_data* light_param;
|
||||
if (elem != tree->end())
|
||||
if (elem != tree.end())
|
||||
light_param = &elem->second;
|
||||
else {
|
||||
light_param = &tree->insert({ cut_id, *default_light_param }).first->second;
|
||||
light_param = &tree.insert({ cut_id, *default_light_param }).first->second;
|
||||
light_param->ibl.ready = false;
|
||||
light_param->light.ready = false;
|
||||
light_param->fog.ready = false;
|
||||
@@ -538,7 +510,7 @@ static void light_param_storage_free_file_handlers(light_param_data_storage* a1)
|
||||
a1->farc_file_handler.free_data();
|
||||
}
|
||||
|
||||
static void light_param_storage_load_stages(light_param_data_storage* a1, std::vector<int32_t>* stage_indices) {
|
||||
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)
|
||||
if (a1->file_handlers[i].check_not_ready())
|
||||
@@ -547,7 +519,7 @@ static void light_param_storage_load_stages(light_param_data_storage* a1, std::v
|
||||
a1->stage_index = -1;
|
||||
a1->stage.clear();
|
||||
|
||||
for (int32_t& i : *stage_indices) {
|
||||
for (int32_t& i : stage_indices) {
|
||||
std::string name;
|
||||
light_param_data_get_stage_name_string(&name, i);
|
||||
if (!name.size())
|
||||
@@ -568,7 +540,7 @@ static void light_param_storage_load_stages(light_param_data_storage* a1, std::v
|
||||
}
|
||||
|
||||
static void light_param_storage_load_stages(light_param_data_storage* a1,
|
||||
std::vector<uint32_t>* stage_hashes, stage_database* stage_data) {
|
||||
std::vector<uint32_t>& stage_hashes, stage_database* stage_data) {
|
||||
if (a1->state)
|
||||
for (int32_t i = 0; i < 6; ++i)
|
||||
if (a1->file_handlers[i].check_not_ready())
|
||||
@@ -577,7 +549,7 @@ static void light_param_storage_load_stages(light_param_data_storage* a1,
|
||||
a1->stage_index = -1;
|
||||
a1->stage.clear();
|
||||
|
||||
for (uint32_t& i : *stage_hashes) {
|
||||
for (uint32_t& i : stage_hashes) {
|
||||
std::string name;
|
||||
light_param_data_get_stage_name_string(&name, i, stage_data);
|
||||
if (!name.size())
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <map>
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/farc.hpp"
|
||||
@@ -74,9 +73,9 @@ extern int32_t light_param_data_storage_data_get_stage_index();
|
||||
extern int32_t light_param_data_storage_data_load_file();
|
||||
extern void light_param_data_storage_data_load_stage(int32_t stage_index);
|
||||
extern void light_param_data_storage_data_load_stage(uint32_t stage_hash, stage_database* stage_data);
|
||||
extern void light_param_data_storage_data_load_stages(std::vector<int32_t>* stage_indices);
|
||||
extern void light_param_data_storage_data_load_stages(std::vector<int32_t>& stage_indices);
|
||||
extern void light_param_data_storage_data_load_stages(
|
||||
std::vector<uint32_t>* stage_hashes, stage_database* stage_data);
|
||||
std::vector<uint32_t>& stage_hashes, stage_database* stage_data);
|
||||
extern void light_param_data_storage_data_reset();
|
||||
extern void light_param_data_storage_data_set_default_light_param(
|
||||
light_param_data_storage_flags flags = LIGHT_PARAM_DATA_STORAGE_ALL);
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
face::face() {
|
||||
offset = 1.0f;
|
||||
scale = 0.35f;
|
||||
position = vec3_null;
|
||||
direction = vec3_null;
|
||||
position = 0.0f;
|
||||
direction = 0.0f;
|
||||
}
|
||||
|
||||
float_t face::get_offset() {
|
||||
|
||||
@@ -443,9 +443,9 @@ void light_set::data_set(face& face, light_set_id id) {
|
||||
shaders_ft.env_frag_set(35, specular);
|
||||
}
|
||||
else {
|
||||
shaders_ft.env_frag_set(33, vec4_null);
|
||||
shaders_ft.env_frag_set(34, vec4_null);
|
||||
shaders_ft.env_frag_set(35, vec4_null);
|
||||
shaders_ft.env_frag_set(33, 0.0f);
|
||||
shaders_ft.env_frag_set(34, 0.0f);
|
||||
shaders_ft.env_frag_set(35, 0.0f);
|
||||
}
|
||||
|
||||
if (lights[LIGHT_TONE_CURVE].get_type() == LIGHT_PARALLEL) {
|
||||
|
||||
@@ -73,7 +73,7 @@ void wind::set_bias(float_t value) {
|
||||
void wind::reset() {
|
||||
strength = 0.0f;
|
||||
frame = 0.0f;
|
||||
wind_direction = vec3_null;
|
||||
wind_direction = 0.0f;
|
||||
}
|
||||
|
||||
static float_t wind_apply_spc(wind* w, float_t frame) {
|
||||
@@ -92,7 +92,7 @@ static void wind_ctrl(wind* w) {
|
||||
mat4 mat = mat4_identity;
|
||||
mat4_rotate_y_mult(&mat, w->rot_y * DEG_TO_RAD_FLOAT, &mat);
|
||||
mat4_rotate_z_mult(&mat, w->rot_z * DEG_TO_RAD_FLOAT, &mat);
|
||||
vec3 wind_direction = vec3_null;
|
||||
vec3 wind_direction = 0.0f;
|
||||
wind_direction.x = value;
|
||||
mat4_mult_vec3(&mat, &wind_direction, &wind_direction);
|
||||
w->wind_direction = wind_direction * w->strength;
|
||||
|
||||
+96
-123
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <new>
|
||||
#include <vector>
|
||||
#include "object.hpp"
|
||||
#include "data.hpp"
|
||||
@@ -27,15 +28,6 @@ static bool obj_set_handler_load_textures_modern(obj_set_handler* handler,
|
||||
const void* data, size_t size, const char* file, texture_database* tex_db);
|
||||
static bool obj_set_handler_vertex_buffer_load(obj_set_handler* handler);
|
||||
static void obj_set_handler_vertex_buffer_free(obj_set_handler* handler);
|
||||
static void obj_skin_block_constraint_attach_point_load(
|
||||
obj_skin_block_constraint_attach_point* attach_point,
|
||||
obj_skin_block_constraint_attach_point* attach_point_file);
|
||||
static void obj_skin_block_constraint_up_vector_load(
|
||||
obj_skin_block_constraint_up_vector* up_vector,
|
||||
obj_skin_block_constraint_up_vector* up_vector_file);
|
||||
static void obj_skin_block_node_load(obj_skin_block_node* node,
|
||||
obj_skin_block_node* node_file);
|
||||
static void obj_skin_block_node_free(obj_skin_block_node* node);
|
||||
static size_t obj_vertex_format_get_vertex_size(obj_vertex_format format);
|
||||
static size_t obj_vertex_format_get_vertex_size_comp(obj_vertex_format format);
|
||||
|
||||
@@ -47,23 +39,23 @@ obj_mesh_index_buffer::obj_mesh_index_buffer() : buffer(), size() {
|
||||
}
|
||||
|
||||
bool obj_mesh_index_buffer::load(obj_mesh& mesh) {
|
||||
int32_t indices_count = 0;
|
||||
int32_t num_index = 0;
|
||||
for (uint32_t i = 0; i < mesh.num_submesh; i++)
|
||||
indices_count += mesh.submesh_array[i].indices_count;
|
||||
num_index += mesh.submesh_array[i].num_index;
|
||||
|
||||
if (!indices_count) {
|
||||
if (!num_index) {
|
||||
buffer = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t* indices = force_malloc_s(uint16_t, indices_count);
|
||||
uint16_t* indices = force_malloc_s(uint16_t, num_index);
|
||||
uint16_t* _indices = indices;
|
||||
for (uint32_t k = 0; k < mesh.num_submesh; k++) {
|
||||
obj_sub_mesh& sub_mesh = mesh.submesh_array[k];
|
||||
int32_t indices_count = sub_mesh.indices_count;
|
||||
uint32_t* sub_mesh_indices = sub_mesh.indices;
|
||||
for (int32_t l = 0; l < indices_count; l++)
|
||||
*_indices++ = (uint16_t)sub_mesh_indices[l];
|
||||
uint32_t num_index = sub_mesh.num_index;
|
||||
uint32_t* index = sub_mesh.index_array;
|
||||
for (uint32_t l = 0; l < num_index; l++, index++)
|
||||
*_indices++ = (uint16_t)*index;
|
||||
}
|
||||
|
||||
_indices = indices;
|
||||
@@ -72,32 +64,31 @@ bool obj_mesh_index_buffer::load(obj_mesh& mesh) {
|
||||
|
||||
sub_mesh.first_index = 0;
|
||||
sub_mesh.last_index = 0;
|
||||
sub_mesh.indices_offset = 0;
|
||||
sub_mesh.index_offset = 0;
|
||||
if (sub_mesh.index_format != OBJ_INDEX_U16)
|
||||
continue;
|
||||
|
||||
uint16_t first_index = 0xFFFF;
|
||||
uint16_t last_index = 0;
|
||||
int32_t indices_count = sub_mesh.indices_count;
|
||||
uint32_t* sub_mesh_indices = sub_mesh.indices;
|
||||
for (int32_t j = 0; j < indices_count; j++) {
|
||||
uint32_t num_index = sub_mesh.num_index;
|
||||
for (uint32_t j = 0; j < num_index; j++) {
|
||||
uint16_t index = *_indices++;
|
||||
if (index == 0xFFFF)
|
||||
continue;
|
||||
|
||||
if (index < first_index)
|
||||
if (first_index > index)
|
||||
first_index = index;
|
||||
if (index > last_index)
|
||||
if (last_index < index)
|
||||
last_index = index;
|
||||
}
|
||||
|
||||
sub_mesh.first_index = first_index;
|
||||
sub_mesh.last_index = last_index;
|
||||
sub_mesh.indices_offset = (int32_t)(sizeof(uint16_t) * offset);
|
||||
offset += sub_mesh.indices_count;
|
||||
sub_mesh.index_offset = (int32_t)(sizeof(uint16_t) * offset);
|
||||
offset += sub_mesh.num_index;
|
||||
}
|
||||
|
||||
bool ret = load_data((size_t)indices_count * sizeof(uint16_t), indices);
|
||||
bool ret = load_data((size_t)num_index * sizeof(uint16_t), indices);
|
||||
free_def(indices);
|
||||
return ret;
|
||||
}
|
||||
@@ -108,8 +99,11 @@ bool obj_mesh_index_buffer::load_data(size_t size, const void* data) {
|
||||
|
||||
this->size = (GLsizeiptr)size;
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_state_bind_element_array_buffer(buffer);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)size, data, GL_STATIC_DRAW);
|
||||
gl_state_bind_element_array_buffer(buffer, true);
|
||||
if (GLAD_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)size, data, 0);
|
||||
else
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)size, data, GL_STATIC_DRAW);
|
||||
gl_state_bind_element_array_buffer(0);
|
||||
return true;
|
||||
}
|
||||
@@ -143,8 +137,8 @@ GLsizeiptr obj_mesh_vertex_buffer::get_size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool obj_mesh_vertex_buffer::load(obj_mesh& mesh) {
|
||||
if (!mesh.num_vertex || !mesh.vertex)
|
||||
bool obj_mesh_vertex_buffer::load(obj_mesh& mesh, bool dynamic) {
|
||||
if (!mesh.num_vertex || !mesh.vertex_array)
|
||||
return false;
|
||||
|
||||
size_t size_vertex;
|
||||
@@ -156,126 +150,126 @@ bool obj_mesh_vertex_buffer::load(obj_mesh& mesh) {
|
||||
void* vertex = force_malloc(size_vertex * mesh.num_vertex);
|
||||
if (vertex) {
|
||||
obj_vertex_format vertex_format = mesh.vertex_format;
|
||||
obj_vertex_data* vertex_file = mesh.vertex;
|
||||
obj_vertex_data* vtx = mesh.vertex_array;
|
||||
int32_t num_vertex = mesh.num_vertex;
|
||||
size_t d = (size_t)vertex;
|
||||
if (!mesh.attrib.m.compressed) {
|
||||
for (int32_t i = 0; i < num_vertex; i++) {
|
||||
for (int32_t i = 0; i < num_vertex; i++, vtx++) {
|
||||
if (vertex_format & OBJ_VERTEX_POSITION) {
|
||||
*(vec3*)d = vertex_file[i].position;
|
||||
*(vec3*)d = vtx->position;
|
||||
d += 12;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_NORMAL) {
|
||||
*(vec3*)d = vertex_file[i].normal;
|
||||
*(vec3*)d = vtx->normal;
|
||||
d += 12;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_TANGENT) {
|
||||
*(vec4*)d = vertex_file[i].tangent;
|
||||
*(vec4*)d = vtx->tangent;
|
||||
d += 16;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_BINORMAL) {
|
||||
*(vec3*)d = vertex_file[i].binormal;
|
||||
*(vec3*)d = vtx->binormal;
|
||||
d += 12;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD0) {
|
||||
*(vec2*)d = vertex_file[i].texcoord0;
|
||||
*(vec2*)d = vtx->texcoord0;
|
||||
d += 8;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD1) {
|
||||
*(vec2*)d = vertex_file[i].texcoord1;
|
||||
*(vec2*)d = vtx->texcoord1;
|
||||
d += 8;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD2) {
|
||||
*(vec2*)d = vertex_file[i].texcoord2;
|
||||
*(vec2*)d = vtx->texcoord2;
|
||||
d += 8;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD3) {
|
||||
*(vec2*)d = vertex_file[i].texcoord3;
|
||||
*(vec2*)d = vtx->texcoord3;
|
||||
d += 8;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_COLOR0) {
|
||||
*(vec4*)d = vertex_file[i].color0;
|
||||
*(vec4*)d = vtx->color0;
|
||||
d += 16;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_COLOR1) {
|
||||
*(vec4*)d = vertex_file[i].color1;
|
||||
*(vec4*)d = vtx->color1;
|
||||
d += 16;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_BONE_DATA) {
|
||||
*(vec4*)d = vertex_file[i].bone_weight;
|
||||
*(vec4*)d = vtx->bone_weight;
|
||||
d += 16;
|
||||
*(vec4i*)d = vertex_file[i].bone_index;
|
||||
*(vec4i*)d = vtx->bone_index;
|
||||
d += 16;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_UNKNOWN) {
|
||||
*(vec4*)d = vertex_file[i].unknown;
|
||||
*(vec4*)d = vtx->unknown;
|
||||
d += 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int32_t i = 0; i < num_vertex; i++) {
|
||||
for (int32_t i = 0; i < num_vertex; i++, vtx++) {
|
||||
if (vertex_format & OBJ_VERTEX_POSITION) {
|
||||
*(vec3*)d = vertex_file[i].position;
|
||||
*(vec3*)d = vtx->position;
|
||||
d += 12;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_NORMAL) {
|
||||
vec3 normal = vertex_file[i].normal * 32727.0f;
|
||||
vec3 normal = vtx->normal * 32727.0f;
|
||||
vec3_to_vec3i16(normal, *(vec3i16*)d);
|
||||
*(int16_t*)(d + 6) = 0;
|
||||
d += 8;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_TANGENT) {
|
||||
vec4 tangent = vertex_file[i].tangent * 32727.0f;
|
||||
vec4 tangent = vtx->tangent * 32727.0f;
|
||||
vec4_to_vec4i16(tangent, *(vec4i16*)d);
|
||||
d += 8;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD0) {
|
||||
vec2_to_vec2h(vertex_file[i].texcoord0, *(vec2h*)d);
|
||||
vec2_to_vec2h(vtx->texcoord0, *(vec2h*)d);
|
||||
d += 4;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD1) {
|
||||
vec2_to_vec2h(vertex_file[i].texcoord1, *(vec2h*)d);
|
||||
vec2_to_vec2h(vtx->texcoord1, *(vec2h*)d);
|
||||
d += 4;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD2) {
|
||||
vec2_to_vec2h(vertex_file[i].texcoord2, *(vec2h*)d);
|
||||
vec2_to_vec2h(vtx->texcoord2, *(vec2h*)d);
|
||||
d += 4;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD3) {
|
||||
vec2_to_vec2h(vertex_file[i].texcoord3, *(vec2h*)d);
|
||||
vec2_to_vec2h(vtx->texcoord3, *(vec2h*)d);
|
||||
d += 4;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_COLOR0) {
|
||||
vec4 color0 = vertex_file[i].color0;
|
||||
vec4 color0 = vtx->color0;
|
||||
vec4_to_vec4h(color0, *(vec4h*)d);
|
||||
d += 8;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_BONE_DATA) {
|
||||
vec4 bone_weight = vertex_file[i].bone_weight * 65535.0f;
|
||||
vec4 bone_weight = vtx->bone_weight * 65535.0f;
|
||||
vec4_to_vec4u16(bone_weight, *(vec4u16*)d);
|
||||
d += 8;
|
||||
|
||||
vec4i bone_index = vertex_file[i].bone_index;
|
||||
vec4i bone_index = vtx->bone_index;
|
||||
vec4i_to_vec4u16(bone_index, *(vec4u16*)d);
|
||||
d += 8;
|
||||
}
|
||||
@@ -284,12 +278,12 @@ bool obj_mesh_vertex_buffer::load(obj_mesh& mesh) {
|
||||
}
|
||||
mesh.size_vertex = (int32_t)size_vertex;
|
||||
|
||||
bool ret = load_data(size_vertex * mesh.num_vertex, vertex, mesh.attrib.m.double_buffer ? 2 : 1);
|
||||
bool ret = load_data(size_vertex * mesh.num_vertex, vertex, mesh.attrib.m.double_buffer ? 2 : 1, dynamic);
|
||||
free_def(vertex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool obj_mesh_vertex_buffer::load_data(size_t size, const void* data, int32_t count) {
|
||||
bool obj_mesh_vertex_buffer::load_data(size_t size, const void* data, int32_t count, bool dynamic) {
|
||||
if (!size || count > 3)
|
||||
return false;
|
||||
|
||||
@@ -298,8 +292,13 @@ bool obj_mesh_vertex_buffer::load_data(size_t size, const void* data, int32_t co
|
||||
|
||||
glGenBuffers(count, buffers);
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
gl_state_bind_array_buffer(buffers[i]);
|
||||
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)size, data, GL_STATIC_DRAW);
|
||||
gl_state_bind_array_buffer(buffers[i], true);
|
||||
if (GLAD_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ARRAY_BUFFER,
|
||||
(GLsizeiptr)size, data, dynamic ? GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT : 0);
|
||||
else
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
(GLsizeiptr)size, data, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
|
||||
}
|
||||
gl_state_bind_array_buffer(0);
|
||||
return true;
|
||||
@@ -380,7 +379,7 @@ obj_set_handler::~obj_set_handler() {
|
||||
|
||||
obj_set_handler_index_buffer_free(this);
|
||||
obj_set_handler_vertex_buffer_free(this);
|
||||
delete obj_set;
|
||||
alloc_handler.reset();
|
||||
while (tex_file_handler.ptr && tex_file_handler.ptr->count)
|
||||
tex_file_handler.free_data();
|
||||
while (obj_file_handler.ptr && obj_file_handler.ptr->count)
|
||||
@@ -429,33 +428,33 @@ inline int32_t obj_material_texture_type_get_texture_index(
|
||||
}
|
||||
|
||||
void obj_skin_set_matrix_buffer(obj_skin* s, mat4* matrices,
|
||||
mat4* ex_data_matrices, mat4* matrix_buffer, mat4* mat, mat4* global_mat) {
|
||||
if (!s->bones_count)
|
||||
mat4* ex_data_matrices, mat4* matrix_buffer, const mat4* mat, const mat4* global_mat) {
|
||||
if (!s->num_bone)
|
||||
return;
|
||||
|
||||
if (mat)
|
||||
for (uint32_t i = 0; i < s->bones_count; i++) {
|
||||
for (uint32_t i = 0; i < s->num_bone; i++) {
|
||||
mat4 temp;
|
||||
int32_t bone_id = s->bones[i].id;
|
||||
int32_t bone_id = s->bone_array[i].id;
|
||||
if (bone_id & 0x8000)
|
||||
mat4_mult(mat, &ex_data_matrices[bone_id & 0x7FFF], &temp);
|
||||
else
|
||||
mat4_mult(mat, &matrices[bone_id], &temp);
|
||||
|
||||
mat4_mult(&temp, global_mat, &temp);
|
||||
mat4_mult(&s->bones[i].inv_bind_pose_mat, &temp, &matrix_buffer[i]);
|
||||
mat4_mult(&s->bone_array[i].inv_bind_pose_mat, &temp, &matrix_buffer[i]);
|
||||
}
|
||||
else
|
||||
for (uint32_t i = 0; i < s->bones_count; i++) {
|
||||
for (uint32_t i = 0; i < s->num_bone; i++) {
|
||||
mat4 temp;
|
||||
int32_t bone_id = s->bones[i].id;
|
||||
int32_t bone_id = s->bone_array[i].id;
|
||||
if (bone_id & 0x8000)
|
||||
temp = ex_data_matrices[bone_id & 0x7FFF];
|
||||
else
|
||||
temp = matrices[bone_id];
|
||||
|
||||
mat4_mult(&temp, global_mat, &temp);
|
||||
mat4_mult(&s->bones[i].inv_bind_pose_mat, &temp, &matrix_buffer[i]);
|
||||
mat4_mult(&s->bone_array[i].inv_bind_pose_mat, &temp, &matrix_buffer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -905,17 +904,14 @@ void object_material_msgpack_read(const char* path, const char* set_name,
|
||||
|
||||
size_t tex_id_num = txp_set->textures.size();
|
||||
if (set->tex_id_num != tex_id_num) {
|
||||
uint32_t* tex_id_data = force_malloc_s(uint32_t, tex_id_num);
|
||||
uint32_t* tex_id_data = handler->alloc_handler->allocate<uint32_t>(tex_id_num);
|
||||
memmove(tex_id_data, set->tex_id_data, sizeof(uint32_t) * set->tex_id_num);
|
||||
free_def(set->tex_id_data);
|
||||
|
||||
memmove(&tex_id_data[set->tex_id_num], ids.data(), sizeof(uint32_t) * (tex_id_num - set->tex_id_num));
|
||||
|
||||
memmove(&tex_id_data[set->tex_id_num], ids.data(),
|
||||
sizeof(uint32_t) * (tex_id_num - set->tex_id_num));
|
||||
set->tex_id_data = tex_id_data;
|
||||
set->tex_id_num = (uint32_t)tex_id_num;
|
||||
handler->tex_num = (uint32_t)tex_id_num;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
msgpack* replace = msg.read_array("Replace");
|
||||
@@ -1622,7 +1618,7 @@ inline obj_skin* object_storage_get_obj_skin(object_info obj_info) {
|
||||
|
||||
for (uint32_t j = 0; j < set->obj_num; j++)
|
||||
if (set->obj_data[j].id == obj_info.id)
|
||||
return set->obj_data[j].skin_init ? &set->obj_data[j].skin : 0;
|
||||
return set->obj_data[j].skin;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1636,7 +1632,7 @@ inline obj_skin* object_storage_get_obj_skin(object_info obj_info) {
|
||||
|
||||
for (uint32_t j = 0; j < set->obj_num; j++)
|
||||
if (set->obj_data[j].id == obj_info.id)
|
||||
return set->obj_data[j].skin_init ? &set->obj_data[j].skin : 0;
|
||||
return set->obj_data[j].skin;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
@@ -1829,9 +1825,12 @@ bool object_storage_load_obj_set_check_not_read(uint32_t set_id,
|
||||
if (!data || !size)
|
||||
return false;
|
||||
|
||||
obj_set* set = new obj_set;
|
||||
prj::shared_ptr<alloc_data>& alloc = handler->alloc_handler;
|
||||
alloc = prj::shared_ptr<alloc_data>(new alloc_data);
|
||||
|
||||
obj_set* set = alloc->allocate<obj_set>();
|
||||
handler->obj_set = set;
|
||||
set->unpack_file(data, size, false);
|
||||
set->unpack_file(alloc, data, size, false);
|
||||
if (!set->ready)
|
||||
return false;
|
||||
|
||||
@@ -1940,9 +1939,12 @@ bool object_storage_load_obj_set_check_not_read(uint32_t set_id,
|
||||
|
||||
handler->name = name;
|
||||
|
||||
obj_set* set = new obj_set;
|
||||
prj::shared_ptr<alloc_data>& alloc = handler->alloc_handler;
|
||||
alloc = prj::shared_ptr<alloc_data>(new alloc_data);
|
||||
|
||||
obj_set* set = alloc->allocate<obj_set>();
|
||||
handler->obj_set = set;
|
||||
set->unpack_file(osd->data, osd->size, true);
|
||||
set->unpack_file(alloc, osd->data, osd->size, true);
|
||||
if (!set->ready)
|
||||
return false;
|
||||
|
||||
@@ -2002,7 +2004,7 @@ inline void object_storage_unload_set(object_database* obj_db, const char* name)
|
||||
handler->load_count = 0;
|
||||
handler->tex_loaded = false;
|
||||
handler->obj_loaded = false;
|
||||
delete handler->obj_set;
|
||||
handler->alloc_handler.reset();
|
||||
handler->obj_set = 0;
|
||||
handler->tex_file_handler.free_data();
|
||||
handler->obj_file_handler.free_data();
|
||||
@@ -2034,14 +2036,14 @@ inline void object_storage_unload_set(uint32_t set_id) {
|
||||
handler->load_count = 0;
|
||||
handler->tex_loaded = false;
|
||||
handler->obj_loaded = false;
|
||||
delete handler->obj_set;
|
||||
handler->alloc_handler.reset();
|
||||
handler->obj_set = 0;
|
||||
handler->tex_file_handler.free_data();
|
||||
handler->obj_file_handler.free_data();
|
||||
handler->farc_file_handler.free_data();
|
||||
if (handler->modern)
|
||||
for (auto i = object_storage_data_modern.begin(); i != object_storage_data_modern.end(); i++)
|
||||
if (i->set_id = set_id) {
|
||||
if (i->set_id == set_id) {
|
||||
i = object_storage_data_modern.erase(i);
|
||||
break;
|
||||
}
|
||||
@@ -2060,25 +2062,25 @@ static void obj_set_handler_calc_axis_aligned_bounding_box(obj_set_handler* hand
|
||||
for (uint32_t j = 0; j < obj.num_mesh; j++) {
|
||||
obj_mesh& mesh = obj.mesh_array[j];
|
||||
for (uint32_t k = 0; k < mesh.num_submesh; k++) {
|
||||
vec3 _min = { 9999999.0f, 9999999.0f, 9999999.0f };
|
||||
vec3 _max = { -100000000.0f, -100000000.0f, -100000000.0f };
|
||||
vec3 _min = vec3( 9999999.0f, 9999999.0f, 9999999.0f);
|
||||
vec3 _max = vec3(-100000000.0f, -100000000.0f, -100000000.0f);
|
||||
|
||||
obj_sub_mesh& sub_mesh = mesh.submesh_array[k];
|
||||
uint32_t* indices = (uint32_t*)sub_mesh.indices;
|
||||
uint32_t indices_count = sub_mesh.indices_count;
|
||||
obj_vertex_data* vertex = mesh.vertex;
|
||||
uint32_t* index = sub_mesh.index_array;
|
||||
uint32_t num_index = sub_mesh.num_index;
|
||||
obj_vertex_data* vertex_array = mesh.vertex_array;
|
||||
if (sub_mesh.index_format == OBJ_INDEX_U16)
|
||||
for (uint32_t l = 0; l < indices_count; l++) {
|
||||
if (indices[l] == 0xFFFFFFFF)
|
||||
for (uint32_t l = 0; l < num_index; l++, index++) {
|
||||
if (*index == 0xFFFFFFFF)
|
||||
continue;
|
||||
|
||||
vec3 pos = vertex[indices[l]].position;
|
||||
vec3 pos = vertex_array[*index].position;
|
||||
_min = vec3::min(_min, pos);
|
||||
_max = vec3::max(_max, pos);
|
||||
}
|
||||
else
|
||||
for (uint32_t l = 0; l < indices_count; l++) {
|
||||
vec3 pos = vertex[indices[l]].position;
|
||||
for (uint32_t l = 0; l < num_index; l++, index++) {
|
||||
vec3 pos = vertex_array[*index].position;
|
||||
_min = vec3::min(_min, pos);
|
||||
_max = vec3::max(_max, pos);
|
||||
}
|
||||
@@ -2236,35 +2238,6 @@ static void obj_set_handler_vertex_buffer_free(obj_set_handler* handler) {
|
||||
handler->vertex_buffer_num = 0;
|
||||
}
|
||||
|
||||
inline static void obj_skin_block_constraint_attach_point_load(
|
||||
obj_skin_block_constraint_attach_point* attach_point,
|
||||
obj_skin_block_constraint_attach_point* attach_point_file) {
|
||||
attach_point->affected_by_orientation = attach_point_file->affected_by_orientation;
|
||||
attach_point->affected_by_scaling = attach_point_file->affected_by_scaling;
|
||||
attach_point->offset = attach_point_file->offset;
|
||||
}
|
||||
inline static void obj_skin_block_constraint_up_vector_load(
|
||||
obj_skin_block_constraint_up_vector* up_vector,
|
||||
obj_skin_block_constraint_up_vector* up_vector_file) {
|
||||
up_vector->active = up_vector_file->active;
|
||||
up_vector->roll = up_vector_file->roll;
|
||||
up_vector->affected_axis = up_vector_file->affected_axis;
|
||||
up_vector->point_at = up_vector_file->point_at;
|
||||
up_vector->name = str_utils_copy(up_vector_file->name);
|
||||
}
|
||||
|
||||
inline static void obj_skin_block_node_load(obj_skin_block_node* node,
|
||||
obj_skin_block_node* node_file) {
|
||||
node->parent_name = str_utils_copy(node_file->parent_name);
|
||||
node->position = node_file->position;
|
||||
node->rotation = node_file->rotation;
|
||||
node->scale = node_file->scale;
|
||||
}
|
||||
|
||||
inline static void obj_skin_block_node_free(obj_skin_block_node* node) {
|
||||
free_def(node->parent_name);
|
||||
}
|
||||
|
||||
inline static size_t obj_vertex_format_get_vertex_size(obj_vertex_format format) {
|
||||
size_t size = 0;
|
||||
if (format & OBJ_VERTEX_POSITION)
|
||||
|
||||
+4
-3
@@ -44,8 +44,8 @@ struct obj_mesh_vertex_buffer {
|
||||
void cycle_index();
|
||||
GLuint get_buffer();
|
||||
GLsizeiptr get_size();
|
||||
bool load(obj_mesh& mesh);
|
||||
bool load_data(size_t size, const void* data, int32_t count);
|
||||
bool load(obj_mesh& mesh, bool dynamic = false);
|
||||
bool load_data(size_t size, const void* data, int32_t count, bool dynamic);
|
||||
void unload();
|
||||
};
|
||||
|
||||
@@ -74,6 +74,7 @@ struct obj_set_handler {
|
||||
bool obj_loaded;
|
||||
p_file_handler tex_file_handler;
|
||||
bool tex_loaded;
|
||||
prj::shared_ptr<alloc_data> alloc_handler;
|
||||
obj_set* obj_set;
|
||||
std::vector<std::pair<uint32_t, uint32_t>> obj_id_data;
|
||||
uint32_t tex_num;
|
||||
@@ -99,7 +100,7 @@ extern int32_t obj_material_texture_type_get_texcoord_index(
|
||||
extern int32_t obj_material_texture_type_get_texture_index(
|
||||
obj_material_texture_type type, int32_t base_index);
|
||||
extern void obj_skin_set_matrix_buffer(obj_skin* s, mat4* matrices,
|
||||
mat4* ex_data_matrices, mat4* matrix_buffer, mat4* global_mat, mat4* mat);
|
||||
mat4* ex_data_matrices, mat4* matrix_buffer, const mat4* mat, const mat4* global_mat);
|
||||
|
||||
extern void object_material_msgpack_read(const char* path, const char* set_name,
|
||||
obj_set* obj_set, object_database* obj_db);
|
||||
|
||||
+389
-31
@@ -6,11 +6,31 @@
|
||||
#include "ogg_vorbis.hpp"
|
||||
#include "../KKdLib/str_utils.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "data.hpp"
|
||||
#include <intrin.h>
|
||||
|
||||
struct ogg_file_handler_storage {
|
||||
std::mutex mtx;
|
||||
bool clear;
|
||||
std::list<p_OggFileHandler*> list;
|
||||
|
||||
ogg_file_handler_storage();
|
||||
~ogg_file_handler_storage();
|
||||
|
||||
void free_data();
|
||||
};
|
||||
|
||||
static int32_t ogg_file_counter = 0;
|
||||
static int32_t ogg_file_handler_counter = 0;
|
||||
|
||||
#define OGG_PLAYBACK_DATA_COUNT 6
|
||||
static OggPlayback* ogg_playback_data[OGG_PLAYBACK_DATA_COUNT];
|
||||
|
||||
static int32_t ogg_file_handler_storage_init_count = 0;
|
||||
static ogg_file_handler_storage* ogg_file_handler_storage_ptr;
|
||||
|
||||
static p_OggFileHandler* ogg_file_handler_storage_get_ogg_file_handler(size_t index);
|
||||
|
||||
OggFileBufferChannelData::OggFileBufferChannelData() : left(), right() {
|
||||
|
||||
}
|
||||
@@ -379,33 +399,6 @@ void OggFileHandler::Ctrl() {
|
||||
duration_dup = _duration;
|
||||
time_dup = _time;
|
||||
}
|
||||
|
||||
int32_t value = ratio_to_db(1.0);
|
||||
if (!_channel_pairs_count)
|
||||
_channel_pairs_count = 2;
|
||||
|
||||
if (_channel_pairs_count >= 3 && _channel_pairs_count <= 4) {
|
||||
for (int32_t i = 0; i < 2; i++) {
|
||||
SetChannelPairVolumePan(i, 0, 0, value);
|
||||
SetChannelPairVolumePan(i, 1, 1, value);
|
||||
SetChannelPairVolumePan(i, 0, 2, -10000);
|
||||
SetChannelPairVolumePan(i, 1, 3, -10000);
|
||||
}
|
||||
|
||||
for (int32_t i = _channel_pairs_count - 2; i < _channel_pairs_count; i++) {
|
||||
SetChannelPairVolumePan(i, 0, 0, -10000);
|
||||
SetChannelPairVolumePan(i, 1, 1, -10000);
|
||||
SetChannelPairVolumePan(i, 0, 2, value);
|
||||
SetChannelPairVolumePan(i, 1, 3, value);
|
||||
}
|
||||
}
|
||||
else
|
||||
for (int32_t i = 0; i < _channel_pairs_count; i++) {
|
||||
SetChannelPairVolumePan(i, 0, 0, value);
|
||||
SetChannelPairVolumePan(i, 1, 1, value);
|
||||
SetChannelPairVolumePan(i, 0, 2, value);
|
||||
SetChannelPairVolumePan(i, 1, 3, value);
|
||||
}
|
||||
}
|
||||
|
||||
void OggFileHandler::FillBuffer(sound_buffer_data* buffer, size_t samples_count) {
|
||||
@@ -422,6 +415,29 @@ void OggFileHandler::FillBuffer(sound_buffer_data* buffer, size_t samples_count)
|
||||
}
|
||||
}
|
||||
|
||||
int32_t OggFileHandler::GetChannelPairsCount() {
|
||||
std::unique_lock<std::mutex> u_lock(dup_mtx);
|
||||
return channel_pairs_count_dup;
|
||||
}
|
||||
|
||||
float_t OggFileHandler::GetDuration() {
|
||||
std::unique_lock<std::mutex> u_lock(dup_mtx);
|
||||
return (float_t)duration_dup;
|
||||
}
|
||||
|
||||
OggFileHandlerFileState OggFileHandler::GetFileState() {
|
||||
return (OggFileHandlerFileState)file_state.get();
|
||||
}
|
||||
|
||||
OggFileHandlerPauseState OggFileHandler::GetPauseState() {
|
||||
return (OggFileHandlerPauseState)pause_state.get();
|
||||
}
|
||||
|
||||
float_t OggFileHandler::GetTime() {
|
||||
std::unique_lock<std::mutex> u_lock(dup_mtx);
|
||||
return (float_t)time_dup;
|
||||
}
|
||||
|
||||
void OggFileHandler::OpenFile() {
|
||||
std::unique_lock<std::mutex> u_lock(file_mtx);
|
||||
if (file.OpenFile(path.c_str(), time_seek)) {
|
||||
@@ -446,7 +462,7 @@ void OggFileHandler::ReadBuffer(sound_buffer_data* buffer, size_t samples_count)
|
||||
for (int32_t j = 0; j < 2; j++)
|
||||
for (int32_t k = 0; k < 4; k++)
|
||||
((float_t*)&channel_pair_volume_pan[i][j])[k]
|
||||
= db_to_ratio(this->channel_pair_volume_pan[i][j][k]);
|
||||
= db_to_ratio(this->channel_pair_volume_pan[i][j][k]);
|
||||
channel_pair_volume[i] = db_to_ratio(this->channel_pair_volume[i]) * master_volume;
|
||||
}
|
||||
}
|
||||
@@ -475,7 +491,7 @@ void OggFileHandler::ReadBuffer(sound_buffer_data* buffer, size_t samples_count)
|
||||
if (_samples_count) {
|
||||
for (size_t i = _samples_count; i; i--, buffer++, _buffer_data++) {
|
||||
OggFileBufferChannelData* channel_pair = _buffer_data->channel_pair;
|
||||
vec4 value = vec4_null;
|
||||
vec4 value = 0.0f;
|
||||
for (size_t j = 0; j < 4; j++, channel_pair++) {
|
||||
value += (channel_pair_volume_pan[j][0] * (channel_pair_volume[j] * channel_pair->left));
|
||||
value += (channel_pair_volume_pan[j][1] * (channel_pair_volume[j] * channel_pair->right));
|
||||
@@ -539,9 +555,15 @@ void OggFileHandler::SetFileState(OggFileHandlerFileState state) {
|
||||
Reset(false);
|
||||
}
|
||||
|
||||
void OggFileHandler::SetMasterVolume(int32_t value) {
|
||||
value = clamp_def(value, -10000, 0);
|
||||
std::unique_lock<std::mutex> u_lock(volume_mtx);
|
||||
master_volume = value;
|
||||
}
|
||||
|
||||
void OggFileHandler::SetPath(std::string& path) {
|
||||
std::unique_lock<std::mutex> u_lock(mtx);
|
||||
file_state.set(1);
|
||||
file_state.set(OGG_FILE_HANDLER_FILE_STATE_LOADING);
|
||||
playback_state.set(OGG_FILE_HANDLER_PLAYBACK_STATE_PLAY);
|
||||
|
||||
{
|
||||
@@ -557,6 +579,19 @@ void OggFileHandler::SetPath(std::string&& path) {
|
||||
SetPath(*(std::string*)&path);
|
||||
}
|
||||
|
||||
void OggFileHandler::SetPauseState(OggFileHandlerPauseState value) {
|
||||
pause_state.set(value);
|
||||
}
|
||||
|
||||
void OggFileHandler::SetPlaybackState(OggFileHandlerPlaybackState value) {
|
||||
playback_state.set(value);
|
||||
}
|
||||
|
||||
void OggFileHandler::SetTimeSeek(float_t value) {
|
||||
std::unique_lock<std::mutex> u_lock(file_mtx);
|
||||
time_seek = value;
|
||||
}
|
||||
|
||||
void OggFileHandler::FillBufferStatic(sound_buffer_data* buffer, size_t samples_count, void* data) {
|
||||
if (data)
|
||||
((OggFileHandler*)data)->FillBuffer(buffer, samples_count);
|
||||
@@ -564,7 +599,12 @@ void OggFileHandler::FillBufferStatic(sound_buffer_data* buffer, size_t samples_
|
||||
|
||||
bool OggFileHandler::LoadFile(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
OggFileHandler* ofh = (OggFileHandler*)data;
|
||||
ofh->SetPath(std::string(path) + file);
|
||||
|
||||
std::string _path;
|
||||
_path.assign(path);
|
||||
_path.append(file);
|
||||
|
||||
ofh->SetPath(_path.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -581,3 +621,321 @@ void OggFileHandler::ThreadMain(OggFileHandler* ofh) {
|
||||
ofh->Ctrl();
|
||||
ofh->thread_state.set(0);
|
||||
}
|
||||
|
||||
|
||||
p_OggFileHandler::p_OggFileHandler(OggFileHandler* ptr) {
|
||||
this->ptr = ptr;
|
||||
}
|
||||
|
||||
p_OggFileHandler::~p_OggFileHandler() {
|
||||
if (ptr) {
|
||||
delete ptr;
|
||||
ptr = 0;
|
||||
}
|
||||
|
||||
std::list<p_OggFileHandler*>& list = ogg_file_handler_storage_ptr->list;
|
||||
for (std::list<p_OggFileHandler*>::iterator i = list.begin(); i != list.end();)
|
||||
if (*i == this) {
|
||||
list.erase(i);
|
||||
break;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
|
||||
int32_t p_OggFileHandler::GetChannelPairsCount() {
|
||||
if (ptr)
|
||||
return ptr->GetChannelPairsCount();
|
||||
return 0;
|
||||
}
|
||||
|
||||
float_t p_OggFileHandler::GetDuration() {
|
||||
if (ptr)
|
||||
return ptr->GetDuration();
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
OggFileHandlerFileState p_OggFileHandler::GetFileState() {
|
||||
if (ptr)
|
||||
return ptr->GetFileState();
|
||||
return OGG_FILE_HANDLER_FILE_STATE_MAX;
|
||||
}
|
||||
|
||||
OggFileHandlerPauseState p_OggFileHandler::GetPauseState() {
|
||||
if (ptr)
|
||||
return ptr->GetPauseState();
|
||||
return OGG_FILE_HANDLER_PAUSE_STATE_MAX;
|
||||
}
|
||||
|
||||
float_t p_OggFileHandler::GetTime() {
|
||||
if (ptr)
|
||||
return ptr->GetTime();
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
void p_OggFileHandler::SetChannelPairVolumePan(size_t src_channel_pair,
|
||||
int32_t src_channel, int32_t dst_channel, int32_t value) {
|
||||
if (ptr)
|
||||
ptr->SetChannelPairVolumePan(src_channel_pair, src_channel, dst_channel, value);
|
||||
}
|
||||
|
||||
void p_OggFileHandler::SetMasterVolume(int32_t value) {
|
||||
if (ptr)
|
||||
ptr->SetMasterVolume(value);
|
||||
}
|
||||
|
||||
void p_OggFileHandler::SetPath(std::string& path) {
|
||||
if (ptr)
|
||||
ptr->SetPath(path);
|
||||
}
|
||||
|
||||
void p_OggFileHandler::SetPath(std::string&& path) {
|
||||
if (ptr)
|
||||
ptr->SetPath(path);
|
||||
}
|
||||
|
||||
void p_OggFileHandler::SetPauseState(OggFileHandlerPauseState value) {
|
||||
if (ptr)
|
||||
ptr->SetPauseState(value);
|
||||
}
|
||||
|
||||
void p_OggFileHandler::SetPlaybackState(OggFileHandlerPlaybackState value) {
|
||||
if (ptr)
|
||||
ptr->SetPlaybackState(value);
|
||||
}
|
||||
|
||||
void p_OggFileHandler::SetTimeSeek(float_t value) {
|
||||
if (ptr)
|
||||
ptr->SetTimeSeek(value);
|
||||
}
|
||||
|
||||
OggPlayback::OggPlayback(size_t index) : state(), ogg_file_handler(), time_seek() {
|
||||
this->index = index;
|
||||
}
|
||||
|
||||
OggPlayback::~OggPlayback() {
|
||||
Reset();
|
||||
}
|
||||
|
||||
int32_t OggPlayback::GetChannelPairsCount() {
|
||||
if (state == 1 && ogg_file_handler)
|
||||
return ogg_file_handler->GetChannelPairsCount();
|
||||
return 0;
|
||||
}
|
||||
|
||||
float_t OggPlayback::GetDuration() {
|
||||
if (state == 1 && ogg_file_handler)
|
||||
return ogg_file_handler->GetDuration();
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
OggFileHandlerFileState OggPlayback::GetFileState() {
|
||||
if (state == 1 && ogg_file_handler)
|
||||
return ogg_file_handler->GetFileState();
|
||||
return OGG_FILE_HANDLER_FILE_STATE_MAX;
|
||||
}
|
||||
|
||||
OggFileHandlerPauseState OggPlayback::GetPauseState() {
|
||||
if (state == 1 && ogg_file_handler)
|
||||
return ogg_file_handler->GetPauseState();
|
||||
return OGG_FILE_HANDLER_PAUSE_STATE_MAX;
|
||||
}
|
||||
|
||||
float_t OggPlayback::GetTime() {
|
||||
if (state == 1 && ogg_file_handler)
|
||||
return ogg_file_handler->GetTime();
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
void OggPlayback::Reset() {
|
||||
if (state == 1)
|
||||
delete ogg_file_handler;
|
||||
state = 0;
|
||||
ogg_file_handler = 0;
|
||||
}
|
||||
|
||||
void OggPlayback::SetChannelPairVolumePan(size_t src_channel_pair,
|
||||
int32_t src_channel, int32_t dst_channel, int32_t value) {
|
||||
if (state != 1 || !ogg_file_handler)
|
||||
return;
|
||||
|
||||
switch (src_channel) {
|
||||
case 0:
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
src_channel = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (dst_channel) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
break;
|
||||
default:
|
||||
dst_channel = 4;
|
||||
break;
|
||||
}
|
||||
ogg_file_handler->SetChannelPairVolumePan(src_channel_pair, src_channel, dst_channel, value);
|
||||
}
|
||||
|
||||
void OggPlayback::SetMasterVolume(int32_t value) {
|
||||
if (state == 1 && ogg_file_handler)
|
||||
ogg_file_handler->SetMasterVolume(value);
|
||||
}
|
||||
|
||||
void OggPlayback::SetPath(std::string& path) {
|
||||
data_list[DATA_AFT].load_file(this, path.c_str(), OggPlayback::LoadFile);
|
||||
}
|
||||
|
||||
void OggPlayback::SetPath(std::string&& path) {
|
||||
SetPath(*(std::string*)&path);
|
||||
}
|
||||
|
||||
void OggPlayback::SetPauseState(OggFileHandlerPauseState value) {
|
||||
if (state == 1 && ogg_file_handler)
|
||||
ogg_file_handler->SetPauseState(value);
|
||||
}
|
||||
|
||||
void OggPlayback::SetPlaybackState(OggFileHandlerPlaybackState value) {
|
||||
if (state == 1 && ogg_file_handler)
|
||||
ogg_file_handler->SetPlaybackState(value);
|
||||
}
|
||||
|
||||
void OggPlayback::SetTimeSeek(float_t value) {
|
||||
time_seek = value;
|
||||
}
|
||||
|
||||
bool OggPlayback::LoadFile(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
OggPlayback* op = (OggPlayback*)data;
|
||||
|
||||
std::string _path;
|
||||
_path.assign(path);
|
||||
_path.append(file);
|
||||
|
||||
if (_path.size() < 4)
|
||||
return false;
|
||||
|
||||
std::string ext;
|
||||
ext.assign(_path.c_str() + (_path.size() - 4), 4);
|
||||
for (char& c : ext)
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
c += 0x20;
|
||||
|
||||
if (ext.compare(".ogg"))
|
||||
return false;
|
||||
|
||||
if (op->state != 1) {
|
||||
op->Reset();
|
||||
op->ogg_file_handler = ogg_file_handler_storage_get_ogg_file_handler(op->index);
|
||||
}
|
||||
|
||||
if (op->ogg_file_handler) {
|
||||
op->ogg_file_handler->SetTimeSeek(op->time_seek);
|
||||
op->ogg_file_handler->SetPath(_path);
|
||||
op->state = 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void OggPlayback::SetChannelPairVolumePan(OggPlayback* op) {
|
||||
if (!op)
|
||||
return;
|
||||
|
||||
int32_t value = ratio_to_db(1.0);
|
||||
|
||||
int32_t _channel_pairs_count = op->GetChannelPairsCount();
|
||||
if (!_channel_pairs_count)
|
||||
_channel_pairs_count = 2;
|
||||
|
||||
if (_channel_pairs_count >= 3 && _channel_pairs_count <= 4) {
|
||||
for (int32_t i = 0; i < 2; i++) {
|
||||
op->SetChannelPairVolumePan(i, 0, 0, value);
|
||||
op->SetChannelPairVolumePan(i, 1, 1, value);
|
||||
op->SetChannelPairVolumePan(i, 0, 2, -10000);
|
||||
op->SetChannelPairVolumePan(i, 1, 3, -10000);
|
||||
}
|
||||
|
||||
for (int32_t i = _channel_pairs_count - 2; i < _channel_pairs_count; i++) {
|
||||
op->SetChannelPairVolumePan(i, 0, 0, -10000);
|
||||
op->SetChannelPairVolumePan(i, 1, 1, -10000);
|
||||
op->SetChannelPairVolumePan(i, 0, 2, value);
|
||||
op->SetChannelPairVolumePan(i, 1, 3, value);
|
||||
}
|
||||
}
|
||||
else
|
||||
for (int32_t i = 0; i < _channel_pairs_count; i++) {
|
||||
op->SetChannelPairVolumePan(i, 0, 0, value);
|
||||
op->SetChannelPairVolumePan(i, 1, 1, value);
|
||||
op->SetChannelPairVolumePan(i, 0, 2, value);
|
||||
op->SetChannelPairVolumePan(i, 1, 3, value);
|
||||
}
|
||||
}
|
||||
|
||||
void ogg_playback_data_init() {
|
||||
for (size_t i = 0; i < OGG_PLAYBACK_DATA_COUNT; i++)
|
||||
ogg_playback_data[i] = new OggPlayback(i);
|
||||
}
|
||||
|
||||
void ogg_playback_data_free() {
|
||||
for (size_t i = 0; i < OGG_PLAYBACK_DATA_COUNT; i++)
|
||||
if (ogg_playback_data[i]) {
|
||||
delete ogg_playback_data[i];
|
||||
ogg_playback_data[i] = 0;
|
||||
}
|
||||
|
||||
if (ogg_file_handler_storage_ptr)
|
||||
ogg_file_handler_storage_ptr->free_data();
|
||||
}
|
||||
|
||||
OggPlayback* ogg_playback_data_get(size_t index) {
|
||||
if (index >= 0 && index < OGG_PLAYBACK_DATA_COUNT)
|
||||
return ogg_playback_data[index];
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ogg_file_handler_storage_init() {
|
||||
if (!ogg_file_handler_storage_init_count)
|
||||
ogg_file_handler_storage_ptr = new ogg_file_handler_storage;
|
||||
ogg_file_handler_storage_init_count++;
|
||||
}
|
||||
|
||||
void ogg_file_handler_storage_free() {
|
||||
if (!--ogg_file_handler_storage_init_count) {
|
||||
delete ogg_file_handler_storage_ptr;
|
||||
ogg_file_handler_storage_ptr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ogg_file_handler_storage::ogg_file_handler_storage() : clear() {
|
||||
|
||||
}
|
||||
|
||||
ogg_file_handler_storage::~ogg_file_handler_storage() {
|
||||
free_data();
|
||||
}
|
||||
|
||||
void ogg_file_handler_storage::free_data() {
|
||||
if (clear)
|
||||
return;
|
||||
|
||||
for (p_OggFileHandler*& i : list)
|
||||
delete i;
|
||||
clear = true;
|
||||
}
|
||||
|
||||
static p_OggFileHandler* ogg_file_handler_storage_get_ogg_file_handler(size_t index) {
|
||||
OggFileHandler* ofh = new OggFileHandler(index);
|
||||
if (ofh) {
|
||||
p_OggFileHandler* pofh = new p_OggFileHandler(ofh);
|
||||
if (pofh) {
|
||||
std::unique_lock<std::mutex> u_lock(ogg_file_handler_storage_ptr->mtx);
|
||||
ogg_file_handler_storage_ptr->list.push_back(pofh);
|
||||
return pofh;
|
||||
}
|
||||
delete ofh;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -133,6 +133,11 @@ struct OggFileHandler {
|
||||
virtual ~OggFileHandler();
|
||||
|
||||
void Ctrl();
|
||||
int32_t GetChannelPairsCount();
|
||||
float_t GetDuration();
|
||||
OggFileHandlerFileState GetFileState();
|
||||
OggFileHandlerPauseState GetPauseState();
|
||||
float_t GetTime();
|
||||
void FillBuffer(sound_buffer_data* buffer, size_t samples_count);
|
||||
void OpenFile();
|
||||
void ReadBuffer(sound_buffer_data* buffer, size_t samples_count);
|
||||
@@ -141,10 +146,70 @@ struct OggFileHandler {
|
||||
void SetChannelPairVolumePan(size_t src_channel_pair,
|
||||
int32_t src_channel, int32_t dst_channel, int32_t value);
|
||||
void SetFileState(OggFileHandlerFileState state);
|
||||
void SetMasterVolume(int32_t value);
|
||||
void SetPath(std::string& path);
|
||||
void SetPath(std::string&& path);
|
||||
void SetPauseState(OggFileHandlerPauseState value);
|
||||
void SetPlaybackState(OggFileHandlerPlaybackState value);
|
||||
void SetTimeSeek(float_t value);
|
||||
|
||||
static void FillBufferStatic(sound_buffer_data* buffer, size_t samples_count, void* data);
|
||||
static bool LoadFile(void* data, const char* path, const char* file, uint32_t hash);
|
||||
static void ThreadMain(OggFileHandler* ofh);
|
||||
};
|
||||
|
||||
struct p_OggFileHandler {
|
||||
OggFileHandler* ptr;
|
||||
|
||||
p_OggFileHandler(OggFileHandler* ptr);
|
||||
~p_OggFileHandler();
|
||||
|
||||
int32_t GetChannelPairsCount();
|
||||
float_t GetDuration();
|
||||
OggFileHandlerFileState GetFileState();
|
||||
OggFileHandlerPauseState GetPauseState();
|
||||
float_t GetTime();
|
||||
void SetChannelPairVolumePan(size_t src_channel_pair,
|
||||
int32_t src_channel, int32_t dst_channel, int32_t value);
|
||||
void SetMasterVolume(int32_t value);
|
||||
void SetPath(std::string& path);
|
||||
void SetPath(std::string&& path);
|
||||
void SetPauseState(OggFileHandlerPauseState value);
|
||||
void SetPlaybackState(OggFileHandlerPlaybackState value);
|
||||
void SetTimeSeek(float_t value);
|
||||
};
|
||||
|
||||
struct OggPlayback {
|
||||
size_t index;
|
||||
int32_t state;
|
||||
p_OggFileHandler* ogg_file_handler;
|
||||
float_t time_seek;
|
||||
|
||||
OggPlayback(size_t index);
|
||||
~OggPlayback();
|
||||
|
||||
int32_t GetChannelPairsCount();
|
||||
float_t GetDuration();
|
||||
OggFileHandlerFileState GetFileState();
|
||||
OggFileHandlerPauseState GetPauseState();
|
||||
float_t GetTime();
|
||||
void Reset();
|
||||
void SetChannelPairVolumePan(size_t src_channel_pair,
|
||||
int32_t src_channel, int32_t dst_channel, int32_t value);
|
||||
void SetMasterVolume(int32_t value);
|
||||
void SetPath(std::string& path);
|
||||
void SetPath(std::string&& path);
|
||||
void SetPauseState(OggFileHandlerPauseState value);
|
||||
void SetPlaybackState(OggFileHandlerPlaybackState value);
|
||||
void SetTimeSeek(float_t value);
|
||||
|
||||
static bool LoadFile(void* data, const char* path, const char* file, uint32_t hash);
|
||||
static void SetChannelPairVolumePan(OggPlayback* op);
|
||||
};
|
||||
|
||||
extern void ogg_playback_data_init();
|
||||
extern void ogg_playback_data_free();
|
||||
extern OggPlayback* ogg_playback_data_get(size_t index);
|
||||
|
||||
extern void ogg_file_handler_storage_init();
|
||||
extern void ogg_file_handler_storage_free();
|
||||
|
||||
+43
-23
@@ -15,9 +15,9 @@
|
||||
|
||||
extern bool task_stage_is_modern;
|
||||
|
||||
post_process::post_process() : ssaa(), mlaa(), ss_alpha_mask(), render_textures_data(),
|
||||
movie_textures_data(), lens_flare_texture(), lens_shaft_texture(), lens_ghost_texture(),
|
||||
lens_flare_count(), lens_flare_pos(), lens_shaft_scale(), lens_shaft_inv_scale(),
|
||||
post_process::post_process() : ssaa(), mlaa(), ss_alpha_mask(), aet_back_tex(), render_textures_data(),
|
||||
movie_textures_data(), texture_counter(), lens_flare_texture(), lens_shaft_texture(),
|
||||
lens_ghost_texture(), lens_flare_count(), lens_flare_pos(), lens_shaft_scale(), lens_shaft_inv_scale(),
|
||||
lens_flare_power(), field_A10(), lens_flare_appear_power(), render_width(), render_height(),
|
||||
view_point(), interest(), view_point_prev(), interest_prev(), reset_exposure(), sprite_width(),
|
||||
sprite_height(), screen_x_offset(), screen_y_offset(), screen_width(), screen_height(), mag_filter() {
|
||||
@@ -94,26 +94,30 @@ sprite_height(), screen_x_offset(), screen_y_offset(), screen_width(), screen_he
|
||||
glSamplerParameteri(samplers[1], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
const float_t verts_quad[] = {
|
||||
-1.0f, 1.0f, 0.15f, 0.85f,
|
||||
-1.0f, -1.0f, 0.15f, 0.15f,
|
||||
1.0f, -1.0f, 0.85f, 0.15f,
|
||||
-1.0f, 1.0f, 0.15f, 0.85f,
|
||||
1.0f, 1.0f, 0.85f, 0.85f,
|
||||
};
|
||||
|
||||
glGenVertexArrays(1, &query_vao);
|
||||
glGenBuffers(1, &query_vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, query_vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(verts_quad), verts_quad, GL_STATIC_DRAW);
|
||||
|
||||
gl_state_bind_vertex_array(query_vao);
|
||||
|
||||
glGenBuffers(1, &query_vbo);
|
||||
gl_state_bind_array_buffer(query_vbo, true);
|
||||
if (GLAD_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ARRAY_BUFFER, sizeof(verts_quad), verts_quad, 0);
|
||||
else
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(verts_quad), verts_quad, GL_STATIC_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 16, (void*)0); // Pos
|
||||
glVertexAttrib4f(3, 1.0f, 1.0f, 1.0f, 1.0f); // Color0
|
||||
glVertexAttrib4f(4, 1.0f, 1.0f, 1.0f, 1.0f); // Color1
|
||||
glEnableVertexAttribArray(8);
|
||||
glVertexAttribPointer(8, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord0
|
||||
gl_state_bind_array_buffer(0);
|
||||
gl_state_bind_vertex_array(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
shader_glsl_param param = {};
|
||||
param.name = "Exposure Chara";
|
||||
@@ -128,6 +132,9 @@ sprite_height(), screen_x_offset(), screen_y_offset(), screen_width(), screen_he
|
||||
}
|
||||
|
||||
post_process::~post_process() {
|
||||
if (aet_back_tex)
|
||||
texture_free(aet_back_tex);
|
||||
|
||||
if (aa) {
|
||||
delete aa;
|
||||
aa = 0;
|
||||
@@ -180,15 +187,15 @@ void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param
|
||||
for (int32_t i = 0; i < 8; i++)
|
||||
gl_state_bind_sampler(i, 0);
|
||||
|
||||
dof->apply(&rend_texture, samplers, cam);
|
||||
dof->apply(&rend_texture, &buf_texture, samplers, cam);
|
||||
|
||||
shaders_ft.state_matrix_set_mvp(mat4_identity, mat4_identity, mat4_identity);
|
||||
|
||||
blur->get_blur(&rend_texture);
|
||||
exposure->get_exposure(cam, render_width, render_height, reset_exposure,
|
||||
blur->tex[4].color_texture->tex, blur->tex[2].color_texture->tex);
|
||||
tone_map->apply(&rend_texture, light_proj_tex, 0,
|
||||
&rend_texture, &buf_texture, &sss_contour_texture,
|
||||
tone_map->apply(&rend_texture, light_proj_tex, (texture*)(aet_back ? aet_back_tex : 0),
|
||||
&rend_texture, &buf_texture,/* &sss_contour_texture,*/
|
||||
blur->tex[0].color_texture->tex,
|
||||
exposure->exposure.color_texture->tex, npr_param);
|
||||
if (mlaa)
|
||||
@@ -210,8 +217,7 @@ void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param
|
||||
gl_state_active_bind_texture_2d(0, rend_texture.color_texture->tex);
|
||||
gl_state_bind_sampler(0, samplers[0]);
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
render_texture::draw_params(&shaders_ft, render_width,
|
||||
render_height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, render_width, render_height);
|
||||
}
|
||||
|
||||
fbo::blit(rend_texture.fbos[0], post_texture.fbos[0],
|
||||
@@ -226,8 +232,7 @@ void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param
|
||||
uniform_value[U_ALPHA_MASK] = ss_alpha_mask ? 1 : 0;
|
||||
uniform_value[U_REDUCE] = 0;
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
render_texture::draw_params(&shaders_ft, render_width,
|
||||
render_height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, render_width, render_height);
|
||||
uniform_value[U_ALPHA_MASK] = 0;
|
||||
}
|
||||
else {
|
||||
@@ -252,8 +257,7 @@ void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param
|
||||
}
|
||||
|
||||
shaders_ft.set(SHADER_FT_MAGNIFY);
|
||||
render_texture::draw_params(&shaders_ft, render_width,
|
||||
render_height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, render_width, render_height);
|
||||
}
|
||||
shader::unbind();
|
||||
|
||||
@@ -297,12 +301,14 @@ void post_process::ctrl(camera* cam) {
|
||||
void post_process::draw_query_samples(GLuint query, float_t scale, mat4& mat) {
|
||||
glBeginQuery(GL_SAMPLES_PASSED, query);
|
||||
gl_state_bind_vertex_array(query_vao);
|
||||
query_shader.use();
|
||||
query_shader.set("mat", false, mat);
|
||||
query_shader.set("scale", scale);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
gl_state_bind_vertex_array(0);
|
||||
glEndQuery(GL_SAMPLES_PASSED);
|
||||
}
|
||||
|
||||
void post_process::init_fbo(int32_t render_width, int32_t render_height,
|
||||
int32_t sprite_width, int32_t sprite_height, int32_t screen_width, int32_t screen_height) {
|
||||
if (this->render_width == render_width && this->render_height == render_height
|
||||
@@ -317,7 +323,11 @@ void post_process::init_fbo(int32_t render_width, int32_t render_height,
|
||||
tone_map->init_fbo();
|
||||
rend_texture.init(render_width, render_height, 0, GL_RGBA16F, GL_DEPTH_COMPONENT32F);
|
||||
buf_texture.init(render_width, render_height, 0, GL_RGBA16F, 0);
|
||||
sss_contour_texture.init(render_width, render_height, 0, GL_RGBA16F, GL_DEPTH_COMPONENT32F);
|
||||
sss_contour_texture.init(render_width, render_height, 0, GL_RGBA8, GL_DEPTH_COMPONENT32F);
|
||||
if (aet_back_tex)
|
||||
texture_free(aet_back_tex);
|
||||
aet_back_tex = texture_load_tex_2d(texture_id(0x25, texture_counter++), GL_RGBA8, render_width, render_height, 0, 0, false);
|
||||
aet_back_texture.set_color_depth_textures(aet_back_tex->tex, 0, rend_texture.depth_texture->tex);
|
||||
pre_texture.init(render_width, render_height, 0, GL_RGBA16F, 0);
|
||||
post_texture.init(render_width, render_height, 0, GL_RGBA16F, 0);
|
||||
alpha_layer_texture.init(render_width, render_height, 0, GL_RGBA16F, GL_DEPTH_COMPONENT32F);
|
||||
@@ -355,7 +365,7 @@ int32_t post_process::movie_texture_set(texture* movie_texture) {
|
||||
return -1;
|
||||
|
||||
movie_textures_data[index] = movie_texture;
|
||||
movie_textures[index].set_color_depth_textures(movie_texture->tex, 0, 0, false);
|
||||
movie_textures[index].set_color_depth_textures(movie_texture->tex, 0, 0);
|
||||
return index;
|
||||
}
|
||||
|
||||
@@ -369,7 +379,7 @@ void post_process::movie_texture_free(texture* movie_texture) {
|
||||
return;
|
||||
|
||||
movie_textures_data[index] = 0;
|
||||
movie_textures[index].free_data();
|
||||
movie_textures[index].free();
|
||||
}
|
||||
|
||||
int32_t post_process::render_texture_set(texture* render_texture, bool task_photo) {
|
||||
@@ -385,7 +395,7 @@ int32_t post_process::render_texture_set(texture* render_texture, bool task_phot
|
||||
return -1;
|
||||
|
||||
render_textures_data[index] = render_texture;
|
||||
render_textures[index].set_color_depth_textures(render_texture->tex, 0, 0, false);
|
||||
render_textures[index].set_color_depth_textures(render_texture->tex, 0, 0);
|
||||
return index;
|
||||
}
|
||||
|
||||
@@ -402,7 +412,7 @@ void post_process::render_texture_free(texture* render_texture, bool task_photo)
|
||||
return;
|
||||
|
||||
render_textures_data[index] = 0;
|
||||
render_textures[index].free_data();
|
||||
render_textures[index].free();
|
||||
}
|
||||
|
||||
void post_process::reset() {
|
||||
@@ -419,3 +429,13 @@ void post_process::reset() {
|
||||
0, tone_trans_start, tone_trans_end, TONE_MAP_YCC_EXPONENT);
|
||||
reset_exposure = true;
|
||||
}
|
||||
|
||||
void post_process::set_render_texture(bool aet_back) {
|
||||
if (aet_back) {
|
||||
aet_back_texture.bind();
|
||||
this->aet_back = 1;
|
||||
}
|
||||
else
|
||||
rend_texture.bind();
|
||||
glViewport(0, 0, render_width, render_height);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ struct post_process {
|
||||
render_texture rend_texture;
|
||||
render_texture buf_texture;
|
||||
render_texture sss_contour_texture;
|
||||
texture* aet_back_tex;
|
||||
render_texture aet_back_texture;
|
||||
render_texture pre_texture;
|
||||
render_texture post_texture;
|
||||
render_texture fbo_texture;
|
||||
@@ -40,6 +42,7 @@ struct post_process {
|
||||
render_texture render_textures[16];
|
||||
texture* movie_textures_data[1];
|
||||
render_texture movie_textures[1];
|
||||
int32_t aet_back;
|
||||
post_process_aa* aa;
|
||||
post_process_blur* blur;
|
||||
post_process_dof* dof;
|
||||
@@ -50,6 +53,7 @@ struct post_process {
|
||||
GLuint query_vao;
|
||||
GLuint query_vbo;
|
||||
shader_glsl alpha_layer_shader;
|
||||
int32_t texture_counter;
|
||||
GLuint lens_flare_texture;
|
||||
GLuint lens_shaft_texture;
|
||||
GLuint lens_ghost_texture;
|
||||
@@ -90,5 +94,6 @@ struct post_process {
|
||||
int32_t render_texture_set(texture* render_texture, bool task_photo);
|
||||
void render_texture_free(texture* render_texture, bool task_photo);
|
||||
void reset();
|
||||
void set_render_texture(bool aet_back = false);
|
||||
};
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ void post_process_aa::apply_mlaa(render_texture* rt,
|
||||
//shaders_ft.set(SHADER_FT_MLAA);
|
||||
uniform_value[U_ALPHA_MASK] = 0;
|
||||
shaders_ft.set(SHADER_FT_MLAA_EDGE);
|
||||
render_texture::draw_params(&shaders_ft, width, height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, width, height);
|
||||
|
||||
mlaa_buffer[1].bind();
|
||||
gl_state_active_bind_texture_2d(0, mlaa_buffer[0].color_texture->tex);
|
||||
@@ -56,7 +56,7 @@ void post_process_aa::apply_mlaa(render_texture* rt,
|
||||
//shaders_ft.set(SHADER_FT_MLAA);
|
||||
uniform_value[U_MLAA_SEARCH] = 2;
|
||||
shaders_ft.set(SHADER_FT_MLAA_AREA);
|
||||
render_texture::draw_params(&shaders_ft, width, height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, width, height);
|
||||
|
||||
buf_rt->bind();
|
||||
gl_state_active_bind_texture_2d(0, rt->color_texture->tex);
|
||||
@@ -67,7 +67,7 @@ void post_process_aa::apply_mlaa(render_texture* rt,
|
||||
//shaders_ft.set(SHADER_FT_MLAA);
|
||||
uniform_value[U_ALPHA_MASK] = ss_alpha_mask ? 1 : 0;
|
||||
shaders_ft.set(SHADER_FT_MLAA_BLEND);
|
||||
render_texture::draw_params(&shaders_ft, width, height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, width, height);
|
||||
uniform_value[U_ALPHA_MASK] = 0;
|
||||
gl_state_active_bind_texture_2d(0, 0);
|
||||
gl_state_active_bind_texture_2d(1, 0);
|
||||
|
||||
@@ -28,7 +28,7 @@ post_process_blur:: ~post_process_blur() {
|
||||
return;
|
||||
|
||||
for (int32_t i = 0; i < count_down; i++)
|
||||
tex_down[i].free_data();
|
||||
tex_down[i].free();
|
||||
free_def(tex_down);
|
||||
free_def(height_down);
|
||||
free_def(width_down);
|
||||
@@ -40,21 +40,20 @@ void post_process_blur::get_blur(render_texture* rt) {
|
||||
int32_t i = 0;
|
||||
if (count_down > 0) {
|
||||
uniform_value[U_REDUCE] = 1;
|
||||
render_texture::shader_set(&shaders_ft, SHADER_FT_REDUCE);
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
for (; i < count_down; i++) {
|
||||
glViewport(0, 0, width_down[i], height_down[i]);
|
||||
tex_down[i].bind();
|
||||
gl_state_active_bind_texture_2d(0, i
|
||||
? tex_down[i - 1].color_texture->tex
|
||||
: rt->color_texture->tex);
|
||||
render_texture::draw_params(&shaders_ft,
|
||||
width_down[i], height_down[i], 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, width_down[i], height_down[i]);
|
||||
}
|
||||
i--;
|
||||
}
|
||||
|
||||
uniform_value[U_REDUCE] = 3;
|
||||
render_texture::shader_set(&shaders_ft, SHADER_FT_REDUCE);
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
shaders_ft.local_frag_set(2, 1.1f, 1.1f, 1.1f, 0.0f);
|
||||
|
||||
glViewport(0, 0, 256, 144);
|
||||
@@ -62,10 +61,11 @@ void post_process_blur::get_blur(render_texture* rt) {
|
||||
gl_state_active_bind_texture_2d(0, count_down > 0
|
||||
? tex_down[i].color_texture->tex
|
||||
: rt->color_texture->tex);
|
||||
render_texture::draw_params(&shaders_ft, width, height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, width, height);
|
||||
|
||||
uniform_value[U_GAUSS] = 1;
|
||||
render_texture::shader_set(&shaders_ft, SHADER_FT_GAUSS);
|
||||
//uniform_value[U_GAUSS] = 1;
|
||||
//shaders_ft.set(SHADER_FT_GAUSS);
|
||||
shaders_ft.set(SHADER_FT_GAUSS_CONE);
|
||||
|
||||
glViewport(0, 0, 256, 144);
|
||||
tex[5].bind();
|
||||
@@ -74,7 +74,7 @@ void post_process_blur::get_blur(render_texture* rt) {
|
||||
1.0f, data.intensity.x * 0.5f, data.intensity.y * 0.5f, data.intensity.z * 0.5f, 1.0f);
|
||||
|
||||
uniform_value[U_REDUCE] = 1;
|
||||
render_texture::shader_set(&shaders_ft, SHADER_FT_REDUCE);
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
|
||||
glViewport(0, 0, 128, 72);
|
||||
tex[1].bind();
|
||||
@@ -82,7 +82,7 @@ void post_process_blur::get_blur(render_texture* rt) {
|
||||
render_texture::draw_params(&shaders_ft, 256, 144, 0.75f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
uniform_value[U_REDUCE] = 1;
|
||||
render_texture::shader_set(&shaders_ft, SHADER_FT_REDUCE);
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
|
||||
glViewport(0, 0, 64, 36);
|
||||
tex[2].bind();
|
||||
@@ -90,20 +90,21 @@ void post_process_blur::get_blur(render_texture* rt) {
|
||||
render_texture::draw_params(&shaders_ft, 128, 72, 0.75f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
uniform_value[U_REDUCE] = 1;
|
||||
render_texture::shader_set(&shaders_ft, SHADER_FT_REDUCE);
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
|
||||
glViewport(0, 0, 32, 18);
|
||||
tex[3].bind();
|
||||
gl_state_active_bind_texture_2d(0, tex[2].color_texture->tex);
|
||||
render_texture::draw_params(&shaders_ft, 64, 36, 0.75f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
uniform_value[U_EXPOSURE] = 0;
|
||||
render_texture::shader_set(&shaders_ft, SHADER_FT_EXPOSURE);
|
||||
//uniform_value[U_EXPOSURE] = 0;
|
||||
//shaders_ft.set(SHADER_FT_EXPOSURE);
|
||||
shaders_ft.set(SHADER_FT_EXPOSURE_MINIFY);
|
||||
|
||||
glViewport(0, 0, 8, 8);
|
||||
tex[4].bind();
|
||||
gl_state_active_bind_texture_2d(0, tex[3].color_texture->tex);
|
||||
render_texture::draw_params(&shaders_ft, 32, 18, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, 32, 18);
|
||||
|
||||
vec3 intensity = data.intensity;
|
||||
vec3* gauss = data.gauss;
|
||||
@@ -112,8 +113,9 @@ void post_process_blur::get_blur(render_texture* rt) {
|
||||
for (int32_t i = 0; i < POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE; i++)
|
||||
v[i] = gauss[i] * intensity;
|
||||
|
||||
uniform_value[U_GAUSS] = 0;
|
||||
render_texture::shader_set(&shaders_ft, SHADER_FT_GAUSS);
|
||||
//uniform_value[U_GAUSS] = 0;
|
||||
//shaders_ft.set(SHADER_FT_GAUSS);
|
||||
shaders_ft.set(SHADER_FT_GAUSS_USUAL);
|
||||
shaders_ft.local_frag_set(1, 1.0f, 0.0f, 1.0f, 0.0f);
|
||||
for (int32_t i = 0; i < POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE; i++)
|
||||
shaders_ft.local_frag_set(4ULL + i, v[i].x, v[i].y, v[i].z, 0.0f);
|
||||
@@ -121,7 +123,7 @@ void post_process_blur::get_blur(render_texture* rt) {
|
||||
glViewport(0, 0, 128, 72);
|
||||
tex[0].bind();
|
||||
gl_state_active_bind_texture_2d(0, tex[1].color_texture->tex);
|
||||
render_texture::draw_params(&shaders_ft, 128, 72, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, 128, 72);
|
||||
fbo::blit(tex[0].fbos[0], tex[1].fbos[0],
|
||||
0, 0, 128, 72,
|
||||
0, 0, 128, 72, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
@@ -129,7 +131,7 @@ void post_process_blur::get_blur(render_texture* rt) {
|
||||
glViewport(0, 0, 64, 36);
|
||||
tex[0].bind();
|
||||
gl_state_active_bind_texture_2d(0, tex[2].color_texture->tex);
|
||||
render_texture::draw_params(&shaders_ft, 64, 36, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, 64, 36);
|
||||
fbo::blit(tex[0].fbos[0], tex[2].fbos[0],
|
||||
0, 0, 64, 36,
|
||||
0, 0, 64, 36, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
@@ -137,7 +139,7 @@ void post_process_blur::get_blur(render_texture* rt) {
|
||||
glViewport(0, 0, 32, 18);
|
||||
tex[0].bind();
|
||||
gl_state_active_bind_texture_2d(0, tex[3].color_texture->tex);
|
||||
render_texture::draw_params(&shaders_ft, 32, 18, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, 32, 18);
|
||||
fbo::blit(tex[0].fbos[0], tex[3].fbos[0],
|
||||
0, 0, 32, 18,
|
||||
0, 0, 32, 18, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
@@ -147,7 +149,7 @@ void post_process_blur::get_blur(render_texture* rt) {
|
||||
glViewport(0, 0, 128, 72);
|
||||
tex[0].bind();
|
||||
gl_state_active_bind_texture_2d(0, tex[1].color_texture->tex);
|
||||
render_texture::draw_params(&shaders_ft, 128, 72, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, 128, 72);
|
||||
fbo::blit(tex[0].fbos[0], tex[1].fbos[0],
|
||||
0, 0, 128, 72,
|
||||
0, 0, 128, 72, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
@@ -155,7 +157,7 @@ void post_process_blur::get_blur(render_texture* rt) {
|
||||
glViewport(0, 0, 64, 36);
|
||||
tex[0].bind();
|
||||
gl_state_active_bind_texture_2d(0, tex[2].color_texture->tex);
|
||||
render_texture::draw_params(&shaders_ft, 64, 36, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, 64, 36);
|
||||
fbo::blit(tex[0].fbos[0], tex[2].fbos[0],
|
||||
0, 0, 64, 36,
|
||||
0, 0, 64, 36, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
@@ -163,13 +165,13 @@ void post_process_blur::get_blur(render_texture* rt) {
|
||||
glViewport(0, 0, 32, 18);
|
||||
tex[0].bind();
|
||||
gl_state_active_bind_texture_2d(0, tex[3].color_texture->tex);
|
||||
render_texture::draw_params(&shaders_ft, 32, 18, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, 32, 18);
|
||||
fbo::blit(tex[0].fbos[0], tex[3].fbos[0],
|
||||
0, 0, 32, 18,
|
||||
0, 0, 32, 18, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
uniform_value[U_REDUCE] = 7;
|
||||
render_texture::shader_set(&shaders_ft, SHADER_FT_REDUCE);
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
|
||||
glViewport(0, 0, 256, 144);
|
||||
tex[0].bind();
|
||||
@@ -249,12 +251,8 @@ void post_process_blur::init_fbo(int32_t width, int32_t height) {
|
||||
}
|
||||
|
||||
void post_process_blur::initialize_data(const vec3& radius, const vec3& intensity) {
|
||||
data.radius.x = clamp_def(radius.x, 1.0f, 3.0f);
|
||||
data.radius.y = clamp_def(radius.y, 1.0f, 3.0f);
|
||||
data.radius.z = clamp_def(radius.z, 1.0f, 3.0f);
|
||||
data.intensity.x = clamp_def(intensity.x, 0.0f, 2.0f);
|
||||
data.intensity.y = clamp_def(intensity.y, 0.0f, 2.0f);
|
||||
data.intensity.z = clamp_def(intensity.z, 0.0f, 2.0f);
|
||||
data.radius = vec3::clamp(radius, 1.0f, 3.0f);
|
||||
data.intensity = vec3::clamp(intensity, 0.0f, 2.0f);
|
||||
post_process_blur_radius_calculate(this);
|
||||
}
|
||||
|
||||
@@ -263,9 +261,7 @@ vec3 post_process_blur::get_intensity() {
|
||||
}
|
||||
|
||||
void post_process_blur::set_intensity(const vec3& value) {
|
||||
data.intensity.x = clamp_def(value.x, 0.0f, 2.0f);
|
||||
data.intensity.y = clamp_def(value.y, 0.0f, 2.0f);
|
||||
data.intensity.z = clamp_def(value.z, 0.0f, 2.0f);
|
||||
data.intensity = vec3::clamp(value, 0.0f, 2.0f);
|
||||
}
|
||||
|
||||
vec3 post_process_blur::get_radius() {
|
||||
@@ -273,11 +269,8 @@ vec3 post_process_blur::get_radius() {
|
||||
}
|
||||
|
||||
void post_process_blur::set_radius(const vec3& value) {
|
||||
vec3 temp;
|
||||
temp.x = clamp_def(value.x, 1.0f, 3.0f);
|
||||
temp.y = clamp_def(value.y, 1.0f, 3.0f);
|
||||
temp.z = clamp_def(value.z, 1.0f, 3.0f);
|
||||
if (memcmp(&temp, &data.radius, sizeof(vec3))) {
|
||||
vec3 temp = vec3::clamp(value, 1.0f, 3.0f);
|
||||
if (temp != data.radius) {
|
||||
data.radius = temp;
|
||||
post_process_blur_radius_calculate(this);
|
||||
}
|
||||
|
||||
@@ -602,20 +602,20 @@ static const dof_pv dof_pv_default = {
|
||||
namespace renderer {
|
||||
struct DOF3 {
|
||||
static void apply_f2(post_process_dof* dof, render_texture* rt,
|
||||
GLuint* samplers, GLuint color_texture, GLuint depth_texture,
|
||||
float_t min_distance, float_t max_distance, float_t fov, float_t focus,
|
||||
float_t focus_range, float_t fuzzing_range, float_t ratio);
|
||||
render_texture* buf, GLuint* samplers, GLuint color_texture,
|
||||
GLuint depth_texture, float_t min_distance, float_t max_distance, float_t fov,
|
||||
float_t focus, float_t focus_range, float_t fuzzing_range, float_t ratio);
|
||||
static void apply_physical(post_process_dof* dof, render_texture* rt,
|
||||
GLuint* samplers, GLuint color_texture, GLuint depth_texture,
|
||||
float_t min_distance, float_t max_distance, float_t focus,
|
||||
float_t focal_length, float_t fov, float_t f_number);
|
||||
render_texture* buf, GLuint* samplers, GLuint color_texture,
|
||||
GLuint depth_texture, float_t min_distance, float_t max_distance,
|
||||
float_t focus, float_t focal_length, float_t fov, float_t f_number);
|
||||
|
||||
static void render_tiles(post_process_dof* dof,
|
||||
GLuint* samplers, GLuint depth_texture, bool f2);
|
||||
static void downsample(post_process_dof* dof,
|
||||
GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2);
|
||||
static void apply_main_filter(post_process_dof* dof, GLuint* samplers, bool f2);
|
||||
static void upsample(post_process_dof* dof, render_texture* rt,
|
||||
static void upsample(post_process_dof* dof, render_texture* rt, render_texture* buf,
|
||||
GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2);
|
||||
|
||||
static void update_data(post_process_dof* dof, float_t min_dist,
|
||||
@@ -650,7 +650,7 @@ post_process_dof::~post_process_dof() {
|
||||
}
|
||||
}
|
||||
|
||||
void post_process_dof::apply(render_texture* rt, GLuint* samplers, camera* cam) {
|
||||
void post_process_dof::apply(render_texture* rt, render_texture* buf, GLuint* samplers, camera* cam) {
|
||||
if (!this)
|
||||
return;
|
||||
|
||||
@@ -663,13 +663,13 @@ void post_process_dof::apply(render_texture* rt, GLuint* samplers, camera* cam)
|
||||
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 & 0x01)
|
||||
if (!rob_chr->get_visibility())
|
||||
continue;
|
||||
|
||||
mat4 mat;
|
||||
sub_1405163C0(rob_chr, 4, &mat);
|
||||
|
||||
vec3 chara_trans = vec3_null;
|
||||
vec3 chara_trans = 0.0f;
|
||||
mat4_get_translation(&mat, &chara_trans);
|
||||
|
||||
mat4 view_transpose;
|
||||
@@ -681,14 +681,14 @@ void post_process_dof::apply(render_texture* rt, GLuint* samplers, camera* cam)
|
||||
}
|
||||
|
||||
focus = max_def(focus, (float_t)cam->min_distance);
|
||||
renderer::DOF3::apply_physical(this, rt, samplers,
|
||||
renderer::DOF3::apply_physical(this, rt, buf, samplers,
|
||||
rt->color_texture->tex, rt->depth_texture->tex,
|
||||
(float_t)cam->min_distance, (float_t)cam->max_distance, focus,
|
||||
data.debug.focal_length, (float_t)cam->fov_rad, data.debug.f_number);
|
||||
}
|
||||
else {
|
||||
float_t fuzzing_range = max_def(data.debug.f2.fuzzing_range, 0.01f);
|
||||
renderer::DOF3::apply_f2(this, rt, samplers,
|
||||
renderer::DOF3::apply_f2(this, rt, buf, samplers,
|
||||
rt->color_texture->tex, rt->depth_texture->tex,
|
||||
(float_t)cam->min_distance, (float_t)cam->max_distance, (float_t)cam->fov_rad,
|
||||
data.debug.f2.focus, data.debug.f2.focus_range, fuzzing_range, data.debug.f2.ratio);
|
||||
@@ -698,7 +698,7 @@ void post_process_dof::apply(render_texture* rt, GLuint* samplers, camera* cam)
|
||||
}
|
||||
else if (data.pv.enable && data.pv.f2.ratio > 0.0f) {
|
||||
float_t fuzzing_range = max_def(data.pv.f2.fuzzing_range, 0.01f);
|
||||
renderer::DOF3::apply_f2(this, rt, samplers,
|
||||
renderer::DOF3::apply_f2(this, rt, buf, samplers,
|
||||
rt->color_texture->tex, rt->depth_texture->tex,
|
||||
(float_t)cam->min_distance, (float_t)cam->max_distance, (float_t)cam->fov_rad,
|
||||
data.pv.f2.focus, data.pv.f2.focus_range, fuzzing_range, data.pv.f2.ratio);
|
||||
@@ -714,20 +714,7 @@ void post_process_dof::init_fbo(int32_t width, int32_t height) {
|
||||
if (!this || (this->width == width && this->height == height))
|
||||
return;
|
||||
|
||||
if (textures[0]) {
|
||||
glDeleteTextures(6, textures);
|
||||
textures[0] = 0;
|
||||
}
|
||||
|
||||
if (ubo[0]) {
|
||||
glDeleteBuffers(2, ubo);
|
||||
ubo[0] = 0;
|
||||
}
|
||||
|
||||
if (vao) {
|
||||
glDeleteVertexArrays(1, &vao);
|
||||
vao = 0;
|
||||
}
|
||||
post_process_dof_free_fbo(this);
|
||||
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
@@ -754,14 +741,21 @@ void post_process_dof::init_fbo(int32_t width, int32_t height) {
|
||||
fbo[3].init_data(w2, h2, &textures[4], 2, 0);
|
||||
|
||||
glGenBuffers(2, ubo);
|
||||
gl_state_bind_uniform_buffer(ubo[0]);
|
||||
glBufferData(GL_UNIFORM_BUFFER, sizeof(post_process_dof_shader_data), 0, GL_STREAM_DRAW);
|
||||
gl_state_bind_uniform_buffer(ubo[0], true);
|
||||
if (GLAD_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_UNIFORM_BUFFER,
|
||||
sizeof(post_process_dof_shader_data), 0, GL_DYNAMIC_STORAGE_BIT);
|
||||
else
|
||||
glBufferData(GL_UNIFORM_BUFFER,
|
||||
sizeof(post_process_dof_shader_data), 0, GL_DYNAMIC_DRAW);
|
||||
|
||||
uint8_t data[align_val(sizeof(vec2[49]), sizeof(vec4))];
|
||||
memset(data, 0, sizeof(data));
|
||||
post_process_dof_calculate_texcoords((vec2*)data, 3.0);
|
||||
gl_state_bind_uniform_buffer(ubo[1]);
|
||||
glBufferData(GL_UNIFORM_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
|
||||
vec2 data[49] = {};
|
||||
post_process_dof_calculate_texcoords(data, 3.0f);
|
||||
gl_state_bind_uniform_buffer(ubo[1], true);
|
||||
if (GLAD_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_UNIFORM_BUFFER, sizeof(data), data, 0);
|
||||
else
|
||||
glBufferData(GL_UNIFORM_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
|
||||
glGenVertexArrays(1, &vao);
|
||||
}
|
||||
|
||||
@@ -914,9 +908,7 @@ static GLuint post_process_dof_shader_compile(GLenum type, const char* data) {
|
||||
if (!success) {
|
||||
GLchar* info_log = force_malloc_s(GLchar, 0x10000);
|
||||
glGetShaderInfoLog(shader, 0x10000, 0, info_log);
|
||||
printf("DOF Shader compile error: ");
|
||||
printf(info_log);
|
||||
putchar('\n');
|
||||
printf_debug("DOF Shader compile error:\n%s\n", info_log);
|
||||
free_def(info_log);
|
||||
}
|
||||
return shader;
|
||||
@@ -935,9 +927,7 @@ static GLuint post_process_dof_program_link(GLuint vert_shad, GLuint frag_shad)
|
||||
if (!success) {
|
||||
GLchar* info_log = force_malloc_s(GLchar, 0x10000);
|
||||
glGetProgramInfoLog(program, 0x10000, 0, info_log);
|
||||
printf("DOF shader linking error:\n");
|
||||
printf(info_log);
|
||||
putchar('\n');
|
||||
printf_debug("DOF shader linking error:\n%s\n", info_log);
|
||||
free_def(info_log);
|
||||
glDeleteProgram(program);
|
||||
return 0;
|
||||
@@ -952,9 +942,9 @@ static void sub_1405163C0(rob_chara* rob_chr, int32_t a2, mat4* mat) {
|
||||
|
||||
namespace renderer {
|
||||
void DOF3::apply_f2(post_process_dof* dof, render_texture* rt,
|
||||
GLuint* samplers, GLuint color_texture, GLuint depth_texture,
|
||||
float_t min_distance, float_t max_distance, float_t fov, float_t focus,
|
||||
float_t focus_range, float_t fuzzing_range, float_t ratio) {
|
||||
render_texture* buf, GLuint* samplers, GLuint color_texture,
|
||||
GLuint depth_texture, float_t min_distance, float_t max_distance, float_t fov,
|
||||
float_t focus, float_t focus_range, float_t fuzzing_range, float_t ratio) {
|
||||
gl_state_disable_blend();
|
||||
gl_state_set_depth_mask(GL_FALSE);
|
||||
gl_state_set_depth_func(GL_ALWAYS);
|
||||
@@ -965,7 +955,7 @@ namespace renderer {
|
||||
render_tiles(dof, samplers, depth_texture, true);
|
||||
downsample(dof, samplers, color_texture, depth_texture, true);
|
||||
apply_main_filter(dof, samplers, true);
|
||||
upsample(dof, rt, samplers, color_texture, depth_texture, true);
|
||||
upsample(dof, rt, buf, samplers, color_texture, depth_texture, true);
|
||||
|
||||
gl_state_use_program(0);
|
||||
for (int32_t i = 0; i < 8; i++) {
|
||||
@@ -976,9 +966,9 @@ namespace renderer {
|
||||
}
|
||||
|
||||
void DOF3::apply_physical(post_process_dof* dof, render_texture* rt,
|
||||
GLuint* samplers, GLuint color_texture, GLuint depth_texture,
|
||||
float_t min_distance, float_t max_distance, float_t focus,
|
||||
float_t focal_length, float_t fov, float_t f_number) {
|
||||
render_texture* buf, GLuint* samplers, GLuint color_texture,
|
||||
GLuint depth_texture, float_t min_distance, float_t max_distance,
|
||||
float_t focus, float_t focal_length, float_t fov, float_t f_number) {
|
||||
gl_state_disable_blend();
|
||||
gl_state_set_depth_mask(GL_FALSE);
|
||||
gl_state_set_depth_func(GL_ALWAYS);
|
||||
@@ -989,7 +979,7 @@ namespace renderer {
|
||||
render_tiles(dof, samplers, depth_texture, false);
|
||||
downsample(dof, samplers, color_texture, depth_texture, false);
|
||||
apply_main_filter(dof, samplers, false);
|
||||
upsample(dof, rt, samplers, color_texture, depth_texture, false);
|
||||
upsample(dof, rt, buf, samplers, color_texture, depth_texture, false);
|
||||
|
||||
gl_state_use_program(0);
|
||||
for (int32_t i = 0; i < 8; i++) {
|
||||
@@ -1057,9 +1047,9 @@ namespace renderer {
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
|
||||
}
|
||||
|
||||
void DOF3::upsample(post_process_dof* dof, render_texture* rt,
|
||||
void DOF3::upsample(post_process_dof* dof, render_texture* rt, render_texture* buf,
|
||||
GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2) {
|
||||
rt->bind();
|
||||
buf->bind();
|
||||
glViewport(0, 0, dof->width, dof->height);
|
||||
if (f2)
|
||||
gl_state_use_program(dof->program[8]);
|
||||
@@ -1078,6 +1068,10 @@ namespace renderer {
|
||||
gl_state_active_bind_texture_2d(4, depth_texture);
|
||||
gl_state_bind_sampler(4, samplers[1]);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
|
||||
|
||||
fbo::blit(buf->fbos[0], rt->fbos[0],
|
||||
0, 0, buf->color_texture->width, buf->color_texture->height,
|
||||
0, 0, rt->color_texture->width, rt->color_texture->height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
}
|
||||
|
||||
void DOF3::update_data(post_process_dof* dof, float_t min_dist,
|
||||
@@ -1102,7 +1096,11 @@ namespace renderer {
|
||||
data.g_depth_params2.z = -4.5f / (fuzzing_range * fuzzing_range);
|
||||
data.g_depth_params2.w = ratio * 8.0f;
|
||||
|
||||
gl_state_bind_uniform_buffer(dof->ubo[0]);
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(post_process_dof_shader_data), &data);
|
||||
if (GLAD_GL_VERSION_4_5)
|
||||
glNamedBufferSubData(dof->ubo[0], 0, sizeof(post_process_dof_shader_data), &data);
|
||||
else {
|
||||
gl_state_bind_uniform_buffer(dof->ubo[0]);
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(post_process_dof_shader_data), &data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ struct post_process_dof {
|
||||
post_process_dof();
|
||||
virtual ~post_process_dof();
|
||||
|
||||
void apply(render_texture* rt, GLuint* samplers, camera* cam);
|
||||
void apply(render_texture* rt, render_texture* buf, GLuint* samplers, camera* cam);
|
||||
void init_fbo(int32_t width, int32_t height);
|
||||
void initialize_data(dof_debug* debug, dof_pv* pv);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ void post_process_exposure::get_exposure(camera* cam, int32_t render_width,
|
||||
float_t v20 = powf(tanf((float_t)(cam->fov_rad * 0.5f)) * 3.4f, 2.0f);
|
||||
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++, v6++) {
|
||||
rob_chara* rob_chr = rob_chara_array_get(i);
|
||||
if (!rob_chr || ~rob_chr->data.field_0 & 1)
|
||||
if (!rob_chr || !rob_chr->get_visibility())
|
||||
continue;
|
||||
|
||||
vec4 v34 = { 0.05f, 0.0f, -0.04f, 1.0f };
|
||||
@@ -142,8 +142,9 @@ void post_process_exposure::get_exposure(camera* cam, int32_t render_width,
|
||||
}
|
||||
|
||||
if (!v2 || reset_exposure) {
|
||||
uniform_value[U_EXPOSURE] = 1;
|
||||
render_texture::shader_set(&shaders_ft, SHADER_FT_EXPOSURE);
|
||||
//uniform_value[U_EXPOSURE] = 1;
|
||||
//shaders_ft.set(SHADER_FT_EXPOSURE);
|
||||
shaders_ft.set(SHADER_FT_EXPOSURE_MEASURE);
|
||||
shaders_ft.local_frag_set(1,
|
||||
chara_data[0].field_80,
|
||||
chara_data[1].field_80,
|
||||
@@ -161,8 +162,7 @@ void post_process_exposure::get_exposure(camera* cam, int32_t render_width,
|
||||
exposure_history.bind();
|
||||
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);
|
||||
render_texture::draw_params(&shaders_ft, reset_exposure ? 32 : 1, 1);
|
||||
exposure_history_counter++;
|
||||
exposure_history_counter %= 32;
|
||||
}
|
||||
@@ -170,7 +170,10 @@ void post_process_exposure::get_exposure(camera* cam, int32_t render_width,
|
||||
glViewport(0, 0, 1, 1);
|
||||
exposure.bind();
|
||||
gl_state_active_bind_texture_2d(0, exposure_history.color_texture->tex);
|
||||
render_texture::draw_params(&shaders_ft, 1, 1, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
//uniform_value[U_EXPOSURE] = 2;
|
||||
//shaders_ft.set(SHADER_FT_EXPOSURE);
|
||||
shaders_ft.set(SHADER_FT_EXPOSURE_AVERAGE);
|
||||
render_texture::draw_params(&shaders_ft, 1, 1);
|
||||
}
|
||||
|
||||
void post_process_exposure::get_exposure_chara_data(void* pp, camera* cam) {
|
||||
@@ -178,13 +181,15 @@ void post_process_exposure::get_exposure_chara_data(void* pp, camera* cam) {
|
||||
|
||||
gl_state_set_color_mask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
gl_state_set_depth_mask(GL_FALSE);
|
||||
gl_state_disable_cull_face();
|
||||
|
||||
post_process_exposure_chara_data* v3 = chara_data;
|
||||
int32_t v4 = query_index++ % 3;
|
||||
int32_t v4 = (query_index + 1) % 3;
|
||||
query_index = v4;
|
||||
int32_t v7 = (v4 + 2) % 3;
|
||||
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++, v3++) {
|
||||
rob_chara* rob_chr = rob_chara_array_get(i);
|
||||
if (!rob_chr || ~rob_chr->data.field_0 & 1)
|
||||
if (!rob_chr || !rob_chr->get_visibility())
|
||||
continue;
|
||||
|
||||
float_t max_face_depth = rob_chr->get_max_face_depth();
|
||||
@@ -213,6 +218,7 @@ void post_process_exposure::get_exposure_chara_data(void* pp, camera* cam) {
|
||||
|
||||
gl_state_set_color_mask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
gl_state_set_depth_mask(GL_TRUE);
|
||||
gl_state_enable_cull_face();
|
||||
}
|
||||
|
||||
void post_process_exposure::init_fbo() {
|
||||
@@ -224,7 +230,7 @@ void post_process_exposure::init_fbo() {
|
||||
if (!exposure_history.color_texture)
|
||||
exposure_history.init(32, 1, 0, GL_R32F, 0);
|
||||
if (!exposure.color_texture)
|
||||
exposure.init(1, 1, 0, GL_R32F, 0);
|
||||
exposure.init(2, 2, 0, GL_R32F, 0);
|
||||
|
||||
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++)
|
||||
if (!chara_data[i].query[0])
|
||||
|
||||
@@ -30,7 +30,7 @@ post_process_tone_map::~post_process_tone_map() {
|
||||
}
|
||||
|
||||
void post_process_tone_map::apply(render_texture* in_tex, texture* light_proj_tex, texture* back_2d_tex,
|
||||
render_texture* rt, render_texture* buf_rt, render_texture* contour_rt,
|
||||
render_texture* rt, render_texture* buf_rt,/* render_texture* contour_rt,*/
|
||||
GLuint in_tex_0, GLuint in_tex_1, int32_t npr_param) {
|
||||
if (!this)
|
||||
return;
|
||||
@@ -43,16 +43,15 @@ void post_process_tone_map::apply(render_texture* in_tex, texture* light_proj_te
|
||||
if (data.update_tex) {
|
||||
post_process_tone_map_calculate_tex(this);
|
||||
|
||||
glBindTexture(GL_TEXTURE_1D, tone_map);
|
||||
glTexImage1D(GL_TEXTURE_1D, 0, GL_RG16F,
|
||||
16 * POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES, 0, GL_RG, GL_FLOAT, data.tex);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
|
||||
GLint swizzle[] = { GL_RED, GL_RED, GL_RED, GL_GREEN };
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteriv(GL_TEXTURE_1D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
|
||||
glBindTexture(GL_TEXTURE_1D, 0);
|
||||
if (GLAD_GL_VERSION_4_5)
|
||||
glTextureSubImage2D(tone_map, 0, 0, 0,
|
||||
16 * POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES, 1, GL_RG, GL_FLOAT, data.tex);
|
||||
else {
|
||||
gl_state_bind_texture_2d(tone_map);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
|
||||
16 * POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES, 1, GL_RG, GL_FLOAT, data.tex);
|
||||
gl_state_bind_texture_2d(0);
|
||||
}
|
||||
data.update_tex = false;
|
||||
}
|
||||
|
||||
@@ -63,14 +62,12 @@ void post_process_tone_map::apply(render_texture* in_tex, texture* light_proj_te
|
||||
mat4_scale(1.0f, (float_t)rt->color_texture->height
|
||||
/ (float_t)rt->color_texture->width, 1.0f, &lens_shaft_mat);
|
||||
|
||||
uniform_value[U16] = 0;
|
||||
uniform_value[U_TONE_MAP] = (int32_t)data.tone_map_method;
|
||||
uniform_value[U_FLARE] = 0;
|
||||
uniform_value[U_SCENE_FADE] = data.scene_fade.w > 0.009999999f ? 1 : 0;
|
||||
uniform_value[U_AET_BACK] = 0;
|
||||
uniform_value[U_LIGHT_PROJ] = 0;
|
||||
uniform_value[U_NPR] = 0;
|
||||
uniform_value[U25] = 0;
|
||||
//uniform_value[U25] = 0;
|
||||
|
||||
glViewport(0, 0, rt->color_texture->width, rt->color_texture->height);
|
||||
buf_rt->bind();
|
||||
@@ -86,29 +83,32 @@ void post_process_tone_map::apply(render_texture* in_tex, texture* light_proj_te
|
||||
shaders_ft.local_frag_set(7, shader_data.p_inv_tone);
|
||||
gl_state_active_bind_texture_2d(0, in_tex->color_texture->tex);
|
||||
gl_state_active_bind_texture_2d(1, in_tex_0);
|
||||
gl_state_active_bind_texture_2d(2, 0);
|
||||
gl_state_active_texture(2);
|
||||
glBindTexture(GL_TEXTURE_1D, tone_map);
|
||||
gl_state_active_bind_texture_2d(2, tone_map);
|
||||
gl_state_active_bind_texture_2d(3, in_tex_1);
|
||||
if (uniform_value[U_LIGHT_PROJ] && light_proj_tex)
|
||||
gl_state_active_bind_texture_2d(6, light_proj_tex->tex);
|
||||
else if (uniform_value[U_AET_BACK] && back_2d_tex)
|
||||
|
||||
if (back_2d_tex) {
|
||||
gl_state_active_bind_texture_2d(6, back_2d_tex->tex);
|
||||
uniform_value[U_AET_BACK] = 1;
|
||||
}
|
||||
|
||||
if (light_proj_tex) {
|
||||
gl_state_active_bind_texture_2d(6, light_proj_tex->tex);
|
||||
uniform_value[U_LIGHT_PROJ] = 1;
|
||||
}
|
||||
|
||||
if (npr_param == 1) {
|
||||
gl_state_active_bind_texture_2d(16, contour_rt->color_texture->tex);
|
||||
/*gl_state_active_bind_texture_2d(16, contour_rt->color_texture->tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
gl_state_active_bind_texture_2d(17, contour_rt->depth_texture->tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);*/
|
||||
gl_state_active_bind_texture_2d(14, rt->depth_texture->tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
}
|
||||
render_texture::draw_custom(&shaders_ft);
|
||||
gl_state_active_texture(2);
|
||||
glBindTexture(GL_TEXTURE_1D, 0);
|
||||
uniform_value[U16] = 1;
|
||||
gl_state_active_bind_texture_2d(2, 0);
|
||||
|
||||
fbo::blit(buf_rt->fbos[0], rt->fbos[0],
|
||||
0, 0, buf_rt->color_texture->width, buf_rt->color_texture->height,
|
||||
@@ -119,8 +119,34 @@ void post_process_tone_map::init_fbo() {
|
||||
if (!this)
|
||||
return;
|
||||
|
||||
if (!tone_map)
|
||||
glGenTextures(1, &tone_map);
|
||||
if (!tone_map) {
|
||||
if (GLAD_GL_VERSION_4_5) {
|
||||
glCreateTextures(GL_TEXTURE_2D, 1, &tone_map);
|
||||
|
||||
glTextureStorage2D(tone_map, 1, GL_RG16F, 16 * POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES, 1);
|
||||
glTextureParameteri(tone_map, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTextureParameteri(tone_map, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
const GLint swizzle[] = { GL_RED, GL_RED, GL_RED, GL_GREEN };
|
||||
glTextureParameteri(tone_map, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTextureParameteri(tone_map, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTextureParameteriv(tone_map, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
|
||||
}
|
||||
else {
|
||||
glGenTextures(1, &tone_map);
|
||||
|
||||
gl_state_bind_texture_2d(tone_map);
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RG16F, 16 * POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES, 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
const GLint swizzle[] = { GL_RED, GL_RED, GL_RED, GL_GREEN };
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
|
||||
gl_state_bind_texture_2d(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void post_process_tone_map::initialize_data(float_t exposure, bool auto_exposure,
|
||||
@@ -142,17 +168,11 @@ void post_process_tone_map::initialize_data(float_t exposure, bool auto_exposure
|
||||
data.gamma_rate = clamp_def(gamma_rate, 0.5f, 2.0f);
|
||||
data.saturate_power = clamp_def(saturate_power, 1, 6);
|
||||
data.saturate_coeff = clamp_def(saturate_coeff, 0.0f, 1.0f);
|
||||
data.scene_fade.x = clamp_def(scene_fade_color.x, 0.0f, 1.0f);
|
||||
data.scene_fade.y = clamp_def(scene_fade_color.y, 0.0f, 1.0f);
|
||||
data.scene_fade.z = clamp_def(scene_fade_color.z, 0.0f, 1.0f);
|
||||
*(vec3*)&data.scene_fade.x = vec3::clamp(scene_fade_color, 0.0f, 1.0f);
|
||||
data.scene_fade.w = clamp_def(scene_fade_alpha, 0.0f, 1.0f);
|
||||
data.scene_fade_blend_func = clamp_def(scene_fade_blend_func, 0, 2);
|
||||
data.tone_trans_start.x = clamp_def(tone_trans_start.x, 0.0f, 1.0f);
|
||||
data.tone_trans_start.y = clamp_def(tone_trans_start.y, 0.0f, 1.0f);
|
||||
data.tone_trans_start.z = clamp_def(tone_trans_start.z, 0.0f, 1.0f);
|
||||
data.tone_trans_end.x = clamp_def(tone_trans_end.x, 0.0f, 1.0f);
|
||||
data.tone_trans_end.y = clamp_def(tone_trans_end.y, 0.0f, 1.0f);
|
||||
data.tone_trans_end.z = clamp_def(tone_trans_end.z, 0.0f, 1.0f);
|
||||
data.tone_trans_start = vec3::clamp(tone_trans_start, 0.0f, 1.0f);
|
||||
data.tone_trans_end = vec3::clamp(tone_trans_end, 0.0f, 1.0f);
|
||||
data.tone_map_method = clamp_def(tone_map_method, TONE_MAP_YCC_EXPONENT, TONE_MAP_RGB_LINEAR2);
|
||||
data.update_tex = false;
|
||||
data.update = true;
|
||||
@@ -270,12 +290,8 @@ vec4 post_process_tone_map::get_scene_fade() {
|
||||
}
|
||||
|
||||
void post_process_tone_map::set_scene_fade(const vec4& value) {
|
||||
vec4 temp;
|
||||
temp.x = clamp_def(value.x, 0.0f, 1.0f);
|
||||
temp.y = clamp_def(value.y, 0.0f, 1.0f);
|
||||
temp.z = clamp_def(value.z, 0.0f, 1.0f);
|
||||
temp.z = clamp_def(value.w, 0.0f, 1.0f);
|
||||
if (memcmp(&temp, &data.scene_fade, sizeof(vec4))) {
|
||||
vec4 temp = vec4::clamp(value, 0.0f, 1.0f);
|
||||
if (temp != data.scene_fade) {
|
||||
data.scene_fade = temp;
|
||||
data.update = true;
|
||||
}
|
||||
@@ -310,11 +326,8 @@ vec3 post_process_tone_map::get_scene_fade_color() {
|
||||
}
|
||||
|
||||
void post_process_tone_map::set_scene_fade_color(const vec3& value) {
|
||||
vec3 temp;
|
||||
temp.x = clamp_def(value.x, 0.0f, 1.0f);
|
||||
temp.y = clamp_def(value.y, 0.0f, 1.0f);
|
||||
temp.z = clamp_def(value.z, 0.0f, 1.0f);
|
||||
if (memcmp(&temp, &data.scene_fade, sizeof(vec3))) {
|
||||
vec3 temp = vec3::clamp(value, 0.0f, 1.0f);
|
||||
if (temp != *(vec3*)&data.scene_fade) {
|
||||
*(vec3*)&data.scene_fade = temp;
|
||||
data.update = true;
|
||||
}
|
||||
@@ -347,11 +360,8 @@ vec3 post_process_tone_map::get_tone_trans_end() {
|
||||
}
|
||||
|
||||
void post_process_tone_map::set_tone_trans_end(const vec3& value) {
|
||||
vec3 temp;
|
||||
temp.x = clamp_def(value.x, 0.0f, 1.0f);
|
||||
temp.y = clamp_def(value.y, 0.0f, 1.0f);
|
||||
temp.z = clamp_def(value.z, 0.0f, 1.0f);
|
||||
if (memcmp(&temp, &data.tone_trans_end, sizeof(vec3))) {
|
||||
vec3 temp = vec3::clamp(value, 0.0f, 1.0f);
|
||||
if (temp != data.tone_trans_end) {
|
||||
data.tone_trans_end = temp;
|
||||
data.update = true;
|
||||
}
|
||||
@@ -362,11 +372,8 @@ vec3 post_process_tone_map::get_tone_trans_start() {
|
||||
}
|
||||
|
||||
void post_process_tone_map::set_tone_trans_start(const vec3& value) {
|
||||
vec3 temp;
|
||||
temp.x = clamp_def(value.x, 0.0f, 1.0f);
|
||||
temp.y = clamp_def(value.y, 0.0f, 1.0f);
|
||||
temp.z = clamp_def(value.z, 0.0f, 1.0f);
|
||||
if (memcmp(&temp, &data.tone_trans_start, sizeof(vec3))) {
|
||||
vec3 temp = vec3::clamp(value, 0.0f, 1.0f);
|
||||
if (temp != data.tone_trans_start) {
|
||||
data.tone_trans_start = temp;
|
||||
data.update = true;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ struct post_process_tone_map {
|
||||
virtual ~post_process_tone_map();
|
||||
|
||||
void apply(render_texture* in_tex, texture* light_proj_tex, texture* back_2d_tex,
|
||||
render_texture* rt, render_texture* buf_rt, render_texture* contour_rt,
|
||||
render_texture* rt, render_texture* buf_rt,/* render_texture* contour_rt,*/
|
||||
GLuint in_tex_0, GLuint in_tex_1, int32_t npr_param);
|
||||
void init_fbo();
|
||||
void initialize_data(float_t exposure, bool auto_exposure,
|
||||
|
||||
+16
-8
@@ -1375,17 +1375,25 @@ namespace pv_db {
|
||||
|
||||
std::string key;
|
||||
std::string val;
|
||||
if (kv.read("0.key", key) && kv.read("0.val", val))
|
||||
ex_info[0] = { key, val };
|
||||
if (kv.read("0.key", key) && kv.read("0.val", val)) {
|
||||
ex_info[0].first.assign(key);
|
||||
ex_info[0].second.assign(val);
|
||||
}
|
||||
|
||||
if (kv.read("1.key", key) && kv.read("1.val", val))
|
||||
ex_info[1] = { key, val };
|
||||
if (kv.read("1.key", key) && kv.read("1.val", val)) {
|
||||
ex_info[1].first.assign(key);
|
||||
ex_info[1].second.assign(val);
|
||||
}
|
||||
|
||||
if (kv.read("2.key", key) && kv.read("2.val", val))
|
||||
ex_info[2] = { key, val };
|
||||
if (kv.read("2.key", key) && kv.read("2.val", val)) {
|
||||
ex_info[2].first.assign(key);
|
||||
ex_info[2].second.assign(val);
|
||||
}
|
||||
|
||||
if (kv.read("3.key", key) && kv.read("3.val", val))
|
||||
ex_info[3] = { key, val };
|
||||
if (kv.read("3.key", key) && kv.read("3.val", val)) {
|
||||
ex_info[3].first.assign(key);
|
||||
ex_info[3].second.assign(val);
|
||||
}
|
||||
|
||||
kv.close_scope();
|
||||
}
|
||||
|
||||
+99
-90
@@ -7,6 +7,7 @@
|
||||
#include <vector>
|
||||
#include "pv_expression.hpp"
|
||||
#include "../KKdLib/hash.hpp"
|
||||
#include "../KKdLib/str_utils.hpp"
|
||||
#include "rob/rob.hpp"
|
||||
#include "render_context.hpp"
|
||||
|
||||
@@ -52,7 +53,10 @@ pv_expression_file::~pv_expression_file() {
|
||||
}
|
||||
|
||||
void pv_expression_file::load_file(pv_expression_file* exp_file, const void* data, size_t size) {
|
||||
exp_file->data->read(data, size, exp_file->data->modern);
|
||||
prj::shared_ptr<alloc_data>& alloc = exp_file->alloc_handler;
|
||||
alloc = prj::shared_ptr<alloc_data>(new alloc_data);
|
||||
|
||||
exp_file->data->unpack_file(alloc, data, size, exp_file->data->modern);
|
||||
}
|
||||
|
||||
void pv_expression_array_ctrl(void* rob_chr) {
|
||||
@@ -177,6 +181,7 @@ void pv_expression_file_unload(const char* file) {
|
||||
}
|
||||
|
||||
i->file_handler.free_data();
|
||||
i->alloc_handler.reset();
|
||||
}
|
||||
delete i;
|
||||
|
||||
@@ -200,6 +205,7 @@ void pv_expression_file_unload(uint32_t hash) {
|
||||
}
|
||||
|
||||
i->file_handler.free_data();
|
||||
i->alloc_handler.reset();
|
||||
}
|
||||
|
||||
pv_expression_file_storage.erase(pv_expression_file_storage.begin()
|
||||
@@ -247,8 +253,8 @@ bool pv_expression::ctrl() {
|
||||
}
|
||||
|
||||
void pv_expression::face_cl_set_data(float_t frame) {
|
||||
pv_exp_data* v2 = face_cl_data_curr;
|
||||
pv_exp_data* v3 = face_cl_data_prev;
|
||||
pv_exp_data* curr = face_cl_data_curr;
|
||||
pv_exp_data* prev = face_cl_data_prev;
|
||||
|
||||
int32_t id = 4;
|
||||
float_t duration = 0.0f;
|
||||
@@ -258,45 +264,45 @@ void pv_expression::face_cl_set_data(float_t frame) {
|
||||
if (face_cl_data_update) {
|
||||
face_cl_data_update = false;
|
||||
|
||||
if (v2->type == 1) {
|
||||
value = v2->value;
|
||||
id = v2->id;
|
||||
if (curr->type == 1) {
|
||||
value = curr->value;
|
||||
id = curr->id;
|
||||
}
|
||||
|
||||
if (v2->type == 1 && frame - v2->frame >= v2->trans)
|
||||
v3 = v2++;
|
||||
else if (v3->type == 1) {
|
||||
id = v3->id;
|
||||
if (curr->type == 1 && frame - curr->frame >= curr->trans)
|
||||
prev = curr++;
|
||||
else if (prev->type == 1) {
|
||||
id = prev->id;
|
||||
duration = 0.0f;
|
||||
value = v3->value;
|
||||
value = prev->value;
|
||||
offset = 0.0f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
float_t v9 = 1.0f;
|
||||
if (v3->trans + v3->frame + 1.0f < v2->frame || v2->trans <= 0.0f)
|
||||
v9 = 0.0f;
|
||||
float_t _offset = 1.0f;
|
||||
if (prev->trans + prev->frame + 1.0f < curr->frame || curr->trans <= 0.0f)
|
||||
_offset = 0.0f;
|
||||
|
||||
if (v2->frame + v9 > frame || v2->type != 1) {
|
||||
face_cl_data_curr = v2;
|
||||
face_cl_data_prev = v3;
|
||||
if (curr->frame + _offset > frame || curr->type != 1) {
|
||||
face_cl_data_curr = curr;
|
||||
face_cl_data_prev = prev;
|
||||
return;
|
||||
}
|
||||
|
||||
value = v2->value;
|
||||
id = v2->id;
|
||||
value = curr->value;
|
||||
id = curr->id;
|
||||
|
||||
float_t v10 = frame - v2->frame;
|
||||
float_t v11 = v2->trans - v10;
|
||||
if (v11 < 0.0f) {
|
||||
v11 = 0.0f;
|
||||
v10 = 0.0f;
|
||||
offset = frame - curr->frame;
|
||||
duration = curr->trans - offset;
|
||||
if (duration < 0.0f) {
|
||||
duration = 0.0f;
|
||||
offset = 0.0f;
|
||||
}
|
||||
|
||||
duration = (1.0f / frame_speed) * v11;
|
||||
duration = (1.0f / frame_speed) * duration;
|
||||
if (duration > 0.0f)
|
||||
offset = (1.0f / frame_speed) * v10;
|
||||
v3 = v2++;
|
||||
offset = (1.0f / frame_speed) * offset;
|
||||
prev = curr++;
|
||||
}
|
||||
|
||||
if (id != 4 && rob_chr) {
|
||||
@@ -306,37 +312,37 @@ void pv_expression::face_cl_set_data(float_t frame) {
|
||||
rob_chr->set_eyelid_mottbl_motion_from_face(id, duration, value, offset, aft_mot_db);
|
||||
}
|
||||
|
||||
face_cl_data_curr = v2;
|
||||
face_cl_data_prev = v3;
|
||||
face_cl_data_curr = curr;
|
||||
face_cl_data_prev = prev;
|
||||
}
|
||||
|
||||
void pv_expression::face_cl_set_frame(float_t frame) {
|
||||
pv_exp_data* v2 = face_cl_data_prev;
|
||||
pv_exp_data* v3 = face_cl_data_curr;
|
||||
pv_exp_data* curr = face_cl_data_curr;
|
||||
pv_exp_data* prev = face_cl_data_prev;
|
||||
|
||||
if (frame < v2->frame) {
|
||||
v2 = face_cl_data;
|
||||
v3 = face_cl_data;
|
||||
if (frame < prev->frame) {
|
||||
curr = face_cl_data;
|
||||
prev = face_cl_data;
|
||||
}
|
||||
|
||||
bool update = false;
|
||||
if (frame > v3->frame && v3->type != -1) {
|
||||
pv_exp_data* v5 = v3 + 1;
|
||||
while (v5->type != -1 && frame > v5->frame) {
|
||||
v2 = v3;
|
||||
v3 = v5++;
|
||||
if (curr->type != -1 && frame > curr->frame) {
|
||||
pv_exp_data* next = curr + 1;
|
||||
while (next->type != -1 && frame > next->frame) {
|
||||
prev = curr;
|
||||
curr = next++;
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
|
||||
face_cl_data_curr = v3;
|
||||
face_cl_data_prev = v2;
|
||||
face_cl_data_curr = curr;
|
||||
face_cl_data_prev = prev;
|
||||
face_cl_data_update = update;
|
||||
}
|
||||
|
||||
void pv_expression::face_set_data(float_t frame) {
|
||||
pv_exp_data* v2 = face_data_curr;
|
||||
pv_exp_data* v3 = face_data_prev;
|
||||
pv_exp_data* curr = face_data_curr;
|
||||
pv_exp_data* prev = face_data_prev;
|
||||
|
||||
int32_t expression_id = 78;
|
||||
float_t value = 0.0f;
|
||||
@@ -345,45 +351,45 @@ void pv_expression::face_set_data(float_t frame) {
|
||||
|
||||
if (face_data_update) {
|
||||
face_data_update = false;
|
||||
if (!v2->type) {
|
||||
expression_id = v2->id;
|
||||
value = v2->value;
|
||||
if (!curr->type) {
|
||||
expression_id = curr->id;
|
||||
value = curr->value;
|
||||
}
|
||||
|
||||
if (!v2->type && frame - v2->frame >= v2->trans || v3->type)
|
||||
v3 = v2++;
|
||||
if (!curr->type && frame - curr->frame >= curr->trans || prev->type)
|
||||
prev = curr++;
|
||||
else {
|
||||
expression_id = v3->id;
|
||||
value = v3->value;
|
||||
expression_id = prev->id;
|
||||
value = prev->value;
|
||||
duration = 0.0f;
|
||||
offset = 0.0f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
float_t v10 = 1.0f;
|
||||
if (v3->trans + v3->frame + 1.0f < v2->frame || v2->trans <= 0.0f)
|
||||
v10 = 0.0f;
|
||||
float_t _offset = 1.0f;
|
||||
if (prev->trans + prev->frame + 1.0f < curr->frame || curr->trans <= 0.0f)
|
||||
_offset = 0.0f;
|
||||
|
||||
if (v2->frame + v10 > frame || v2->type) {
|
||||
face_data_prev = v3;
|
||||
face_data_curr = v2;
|
||||
if (curr->frame + _offset > frame || curr->type) {
|
||||
face_data_prev = prev;
|
||||
face_data_curr = curr;
|
||||
return;
|
||||
}
|
||||
|
||||
expression_id = v2->id;
|
||||
value = v2->value;
|
||||
expression_id = curr->id;
|
||||
value = curr->value;
|
||||
|
||||
float_t v11 = frame - v2->frame;
|
||||
float_t v12 = v2->trans - v11;
|
||||
if (v12 < 0.0f) {
|
||||
v12 = 0.0f;
|
||||
v11 = 0.0f;
|
||||
offset = frame - curr->frame;
|
||||
duration = curr->trans - offset;
|
||||
if (duration < 0.0f) {
|
||||
duration = 0.0f;
|
||||
offset = 0.0f;
|
||||
}
|
||||
|
||||
duration = (1.0f / frame_speed) * v12;
|
||||
duration = (1.0f / frame_speed) * duration;
|
||||
if (duration > 0.0f)
|
||||
offset = (1.0f / frame_speed) * v11;
|
||||
v3 = v2++;
|
||||
offset = (1.0f / frame_speed) * offset;
|
||||
prev = curr++;
|
||||
}
|
||||
|
||||
if (expression_id != 78 && rob_chr) {
|
||||
@@ -395,31 +401,31 @@ void pv_expression::face_set_data(float_t frame) {
|
||||
duration, 0.0f, 1.0f, -1, offset, false, aft_mot_db);
|
||||
}
|
||||
|
||||
face_data_prev = v3;
|
||||
face_data_curr = v2;
|
||||
face_data_prev = prev;
|
||||
face_data_curr = curr;
|
||||
}
|
||||
|
||||
void pv_expression::face_set_frame(float_t frame) {
|
||||
pv_exp_data* v2 = face_data_prev;
|
||||
pv_exp_data* v3 = face_data_curr;
|
||||
pv_exp_data* curr = face_data_curr;
|
||||
pv_exp_data* prev = face_data_prev;
|
||||
|
||||
if (frame < v2->frame) {
|
||||
v2 = face_data;
|
||||
v3 = face_data;
|
||||
if (frame < prev->frame) {
|
||||
curr = face_data;
|
||||
prev = face_data;
|
||||
}
|
||||
|
||||
bool update = false;
|
||||
if (frame > v3->frame && v3->type != -1) {
|
||||
pv_exp_data* v5 = v3 + 1;
|
||||
while (v5->type != -1 && frame > v5->frame) {
|
||||
v2 = v3;
|
||||
v3 = v5++;
|
||||
if (curr->type != -1 && frame > curr->frame) {
|
||||
pv_exp_data* next = curr + 1;
|
||||
while (next->type != -1 && frame > next->frame) {
|
||||
prev = curr;
|
||||
curr = next++;
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
|
||||
face_data_curr = v3;
|
||||
face_data_prev = v2;
|
||||
face_data_curr = curr;
|
||||
face_data_prev = prev;
|
||||
face_data_update = update;
|
||||
}
|
||||
|
||||
@@ -465,7 +471,7 @@ bool pv_expression::set_motion(uint32_t hash, int32_t motion_id) {
|
||||
return false;
|
||||
|
||||
pv_exp* exp = pv_exp_file->data;
|
||||
if (!exp->motion_data.size()) {
|
||||
if (!exp->motion_num) {
|
||||
reset_data();
|
||||
return false;
|
||||
}
|
||||
@@ -475,32 +481,35 @@ bool pv_expression::set_motion(uint32_t hash, int32_t motion_id) {
|
||||
|
||||
const char* motion_name = aft_mot_db->get_motion_name(motion_id);
|
||||
|
||||
size_t motion_index = -1;
|
||||
for (pv_exp_mot& i : exp->motion_data)
|
||||
if (!i.name.compare(motion_name)) {
|
||||
motion_index = (&i - exp->motion_data.data());
|
||||
pv_exp_mot* mot = 0;
|
||||
|
||||
pv_exp_mot* motion_data = exp->motion_data;
|
||||
uint32_t motion_num = exp->motion_num;
|
||||
for (uint32_t i = 0; i < motion_num; i++)
|
||||
if (!str_utils_compare(motion_data[i].name, motion_name)) {
|
||||
mot = &motion_data[i];
|
||||
break;
|
||||
}
|
||||
|
||||
if (motion_index == -1) {
|
||||
if (!mot) {
|
||||
reset_data();
|
||||
return false;
|
||||
}
|
||||
|
||||
this->motion_id = motion_id;
|
||||
|
||||
pv_exp_data* face_data = exp->motion_data[motion_index].face_data;
|
||||
pv_exp_data* face_data = mot->face_data;
|
||||
if (this->face_data != face_data) {
|
||||
this->face_data = face_data;
|
||||
this->face_data_prev = face_data;
|
||||
this->face_data_curr = face_data;
|
||||
this->face_data_prev = face_data;
|
||||
}
|
||||
|
||||
pv_exp_data* face_cl_data = exp->motion_data[motion_index].face_cl_data;
|
||||
pv_exp_data* face_cl_data = mot->face_cl_data;
|
||||
if (this->face_cl_data != face_cl_data) {
|
||||
this->face_cl_data = face_cl_data;
|
||||
this->face_cl_data_prev = face_cl_data;
|
||||
this->face_cl_data_curr = face_cl_data;
|
||||
this->face_cl_data_prev = face_cl_data;
|
||||
if (rob_chr)
|
||||
rob_chr->autoblink_disable();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
struct pv_expression_file {
|
||||
p_file_handler file_handler;
|
||||
pv_exp* data;
|
||||
prj::shared_ptr<alloc_data> alloc_handler;
|
||||
int32_t load_count;
|
||||
uint32_t hash;
|
||||
|
||||
|
||||
+71
-57
@@ -19,8 +19,8 @@ namespace pv_param {
|
||||
|
||||
bloom::bloom() {
|
||||
id = -1;
|
||||
color = vec3_null;
|
||||
brightpass = vec3_null;
|
||||
color = 0.0f;
|
||||
brightpass = 0.0f;
|
||||
range = 0.0f;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace pv_param {
|
||||
saturation = 1.0f;
|
||||
lightness = 1.0f;
|
||||
exposure = 1.0f;
|
||||
gamma = vec3_identity;
|
||||
gamma = 1.0f;
|
||||
contrast = 1.0f;
|
||||
}
|
||||
|
||||
@@ -282,26 +282,26 @@ namespace pv_param {
|
||||
if (!aft_data->check_directory_exists(path.c_str()))
|
||||
return false;
|
||||
|
||||
if (aft_data->check_file_exists(path.c_str(), "dof.txt"))
|
||||
dof_file = path + "dof.txt";
|
||||
else {
|
||||
if (aft_data->check_file_exists(path.c_str(), "dof.txt")) {
|
||||
dof_file.assign(path);
|
||||
dof_file.append("dof.txt");
|
||||
}
|
||||
else
|
||||
dof_file.clear();
|
||||
dof_file.shrink_to_fit();
|
||||
}
|
||||
|
||||
if (aft_data->check_file_exists(path.c_str(), "cc.txt"))
|
||||
cc_file = path + "cc.txt";
|
||||
else {
|
||||
if (aft_data->check_file_exists(path.c_str(), "cc.txt")) {
|
||||
dof_file.assign(path);
|
||||
dof_file.append("cc.txt");
|
||||
}
|
||||
else
|
||||
cc_file.clear();
|
||||
cc_file.shrink_to_fit();
|
||||
}
|
||||
|
||||
if (aft_data->check_file_exists(path.c_str(), "bloom.txt"))
|
||||
bloom_file = path + "bloom.txt";
|
||||
else {
|
||||
bloom_file.clear();
|
||||
bloom_file.shrink_to_fit();
|
||||
if (aft_data->check_file_exists(path.c_str(), "bloom.txt")) {
|
||||
dof_file.assign(path);
|
||||
dof_file.append("bloom.txt");
|
||||
}
|
||||
else
|
||||
bloom_file.clear();
|
||||
|
||||
if ((!dof_file.size() || file_data.load_dof_file(dof_file))
|
||||
&& (!cc_file.size() || file_data.load_color_correction_file(cc_file))
|
||||
@@ -411,11 +411,15 @@ namespace pv_param {
|
||||
}
|
||||
|
||||
static bool load_text_file(void* data, const char* path, const char* file, uint32_t hash) {
|
||||
file_stream s;
|
||||
s.open((std::string(path) + file).c_str(), "rb");
|
||||
if (s.check_not_null()) {
|
||||
*(std::string*)data = s.read_string(s.length);
|
||||
s.close();
|
||||
std::string s;
|
||||
s.assign(path);
|
||||
s.append(file);
|
||||
|
||||
file_stream fs;
|
||||
fs.open(s.c_str(), "rb");
|
||||
if (fs.check_not_null()) {
|
||||
*(std::string*)data = fs.read_string(fs.get_length());
|
||||
fs.close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -676,6 +680,47 @@ namespace pv_param_task {
|
||||
frame = -1.0f;
|
||||
}
|
||||
|
||||
static void get_autofocus_data(float_t distance, float_t fov, float_t& focus,
|
||||
float_t& focus_range, float_t& fuzzing_range, float_t& ratio) {
|
||||
float_t v5 = tanf(fov * DEG_TO_RAD_FLOAT * 0.5f);
|
||||
float_t v6 = distance * 1000.0f;
|
||||
float_t v7 = 36.0f / (v5 * 2.0f);
|
||||
v7 *= v7;
|
||||
|
||||
float_t _focus_range = (v6 * 0.36608f * v6) / (v7 - v6 * 0.36608f) * 0.001f;
|
||||
if (_focus_range >= 0.0f) {
|
||||
float_t _ratio = (v7 * 20000.0f) / (v6 * 220000.0f + v6 * 11.0f * v6) * 3.0048077f;
|
||||
|
||||
float_t range;
|
||||
if (_ratio >= 1.0f) {
|
||||
range = (v6 * 3.6608f * v6) / (v7 - v6 * 3.6608f) * 0.001f;
|
||||
if (range < 0.2f)
|
||||
range = 0.2f;
|
||||
_ratio = 1.0f;
|
||||
}
|
||||
else
|
||||
range = 20.0f;
|
||||
|
||||
if (_focus_range < 0.2f)
|
||||
_focus_range = 0.2f;
|
||||
|
||||
float_t _fuzzing_range = range - _focus_range;
|
||||
if (_fuzzing_range < 0.01f)
|
||||
_fuzzing_range = 0.01f;
|
||||
|
||||
focus = distance;
|
||||
focus_range = _focus_range;
|
||||
fuzzing_range = _fuzzing_range;
|
||||
ratio = _ratio;
|
||||
}
|
||||
else {
|
||||
focus = 0.0f;
|
||||
focus_range = 0.0f;
|
||||
fuzzing_range = 0.0f;
|
||||
ratio = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
#define DOF_FIX 1
|
||||
|
||||
void PostProcessCtrlDof::Set() {
|
||||
@@ -693,7 +738,7 @@ namespace pv_param_task {
|
||||
#else
|
||||
if (autofocus) {
|
||||
#endif
|
||||
vec3 trans = vec3_null;
|
||||
vec3 trans = 0.0f;
|
||||
rob_chara* rob_chr = rob_chara_array_get(autofocus ? data.data.chara_id : 0);
|
||||
if (rob_chr) {
|
||||
motion_blend_mot* mot = rob_chr->bone_data->motion_loaded.front();
|
||||
@@ -708,40 +753,9 @@ namespace pv_param_task {
|
||||
cam->get_view_point(view_point);
|
||||
float_t fov = (float_t)cam->get_fov();
|
||||
|
||||
focus = vec3::distance(trans, view_point);
|
||||
float_t distance = vec3::distance(trans, view_point);
|
||||
|
||||
float_t v5 = tanf(fov * DEG_TO_RAD_FLOAT * 0.5f);
|
||||
float_t v6 = focus * 1000.0f;
|
||||
float_t v7 = 36.0f / (v5 * 2.0f);
|
||||
v7 *= v7;
|
||||
float_t v8 = v6 * 0.36608f * v6 / (v7 - v6 * 0.36608f) * 0.001f;
|
||||
if (v8 >= 0.0f) {
|
||||
float_t v9 = v7 - (v6 * 3.6608f);
|
||||
float_t v10 = 20.0f;
|
||||
float_t v11 = (v7 * 20000.0f) / (v6 * 220000.0f + v6 * 11.0f * v6);
|
||||
focus_range = (v8 + v8) * 0.5f;
|
||||
float_t v13 = (v6 * 3.6608f * v6) / v9 * 0.001f;
|
||||
if (v11 >= 0.3328f)
|
||||
v10 = v13;
|
||||
if (v10 <= 0.2f)
|
||||
v10 = 0.2f;
|
||||
if (focus_range <= 0.2f)
|
||||
focus_range = 0.2f;
|
||||
if (v11 >= 0.3328f)
|
||||
ratio = 1.0f;
|
||||
else
|
||||
ratio = v11 * 3.004807711f;
|
||||
|
||||
fuzzing_range = v10 - focus_range;
|
||||
if (fuzzing_range <= 0.01f)
|
||||
fuzzing_range = 0.01f;
|
||||
}
|
||||
else {
|
||||
focus = 0.0f;
|
||||
focus_range = 0.0f;
|
||||
fuzzing_range = 0.0f;
|
||||
ratio = 0.0f;
|
||||
}
|
||||
get_autofocus_data(distance, fov, focus, focus_range, fuzzing_range, ratio);
|
||||
|
||||
if (autofocus) {
|
||||
data.data.focus = focus;
|
||||
|
||||
@@ -54,6 +54,16 @@ uint32_t rand_state_array_get_int(uint32_t min, uint32_t max, int32_t id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rand_state_array_set_seed(uint32_t seed, int32_t id) {
|
||||
RandState* rand_state = rand_state_array_get(id);
|
||||
if (rand_state)
|
||||
rand_state->mt.seed(seed);
|
||||
}
|
||||
|
||||
void rand_state_array_4_set_seed_1393939() {
|
||||
rand_state_array_set_seed(1393939, 4);
|
||||
}
|
||||
|
||||
void rand_state_array_free() {
|
||||
delete[] rand_state_array;
|
||||
}
|
||||
|
||||
@@ -20,4 +20,6 @@ extern RandState* rand_state_array_get(int32_t id);
|
||||
extern float_t rand_state_array_get_float(int32_t id);
|
||||
extern uint32_t rand_state_array_get_int(int32_t id);
|
||||
extern uint32_t rand_state_array_get_int(uint32_t min, uint32_t max, int32_t id);
|
||||
extern void rand_state_array_set_seed(uint32_t seed, int32_t id);
|
||||
extern void rand_state_array_4_set_seed_1393939();
|
||||
extern void rand_state_array_free();
|
||||
|
||||
+531
-232
File diff suppressed because it is too large
Load Diff
+52
-14
@@ -27,6 +27,13 @@
|
||||
#define TEXTURE_PATTERN_COUNT 24
|
||||
#define TEXTURE_TRANSFORM_COUNT 24
|
||||
|
||||
enum blur_filter_mode {
|
||||
BLUR_FILTER_4 = 0x00,
|
||||
BLUR_FILTER_9 = 0x01,
|
||||
BLUR_FILTER_16 = 0x02,
|
||||
BLUR_FILTER_32 = 0x03,
|
||||
};
|
||||
|
||||
enum draw_object_type {
|
||||
DRAW_OBJECT_OPAQUE = 0x00,
|
||||
DRAW_OBJECT_TRANSLUCENT = 0x01,
|
||||
@@ -57,7 +64,7 @@ enum draw_object_type {
|
||||
DRAW_OBJECT_OPAQUE_ALPHA_ORDER_3 = 0x1A,
|
||||
DRAW_OBJECT_TRANSPARENT_ALPHA_ORDER_3 = 0x1B,
|
||||
DRAW_OBJECT_TRANSLUCENT_ALPHA_ORDER_3 = 0x1C,
|
||||
DRAW_OBJECT_PREPROCESS = 0x1D,
|
||||
DRAW_OBJECT_PREPROCESS = 0x1D,
|
||||
DRAW_OBJECT_OPAQUE_LOCAL = 0x1E, // X
|
||||
DRAW_OBJECT_TRANSLUCENT_LOCAL = 0x1F,
|
||||
DRAW_OBJECT_TRANSPARENT_LOCAL = 0x20,
|
||||
@@ -109,7 +116,7 @@ enum draw_task_flags : uint32_t {
|
||||
DRAW_TASK_200000 = 0x00200000,
|
||||
DRAW_TASK_400000 = 0x00400000,
|
||||
DRAW_TASK_800000 = 0x00800000,
|
||||
DRAW_TASK_PREPROCESS = 0x01000000,
|
||||
DRAW_TASK_PREPROCESS = 0x01000000,
|
||||
DRAW_TASK_2000000 = 0x02000000,
|
||||
DRAW_TASK_4000000 = 0x04000000,
|
||||
DRAW_TASK_8000000 = 0x08000000,
|
||||
@@ -122,7 +129,7 @@ enum draw_task_flags : uint32_t {
|
||||
enum draw_task_type {
|
||||
DRAW_TASK_OBJECT = 0x00,
|
||||
DRAW_TASK_OBJECT_PRIMITIVE = 0x01,
|
||||
DRAW_TASK_OBJECT_PREPROCESS = 0x02,
|
||||
DRAW_TASK_OBJECT_PREPROCESS = 0x02,
|
||||
DRAW_TASK_OBJECT_TRANSLUCENT = 0x03,
|
||||
};
|
||||
|
||||
@@ -132,13 +139,6 @@ enum reflect_refract_resolution_mode {
|
||||
REFLECT_REFRACT_RESOLUTION_512x512 = 0x02,
|
||||
};
|
||||
|
||||
enum blur_filter_mode {
|
||||
BLUR_FILTER_4 = 0x00,
|
||||
BLUR_FILTER_9 = 0x01,
|
||||
BLUR_FILTER_16 = 0x02,
|
||||
BLUR_FILTER_32 = 0x03,
|
||||
};
|
||||
|
||||
enum shadow_type_enum {
|
||||
SHADOW_CHARA = 0x00,
|
||||
SHADOW_STAGE = 0x01,
|
||||
@@ -157,6 +157,10 @@ struct draw_state_stats {
|
||||
int32_t draw_count;
|
||||
int32_t draw_triangle_count;
|
||||
int32_t field_1C;
|
||||
|
||||
draw_state_stats();
|
||||
|
||||
void reset();
|
||||
};
|
||||
|
||||
struct sss_data {
|
||||
@@ -170,6 +174,12 @@ struct sss_data {
|
||||
~sss_data();
|
||||
};
|
||||
|
||||
struct draw_preprocess {
|
||||
int32_t type;
|
||||
void(*func)(void*);
|
||||
void* data;
|
||||
};
|
||||
|
||||
struct draw_pass {
|
||||
bool enable[DRAW_PASS_MAX];
|
||||
shadow* shadow_ptr;
|
||||
@@ -186,14 +196,17 @@ struct draw_pass {
|
||||
bool alpha_z_sort;
|
||||
bool draw_pass_3d[DRAW_PASS_3D_MAX];
|
||||
stage_data_reflect_type reflect_type;
|
||||
render_texture reflect_texture;
|
||||
render_texture refract_texture;
|
||||
int32_t tex_index[11];
|
||||
render_texture render_textures[8];
|
||||
GLuint multisample_framebuffer;
|
||||
GLuint multisample_renderbuffer;
|
||||
bool multisample;
|
||||
int32_t show_vector_flags;
|
||||
float_t show_vector_length;
|
||||
float_t show_vector_z_offset;
|
||||
bool field_2F8;
|
||||
//std::vector<draw_preprocess> preprocess;
|
||||
texture* sss_texture;
|
||||
std::list<draw_preprocess> preprocess;
|
||||
texture* effect_texture;
|
||||
int32_t npr_param;
|
||||
bool field_31C;
|
||||
bool field_31D;
|
||||
@@ -202,9 +215,27 @@ struct draw_pass {
|
||||
bool field_320;
|
||||
bool npr;
|
||||
sss_data sss_data;
|
||||
GLuint samplers[18];
|
||||
|
||||
draw_pass();
|
||||
~draw_pass();
|
||||
|
||||
void add_preprocess(int32_t type, void(*func)(void*), void* data);
|
||||
void clear_preprocess(int32_t type);
|
||||
render_texture& get_render_texture(int32_t index);
|
||||
void resize(int32_t width, int32_t height);
|
||||
void set_enable(draw_pass_type type, bool value);
|
||||
void set_effect_texture(texture* value);
|
||||
void set_multisample(bool value);
|
||||
void set_npr_param(int32_t value);
|
||||
void set_reflect(bool value);
|
||||
void set_reflect_blur(int32_t reflect_blur_num, blur_filter_mode reflect_blur_filter);
|
||||
void set_reflect_resolution_mode(reflect_refract_resolution_mode mode);
|
||||
void set_reflect_type(stage_data_reflect_type type);
|
||||
void set_refract(bool value);
|
||||
void set_refract_resolution_mode(reflect_refract_resolution_mode mode);
|
||||
void set_shadow_false();
|
||||
void set_shadow_true();
|
||||
};
|
||||
|
||||
struct draw_state {
|
||||
@@ -230,6 +261,8 @@ struct draw_state {
|
||||
float_t fresnel;
|
||||
|
||||
draw_state();
|
||||
|
||||
void set_fog_height(bool value);
|
||||
};
|
||||
|
||||
struct material_list_struct {
|
||||
@@ -439,9 +472,14 @@ struct object_data_culling_info {
|
||||
struct object_data_vertex_array {
|
||||
GLuint array_buffer;
|
||||
GLuint morph_array_buffer;
|
||||
GLuint element_array_buffer;
|
||||
int32_t alive_time;
|
||||
GLuint vertex_array;
|
||||
bool vertex_attrib_array[16];
|
||||
obj_vertex_format vertex_format;
|
||||
GLsizei size_vertex;
|
||||
bool compressed;
|
||||
GLuint vertex_attrib_buffer_binding[16];
|
||||
int32_t texcoord_array[2];
|
||||
};
|
||||
|
||||
|
||||
+80
-78
@@ -8,7 +8,8 @@
|
||||
#include "texture.hpp"
|
||||
|
||||
static shader_glsl render_texture_shader;
|
||||
static GLuint render_texture_vao, render_texture_vbo;
|
||||
static GLuint render_texture_vao;
|
||||
static GLuint render_texture_vbo;
|
||||
static bool render_texture_data_initialized;
|
||||
static uint32_t render_texture_counter;
|
||||
|
||||
@@ -22,7 +23,7 @@ depth_texture(), binding(), max_level(), fbos(), rbo(), field_2C() {
|
||||
}
|
||||
|
||||
render_texture::~render_texture() {
|
||||
free_data();
|
||||
free();
|
||||
}
|
||||
|
||||
int32_t render_texture::bind(int32_t index) {
|
||||
@@ -32,6 +33,7 @@ int32_t render_texture::bind(int32_t index) {
|
||||
gl_state_bind_framebuffer(fbos[index]);
|
||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
return -1;
|
||||
|
||||
glGetError();
|
||||
return 0;
|
||||
}
|
||||
@@ -45,7 +47,7 @@ void render_texture::draw(bool depth) {
|
||||
gl_state_bind_vertex_array(0);
|
||||
}
|
||||
|
||||
void render_texture::free_data() {
|
||||
void render_texture::free() {
|
||||
if (depth_texture) {
|
||||
texture_free(depth_texture);
|
||||
depth_texture = 0;
|
||||
@@ -81,7 +83,7 @@ int32_t render_texture::init(int32_t width, int32_t height,
|
||||
max_level = min_def(max_level, 15);
|
||||
if (max_level < 0)
|
||||
return 0;
|
||||
free_data();
|
||||
free();
|
||||
|
||||
GLuint color_texture;
|
||||
if (color_format) {
|
||||
@@ -143,7 +145,6 @@ int32_t render_texture::set_color_depth_textures(GLuint color_texture,
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
void render_texture::draw_custom(shader_set_data* set) {
|
||||
gl_state_bind_vertex_array(render_texture_vao);
|
||||
set->draw_arrays(GL_TRIANGLE_STRIP, 0, 3);
|
||||
@@ -170,14 +171,7 @@ void render_texture::draw_params(shader_set_data* set, int32_t width, int32_t he
|
||||
gl_state_bind_vertex_array(0);
|
||||
}
|
||||
|
||||
void render_texture::shader_set(shader_set_data* set, uint32_t index) {
|
||||
if (set && index)
|
||||
set->set(index);
|
||||
else
|
||||
render_texture_shader.use();
|
||||
}
|
||||
|
||||
void render_texture::shader_set_glsl(shader_glsl* shader) {
|
||||
void render_texture::shader_set(shader_glsl* shader) {
|
||||
if (shader)
|
||||
shader->use();
|
||||
else
|
||||
@@ -185,80 +179,88 @@ void render_texture::shader_set_glsl(shader_glsl* shader) {
|
||||
}
|
||||
|
||||
void render_texture_data_init() {
|
||||
if (!render_texture_data_initialized) {
|
||||
static const char* render_texture_vert_shader =
|
||||
"#version 430 core\n"
|
||||
"out VertexData {\n"
|
||||
" vec2 texcoord;\n"
|
||||
"} result;\n"
|
||||
"\n"
|
||||
"void main() {\n"
|
||||
" gl_Position.x = -1.0 + float(gl_VertexID / 2) * 4.0;\n"
|
||||
" gl_Position.y = 1.0 - float(gl_VertexID % 2) * 4.0;\n"
|
||||
" gl_Position.z = 0.0;\n"
|
||||
" gl_Position.w = 1.0;\n"
|
||||
" result.texcoord = gl_Position.xy * 0.5 + 0.5;\n"
|
||||
"}\n";
|
||||
if (render_texture_data_initialized)
|
||||
return;
|
||||
|
||||
static const char* render_texture_frag_shader =
|
||||
"#version 430 core\n"
|
||||
"layout(location = 0) out vec4 result;\n"
|
||||
"\n"
|
||||
"in VertexData {\n"
|
||||
" vec2 texcoord;\n"
|
||||
"} frg;\n"
|
||||
"\n"
|
||||
"layout(binding = 0) uniform sampler2D g_color;\n"
|
||||
"\n"
|
||||
"void main() {\n"
|
||||
" result = texture(g_color, frg.texcoord);\n"
|
||||
"}\n";
|
||||
static const char* render_texture_vert_shader =
|
||||
"#version 430 core\n"
|
||||
"out VertexData {\n"
|
||||
" vec2 texcoord;\n"
|
||||
"} result;\n"
|
||||
"\n"
|
||||
"void main() {\n"
|
||||
" gl_Position.x = -1.0 + float(gl_VertexID / 2) * 4.0;\n"
|
||||
" gl_Position.y = 1.0 - float(gl_VertexID % 2) * 4.0;\n"
|
||||
" gl_Position.z = 0.0;\n"
|
||||
" gl_Position.w = 1.0;\n"
|
||||
" result.texcoord = gl_Position.xy * 0.5 + 0.5;\n"
|
||||
"}\n";
|
||||
|
||||
shader_glsl_param param = {};
|
||||
param.name = "Render Texture";
|
||||
render_texture_shader.load(render_texture_vert_shader,
|
||||
render_texture_frag_shader, 0, ¶m);
|
||||
static const char* render_texture_frag_shader =
|
||||
"#version 430 core\n"
|
||||
"layout(location = 0) out vec4 result;\n"
|
||||
"\n"
|
||||
"in VertexData {\n"
|
||||
" vec2 texcoord;\n"
|
||||
"} frg;\n"
|
||||
"\n"
|
||||
"layout(binding = 0) uniform sampler2D g_color;\n"
|
||||
"\n"
|
||||
"void main() {\n"
|
||||
" result = texture(g_color, frg.texcoord);\n"
|
||||
"}\n";
|
||||
|
||||
const float_t verts_quad[] = {
|
||||
-1.0f, 1.0f, 0.0f, 1.0f,
|
||||
-1.0f, -3.0f, 0.0f, -1.0f,
|
||||
3.0f, 1.0f, 2.0f, 1.0f,
|
||||
};
|
||||
shader_glsl_param param = {};
|
||||
param.name = "Render Texture";
|
||||
render_texture_shader.load(render_texture_vert_shader,
|
||||
render_texture_frag_shader, 0, ¶m);
|
||||
|
||||
glGenVertexArrays(1, &render_texture_vao);
|
||||
glGenBuffers(1, &render_texture_vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, render_texture_vbo);
|
||||
const float_t verts_quad[] = {
|
||||
-1.0f, 1.0f, 0.0f, 1.0f,
|
||||
-1.0f, -3.0f, 0.0f, -1.0f,
|
||||
3.0f, 1.0f, 2.0f, 1.0f,
|
||||
};
|
||||
|
||||
glGenVertexArrays(1, &render_texture_vao);
|
||||
gl_state_bind_vertex_array(render_texture_vao, true);
|
||||
|
||||
glGenBuffers(1, &render_texture_vbo);
|
||||
gl_state_bind_array_buffer(render_texture_vbo, true);
|
||||
if (GLAD_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ARRAY_BUFFER, sizeof(verts_quad), verts_quad, 0);
|
||||
else
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(verts_quad), verts_quad, GL_STATIC_DRAW);
|
||||
|
||||
gl_state_bind_vertex_array(render_texture_vao);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 16, (void*)0); // Pos
|
||||
glVertexAttrib4f(3, 1.0f, 1.0f, 1.0f, 1.0f); // Color0
|
||||
glVertexAttrib4f(4, 1.0f, 1.0f, 1.0f, 1.0f); // Color1
|
||||
glEnableVertexAttribArray(8);
|
||||
glVertexAttribPointer(8, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord0
|
||||
glEnableVertexAttribArray(9);
|
||||
glVertexAttribPointer(9, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord1
|
||||
glEnableVertexAttribArray(10);
|
||||
glVertexAttribPointer(10, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord2
|
||||
glEnableVertexAttribArray(11);
|
||||
glVertexAttribPointer(11, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord3
|
||||
glEnableVertexAttribArray(12);
|
||||
glVertexAttribPointer(12, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord4
|
||||
glEnableVertexAttribArray(13);
|
||||
glVertexAttribPointer(13, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord5
|
||||
glEnableVertexAttribArray(14);
|
||||
glVertexAttribPointer(14, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord6
|
||||
glEnableVertexAttribArray(15);
|
||||
glVertexAttribPointer(15, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord7
|
||||
gl_state_bind_vertex_array(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 16, (void*)0); // Pos
|
||||
glVertexAttrib4f(3, 1.0f, 1.0f, 1.0f, 1.0f); // Color0
|
||||
glVertexAttrib4f(4, 1.0f, 1.0f, 1.0f, 1.0f); // Color1
|
||||
glEnableVertexAttribArray(8);
|
||||
glVertexAttribPointer(8, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord0
|
||||
glEnableVertexAttribArray(9);
|
||||
glVertexAttribPointer(9, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord1
|
||||
glEnableVertexAttribArray(10);
|
||||
glVertexAttribPointer(10, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord2
|
||||
glEnableVertexAttribArray(11);
|
||||
glVertexAttribPointer(11, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord3
|
||||
glEnableVertexAttribArray(12);
|
||||
glVertexAttribPointer(12, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord4
|
||||
glEnableVertexAttribArray(13);
|
||||
glVertexAttribPointer(13, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord5
|
||||
glEnableVertexAttribArray(14);
|
||||
glVertexAttribPointer(14, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord6
|
||||
glEnableVertexAttribArray(15);
|
||||
glVertexAttribPointer(15, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord7
|
||||
gl_state_bind_array_buffer(0);
|
||||
gl_state_bind_vertex_array(0);
|
||||
|
||||
render_texture_data_initialized = true;
|
||||
}
|
||||
render_texture_data_initialized = true;
|
||||
}
|
||||
|
||||
void render_texture_data_free() {
|
||||
if (!render_texture_data_initialized)
|
||||
return;
|
||||
|
||||
render_texture_shader.unload();
|
||||
|
||||
glDeleteBuffers(1, &render_texture_vbo);
|
||||
@@ -330,4 +332,4 @@ static int32_t render_texture_framebuffer_set_texture(render_texture* rt,
|
||||
gl_state_bind_framebuffer(0);
|
||||
glGetError();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,18 +24,17 @@ struct render_texture {
|
||||
|
||||
int32_t bind(int32_t index = 0);
|
||||
void draw(bool depth = false);
|
||||
void free_data();
|
||||
void free();
|
||||
int32_t init(int32_t width, int32_t height,
|
||||
int32_t max_level, GLenum color_format, GLenum depth_format);
|
||||
int32_t set_color_depth_textures(GLuint color_texture,
|
||||
int32_t max_level, GLuint depth_texture, bool stencil);
|
||||
int32_t max_level, GLuint depth_texture, bool stencil = false);
|
||||
|
||||
static void draw_custom(shader_set_data* set);
|
||||
static void draw_custom_glsl();
|
||||
static void draw_params(shader_set_data* set, int32_t width, int32_t height,
|
||||
float_t scale, float_t param_x, float_t param_y, float_t param_z, float_t param_w);
|
||||
static void shader_set(shader_set_data* set, uint32_t index);
|
||||
static void shader_set_glsl(shader_glsl* shader);
|
||||
static void draw_params(shader_set_data* set, int32_t width, int32_t height, float_t scale = 1.0f,
|
||||
float_t param_x = 1.0f, float_t param_y = 1.0f, float_t param_z = 1.0f, float_t param_w = 1.0f);
|
||||
static void shader_set(shader_glsl* shader);
|
||||
};
|
||||
|
||||
extern void render_texture_data_init();
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "resolution_mode.hpp"
|
||||
|
||||
const resolution_table_struct resolution_table[] = {
|
||||
{ 320, 240, 0, 0, 0, 320, 225 },
|
||||
{ 640, 480, 0, 0, 60, 640, 360 },
|
||||
{ 800, 600, 0, 0, 75, 800, 450 },
|
||||
{ 1024, 768, 0, 0, 96, 1024, 576 },
|
||||
{ 1280, 1024, 1, 0, 152, 1280, 720 },
|
||||
{ 1400, 1050, 0, 0, 131, 1400, 788 },
|
||||
{ 1600, 1200, 0, 0, 150, 1600, 900 },
|
||||
{ 800, 480, 2, 0, 15, 800, 450 },
|
||||
{ 1024, 600, 2, 0, 12, 1024, 576 },
|
||||
{ 1280, 768, 2, 0, 24, 1280, 720 },
|
||||
{ 1360, 768, 3, 0, 2, 1360, 765 },
|
||||
{ 1920, 1200, 2, 0, 60, 1920, 1200 },
|
||||
{ 2560, 1536, 2, 0, 48, 2560, 1440 },
|
||||
{ 1280, 720, 3, 0, 0, 1280, 720 },
|
||||
{ 1920, 1080, 3, 0, 0, 1920, 1080 },
|
||||
{ 2560, 1440, 3, 0, 0, 2560, 1440 },
|
||||
{ 480, 272, 3, 0, 0, 480, 272 },
|
||||
{ 960, 544, 3, 0, 0, 960, 544 },
|
||||
};
|
||||
|
||||
vec2 resolution_mode_get_scale(const resolution_mode dst_mode, const resolution_mode src_mode) {
|
||||
if (dst_mode == RESOLUTION_MODE_END
|
||||
|| src_mode == RESOLUTION_MODE_END
|
||||
|| dst_mode < RESOLUTION_MODE_QVGA
|
||||
|| src_mode < RESOLUTION_MODE_QVGA
|
||||
|| dst_mode >= RESOLUTION_MODE_END
|
||||
|| src_mode >= RESOLUTION_MODE_END)
|
||||
return 1.0f;
|
||||
|
||||
float_t scale_x = (float_t)resolution_table[dst_mode].width_full / (float_t)resolution_table[src_mode].width_full;
|
||||
float_t scale_y = (float_t)resolution_table[dst_mode].height_full / (float_t)resolution_table[src_mode].height_full;
|
||||
int32_t v9 = resolution_table[src_mode].field_8;
|
||||
int32_t v10 = resolution_table[dst_mode].field_8;
|
||||
if (v9 != v10) {
|
||||
if (!v9 && 10 == 1)
|
||||
return scale_x;
|
||||
|
||||
if (v9 == 2 || v9 == 3)
|
||||
switch (v10) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return scale_x;
|
||||
}
|
||||
}
|
||||
|
||||
if (src_mode == RESOLUTION_MODE_qHD && dst_mode != RESOLUTION_MODE_qHD && v10 == 3)
|
||||
return scale_x;
|
||||
else
|
||||
return scale_y;
|
||||
}
|
||||
|
||||
void resolution_mode_scale_pos(vec2& dst_pos, const resolution_mode dst_mode,
|
||||
const vec2& src_pos, const resolution_mode src_mode) {
|
||||
if (dst_mode == RESOLUTION_MODE_END
|
||||
|| src_mode == RESOLUTION_MODE_END
|
||||
|| dst_mode < RESOLUTION_MODE_QVGA
|
||||
|| src_mode < RESOLUTION_MODE_QVGA
|
||||
|| dst_mode >= RESOLUTION_MODE_END
|
||||
|| src_mode >= RESOLUTION_MODE_END) {
|
||||
dst_pos = src_pos;
|
||||
return;
|
||||
}
|
||||
|
||||
const resolution_table_struct* src = &resolution_table[src_mode];
|
||||
const resolution_table_struct* dst = &resolution_table[dst_mode];
|
||||
|
||||
vec2 src_size((float_t)src->width_full, (float_t)src->height_full);
|
||||
vec2 dst_size((float_t)dst->width_full, (float_t)dst->height_full);
|
||||
vec2 scale = resolution_mode_get_scale(dst_mode, src_mode);
|
||||
dst_pos = dst_size * 0.5f + (src_pos - src_size * 0.5f) * scale;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
|
||||
enum resolution_mode {
|
||||
RESOLUTION_MODE_QVGA = 0x00,
|
||||
RESOLUTION_MODE_VGA = 0x01,
|
||||
RESOLUTION_MODE_SVGA = 0x02,
|
||||
RESOLUTION_MODE_XGA = 0x03,
|
||||
RESOLUTION_MODE_SXGA = 0x04,
|
||||
RESOLUTION_MODE_SXGAPlus = 0x05,
|
||||
RESOLUTION_MODE_UXGA = 0x06,
|
||||
RESOLUTION_MODE_WVGA = 0x07,
|
||||
RESOLUTION_MODE_WSVGA = 0x08,
|
||||
RESOLUTION_MODE_WXGA = 0x09,
|
||||
RESOLUTION_MODE_FWXGA = 0x0A,
|
||||
RESOLUTION_MODE_WUXGA = 0x0B,
|
||||
RESOLUTION_MODE_WQXGA = 0x0C,
|
||||
RESOLUTION_MODE_HD = 0x0D,
|
||||
RESOLUTION_MODE_FHD = 0x0E,
|
||||
RESOLUTION_MODE_QHD = 0x0F,
|
||||
RESOLUTION_MODE_WQVGA = 0x10,
|
||||
RESOLUTION_MODE_qHD = 0x11,
|
||||
RESOLUTION_MODE_END = 0x12,
|
||||
RESOLUTION_MODE_13 = 0x13,
|
||||
};
|
||||
|
||||
struct resolution_table_struct {
|
||||
int32_t width_full;
|
||||
int32_t height_full;
|
||||
int32_t field_8;
|
||||
int32_t x_offset;
|
||||
int32_t y_offset;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
};
|
||||
|
||||
struct resolution_struct {
|
||||
resolution_mode resolution_mode;
|
||||
int32_t x_offset;
|
||||
int32_t y_offset;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
double_t aspect;
|
||||
int32_t field_20;
|
||||
};
|
||||
|
||||
extern const resolution_table_struct resolution_table[];
|
||||
|
||||
extern vec2 resolution_mode_get_scale(const resolution_mode dst_mode, const resolution_mode src_mode);
|
||||
extern void resolution_mode_scale_pos(vec2& dst_pos, const resolution_mode dst_mode,
|
||||
const vec2& src_pos, const resolution_mode src_mode);
|
||||
+167
-184
@@ -113,7 +113,7 @@ static void sub_14047C750(RobOsage* rob_osg, mat4* mat, vec3* parent_scale, floa
|
||||
static void sub_14047C770(RobOsage* rob_osg, mat4* mat, vec3* parent_scale, float_t step, bool a5);
|
||||
static void sub_14047D620(RobOsage* rob_osg, float_t step);
|
||||
static void sub_14047ECA0(RobOsage* rob_osg, float_t step);
|
||||
static void sub_14047F990(RobOsage* rob_osg, mat4* a2, vec3* a3, bool a4);
|
||||
static void sub_14047F990(RobOsage* rob_osg, mat4* a2, vec3* parent_scale, bool a4);
|
||||
static void sub_140480260(RobOsage* rob_osg, mat4* mat, vec3* parent_scale, float_t step, bool v5);
|
||||
static void sub_140482100(struc_476* a1, opd_blend_data* a2, struc_477* a3);
|
||||
static void sub_140482DF0(struc_477* dst, struc_477* src0, struc_477* src1, float_t blend);
|
||||
@@ -201,7 +201,7 @@ void ExNodeBlock::Field_58() {
|
||||
field_59 = false;
|
||||
}
|
||||
|
||||
void ExNodeBlock::InitData(bone_node* bone_node, ex_node_type type,
|
||||
void ExNodeBlock::InitData(bone_node* bone_node, ExNodeType type,
|
||||
const char* name, rob_chara_item_equip_object* itm_eq_obj) {
|
||||
bone_node_ptr = bone_node;
|
||||
this->type = type;
|
||||
@@ -324,17 +324,6 @@ void RobOsageNodeDataNormalRef::GetMat() {
|
||||
}
|
||||
}
|
||||
|
||||
skin_param_hinge::skin_param_hinge() {
|
||||
ymin = -90.0f;
|
||||
ymax = 90.0f;
|
||||
zmin = -90.0f;
|
||||
zmax = 90.0f;
|
||||
}
|
||||
|
||||
skin_param_hinge::~skin_param_hinge() {
|
||||
|
||||
}
|
||||
|
||||
void skin_param_hinge::limit() {
|
||||
ymin = max_def(ymin, -179.0f) * DEG_TO_RAD_FLOAT;
|
||||
ymax = min_def(ymax, 179.0f) * DEG_TO_RAD_FLOAT;
|
||||
@@ -342,14 +331,11 @@ void skin_param_hinge::limit() {
|
||||
zmax = min_def(zmax, 179.0f) * DEG_TO_RAD_FLOAT;
|
||||
}
|
||||
|
||||
skin_param_osage_node::skin_param_osage_node() : coli_r(0.0f), weight(1.0f), inertial_cancel(0.0f) {
|
||||
skin_param_osage_node::skin_param_osage_node() : coli_r(), inertial_cancel() {
|
||||
weight = 1.0f;
|
||||
hinge.limit();
|
||||
}
|
||||
|
||||
skin_param_osage_node::~skin_param_osage_node() {
|
||||
|
||||
}
|
||||
|
||||
RobOsageNodeResetData::RobOsageNodeResetData() : length() {
|
||||
|
||||
}
|
||||
@@ -400,23 +386,23 @@ RobOsageNode::~RobOsageNode() {
|
||||
|
||||
void RobOsageNode::Reset() {
|
||||
length = 0.0f;
|
||||
trans = vec3_null;
|
||||
trans_orig = vec3_null;
|
||||
trans_diff = vec3_null;
|
||||
field_28 = vec3_null;
|
||||
trans = 0.0f;
|
||||
trans_orig = 0.0f;
|
||||
trans_diff = 0.0f;
|
||||
field_28 = 0.0f;
|
||||
child_length = 0.0f;
|
||||
bone_node_ptr = 0;
|
||||
bone_node_mat = 0;
|
||||
sibling_node = 0;
|
||||
max_distance = 0.0f;
|
||||
field_94 = vec3_null;
|
||||
reset_data.trans = vec3_null;
|
||||
reset_data.trans_diff = vec3_null;
|
||||
reset_data.rotation = vec3_null;
|
||||
field_94 = 0.0f;
|
||||
reset_data.trans = 0.0f;
|
||||
reset_data.trans_diff = 0.0f;
|
||||
reset_data.rotation = 0.0f;
|
||||
reset_data.length = 0.0f;
|
||||
field_C8 = 0.0f;
|
||||
field_CC = 1.0f;
|
||||
external_force = vec3_null;
|
||||
external_force = 0.0f;
|
||||
force = 1.0f;
|
||||
data.Reset();
|
||||
data_ptr = &data;
|
||||
@@ -460,33 +446,15 @@ skin_param_osage_root::~skin_param_osage_root() {
|
||||
|
||||
}
|
||||
|
||||
skin_param::skin_param() : friction(1.0f), wind_afc(), air_res(1.0f), rot(), init_rot(),
|
||||
coli_type(), stiffness(), move_cancel(-0.01f), coli_r(), force(), force_gain(), colli_tgt_osg() {
|
||||
hinge.limit();
|
||||
skin_param::skin_param() : friction(), wind_afc(), air_res(), rot(), init_rot(),
|
||||
coli_type(), stiffness(), move_cancel(), coli_r(), force(), force_gain(), colli_tgt_osg() {
|
||||
reset();
|
||||
}
|
||||
|
||||
skin_param::~skin_param() {
|
||||
|
||||
}
|
||||
|
||||
void skin_param::reset() {
|
||||
coli.clear();
|
||||
friction = 1.0f;
|
||||
wind_afc = 0.0f;
|
||||
air_res = 1.0f;
|
||||
rot = vec3_null;
|
||||
init_rot = vec3_null;
|
||||
coli_type = 0;
|
||||
stiffness = 0.0f;
|
||||
move_cancel = -0.01f;
|
||||
coli_r = 0.0f;
|
||||
hinge = skin_param_hinge();
|
||||
hinge.limit();
|
||||
force = 0.0f;
|
||||
force_gain = 0.0f;
|
||||
colli_tgt_osg = 0;
|
||||
}
|
||||
|
||||
osage_coli::osage_coli() : type(), radius(), bone0_pos(), bone1_pos(),
|
||||
bone_pos_diff(), bone_pos_diff_length(), bone_pos_diff_length_squared(), field_34() {
|
||||
|
||||
@@ -528,9 +496,9 @@ void osage_coli::ring_set(osage_coli* coli,
|
||||
if (!vec_skp_root_coli.size()) {
|
||||
coli->type = (skin_param_osage_root_coli_type)0;
|
||||
coli->radius = 0.0f;
|
||||
coli->bone0_pos = vec3_null;
|
||||
coli->bone1_pos = vec3_null;
|
||||
coli->bone_pos_diff = vec3_null;
|
||||
coli->bone0_pos = 0.0f;
|
||||
coli->bone1_pos = 0.0f;
|
||||
coli->bone_pos_diff = 0.0f;
|
||||
coli->bone_pos_diff_length = 0.0f;
|
||||
coli->bone_pos_diff_length_squared = 0.0f;
|
||||
coli->field_34 = 1.0f;
|
||||
@@ -637,10 +605,10 @@ void CLOTH::Reset() {
|
||||
root_count = 0;
|
||||
nodes_count = 0;
|
||||
nodes.clear();
|
||||
wind_direction = vec3_null;
|
||||
wind_direction = 0.0f;
|
||||
field_44 = 0.0f;
|
||||
set_external_force = false;
|
||||
external_force = vec3_null;
|
||||
external_force = 0.0f;
|
||||
skin_param.reset();
|
||||
skin_param_ptr = &skin_param;
|
||||
}
|
||||
@@ -762,7 +730,7 @@ void RobCloth::InitData(size_t root_count, size_t nodes_count, obj_skin_block_cl
|
||||
mesh[i].submesh_array[j].attrib.m.cloth = 1;
|
||||
v27.attrib.m.cloth = 0;
|
||||
v27.bounding_sphere.radius = 1000.0f;
|
||||
v27.axis_aligned_bounding_box.center = vec3_null;
|
||||
v27.axis_aligned_bounding_box.center = 0.0f;
|
||||
v27.axis_aligned_bounding_box.size = { 1000.0f, 1000.0f, 1000.0f };
|
||||
}
|
||||
mesh[i].submesh_array = submesh.arr;
|
||||
@@ -770,14 +738,14 @@ void RobCloth::InitData(size_t root_count, size_t nodes_count, obj_skin_block_cl
|
||||
}
|
||||
|
||||
this->index_buffer[0] = index_buffer[mesh_name_index];
|
||||
if (!vertex_buffer[0].load(mesh[0]))
|
||||
if (!vertex_buffer[0].load(mesh[0], true))
|
||||
return;
|
||||
|
||||
this->index_buffer[1] = {};
|
||||
if (cls_data->backface_mesh_name && backface_mesh_name_index != -1)
|
||||
this->index_buffer[1] = index_buffer[backface_mesh_name_index];
|
||||
|
||||
if (cls_data->backface_mesh_name && !vertex_buffer[1].load(mesh[1]))
|
||||
if (cls_data->backface_mesh_name && !vertex_buffer[1].load(mesh[1], true))
|
||||
return;
|
||||
|
||||
field_8 = (((field_8 ^ (4 * a7)) & 0x04) ^ field_8) | 0x03;
|
||||
@@ -819,14 +787,20 @@ void RobCloth::InitData(size_t root_count, size_t nodes_count, obj_skin_block_cl
|
||||
v55.trans_orig = root[i].trans;
|
||||
}
|
||||
|
||||
uint16_t* mesh_indices = cls_data->mesh_indices;
|
||||
uint16_t* mesh_index_array = cls_data->mesh_index_array;
|
||||
|
||||
obj_mesh* mesh = object_storage_get_obj_mesh(itm_eq_obj->obj_info, cls_data->mesh_name);
|
||||
if (mesh && mesh->vertex_format
|
||||
obj_vertex_format vertex_format = (obj_vertex_format)0;
|
||||
obj_vertex_data* vertex_array = 0;
|
||||
if (mesh) {
|
||||
vertex_format = mesh->vertex_format;
|
||||
vertex_array = mesh->vertex_array;
|
||||
}
|
||||
|
||||
if (mesh && vertex_format
|
||||
& (OBJ_VERTEX_TEXCOORD0 | OBJ_VERTEX_TANGENT | OBJ_VERTEX_NORMAL | OBJ_VERTEX_POSITION)) {
|
||||
obj_vertex_data* vertex = mesh->vertex;
|
||||
for (size_t i = 0; i < root_count; ++i)
|
||||
this->root.data()[i].tangent = vertex[mesh_indices[i]].tangent;
|
||||
this->root.data()[i].tangent = vertex_array[mesh_index_array[i]].tangent;
|
||||
}
|
||||
|
||||
for (size_t i = 1; i < nodes_count; i++)
|
||||
@@ -858,8 +832,8 @@ void RobCloth::InitData(size_t root_count, size_t nodes_count, obj_skin_block_cl
|
||||
flags |= 0x08;
|
||||
v72.flags = flags;
|
||||
|
||||
if (mesh && mesh->vertex_format & OBJ_VERTEX_TEXCOORD0)
|
||||
v72.texcoord = mesh->vertex[mesh_indices[i * root_count + j]].texcoord0;
|
||||
if (mesh && vertex_format & OBJ_VERTEX_TEXCOORD0)
|
||||
v72.texcoord = vertex_array[mesh_index_array[i * root_count + j]].texcoord0;
|
||||
}
|
||||
|
||||
Init();
|
||||
@@ -869,8 +843,8 @@ void RobCloth::InitDataParent(obj_skin_block_cloth* cls_data,
|
||||
rob_chara_item_equip_object* itm_eq_obj, bone_database* bone_data) {
|
||||
ResetData();
|
||||
this->cls_data = cls_data;
|
||||
InitData(cls_data->root_count, cls_data->nodes_count, cls_data->root,
|
||||
cls_data->nodes, cls_data->mats, cls_data->field_14, itm_eq_obj, bone_data);
|
||||
InitData(cls_data->num_root, cls_data->num_node, cls_data->root_array,
|
||||
cls_data->node_array, cls_data->mat_array, cls_data->field_14, itm_eq_obj, bone_data);
|
||||
}
|
||||
|
||||
float_t* RobCloth::LoadOpdData(size_t node_index, float_t* opd_data, size_t opd_count) {
|
||||
@@ -900,7 +874,7 @@ void RobCloth::LoadSkinParam(void* kv, const char* name, bone_database* bone_dat
|
||||
|
||||
void RobCloth::ResetExtrenalForce() {
|
||||
set_external_force = false;
|
||||
external_force = vec3_null;
|
||||
external_force = 0.0f;
|
||||
}
|
||||
|
||||
void RobCloth::SetForceAirRes(float_t force, float_t force_gain, float_t air_res) {
|
||||
@@ -951,8 +925,7 @@ void RobCloth::SetOsagePlayData(std::vector<opd_blend_data>& opd_blend_data) {
|
||||
CLOTHNode& root_node = nodes.data()[j];
|
||||
vec3 v26 = root_node.trans;
|
||||
mat4 mat = root.data()[j].field_98;
|
||||
mat4_translate_mult(&mat, root_node.trans_orig.x,
|
||||
root_node.trans_orig.y, root_node.trans_orig.z, &mat);
|
||||
mat4_translate_mult(&mat, &root_node.trans_orig, &mat);
|
||||
|
||||
CLOTHNode* v29 = &nodes.data()[j + root_count];
|
||||
|
||||
@@ -992,7 +965,7 @@ void RobCloth::SetOsagePlayData(std::vector<opd_blend_data>& opd_blend_data) {
|
||||
vec3 v85;
|
||||
mat4_mult_vec3_inv_trans(&mat, &v57, &v85);
|
||||
|
||||
vec3 rotation = vec3_null;
|
||||
vec3 rotation = 0.0f;
|
||||
int32_t yz_order = 0;
|
||||
sub_140482FF0(mat, v85, 0, &rotation, yz_order);
|
||||
|
||||
@@ -1013,8 +986,7 @@ void RobCloth::SetOsagePlayData(std::vector<opd_blend_data>& opd_blend_data) {
|
||||
for (size_t i = 0; i < root_count; i++) {
|
||||
CLOTHNode& root_node = nodes.data()[i];
|
||||
mat4 mat = root.data()[0].field_98;
|
||||
mat4_translate_mult(&mat, root_node.trans_orig.x,
|
||||
root_node.trans_orig.y, root_node.trans_orig.z, &mat);
|
||||
mat4_translate_mult(&mat, &root_node.trans_orig, &mat);
|
||||
|
||||
CLOTHNode* v50 = &nodes.data()[i + root_count];
|
||||
|
||||
@@ -1068,13 +1040,13 @@ void RobCloth::UpdateDisp() {
|
||||
obj_mesh* backface_mesh = object_storage_get_obj_mesh(itm_eq_obj->obj_info, cls_data->backface_mesh_name);
|
||||
if (cls_data->backface_mesh_name) {
|
||||
UpdateVertexBuffer(mesh, &vertex_buffer[0], nodes.data(),
|
||||
1.0f, cls_data->mesh_indices_count, cls_data->mesh_indices, false);
|
||||
1.0f, cls_data->num_mesh_index, cls_data->mesh_index_array, false);
|
||||
UpdateVertexBuffer(backface_mesh, &vertex_buffer[1], nodes.data(),
|
||||
-1.0f, cls_data->backface_mesh_indices_count, cls_data->backface_mesh_indices, false);
|
||||
-1.0f, cls_data->num_backface_mesh_index, cls_data->backface_mesh_index_array, false);
|
||||
}
|
||||
else
|
||||
UpdateVertexBuffer(mesh, &vertex_buffer[0], nodes.data(),
|
||||
1.0, cls_data->backface_mesh_indices_count, cls_data->mesh_indices, true);
|
||||
1.0, cls_data->num_mesh_index, cls_data->mesh_index_array, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1120,11 +1092,21 @@ void RobCloth::UpdateVertexBuffer(obj_mesh* mesh, obj_mesh_vertex_buffer* vertex
|
||||
return;
|
||||
|
||||
vertex_buffer->cycle_index();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer->get_buffer());
|
||||
size_t data = (size_t)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
if (!data) {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
return;
|
||||
size_t data;
|
||||
if (GLAD_GL_VERSION_4_5) {
|
||||
data = (size_t)glMapNamedBuffer(vertex_buffer->get_buffer(), GL_WRITE_ONLY);
|
||||
if (!data) {
|
||||
glUnmapNamedBuffer(vertex_buffer->get_buffer());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
gl_state_bind_array_buffer(vertex_buffer->get_buffer());
|
||||
data = (size_t)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
if (!data) {
|
||||
gl_state_bind_array_buffer(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (double_sided)
|
||||
@@ -1139,7 +1121,7 @@ void RobCloth::UpdateVertexBuffer(obj_mesh* mesh, obj_mesh_vertex_buffer* vertex
|
||||
CLOTHNode* node = &nodes[*indices];
|
||||
|
||||
*(vec3*)data = node->trans;
|
||||
vec3_mult_scalar(node->normal, facing, *(vec3*)(data + 0x0C));
|
||||
*(vec3*)(data + 0x0C) = node->normal * facing;
|
||||
*(vec3*)(data + 0x18) = node->tangent;
|
||||
*(float_t*)(data + 0x24) = node->tangent_sign;
|
||||
|
||||
@@ -1155,7 +1137,7 @@ void RobCloth::UpdateVertexBuffer(obj_mesh* mesh, obj_mesh_vertex_buffer* vertex
|
||||
CLOTHNode* node = &nodes[*indices];
|
||||
|
||||
*(vec3*)data = node->trans;
|
||||
vec3_mult_scalar(node->normal, facing, *(vec3*)(data + 0x0C));
|
||||
*(vec3*)(data + 0x0C) = node->normal * facing;
|
||||
|
||||
data += mesh->size_vertex;
|
||||
}
|
||||
@@ -1172,15 +1154,14 @@ void RobCloth::UpdateVertexBuffer(obj_mesh* mesh, obj_mesh_vertex_buffer* vertex
|
||||
|
||||
*(vec3*)data = node->trans;
|
||||
|
||||
vec3 normal;
|
||||
vec3_mult_scalar(node->normal, 32727.0f * facing, normal);
|
||||
vec3 normal = node->normal * (32727.0f * facing);
|
||||
vec3_to_vec3i16(normal, *(vec3i16*)(data + 0x0C));
|
||||
*(int16_t*)(data + 0x12) = 0;
|
||||
|
||||
vec4 tangent;
|
||||
*(vec3*)&tangent = node->tangent;
|
||||
tangent.w = node->tangent_sign;
|
||||
vec4_mult_scalar(tangent, 32727.0f, tangent);
|
||||
tangent *= 32727.0f;
|
||||
vec4_to_vec4i16(tangent, *(vec4i16*)(data + 0x14));
|
||||
|
||||
data += mesh->size_vertex;
|
||||
@@ -1196,8 +1177,7 @@ void RobCloth::UpdateVertexBuffer(obj_mesh* mesh, obj_mesh_vertex_buffer* vertex
|
||||
|
||||
*(vec3*)data = node->trans;
|
||||
|
||||
vec3 normal;
|
||||
vec3_mult_scalar(node->normal, 32727.0f * facing, normal);
|
||||
vec3 normal = node->normal * (32727.0f * facing);
|
||||
vec3_to_vec3i16(normal, *(vec3i16*)(data + 0x0C));
|
||||
*(int16_t*)(data + 0x12) = 0;
|
||||
|
||||
@@ -1209,8 +1189,12 @@ void RobCloth::UpdateVertexBuffer(obj_mesh* mesh, obj_mesh_vertex_buffer* vertex
|
||||
}
|
||||
}
|
||||
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
if (GLAD_GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(vertex_buffer->get_buffer());
|
||||
else {
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
gl_state_bind_array_buffer(0);
|
||||
}
|
||||
}
|
||||
|
||||
ExClothBlock::ExClothBlock() {
|
||||
@@ -1388,7 +1372,7 @@ RobOsageNode* RobOsage::GetNode(size_t index) {
|
||||
void RobOsage::InitData(obj_skin_block_osage* osg_data, obj_skin_osage_node* osg_nodes,
|
||||
bone_node* ex_data_bone_nodes, obj_skin* skin) {
|
||||
Reset();
|
||||
exp_data.set_position_rotation(osg_data->base.position, osg_data->base.rotation);
|
||||
exp_data.set_position_rotation(osg_data->node.position, osg_data->node.rotation);
|
||||
nodes.clear();
|
||||
nodes.resize(osg_data->count + 1ULL);
|
||||
|
||||
@@ -1425,35 +1409,34 @@ void RobOsage::InitData(obj_skin_block_osage* osg_data, obj_skin_osage_node* osg
|
||||
*node.bone_node_ptr->ex_data_mat = mat4_identity;
|
||||
|
||||
if (osg_data->count) {
|
||||
obj_skin_osage_node* v23 = osg_data->nodes;
|
||||
obj_skin_osage_node* node_array = osg_data->node_array;
|
||||
size_t v24 = 0;
|
||||
RobOsageNode* v26 = &nodes.data()[1];
|
||||
for (size_t i = 0; i < osg_data->count; i++) {
|
||||
vec3 v27 = vec3_null;
|
||||
if (v23)
|
||||
v27 = v23[i].rotation;
|
||||
vec3 v27 = 0.0f;
|
||||
if (node_array)
|
||||
v27 = node_array[i].rotation;
|
||||
|
||||
mat4 mat;
|
||||
mat4_rotate(v27.x, v27.y, v27.z, &mat);
|
||||
mat4_rotate(&v27, &mat);
|
||||
|
||||
vec3 v49;
|
||||
v49 = vec3_null;
|
||||
v49 = 0.0f;
|
||||
v49.x = v26[i].length;
|
||||
mat4_mult_vec3(&mat, &v49, &v26[i].field_94);
|
||||
}
|
||||
}
|
||||
|
||||
if (osg_data->count) {
|
||||
obj_skin_osage_node* v23 = osg_data->nodes;
|
||||
RobOsageNode* v26 = &nodes.data()[1];
|
||||
size_t v33 = 0;
|
||||
for (uint32_t i = 0; i < osg_data->count; i++) {
|
||||
v26[i].mat = mat4_null;
|
||||
|
||||
obj_skin_bone* v36 = skin->bones;
|
||||
for (uint32_t j = 0; j < skin->bones_count; j++, v36++)
|
||||
if (v36->id == osg_nodes->name_index) {
|
||||
mat4_inverse_normalized(&skin->bones[j].inv_bind_pose_mat, &v26[i].mat);
|
||||
obj_skin_bone* bone = skin->bone_array;
|
||||
for (uint32_t j = 0; j < skin->num_bone; j++, bone++)
|
||||
if (bone->id == osg_nodes->name_index) {
|
||||
mat4_inverse_normalized(&bone->inv_bind_pose_mat, &v26[i].mat);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1507,7 +1490,7 @@ void RobOsage::LoadSkinParam(void* kv, const char* name,
|
||||
void RobOsage::Reset() {
|
||||
nodes.clear();
|
||||
node.Reset();
|
||||
wind_direction = vec3_null;
|
||||
wind_direction = 0.0f;
|
||||
field_1EB4 = 0.0f;
|
||||
yz_order = 0;
|
||||
field_2A0 = true;
|
||||
@@ -1525,14 +1508,14 @@ void RobOsage::Reset() {
|
||||
field_2A4 = 0.0f;
|
||||
field_2A1 = false;
|
||||
set_external_force = false;
|
||||
external_force = vec3_null;
|
||||
external_force = 0.0f;
|
||||
parent_mat_ptr = 0;
|
||||
parent_mat = mat4_null;
|
||||
}
|
||||
|
||||
void RobOsage::ResetExtrenalForce() {
|
||||
set_external_force = false;
|
||||
external_force = vec3_null;
|
||||
external_force = 0.0f;
|
||||
}
|
||||
|
||||
void RobOsage::SetAirRes(float_t air_res) {
|
||||
@@ -1590,7 +1573,7 @@ void RobOsage::SetNodesExternalForce(vec3* external_force, float_t strength) {
|
||||
if (external_force)
|
||||
v4 = *external_force;
|
||||
else
|
||||
v4 = vec3_null;
|
||||
v4 = 0.0f;
|
||||
|
||||
size_t exf = osage_setting.exf;
|
||||
size_t v8 = 0;
|
||||
@@ -1598,18 +1581,18 @@ void RobOsage::SetNodesExternalForce(vec3* external_force, float_t strength) {
|
||||
float_t strength4 = strength * strength * strength * strength;
|
||||
v8 = ((exf - 4) / 4 + 1) * 4;
|
||||
for (size_t v10 = v8 / 4; v10; v10--)
|
||||
vec3_mult_scalar(v4, strength4, v4);
|
||||
v4 *= strength4;
|
||||
}
|
||||
|
||||
if (v8 < exf)
|
||||
for (size_t v12 = exf - v8; v12; v12--)
|
||||
vec3_mult_scalar(v4, strength, v4);
|
||||
v4 *= strength;
|
||||
|
||||
RobOsageNode* i_begin = nodes.data() + 1;
|
||||
RobOsageNode* i_end = nodes.data() + nodes.size();
|
||||
for (RobOsageNode* i = i_begin; i != i_end; i++) {
|
||||
i->external_force = v4;
|
||||
vec3_mult_scalar(v4, strength, v4);
|
||||
v4 *= strength;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1690,7 +1673,7 @@ void RobOsage::SetOsagePlayData(mat4* parent_mat,
|
||||
vec3 v86;
|
||||
mat4_mult_vec3_inv_trans(&v87, &v82, &v86);
|
||||
|
||||
vec3 rotation = vec3_null;
|
||||
vec3 rotation = 0.0f;
|
||||
sub_140482FF0(v87, v86, 0, &rotation, yz_order);
|
||||
mat4_set_translation(&v87, &v82);
|
||||
|
||||
@@ -1723,7 +1706,7 @@ void RobOsage::SetOsagePlayData(mat4* parent_mat,
|
||||
*j->bone_node_ptr->ex_data_mat = v85;
|
||||
if (j->bone_node_mat) {
|
||||
mat4 mat = v85;
|
||||
mat4_scale_rot(&mat, parent_scale.x, parent_scale.y, parent_scale.z, &mat);
|
||||
mat4_scale_rot(&mat, &parent_scale, &mat);
|
||||
*j->bone_node_mat = mat;
|
||||
}
|
||||
mat4_translate_mult(&v85, j->field_1B0.field_0.length, 0.0f, 0.0f, &v85);
|
||||
@@ -1736,7 +1719,7 @@ void RobOsage::SetOsagePlayData(mat4* parent_mat,
|
||||
mat4_translate_mult(&v87, node.length * parent_scale.x, 0.0f, 0.0f, &v87);
|
||||
*node.bone_node_ptr->ex_data_mat = v87;
|
||||
|
||||
mat4_scale_rot(&v87, parent_scale.x, parent_scale.y, parent_scale.z, &v87);
|
||||
mat4_scale_rot(&v87, &parent_scale, &v87);
|
||||
*node.bone_node_mat = v87;
|
||||
node.bone_node_ptr->exp_data.parent_scale = parent_scale;
|
||||
}
|
||||
@@ -1868,8 +1851,8 @@ void ExOsageBlock::Field_20() {
|
||||
|
||||
mat4 mat = *parent_bone_node->ex_data_mat;
|
||||
if (scale.x != 1.0f || scale.y != 1.0f || scale.z != 1.0f) {
|
||||
vec3_div(vec3_identity, scale, scale);
|
||||
mat4_scale_rot(&mat, scale.x, scale.y, scale.z, &mat);
|
||||
vec3_div(1.0f, scale, scale);
|
||||
mat4_scale_rot(&mat, &scale, &mat);
|
||||
}
|
||||
SetWindDirection();
|
||||
rob.ColiSet(mats);
|
||||
@@ -2020,9 +2003,9 @@ void ExConstraintBlock::Init() {
|
||||
void ExConstraintBlock::Field_10() {
|
||||
if (bone_node_ptr) {
|
||||
bone_node_expression_data* node_exp_data = &bone_node_ptr->exp_data;
|
||||
node_exp_data->position = cns_data->base.position;
|
||||
node_exp_data->rotation = cns_data->base.rotation;
|
||||
node_exp_data->scale = cns_data->base.scale;
|
||||
node_exp_data->position = cns_data->node.position;
|
||||
node_exp_data->rotation = cns_data->node.rotation;
|
||||
node_exp_data->scale = cns_data->node.scale;
|
||||
}
|
||||
field_59 = false;
|
||||
}
|
||||
@@ -2086,26 +2069,27 @@ void ExConstraintBlock::Calc() {
|
||||
vec3_mult(parent_bone_node->exp_data.parent_scale, node->exp_data.position, pos);
|
||||
|
||||
mat4 mat;
|
||||
mat4_translate_mult(parent_bone_node->ex_data_mat, pos.x, pos.y, pos.z, &mat);
|
||||
mat4_translate_mult(parent_bone_node->ex_data_mat, &pos, &mat);
|
||||
|
||||
switch (constraint_type) {
|
||||
case OBJ_SKIN_BLOCK_CONSTRAINT_ORIENTATION: {
|
||||
obj_skin_block_constraint_orientation* orientation = cns_data->orientation;
|
||||
|
||||
vec3 trans;
|
||||
mat4_get_translation(&mat, &trans);
|
||||
|
||||
mat3 rot;
|
||||
mat3_from_mat4(source_node_bone_node->mat, &rot);
|
||||
mat3_normalize_rotation(&rot, &rot);
|
||||
|
||||
vec3 offset = cns_data->orientation.offset;
|
||||
mat3_rotate_mult(&rot, offset.x, offset.y, offset.z, &rot);
|
||||
|
||||
mat3_rotate_mult(&rot, &orientation->offset, &rot);
|
||||
mat4_from_mat3(&rot, node->mat);
|
||||
mat4_set_translation(node->mat, &trans);
|
||||
} break;
|
||||
case OBJ_SKIN_BLOCK_CONSTRAINT_DIRECTION: {
|
||||
vec3 align_axis = cns_data->direction.align_axis;
|
||||
vec3 target_offset = cns_data->direction.target_offset;
|
||||
obj_skin_block_constraint_direction* direction = cns_data->direction;
|
||||
|
||||
vec3 align_axis = direction->align_axis;
|
||||
vec3 target_offset = direction->target_offset;
|
||||
mat4_mult_vec3_trans(source_node_bone_node->mat, &target_offset, &target_offset);
|
||||
mat4_mult_vec3_inv_trans(&mat, &target_offset, &target_offset);
|
||||
float_t target_offset_length;
|
||||
@@ -2116,7 +2100,7 @@ void ExConstraintBlock::Calc() {
|
||||
mat4 v59;
|
||||
sub_1401EB410(&v59, &align_axis, &target_offset);
|
||||
if (direction_up_vector_bone_node) {
|
||||
vec3 affected_axis = cns_data->direction.up_vector.affected_axis;
|
||||
vec3 affected_axis = direction->up_vector.affected_axis;
|
||||
mat4 v56;
|
||||
mat4_mult(&v59, &mat, &v56);
|
||||
mat4_mult_vec3(&v56, &affected_axis, &affected_axis);
|
||||
@@ -2157,9 +2141,11 @@ void ExConstraintBlock::Calc() {
|
||||
mat4_mult(&v59, &mat, node->mat);
|
||||
} break;
|
||||
case OBJ_SKIN_BLOCK_CONSTRAINT_POSITION: {
|
||||
vec3 constraining_offset = cns_data->position.constraining_object.offset;
|
||||
vec3 constrained_offset = cns_data->position.constrained_object.offset;
|
||||
if (cns_data->position.constraining_object.affected_by_orientation)
|
||||
obj_skin_block_constraint_position* position = cns_data->position;
|
||||
|
||||
vec3 constraining_offset = position->constraining_object.offset;
|
||||
vec3 constrained_offset = position->constrained_object.offset;
|
||||
if (position->constraining_object.affected_by_orientation)
|
||||
mat4_mult_vec3(source_node_bone_node->mat, &constraining_offset, &constraining_offset);
|
||||
|
||||
vec3 source_node_trans;
|
||||
@@ -2172,15 +2158,14 @@ void ExConstraintBlock::Calc() {
|
||||
mat4_mult_vec3_inv_trans(&mat, &up_vector_trans, &up_vector_trans);
|
||||
|
||||
mat4 v26;
|
||||
sub_1401EB410(&v26, &cns_data->position.up_vector.affected_axis, &up_vector_trans);
|
||||
sub_1401EB410(&v26, &position->up_vector.affected_axis, &up_vector_trans);
|
||||
mat4_mult(&v26, &mat, &mat);
|
||||
}
|
||||
if (cns_data->position.constrained_object.affected_by_orientation)
|
||||
if (position->constrained_object.affected_by_orientation)
|
||||
mat4_mult_vec3(&mat, &constrained_offset, &constrained_offset);
|
||||
|
||||
mat4 constrained_offset_mat;
|
||||
mat4_translate(constrained_offset.x, constrained_offset.y,
|
||||
constrained_offset.z, &constrained_offset_mat);
|
||||
mat4_translate(&constrained_offset, &constrained_offset_mat);
|
||||
mat4_mult(&mat, &constrained_offset_mat, node->mat);
|
||||
} break;
|
||||
case OBJ_SKIN_BLOCK_CONSTRAINT_DISTANCE:
|
||||
@@ -2209,7 +2194,7 @@ void ExConstraintBlock::DataSet() {
|
||||
if (fabsf(parent_scale.z) > 0.000001f)
|
||||
exp_data->position.z /= parent_scale.z;
|
||||
*bone_node_ptr->ex_data_mat = *bone_node_ptr->mat;
|
||||
mat4_scale_rot(bone_node_ptr->mat, parent_scale.x, parent_scale.y, parent_scale.z, bone_node_ptr->mat);
|
||||
mat4_scale_rot(bone_node_ptr->mat, &parent_scale, bone_node_ptr->mat);
|
||||
vec3_mult(exp_data->scale, parent_scale, exp_data->parent_scale);
|
||||
}
|
||||
|
||||
@@ -2228,15 +2213,15 @@ void ExConstraintBlock::InitData(rob_chara_item_equip_object* itm_eq_obj,
|
||||
const char* up_vector_name;
|
||||
if (type == OBJ_SKIN_BLOCK_CONSTRAINT_DIRECTION) {
|
||||
constraint_type = OBJ_SKIN_BLOCK_CONSTRAINT_DIRECTION;
|
||||
up_vector_name = cns_data->direction.up_vector.name;
|
||||
up_vector_name = cns_data->direction->up_vector.name;
|
||||
}
|
||||
else if (type == OBJ_SKIN_BLOCK_CONSTRAINT_POSITION) {
|
||||
constraint_type = OBJ_SKIN_BLOCK_CONSTRAINT_POSITION;
|
||||
up_vector_name = cns_data->position.up_vector.name;
|
||||
up_vector_name = cns_data->position->up_vector.name;
|
||||
}
|
||||
else if (type == OBJ_SKIN_BLOCK_CONSTRAINT_DISTANCE) {
|
||||
constraint_type = OBJ_SKIN_BLOCK_CONSTRAINT_DISTANCE;
|
||||
up_vector_name = cns_data->distance.up_vector.name;
|
||||
up_vector_name = cns_data->distance->up_vector.name;
|
||||
}
|
||||
else if (type == OBJ_SKIN_BLOCK_CONSTRAINT_ORIENTATION) {
|
||||
constraint_type = OBJ_SKIN_BLOCK_CONSTRAINT_ORIENTATION;
|
||||
@@ -2311,9 +2296,9 @@ void ExExpressionBlock::Init() {
|
||||
|
||||
void ExExpressionBlock::Field_10() {
|
||||
bone_node_expression_data* node_exp_data = &bone_node_ptr->exp_data;
|
||||
node_exp_data->position = exp_data->base.position;
|
||||
node_exp_data->rotation = exp_data->base.rotation;
|
||||
node_exp_data->scale = exp_data->base.scale;
|
||||
node_exp_data->position = exp_data->node.position;
|
||||
node_exp_data->rotation = exp_data->node.rotation;
|
||||
node_exp_data->scale = exp_data->node.scale;
|
||||
field_59 = false;
|
||||
}
|
||||
|
||||
@@ -2413,9 +2398,9 @@ void ExExpressionBlock::InitData(rob_chara_item_equip_object* itm_eq_obj,
|
||||
name = node->name;
|
||||
item_equip_object = itm_eq_obj;
|
||||
|
||||
node->exp_data.position = exp_data->base.position;
|
||||
node->exp_data.rotation = exp_data->base.rotation;
|
||||
node->exp_data.scale = exp_data->base.scale;
|
||||
node->exp_data.position = exp_data->node.position;
|
||||
node->exp_data.rotation = exp_data->node.rotation;
|
||||
node->exp_data.scale = exp_data->node.scale;
|
||||
field_3D28 = 0;
|
||||
|
||||
ex_expression_block_stack* stack_val = stack_data;
|
||||
@@ -2425,7 +2410,7 @@ void ExExpressionBlock::InitData(rob_chara_item_equip_object* itm_eq_obj,
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < 9; i++) {
|
||||
const char* expression = exp_data->expressions[i];
|
||||
const char* expression = exp_data->expression_array[i];
|
||||
if (!expression || str_utils_compare_length(expression, utf8_length(expression), "= ", 2))
|
||||
break;
|
||||
|
||||
@@ -2700,7 +2685,7 @@ void skin_param_osage_root_parse(void* kv, const char* name,
|
||||
c->bone0_index = bone_data->get_skeleton_object_bone_index(
|
||||
bone_database_skeleton_type_to_string(BONE_DATABASE_SKELETON_COMMON), bone0_name);
|
||||
|
||||
vec3 bone0_pos = vec3_null;
|
||||
vec3 bone0_pos = 0.0f;
|
||||
if (!_kv->read("bone.0.posx", bone0_pos.x)
|
||||
|| !_kv->read("bone.0.posy", bone0_pos.y)
|
||||
|| !_kv->read("bone.0.posz", bone0_pos.z)) {
|
||||
@@ -2715,7 +2700,7 @@ void skin_param_osage_root_parse(void* kv, const char* name,
|
||||
c->bone1_index = bone_data->get_skeleton_object_bone_index(
|
||||
bone_database_skeleton_type_to_string(BONE_DATABASE_SKELETON_COMMON), bone1_name);
|
||||
|
||||
vec3 bone1_pos = vec3_null;
|
||||
vec3 bone1_pos = 0.0f;
|
||||
if (!_kv->read("bone.1.posx", bone1_pos.x)
|
||||
|| !_kv->read("bone.1.posy", bone1_pos.y)
|
||||
|| !_kv->read("bone.1.posz", bone1_pos.z)) {
|
||||
@@ -3118,7 +3103,7 @@ static void sub_140218560(RobCloth* rob_cls, float_t step, bool a3) {
|
||||
|
||||
if (!a3) {
|
||||
rob_cls->set_external_force = false;
|
||||
rob_cls->external_force = vec3_null;
|
||||
rob_cls->external_force = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3224,7 +3209,7 @@ static void sub_140219940(RobCloth* rob_cls) {
|
||||
root_node.tangent_sign = root.tangent.w;
|
||||
root_node.field_1C = root_node.trans;
|
||||
|
||||
mat4_translate_mult(&m, root_node.trans_orig.x, root_node.trans_orig.y, root_node.trans_orig.z, &m);
|
||||
mat4_translate_mult(&m, &root_node.trans_orig, &m);
|
||||
root.field_D8 = m;
|
||||
mat4_inverse(&m, &m);
|
||||
root.field_118 = m;
|
||||
@@ -3444,7 +3429,7 @@ void sub_14021AA60(RobCloth* rob_cls, float_t step, bool a3) {
|
||||
|
||||
if (v19 > node->trans.y && v19 < 1001.0) {
|
||||
node->trans.y = v19;
|
||||
node->trans_diff = vec3_null;
|
||||
node->trans_diff = 0.0f;
|
||||
}
|
||||
|
||||
mat4 mat = root->field_98;
|
||||
@@ -3518,7 +3503,7 @@ static void sub_14021D480(RobCloth* rob_cls) {
|
||||
if (v10 > node->trans.y && v10 < 1001.0f)
|
||||
node->trans.y = v10;
|
||||
|
||||
node->trans_diff = vec3_null;
|
||||
node->trans_diff = 0.0f;
|
||||
node->field_1C = node->trans;
|
||||
}
|
||||
}
|
||||
@@ -3529,7 +3514,7 @@ static void sub_14021D480(RobCloth* rob_cls) {
|
||||
node = &rob_cls->nodes.data()[root_count];
|
||||
for (size_t i = 1; i < nodes_count; i++)
|
||||
for (ssize_t j = 0; j < root_count; j++, node++)
|
||||
node->trans_diff = vec3_null;
|
||||
node->trans_diff = 0.0f;
|
||||
}
|
||||
|
||||
static void sub_14021DC60(RobCloth* rob_cls, float_t step) {
|
||||
@@ -3691,7 +3676,7 @@ static void sub_14047C800(RobOsage* rob_osg, mat4* mat, vec3* parent_scale,
|
||||
float_t v96 = ring_height + coli_r;
|
||||
RobOsageNode* v98_begin = rob_osg->nodes.data() + 1;
|
||||
RobOsageNode* v98_end = rob_osg->nodes.data() + rob_osg->nodes.size();
|
||||
for (auto v98 = v98_begin; v98 != v98_end; v98++) {
|
||||
for (RobOsageNode* v98 = v98_begin; v98 != v98_end; v98++) {
|
||||
sub_140482490(v98, step, v25);
|
||||
sub_140482180(v98, v96);
|
||||
}
|
||||
@@ -3741,7 +3726,7 @@ static void sub_14047E1C0(RobOsage* rob_osg, vec3* scale) {
|
||||
for (RobOsageNode* i = i_begin; i != i_end; i++)
|
||||
if (i->data_ptr->normal_ref.field_0) {
|
||||
sub_14053CE30(&i->data_ptr->normal_ref, i->bone_node_mat);
|
||||
mat4_scale_rot(i->bone_node_mat, scale->x, scale->y, scale->z, i->bone_node_mat);
|
||||
mat4_scale_rot(i->bone_node_mat, scale, i->bone_node_mat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3765,18 +3750,15 @@ static void sub_14047EE90(RobOsage* rob_osg, mat4* mat) {
|
||||
}
|
||||
|
||||
static void sub_14047F110(RobOsage* rob_osg, mat4* mat, vec3* parent_scale, bool init_rot) {
|
||||
vec3 position;
|
||||
vec3_mult(rob_osg->exp_data.position, *parent_scale, position);
|
||||
mat4_translate_mult(mat, position.x, position.y, position.z, mat);
|
||||
|
||||
vec3 rotation = rob_osg->exp_data.rotation;
|
||||
mat4_rotate_mult(mat, rotation.x, rotation.y, rotation.z, mat);
|
||||
vec3 position = rob_osg->exp_data.position * *parent_scale;
|
||||
mat4_translate_mult(mat, &position, mat);
|
||||
mat4_rotate_mult(mat, &rob_osg->exp_data.rotation, mat);
|
||||
|
||||
skin_param* skin_param = rob_osg->skin_param_ptr;
|
||||
vec3 rot = skin_param->rot;
|
||||
if (init_rot)
|
||||
vec3_add(rot, skin_param->init_rot, rot);
|
||||
mat4_rotate_mult(mat, rot.x, rot.y, rot.z, mat);
|
||||
rot = skin_param->init_rot + rot;
|
||||
mat4_rotate_mult(mat, &rot, mat);
|
||||
}
|
||||
|
||||
static void sub_1404803B0(RobOsage* rob_osg, mat4* mat, vec3* parent_scale, bool has_children_node) {
|
||||
@@ -3861,7 +3843,7 @@ static void sub_140482180(RobOsageNode* node, float_t a2) {
|
||||
vec3_normalize(v3, v3);
|
||||
vec3_mult_scalar(v3, node->length, v3);
|
||||
vec3_add(node[-1].trans, v3, node->trans);
|
||||
node->trans_diff = vec3_null;
|
||||
node->trans_diff = 0.0f;
|
||||
node->field_C8 += 1.0f;
|
||||
}
|
||||
|
||||
@@ -3929,9 +3911,9 @@ static int32_t sub_140483B30(vec3* a1, vec3* a2, osage_coli* a3, float_t radius)
|
||||
return 0;
|
||||
}
|
||||
|
||||
vec3 v28 = vec3_null;
|
||||
vec3 v32 = vec3_null;
|
||||
vec3 v27 = vec3_identity;
|
||||
vec3 v28 = 0.0f;
|
||||
vec3 v32 = 0.0f;
|
||||
vec3 v27 = 1.0f;
|
||||
|
||||
float_t v16 = 0.0f;
|
||||
for (int32_t i = 0; i < 3; i++) {
|
||||
@@ -4113,7 +4095,7 @@ static int32_t sub_140485220(vec3* a1, float_t& coli_r, osage_coli* a3, float_t*
|
||||
int32_t v8 = 0;
|
||||
while (a3->type) {
|
||||
int32_t v11 = 0;
|
||||
vec3 v31 = vec3_null;
|
||||
vec3 v31 = 0.0f;
|
||||
switch (a3->type) {
|
||||
case SKIN_PARAM_OSAGE_ROOT_COLI_TYPE_BALL:
|
||||
v11 = sub_140483DE0(&v31, a1, &a3->bone0_pos, a3->radius + coli_r);
|
||||
@@ -4192,7 +4174,7 @@ static void sub_14047D8C0(RobOsage* rob_osg, mat4* mat, vec3* parent_scale, floa
|
||||
RobOsageNode* v27_begin = rob_osg->nodes.data() + 1;
|
||||
RobOsageNode* v27_end = rob_osg->nodes.data() + rob_osg->nodes.size();
|
||||
for (RobOsageNode* v27 = v27_begin; v27 != v27_end; v27++) {
|
||||
vec3 v62 = vec3_null;
|
||||
vec3 v62 = 0.0f;
|
||||
|
||||
RobOsageNode* v30_begin = v24->data() + 1;
|
||||
RobOsageNode* v30_end = v24->data() + v24->size();
|
||||
@@ -4230,7 +4212,7 @@ static void sub_14047D8C0(RobOsage* rob_osg, mat4* mat, vec3* parent_scale, floa
|
||||
|
||||
if (v35->bone_node_mat) {
|
||||
mat4* v41 = v35->bone_node_mat;
|
||||
mat4_scale_rot(&v64, parent_scale->x, parent_scale->y, parent_scale->z, v41);
|
||||
mat4_scale_rot(&v64, parent_scale, v41);
|
||||
}
|
||||
|
||||
float_t v42 = v35->length * parent_scale->x;
|
||||
@@ -4272,7 +4254,7 @@ static void sub_14047D8C0(RobOsage* rob_osg, mat4* mat, vec3* parent_scale, floa
|
||||
mat4 v65 = *rob_osg->nodes.back().bone_node_ptr->ex_data_mat;
|
||||
mat4_translate_mult(&v65, rob_osg->node.length * parent_scale->x, 0.0f, 0.0f, &v65);
|
||||
*rob_osg->node.bone_node_ptr->ex_data_mat = v65;
|
||||
mat4_scale_rot(&v65, parent_scale->x, parent_scale->y, parent_scale->z, &v65);
|
||||
mat4_scale_rot(&v65, parent_scale, &v65);
|
||||
*rob_osg->node.bone_node_mat = v65;
|
||||
rob_osg->node.bone_node_ptr->exp_data.parent_scale = *parent_scale;
|
||||
}
|
||||
@@ -4292,12 +4274,13 @@ static void sub_14047D620(RobOsage* rob_osg, float_t step) {
|
||||
if (step < 0.0f && rob_osg->field_1F0F)
|
||||
return;
|
||||
|
||||
vec3 v7 = rob_osg->nodes.data()[0].trans;
|
||||
std::vector<RobOsageNode>& nodes = rob_osg->nodes;
|
||||
vec3 v7 = nodes.data()[0].trans;
|
||||
osage_coli* coli = rob_osg->coli;
|
||||
osage_coli* coli_ring = rob_osg->coli_ring;
|
||||
int32_t coli_type = rob_osg->skin_param_ptr->coli_type;
|
||||
RobOsageNode* i_begin = rob_osg->nodes.data() + 1;
|
||||
RobOsageNode* i_end = rob_osg->nodes.data() + rob_osg->nodes.size();
|
||||
RobOsageNode* i_begin = nodes.data() + 1;
|
||||
RobOsageNode* i_end = nodes.data() + nodes.size();
|
||||
for (RobOsageNode* i = i_begin; i != i_end; i++) {
|
||||
RobOsageNodeData* data = i->data_ptr;
|
||||
for (RobOsageNode*& j : data->boc) {
|
||||
@@ -4316,7 +4299,7 @@ static void sub_14047D620(RobOsage* rob_osg, float_t step) {
|
||||
i[-1].field_C8 += v20;
|
||||
}
|
||||
}
|
||||
rob_osg->nodes.data()[0].trans = v7;
|
||||
nodes.data()[0].trans = v7;
|
||||
}
|
||||
|
||||
static void sub_14047ECA0(RobOsage* rob_osg, float_t step) {
|
||||
@@ -4345,18 +4328,18 @@ static void sub_14047ECA0(RobOsage* rob_osg, float_t step) {
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_14047F990(RobOsage* rob_osg, mat4* a2, vec3* a3, bool a4) {
|
||||
static void sub_14047F990(RobOsage* rob_osg, mat4* a2, vec3* parent_scale, bool a4) {
|
||||
if (!rob_osg->nodes.size())
|
||||
return;
|
||||
|
||||
vec3 v76;
|
||||
vec3_mult(rob_osg->exp_data.position, *a3, v76);
|
||||
vec3_mult(rob_osg->exp_data.position, *parent_scale, v76);
|
||||
mat4_mult_vec3_trans(a2, &v76, &v76);
|
||||
vec3 v74 = v76;
|
||||
RobOsageNode* v12 = &rob_osg->nodes.data()[0];
|
||||
v12->trans = v76;
|
||||
v12->trans_orig = v76;
|
||||
v12->trans_diff = vec3_null;
|
||||
v12->trans_diff = 0.0f;
|
||||
|
||||
float_t ring_height;
|
||||
RobOsageNode* v14 = &rob_osg->nodes.data()[0];
|
||||
@@ -4370,14 +4353,14 @@ static void sub_14047F990(RobOsage* rob_osg, mat4* a2, vec3* a3, bool a4) {
|
||||
ring_height = rob_osg->ring.ring_height;
|
||||
|
||||
mat4 v78 = *a2;
|
||||
sub_14047F110(rob_osg, &v78, a3, true);
|
||||
sub_14047F110(rob_osg, &v78, parent_scale, true);
|
||||
vec3 v60 = { 1.0f, 0.0f, 0.0f };
|
||||
mat4_mult_vec3(&v78, &v60, &v60);
|
||||
|
||||
osage_coli* coli_ring = rob_osg->coli_ring;
|
||||
osage_coli* coli = rob_osg->coli;
|
||||
float_t v25 = ring_height + coli_r;
|
||||
float_t v16 = a3->x;
|
||||
float_t v16 = parent_scale->x;
|
||||
RobOsageNode* i = rob_osg->nodes.data();
|
||||
RobOsageNode* j_begin = rob_osg->nodes.data() + 1;
|
||||
RobOsageNode* j_end = rob_osg->nodes.data() + rob_osg->nodes.size();
|
||||
@@ -4401,15 +4384,15 @@ static void sub_14047F990(RobOsage* rob_osg, mat4* a2, vec3* a3, bool a4) {
|
||||
vec3_add(v74, i->trans, v74);
|
||||
}
|
||||
j->trans = v74;
|
||||
j->trans_diff = vec3_null;
|
||||
j->trans_diff = 0.0f;
|
||||
vec3 v77;
|
||||
mat4_mult_vec3_inv_trans(&v78, &j->trans, &v77);
|
||||
sub_140482FF0(v78, v77, &j->data_ptr->skp_osg_node.hinge,
|
||||
&j->reset_data.rotation, rob_osg->yz_order);
|
||||
j->bone_node_ptr->exp_data.parent_scale = *a3;
|
||||
j->bone_node_ptr->exp_data.parent_scale = *parent_scale;
|
||||
*j->bone_node_ptr->ex_data_mat = v78;
|
||||
if (j->bone_node_mat)
|
||||
mat4_scale_rot(&v78, a3->x, a3->y, a3->z, j->bone_node_mat);
|
||||
mat4_scale_rot(&v78, parent_scale, j->bone_node_mat);
|
||||
|
||||
float_t v55;
|
||||
vec3_distance(j->trans, i->trans, v55);
|
||||
@@ -4425,9 +4408,9 @@ static void sub_14047F990(RobOsage* rob_osg, mat4* a2, vec3* a3, bool a4) {
|
||||
mat4 v79 = *rob_osg->nodes.back().bone_node_ptr->ex_data_mat;
|
||||
mat4_translate_mult(&v79, v16 * rob_osg->node.length, 0.0f, 0.0f, &v79);
|
||||
*rob_osg->node.bone_node_ptr->ex_data_mat = v79;
|
||||
mat4_scale_rot(&v79, a3->x, a3->y, a3->z, &v79);
|
||||
mat4_scale_rot(&v79, parent_scale, &v79);
|
||||
*rob_osg->node.bone_node_mat = v79;
|
||||
rob_osg->node.bone_node_ptr->exp_data.parent_scale = *a3;
|
||||
rob_osg->node.bone_node_ptr->exp_data.parent_scale = *parent_scale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4436,7 +4419,7 @@ static void sub_140480260(RobOsage* rob_osg, mat4* mat, vec3* parent_scale, floa
|
||||
rob_osg->SetNodesExternalForce(0, 1.0f);
|
||||
rob_osg->SetNodesForce(1.0f);
|
||||
rob_osg->set_external_force = false;
|
||||
rob_osg->external_force = vec3_null;
|
||||
rob_osg->external_force = 0.0f;
|
||||
}
|
||||
|
||||
rob_osg->field_2A0 = true;
|
||||
@@ -4446,9 +4429,9 @@ static void sub_140480260(RobOsage* rob_osg, mat4* mat, vec3* parent_scale, floa
|
||||
rob_osg->osage_reset = false;
|
||||
rob_osg->field_1F0E = false;
|
||||
|
||||
for (auto i = rob_osg->nodes.begin(); i != rob_osg->nodes.end(); i++) {
|
||||
i->field_C8 = 0.0f;
|
||||
i->field_CC = 1.0f;
|
||||
for (RobOsageNode& i : rob_osg->nodes) {
|
||||
i.field_C8 = 0.0f;
|
||||
i.field_CC = 1.0f;
|
||||
}
|
||||
|
||||
rob_osg->parent_mat = *rob_osg->parent_mat_ptr;
|
||||
@@ -4660,7 +4643,7 @@ static int32_t sub_140485000(vec3* a1, vec3* a2, skin_param_osage_node* a3, osag
|
||||
int32_t v8 = 0;
|
||||
while (a4->type) {
|
||||
int32_t type = a4->type;
|
||||
vec3 v21 = vec3_null;
|
||||
vec3 v21 = 0.0f;
|
||||
switch (a4->type) {
|
||||
case SKIN_PARAM_OSAGE_ROOT_COLI_TYPE_BALL:
|
||||
v8 += sub_140484450(&v21, a1, a2, &a4->bone0_pos, a3->coli_r + a4->radius);
|
||||
|
||||
+1447
-1226
File diff suppressed because it is too large
Load Diff
+175
-55
@@ -25,14 +25,6 @@ enum ex_expression_block_stack_type {
|
||||
EX_EXPRESSION_BLOCK_STACK_OP3 = 0x05,
|
||||
};
|
||||
|
||||
enum ex_node_type {
|
||||
EX_NONE = 0x00,
|
||||
EX_OSAGE = 0x01,
|
||||
EX_EXPRESSION = 0x02,
|
||||
EX_CONSTRAINT = 0x03,
|
||||
EX_CLOTH = 0x04,
|
||||
};
|
||||
|
||||
enum eyes_base_adjust_type {
|
||||
EYES_BASE_ADJUST_NONE = -1,
|
||||
EYES_BASE_ADJUST_DIRECTION = 0x00,
|
||||
@@ -246,6 +238,24 @@ enum mot_bone_index {
|
||||
MOT_BONE_MAX = 0xC9,
|
||||
};
|
||||
|
||||
enum mot_play_frame_data_loop_state {
|
||||
MOT_PLAY_FRAME_DATA_LOOP_NONE = -1,
|
||||
MOT_PLAY_FRAME_DATA_LOOP_ONCE = 0x00,
|
||||
MOT_PLAY_FRAME_DATA_LOOP_CONTINUOUS = 0x01,
|
||||
MOT_PLAY_FRAME_DATA_LOOP_RESET = 0x02,
|
||||
MOT_PLAY_FRAME_DATA_LOOP_REVERSE = 0x03,
|
||||
MOT_PLAY_FRAME_DATA_LOOP_MAX = 0x04,
|
||||
};
|
||||
|
||||
enum mot_play_frame_data_playback_state {
|
||||
MOT_PLAY_FRAME_DATA_PLAYBACK_NONE = -1,
|
||||
MOT_PLAY_FRAME_DATA_PLAYBACK_STOP = 0x00,
|
||||
MOT_PLAY_FRAME_DATA_PLAYBACK_FORWARD = 0x01,
|
||||
MOT_PLAY_FRAME_DATA_PLAYBACK_BACKWARD = 0x02,
|
||||
MOT_PLAY_FRAME_DATA_PLAYBACK_EXTERNAL = 0x03,
|
||||
MOT_PLAY_FRAME_DATA_PLAYBACK_MAX = 0x04,
|
||||
};
|
||||
|
||||
enum mothead_data_type {
|
||||
MOTHEAD_DATA_TYPE_0 = 0x00,
|
||||
MOTHEAD_DATA_TYPE_1 = 0x01,
|
||||
@@ -748,6 +758,11 @@ enum rob_chara_data_hand_adjust_type : uint16_t {
|
||||
ROB_CHARA_DATA_HAND_ADJUST_2P = 0x08,
|
||||
ROB_CHARA_DATA_HAND_ADJUST_3P = 0x09,
|
||||
ROB_CHARA_DATA_HAND_ADJUST_4P = 0x0A,
|
||||
ROB_CHARA_DATA_HAND_ADJUST_TYPE_11 = 0x0B, // X
|
||||
ROB_CHARA_DATA_HAND_ADJUST_TYPE_12 = 0x0C,
|
||||
ROB_CHARA_DATA_HAND_ADJUST_TYPE_13 = 0x0D,
|
||||
ROB_CHARA_DATA_HAND_ADJUST_TYPE_14 = 0x0E,
|
||||
ROB_CHARA_DATA_HAND_ADJUST_ITEM = 0x0F,
|
||||
};
|
||||
|
||||
enum rob_osage_parts {
|
||||
@@ -793,6 +808,14 @@ enum skin_param_osage_root_coli_type {
|
||||
SKIN_PARAM_OSAGE_ROOT_COLI_TYPE_5 = 0x05,
|
||||
};
|
||||
|
||||
enum ExNodeType {
|
||||
EX_NONE = 0x00,
|
||||
EX_OSAGE = 0x01,
|
||||
EX_EXPRESSION = 0x02,
|
||||
EX_CONSTRAINT = 0x03,
|
||||
EX_CLOTH = 0x04,
|
||||
};
|
||||
|
||||
enum SubActExecType {
|
||||
SUB_ACTION_EXECUTE_NONE = 0,
|
||||
SUB_ACTION_EXECUTE_CRY = 1,
|
||||
@@ -947,24 +970,25 @@ struct mot_play_frame_data {
|
||||
float_t step_prev;
|
||||
float_t frame_count;
|
||||
float_t last_frame;
|
||||
float_t field_14;
|
||||
int32_t field_18;
|
||||
int32_t field_1C;
|
||||
float_t field_20;
|
||||
float_t field_24;
|
||||
bool field_28;
|
||||
int32_t field_2C;
|
||||
float_t max_frame;
|
||||
mot_play_frame_data_playback_state playback_state;
|
||||
mot_play_frame_data_loop_state loop_state;
|
||||
float_t loop_begin;
|
||||
float_t loop_end;
|
||||
bool looped;
|
||||
int32_t loop_count;
|
||||
|
||||
void reset();
|
||||
void set_frame(float_t frame);
|
||||
};
|
||||
|
||||
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;
|
||||
int32_t loop_index;
|
||||
bool loop_frames_enabled;
|
||||
float_t loop_frames;
|
||||
float_t* ext_frame;
|
||||
float_t* ext_step;
|
||||
|
||||
void reset();
|
||||
};
|
||||
@@ -1003,7 +1027,7 @@ struct struc_400 {
|
||||
|
||||
class MotionBlend {
|
||||
public:
|
||||
bool field_8;
|
||||
bool enable;
|
||||
bool rot_y;
|
||||
float_t duration;
|
||||
float_t frame;
|
||||
@@ -1013,6 +1037,7 @@ public:
|
||||
|
||||
MotionBlend();
|
||||
virtual ~MotionBlend();
|
||||
|
||||
virtual void Reset();
|
||||
virtual void Field_10(float_t a2, float_t a3, int32_t a4) = 0;
|
||||
virtual void Step(struc_400*) = 0;
|
||||
@@ -1034,6 +1059,7 @@ public:
|
||||
|
||||
MotionBlendCross();
|
||||
virtual ~MotionBlendCross() override;
|
||||
|
||||
virtual void Reset() override;
|
||||
virtual void Field_10(float_t a2, float_t a3, int32_t a4) override;
|
||||
virtual void Step(struc_400*) override;
|
||||
@@ -1045,6 +1071,7 @@ class MotionBlendCombine : public MotionBlendCross {
|
||||
public:
|
||||
MotionBlendCombine();
|
||||
virtual ~MotionBlendCombine() override;
|
||||
|
||||
virtual void Step(struc_400*) override;
|
||||
virtual bool Field_30() override;
|
||||
};
|
||||
@@ -1064,6 +1091,7 @@ public:
|
||||
|
||||
MotionBlendFreeze();
|
||||
virtual ~MotionBlendFreeze() override;
|
||||
|
||||
virtual void Reset() override;
|
||||
virtual void Field_10(float_t a2, float_t a3, int32_t a4) override;
|
||||
virtual void Step(struc_400*) override;
|
||||
@@ -1075,6 +1103,7 @@ class PartialMotionBlendFreeze : public MotionBlendFreeze {
|
||||
public:
|
||||
PartialMotionBlendFreeze();
|
||||
virtual ~PartialMotionBlendFreeze() override;
|
||||
|
||||
virtual void Reset() override;
|
||||
virtual void Field_10(float_t a2, float_t a3, int32_t a4) override;
|
||||
virtual void Step(struc_400*) override;
|
||||
@@ -1116,6 +1145,7 @@ struct motion_blend_mot {
|
||||
motion_blend_mot();
|
||||
virtual ~motion_blend_mot();
|
||||
|
||||
MotionBlendType get_type();
|
||||
void reset();
|
||||
};
|
||||
|
||||
@@ -1295,8 +1325,14 @@ struct rob_chara_bone_data {
|
||||
|
||||
float_t get_frame();
|
||||
float_t get_frame_count();
|
||||
bool get_motion_has_looped();
|
||||
void reset();
|
||||
void set_frame(float_t frame);
|
||||
void set_motion_frame(float_t frame, float_t step, float_t frame_count);
|
||||
void set_motion_loop(float_t loop_begin, int32_t loop_count, float_t loop_end);
|
||||
void set_motion_loop_state(mot_play_frame_data_loop_state value);
|
||||
void set_motion_max_frame(float_t value);
|
||||
void set_motion_playback_state(mot_play_frame_data_playback_state value);
|
||||
};
|
||||
|
||||
union rob_chara_pv_data_item {
|
||||
@@ -1364,7 +1400,7 @@ struct rob_chara_item_equip_object;
|
||||
class ExNodeBlock {
|
||||
public:
|
||||
bone_node* bone_node_ptr;
|
||||
ex_node_type type;
|
||||
ExNodeType type;
|
||||
const char* name;
|
||||
bone_node* parent_bone_node;
|
||||
std::string parent_name;
|
||||
@@ -1376,6 +1412,7 @@ public:
|
||||
|
||||
ExNodeBlock();
|
||||
virtual ~ExNodeBlock();
|
||||
|
||||
virtual void Init() = 0;
|
||||
virtual void Field_10() = 0;
|
||||
virtual void Field_18(int32_t stage, bool a3) = 0;
|
||||
@@ -1388,7 +1425,7 @@ public:
|
||||
virtual void Field_50() = 0;
|
||||
virtual void Field_58();
|
||||
|
||||
void InitData(bone_node* bone_node, ex_node_type type,
|
||||
void InitData(bone_node* bone_node, ExNodeType type,
|
||||
const char* name, rob_chara_item_equip_object* itm_eq_obj);
|
||||
};
|
||||
|
||||
@@ -1398,6 +1435,7 @@ public:
|
||||
|
||||
ExNullBlock();
|
||||
virtual ~ExNullBlock() override;
|
||||
|
||||
virtual void Init() override;
|
||||
virtual void Field_10();
|
||||
virtual void Field_18(int32_t stage, bool a3) override;
|
||||
@@ -1434,8 +1472,12 @@ struct skin_param_hinge {
|
||||
float_t zmin;
|
||||
float_t zmax;
|
||||
|
||||
skin_param_hinge();
|
||||
~skin_param_hinge();
|
||||
inline skin_param_hinge() {
|
||||
ymin = -90.0f;
|
||||
ymax = 90.0f;
|
||||
zmin = -90.0f;
|
||||
zmax = 90.0f;
|
||||
}
|
||||
|
||||
void limit();
|
||||
};
|
||||
@@ -1447,7 +1489,6 @@ struct skin_param_osage_node {
|
||||
skin_param_hinge hinge;
|
||||
|
||||
skin_param_osage_node();
|
||||
~skin_param_osage_node();
|
||||
};
|
||||
|
||||
struct RobOsageNodeResetData {
|
||||
@@ -1599,7 +1640,23 @@ struct skin_param {
|
||||
skin_param();
|
||||
~skin_param();
|
||||
|
||||
void reset();
|
||||
inline void reset() {
|
||||
coli.clear();
|
||||
friction = 1.0f;
|
||||
wind_afc = 0.0f;
|
||||
air_res = 1.0f;
|
||||
rot = 0.0f;
|
||||
init_rot = 0.0f;
|
||||
coli_type = 0;
|
||||
stiffness = 0.0f;
|
||||
move_cancel = -0.01f;
|
||||
coli_r = 0.0f;
|
||||
hinge = skin_param_hinge();
|
||||
hinge.limit();
|
||||
force = 0.0f;
|
||||
force_gain = 0.0f;
|
||||
colli_tgt_osg = 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct osage_coli {
|
||||
@@ -1772,7 +1829,7 @@ struct RobCloth : public CLOTH {
|
||||
CLOTHNode* node, float_t facing, int32_t indices_count, uint16_t* indices, bool double_faced);
|
||||
};
|
||||
|
||||
struct ExClothBlock : public ExNodeBlock {
|
||||
class ExClothBlock : public ExNodeBlock {
|
||||
public:
|
||||
RobCloth rob;
|
||||
obj_skin_block_cloth* cls_data;
|
||||
@@ -1890,6 +1947,7 @@ public:
|
||||
|
||||
ExOsageBlock();
|
||||
virtual ~ExOsageBlock() override;
|
||||
|
||||
virtual void Init() override;
|
||||
virtual void Field_10();
|
||||
virtual void Field_18(int32_t stage, bool a3) override;
|
||||
@@ -1927,6 +1985,7 @@ public:
|
||||
|
||||
ExConstraintBlock();
|
||||
virtual ~ExConstraintBlock() override;
|
||||
|
||||
virtual void Init() override;
|
||||
virtual void Field_10() override;
|
||||
virtual void Field_18(int32_t stage, bool a3) override;
|
||||
@@ -2004,6 +2063,7 @@ public:
|
||||
|
||||
ExExpressionBlock();
|
||||
virtual ~ExExpressionBlock() override;
|
||||
|
||||
virtual void Init() override;
|
||||
virtual void Field_10() override;
|
||||
virtual void Field_18(int32_t stage, bool a3) override;
|
||||
@@ -2022,7 +2082,7 @@ public:
|
||||
|
||||
struct ex_data_name_bone_index {
|
||||
const char* name;
|
||||
int32_t bone_index;
|
||||
uint32_t bone_index;
|
||||
};
|
||||
|
||||
struct rob_chara_item_equip;
|
||||
@@ -2363,6 +2423,7 @@ public:
|
||||
|
||||
SubActExec(SubActExecType type);
|
||||
virtual ~SubActExec();
|
||||
|
||||
virtual void Field_8() = 0;
|
||||
virtual void Field_10(SubActParam* param) = 0;
|
||||
virtual void Field_18(rob_chara* rob_chr) = 0;
|
||||
@@ -2373,6 +2434,7 @@ class SubActExecAngry : public SubActExec {
|
||||
public:
|
||||
SubActExecAngry();
|
||||
virtual ~SubActExecAngry() override;
|
||||
|
||||
virtual void Field_8() override;
|
||||
virtual void Field_10(SubActParam* param) override;
|
||||
virtual void Field_18(rob_chara* rob_chr) override;
|
||||
@@ -2387,6 +2449,7 @@ public:
|
||||
|
||||
SubActExecCountNum();
|
||||
virtual ~SubActExecCountNum() override;
|
||||
|
||||
virtual void Field_8() override;
|
||||
virtual void Field_10(SubActParam* param) override;
|
||||
virtual void Field_18(rob_chara* rob_chr) override;
|
||||
@@ -2397,6 +2460,7 @@ class SubActExecCry : public SubActExec {
|
||||
public:
|
||||
SubActExecCry();
|
||||
virtual ~SubActExecCry() override;
|
||||
|
||||
virtual void Field_8() override;
|
||||
virtual void Field_10(SubActParam* param) override;
|
||||
virtual void Field_18(rob_chara* rob_chr) override;
|
||||
@@ -2408,6 +2472,7 @@ public:
|
||||
int8_t field_10;
|
||||
SubActExecEmbarrassed();
|
||||
virtual ~SubActExecEmbarrassed() override;
|
||||
|
||||
virtual void Field_8() override;
|
||||
virtual void Field_10(SubActParam* param) override;
|
||||
virtual void Field_18(rob_chara* rob_chr) override;
|
||||
@@ -2418,6 +2483,7 @@ class SubActExecLaugh : public SubActExec {
|
||||
public:
|
||||
SubActExecLaugh();
|
||||
virtual ~SubActExecLaugh() override;
|
||||
|
||||
virtual void Field_8() override;
|
||||
virtual void Field_10(SubActParam* param) override;
|
||||
virtual void Field_18(rob_chara* rob_chr) override;
|
||||
@@ -2429,8 +2495,10 @@ public:
|
||||
int32_t field_10;
|
||||
int32_t field_14;
|
||||
int8_t field_18;
|
||||
|
||||
SubActExecShakeHand();
|
||||
virtual ~SubActExecShakeHand() override;
|
||||
|
||||
virtual void Field_8() override;
|
||||
virtual void Field_10(SubActParam* param) override;
|
||||
virtual void Field_18(rob_chara* rob_chr) override;
|
||||
@@ -2481,20 +2549,44 @@ public:
|
||||
float_t frame;
|
||||
float_t play_frame_step;
|
||||
float_t frame_count;
|
||||
float_t duration;
|
||||
float_t step;
|
||||
float_t offset;
|
||||
float_t blend_duration;
|
||||
float_t blend_step;
|
||||
float_t blend_offset;
|
||||
float_t field_24;
|
||||
struc_389* frame_data;
|
||||
struc_406* step_data;
|
||||
int32_t field_38;
|
||||
|
||||
Data();
|
||||
~Data();
|
||||
inline Data() : motion_id(), mottbl_index(), state(), frame(),
|
||||
play_frame_step(), frame_count(), blend_duration(), blend_step(),
|
||||
blend_offset(), field_24(), frame_data(), step_data(), field_38() {
|
||||
Reset();
|
||||
}
|
||||
|
||||
inline ~Data() {
|
||||
|
||||
}
|
||||
|
||||
inline void Reset() {
|
||||
motion_id = -1;
|
||||
mottbl_index = 6;
|
||||
state = -1;
|
||||
frame = 0.0f;
|
||||
play_frame_step = 1.0f;
|
||||
frame_count = 0.0f;
|
||||
blend_duration = 0.0f;
|
||||
blend_step = 1.0f;
|
||||
blend_offset = 1.0f;
|
||||
field_24 = 0.0f;
|
||||
frame_data = 0;
|
||||
step_data = 0;
|
||||
field_38 = -1;
|
||||
}
|
||||
} data;
|
||||
|
||||
RobPartialMotion();
|
||||
virtual ~RobPartialMotion();
|
||||
|
||||
virtual void Reset() = 0;
|
||||
};
|
||||
|
||||
@@ -2502,6 +2594,7 @@ class RobFaceMotion : public RobPartialMotion {
|
||||
public:
|
||||
RobFaceMotion();
|
||||
virtual ~RobFaceMotion() override;
|
||||
|
||||
virtual void Reset() override;
|
||||
};
|
||||
|
||||
@@ -2509,6 +2602,7 @@ class RobHandMotion : public RobPartialMotion {
|
||||
public:
|
||||
RobHandMotion();
|
||||
virtual ~RobHandMotion() override;
|
||||
|
||||
virtual void Reset() override;
|
||||
};
|
||||
|
||||
@@ -2516,6 +2610,7 @@ class RobMouthMotion : public RobPartialMotion {
|
||||
public:
|
||||
RobMouthMotion();
|
||||
virtual ~RobMouthMotion() override;
|
||||
|
||||
virtual void Reset() override;
|
||||
};
|
||||
|
||||
@@ -2523,6 +2618,7 @@ class RobEyesMotion : public RobPartialMotion {
|
||||
public:
|
||||
RobEyesMotion();
|
||||
virtual ~RobEyesMotion() override;
|
||||
|
||||
virtual void Reset() override;
|
||||
};
|
||||
|
||||
@@ -2530,6 +2626,7 @@ class RobEyelidMotion : public RobPartialMotion {
|
||||
public:
|
||||
RobEyelidMotion();
|
||||
virtual ~RobEyelidMotion() override;
|
||||
|
||||
virtual void Reset() override;
|
||||
};
|
||||
|
||||
@@ -2538,7 +2635,7 @@ struct struc_405 {
|
||||
RobHandMotion hand_l;
|
||||
RobHandMotion hand_r;
|
||||
RobMouthMotion mouth;
|
||||
RobEyesMotion eye;
|
||||
RobEyesMotion eyes;
|
||||
RobEyelidMotion eyelid;
|
||||
object_info head_object;
|
||||
object_info hand_l_object;
|
||||
@@ -2625,7 +2722,7 @@ struct rob_chara_motion {
|
||||
int8_t field_28;
|
||||
int8_t field_29;
|
||||
int8_t field_2A;
|
||||
int32_t field_2C;
|
||||
int32_t loop_index;
|
||||
uint32_t field_30;
|
||||
int16_t field_34;
|
||||
int16_t field_36;
|
||||
@@ -2687,6 +2784,7 @@ struct mothead_mot {
|
||||
std::vector<mothead_data2> field_18;
|
||||
std::vector<mothead_data> data;
|
||||
std::vector<int64_t> field_28;
|
||||
bool is_x;
|
||||
|
||||
mothead_mot();
|
||||
virtual ~mothead_mot();
|
||||
@@ -2697,6 +2795,7 @@ struct mothead {
|
||||
int32_t first_mot_id;
|
||||
int32_t last_mot_id;
|
||||
std::vector<mothead_mot*> mots;
|
||||
void* data_x;
|
||||
|
||||
mothead();
|
||||
virtual ~mothead();
|
||||
@@ -2729,8 +2828,9 @@ struct mothead_mot_file {
|
||||
};
|
||||
|
||||
struct struc_377 {
|
||||
const mothead_data* field_0;
|
||||
const mothead_data* field_8;
|
||||
const mothead_data* current;
|
||||
const mothead_data* data;
|
||||
bool is_x; // X
|
||||
};
|
||||
|
||||
struct struc_226 {
|
||||
@@ -2782,9 +2882,9 @@ struct struc_652 {
|
||||
int32_t field_60;
|
||||
int32_t field_64;
|
||||
int32_t field_68;
|
||||
int32_t field_6C;
|
||||
float_t field_70;
|
||||
float_t field_74;
|
||||
int32_t loop_count;
|
||||
float_t loop_begin;
|
||||
float_t loop_end;
|
||||
float_t field_78;
|
||||
float_t field_7C;
|
||||
float_t field_80;
|
||||
@@ -2870,6 +2970,10 @@ struct struc_652 {
|
||||
|
||||
struc_652();
|
||||
~struc_652();
|
||||
|
||||
void reset();
|
||||
|
||||
void sub_140536DD0();
|
||||
};
|
||||
|
||||
struct struc_651 {
|
||||
@@ -2883,6 +2987,10 @@ struct struc_651 {
|
||||
struc_225 field_80[3];
|
||||
struc_224 field_1C4[3];
|
||||
int64_t field_308;
|
||||
float_t arm_adjust_next_value; // X
|
||||
float_t arm_adjust_prev_value; // X
|
||||
int32_t arm_adjust_start_frame; // X
|
||||
float_t arm_adjust_duration; // X
|
||||
float_t field_310;
|
||||
float_t field_314;
|
||||
int8_t field_318;
|
||||
@@ -2897,6 +3005,8 @@ struct struc_651 {
|
||||
struc_306 field_33C[4];
|
||||
|
||||
struc_651();
|
||||
|
||||
void reset();
|
||||
};
|
||||
|
||||
struct struc_223 {
|
||||
@@ -2907,6 +3017,8 @@ struct struc_223 {
|
||||
|
||||
struc_223();
|
||||
~struc_223();
|
||||
|
||||
void reset();
|
||||
};
|
||||
|
||||
struct rob_chara_data_miku_rot {
|
||||
@@ -2950,6 +3062,9 @@ struct rob_chara_adjust_data {
|
||||
float_t right_hand_scale;
|
||||
float_t left_hand_scale_default;
|
||||
float_t right_hand_scale_default;
|
||||
mat4 item_mat; // X
|
||||
vec3 item_trans; // X
|
||||
float_t item_scale; // X
|
||||
|
||||
rob_chara_adjust_data();
|
||||
|
||||
@@ -3141,6 +3256,7 @@ struct rob_chara_data {
|
||||
int32_t field_3DD8;
|
||||
float_t field_3DDC;
|
||||
uint8_t field_3DE0;
|
||||
float_t arm_adjust_scale; // X
|
||||
|
||||
rob_chara_data();
|
||||
~rob_chara_data();
|
||||
@@ -3188,6 +3304,7 @@ struct rob_chara {
|
||||
float_t get_frame_count();
|
||||
float_t get_max_face_depth();
|
||||
int32_t get_rob_cmn_mottbl_motion_id(int32_t id);
|
||||
bool get_visibility();
|
||||
void load_motion(int32_t motion_id, bool a3, float_t frame,
|
||||
MotionBlendType blend_type, bone_database* bone_data, motion_database* mot_db);
|
||||
void reset_data(rob_chara_pv_data* pv_data,
|
||||
@@ -3199,31 +3316,31 @@ struct rob_chara {
|
||||
void set_chara_pos_adjust_y(float_t value);
|
||||
void set_chara_size(float_t value);
|
||||
void set_eyelid_mottbl_motion_from_face(int32_t a2,
|
||||
float_t duration, float_t value, float_t offset, motion_database* mot_db);
|
||||
float_t blend_duration, float_t value, float_t blend_offset, motion_database* mot_db);
|
||||
void set_eyelid_mottbl_motion(int32_t type,
|
||||
int32_t mottbl_index, float_t value, int32_t state, float_t duration,
|
||||
float_t a7, float_t step, int32_t a9, float_t offset, motion_database* mot_db);
|
||||
int32_t mottbl_index, float_t value, int32_t state, float_t blend_duration,
|
||||
float_t a7, float_t step, int32_t a9, float_t blend_offset, motion_database* mot_db);
|
||||
void set_eyes_mottbl_motion(int32_t type,
|
||||
int32_t mottbl_index, float_t value, int32_t state, float_t duration,
|
||||
float_t a7, float_t step, int32_t a9, float_t offset, motion_database* mot_db);
|
||||
int32_t mottbl_index, float_t value, int32_t state, float_t blend_duration,
|
||||
float_t a7, float_t step, int32_t a9, float_t blend_offset, motion_database* mot_db);
|
||||
void set_face_mottbl_motion(int32_t type, int32_t mottbl_index,
|
||||
float_t value, int32_t state, float_t duration, float_t a7,
|
||||
float_t step, int32_t a9, float_t offset, bool a11, motion_database* mot_db);
|
||||
float_t value, int32_t state, float_t blend_duration, float_t a7,
|
||||
float_t step, int32_t a9, float_t blend_offset, bool a11, motion_database* mot_db);
|
||||
void set_frame(float_t frame);
|
||||
void set_hand_l_mottbl_motion(int32_t type, int32_t mottbl_index,
|
||||
float_t value, int32_t state, float_t duration, float_t a7,
|
||||
float_t step, int32_t a9, float_t offset, motion_database* mot_db);
|
||||
float_t value, int32_t state, float_t blend_duration, float_t a7,
|
||||
float_t step, int32_t a9, float_t blend_offset, motion_database* mot_db);
|
||||
void set_hand_r_mottbl_motion(int32_t type, int32_t mottbl_index,
|
||||
float_t value, int32_t state, float_t duration, float_t a7,
|
||||
float_t step, int32_t a9, float_t offset, motion_database* mot_db);
|
||||
float_t value, int32_t state, float_t blend_duration, float_t a7,
|
||||
float_t step, int32_t a9, float_t blend_offset, motion_database* mot_db);
|
||||
bool set_motion_id(int32_t motion_id, float_t frame,
|
||||
float_t duration, bool a5, bool set_motion_reset_data,
|
||||
float_t blend_duration, bool a5, bool set_motion_reset_data,
|
||||
MotionBlendType blend_type, bone_database* bone_data, motion_database* mot_db);
|
||||
void set_motion_reset_data(int32_t motion_id, float_t frame);
|
||||
void set_motion_skin_param(int32_t motion_id, float_t frame);
|
||||
void set_mouth_mottbl_motion(int32_t type, int32_t mottbl_index,
|
||||
float_t value, int32_t state, float_t duration, float_t a7,
|
||||
float_t step, int32_t a9, float_t offset, motion_database* mot_db);
|
||||
float_t value, int32_t state, float_t blend_duration, float_t a7,
|
||||
float_t step, int32_t a9, float_t blend_offset, motion_database* mot_db);
|
||||
void set_osage_move_cancel(uint8_t id, float_t value);
|
||||
void set_osage_reset();
|
||||
void set_osage_step(float_t value);
|
||||
@@ -3263,7 +3380,10 @@ extern void rob_free();
|
||||
|
||||
extern mat4* rob_chara_bone_data_get_mats_mat(rob_chara_bone_data* rob_bone_data, size_t index);
|
||||
|
||||
extern bool rob_chara_array_check_visibility(int32_t chara_id);
|
||||
extern rob_chara* rob_chara_array_get(int32_t chara_id);
|
||||
extern rob_chara_bone_data* rob_chara_array_get_bone_data(int32_t chara_id);
|
||||
extern float_t rob_chara_array_get_data_adjust_scale(int32_t chara_id);
|
||||
extern rob_chara_item_equip* rob_chara_array_get_item_equip(int32_t chara_id);
|
||||
extern int32_t rob_chara_array_init_chara_index(chara_index chara_index,
|
||||
rob_chara_pv_data* pv_data, int32_t module_index, bool can_set_default);
|
||||
|
||||
+442
-332
File diff suppressed because it is too large
Load Diff
+42
-4
@@ -25,6 +25,7 @@
|
||||
#define SHADER_MAX_TEXTURE_IMAGE_UNITS 32
|
||||
#define SHADER_MAX_TEXTURE_UNITS 4
|
||||
#define SHADER_MAX_UNIFORM_BLOCK_SIZE 65536
|
||||
#define SHADER_MAX_UNIFORM_VALUES 16
|
||||
#define SHADER_MAX_VERTEX_UNITS 4
|
||||
|
||||
struct shader_state_clip {
|
||||
@@ -167,15 +168,22 @@ struct shader_state {
|
||||
shader_state();
|
||||
};
|
||||
|
||||
struct shader_local;
|
||||
struct shader_local_uniform;
|
||||
|
||||
struct shader_data {
|
||||
shader_state state;
|
||||
shader_state_matrix state_matrix;
|
||||
shader_env env;
|
||||
shader_buffer buffer;
|
||||
shader_local* local;
|
||||
shader_local_uniform* local_uniform;
|
||||
bool state_update_data;
|
||||
bool state_matrix_update_data;
|
||||
bool env_update_data;
|
||||
bool buffer_update_data;
|
||||
bool* local_update_data;
|
||||
bool* local_uniform_update_data;
|
||||
GLuint state_ubo;
|
||||
GLuint state_matrix_ubo;
|
||||
GLuint env_ubo;
|
||||
@@ -190,15 +198,32 @@ struct shader_set_data;
|
||||
typedef void (*PFNSHADERBINDFUNCPROC)(shader_set_data* set, shader* shad);
|
||||
|
||||
struct shader_bind_func {
|
||||
uint32_t index;
|
||||
uint32_t name_index;
|
||||
PFNSHADERBINDFUNCPROC bind_func;
|
||||
};
|
||||
|
||||
struct shader_local {
|
||||
vec4 vert[SHADER_MAX_PROGRAM_LOCAL_PARAMETERS];
|
||||
vec4 frag[SHADER_MAX_PROGRAM_LOCAL_PARAMETERS];
|
||||
};
|
||||
|
||||
struct shader_local_uniform {
|
||||
int32_t uniform_val[SHADER_MAX_UNIFORM_VALUES];
|
||||
};
|
||||
|
||||
struct shader_sub_shader {
|
||||
GLuint program;
|
||||
shader_local data;
|
||||
shader_local_uniform data_uniform;
|
||||
bool data_update[2];
|
||||
bool data_uniform_update;
|
||||
};
|
||||
|
||||
struct shader_sub {
|
||||
uint32_t sub_index;
|
||||
const int32_t* vp_unival_max;
|
||||
const int32_t* fp_unival_max;
|
||||
GLuint* program;
|
||||
shader_sub_shader* shaders;
|
||||
};
|
||||
|
||||
struct shader_sub_table {
|
||||
@@ -230,6 +255,11 @@ struct shader {
|
||||
PFNSHADERBINDFUNCPROC bind_func;
|
||||
|
||||
int32_t bind(shader_set_data* set, uint32_t sub_index);
|
||||
|
||||
static bool parse_define(const char* data, int32_t num_uniform,
|
||||
const int32_t* vp_unival_max, const int32_t* fp_unival_max,
|
||||
int32_t* uniform_value, char** temp, size_t* temp_size);
|
||||
static char* parse_include(char* data, farc* f);
|
||||
static void unbind();
|
||||
};
|
||||
|
||||
@@ -237,19 +267,24 @@ struct shader_set_data {
|
||||
shader* shaders;
|
||||
size_t size;
|
||||
shader_data data;
|
||||
GLboolean primitive_restart;
|
||||
GLuint primitive_restart_index;
|
||||
|
||||
shader_set_data();
|
||||
|
||||
void disable_primitive_restart();
|
||||
void draw_arrays(GLenum mode, GLint first, GLsizei count);
|
||||
void draw_elements(GLenum mode,
|
||||
GLsizei count, GLenum type, const void* indices);
|
||||
void draw_range_elements(GLenum mode,
|
||||
GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices);
|
||||
void enable_primitive_restart();
|
||||
int32_t get_index_by_name(const char* name);
|
||||
void load(farc* f, bool ignore_cache, bool not_load_cache,
|
||||
const char* name, const shader_table* shaders_table, const size_t size,
|
||||
void load(farc* f, bool ignore_cache, const char* name,
|
||||
const shader_table* shaders_table, const size_t size,
|
||||
const shader_bind_func* bind_func_table, const size_t bind_func_table_size);
|
||||
void set(uint32_t index);
|
||||
void set_primitive_restart_index(GLuint index);
|
||||
void unload();
|
||||
|
||||
void buffer_get(size_t index, vec4& data);
|
||||
@@ -359,10 +394,13 @@ struct shader_set_data {
|
||||
void state_material_set_emission(bool back, const vec4& data);
|
||||
void state_material_set_shininess(bool back, float_t x, float_t y, float_t z, float_t w);
|
||||
void state_material_set_shininess(bool back, const vec4& data);
|
||||
void state_matrix_set_modelview(const mat4& data, bool mult);
|
||||
void state_matrix_set_modelview(size_t index, const mat4& data, bool mult);
|
||||
void state_matrix_set_projection(const mat4& data, bool mult);
|
||||
void state_matrix_set_mvp(const mat4& data);
|
||||
void state_matrix_set_modelview(const mat4& model, const mat4& view, bool mult);
|
||||
void state_matrix_set_modelview(size_t index, const mat4& model, const mat4& view, bool mult);
|
||||
void state_matrix_set_mvp(const mat4& modelview, const mat4& projection);
|
||||
void state_matrix_set_mvp(const mat4& model, const mat4& view, const mat4& projection);
|
||||
void state_matrix_set_texture(size_t index, const mat4& data);
|
||||
void state_matrix_set_palette(size_t index, const mat4& data);
|
||||
|
||||
+411
-62
@@ -14,7 +14,10 @@ enum shader_ft_sub_enum {
|
||||
SHADER_FT_SUB_STAGE_BLINN,
|
||||
SHADER_FT_SUB_SKIN_DEFAULT,
|
||||
SHADER_FT_SUB_SSS_SKIN,
|
||||
SHADER_FT_SUB_SSS_FILTER,
|
||||
//SHADER_FT_SUB_SSS_FILTER,
|
||||
SHADER_FT_SUB_SSS_FILTER_MIN,
|
||||
SHADER_FT_SUB_SSS_FILTER_MIN_NPR,
|
||||
SHADER_FT_SUB_SSS_FILTER_GAUSS_2D,
|
||||
SHADER_FT_SUB_HAIR_DEFAULT,
|
||||
SHADER_FT_SUB_HAIR_ANISO,
|
||||
SHADER_FT_SUB_HAIR_NPR1,
|
||||
@@ -30,7 +33,9 @@ enum shader_ft_sub_enum {
|
||||
SHADER_FT_SUB_SHADOWMAP,
|
||||
SHADER_FT_SUB_ESM,
|
||||
SHADER_FT_SUB_ESM_GAUSS,
|
||||
SHADER_FT_SUB_ESM_FILTER,
|
||||
//SHADER_FT_SUB_ESM_FILTER,
|
||||
SHADER_FT_SUB_ESM_FILTER_MIN,
|
||||
SHADER_FT_SUB_ESM_FILTER_EROSION,
|
||||
SHADER_FT_SUB_LIT_PROJ,
|
||||
SHADER_FT_SUB_SIMPLE,
|
||||
SHADER_FT_SUB_SILHOUETTE,
|
||||
@@ -46,8 +51,14 @@ enum shader_ft_sub_enum {
|
||||
SHADER_FT_SUB_MLAA_AREA,
|
||||
SHADER_FT_SUB_MLAA_BLEND,
|
||||
SHADER_FT_SUB_CONTOUR,
|
||||
SHADER_FT_SUB_EXPOSURE,
|
||||
SHADER_FT_SUB_PP_GAUSS,
|
||||
SHADER_FT_SUB_CONTOUR_NPR,
|
||||
//SHADER_FT_SUB_EXPOSURE,
|
||||
SHADER_FT_SUB_EXPOSURE_AVERAGE,
|
||||
SHADER_FT_SUB_EXPOSURE_MEASURE,
|
||||
SHADER_FT_SUB_EXPOSURE_MINIFY,
|
||||
//SHADER_FT_SUB_PP_GAUSS,
|
||||
SHADER_FT_SUB_PP_GAUSS_USUAL,
|
||||
SHADER_FT_SUB_PP_GAUSS_CONE,
|
||||
SHADER_FT_SUB_SUN,
|
||||
SHADER_FT_SUB_FADE,
|
||||
SHADER_FT_SUB_WATER01,
|
||||
@@ -57,6 +68,7 @@ enum shader_ft_sub_enum {
|
||||
SHADER_FT_SUB_SNOW_PARTICLE,
|
||||
SHADER_FT_SUB_LEAF_PARTICLE,
|
||||
SHADER_FT_SUB_STAR,
|
||||
SHADER_FT_SUB_STAR_MILKY_WAY,
|
||||
SHADER_FT_SUB_SNOW_RING,
|
||||
SHADER_FT_SUB_SNOW_FOOTPRINT,
|
||||
SHADER_FT_SUB_SNOW_TEX_SPACE_LIGHT,
|
||||
@@ -129,36 +141,60 @@ static const int32_t sss_skin_fpt_unival_max[] = {
|
||||
1, 0, 1, 1, 1, 0, 1, 1,
|
||||
};
|
||||
|
||||
static const int32_t sss_filter_vpt_unival_max[] = {
|
||||
/*static const int32_t sss_filter_vpt_unival_max[] = {
|
||||
0, 3, 0,
|
||||
};
|
||||
|
||||
static const int32_t sss_filter_fpt_unival_max[] = {
|
||||
1, 3, 1,
|
||||
};*/
|
||||
|
||||
static const int32_t sss_filter_min_vpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t sss_filter_min_fpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t sss_filter_min_npr_vpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t sss_filter_min_npr_fpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t sss_filter_gauss_2d_vpt_unival_max[] = {
|
||||
0,
|
||||
};
|
||||
|
||||
static const int32_t sss_filter_gauss_2d_fpt_unival_max[] = {
|
||||
1,
|
||||
};
|
||||
|
||||
static const int32_t hair_default_vpt_unival_max[] = {
|
||||
1, 1, 0, 0, 1, 0, 0, 3, 0, 2, 1, 0, 0, 0, 0, // 14th Added
|
||||
1, 1, 0, 0, 1, 0, 0, 3, 0, 2, 1, 0, 0, 0, 0, // 14th added
|
||||
};
|
||||
|
||||
static const int32_t hair_default_fpt_unival_max[] = {
|
||||
1, 0, 2, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, // 14th Added
|
||||
1, 0, 2, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, // 14th added
|
||||
};
|
||||
|
||||
static const int32_t hair_aniso_vpt_unival_max[] = {
|
||||
1, 1, 0, 0, 1, 0, 0, 3, 0, 2, 1, 0, 0, 0, 0, // 14th Added
|
||||
1, 1, 0, 0, 1, 0, 0, 3, 0, 2, 1, 0, 0, 0, 0, // 14th added
|
||||
};
|
||||
|
||||
static const int32_t hair_aniso_fpt_unival_max[] = {
|
||||
1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, // 14th Added
|
||||
1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, // 14th added
|
||||
};
|
||||
|
||||
static const int32_t hair_npr1_vpt_unival_max[] = {
|
||||
1, 1, 0, 0, 1, 0, 0, 3, 0, 2, 1, 0, 0, 0, 0, // 14th Added
|
||||
1, 1, 0, 0, 1, 0, 0, 3, 0, 2, 1, 0, 0, 0, 0, // 14th added
|
||||
};
|
||||
|
||||
static const int32_t hair_npr1_fpt_unival_max[] = {
|
||||
1, 0, 0, 0, 0, 1, 0, 3, 1, 0, 0, 0, 0, 0, 1, // 14th Added
|
||||
1, 0, 0, 0, 0, 1, 0, 3, 1, 0, 0, 0, 0, 0, 1, // 14th added
|
||||
};
|
||||
|
||||
static const int32_t cloth_default_vpt_unival_max[] = {
|
||||
@@ -257,12 +293,28 @@ static const int32_t esm_gauss_fpt_unival_max[] = {
|
||||
1,
|
||||
};
|
||||
|
||||
static const int32_t esm_filter_vpt_unival_max[] = {
|
||||
/*static const int32_t esm_filter_vpt_unival_max[] = {
|
||||
0,
|
||||
};
|
||||
|
||||
static const int32_t esm_filter_fpt_unival_max[] = {
|
||||
1,
|
||||
};*/
|
||||
|
||||
static const int32_t esm_filter_min_vpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t esm_filter_min_fpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t esm_filter_erosion_vpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t esm_filter_erosion_fpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t lit_proj_vpt_unival_max[] = {
|
||||
@@ -314,19 +366,23 @@ static const int32_t peel_fpt_unival_max[] = {
|
||||
};
|
||||
|
||||
static const int32_t tonemap_vpt_unival_max[] = {
|
||||
0, 0, 0, 0, 1, 0, 0, 0,
|
||||
//0, 0, 0, 0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 1, 0, 0, // 7th removed
|
||||
};
|
||||
|
||||
static const int32_t tonemap_fpt_unival_max[] = {
|
||||
0, 2, 2, 1, 1, 1, 0, 0,
|
||||
//0, 2, 2, 1, 1, 1, 0, 0,
|
||||
0, 2, 2, 1, 1, 1, 0, // 7th removed
|
||||
};
|
||||
|
||||
static const int32_t tonemap_npr1_vpt_unival_max[] = {
|
||||
0, 0, 0, 0, 1, 0, 0, 0,
|
||||
//0, 0, 0, 0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 1, 0, 0, // 7th removed
|
||||
};
|
||||
|
||||
static const int32_t tonemap_npr1_fpt_unival_max[] = {
|
||||
1, 0, 0, 1, 1, 0, 0, 1,
|
||||
//1, 0, 0, 1, 1, 0, 0, 1,
|
||||
1, 0, 0, 1, 1, 0, 0, // 7th removed
|
||||
};
|
||||
|
||||
static const int32_t reduce_tex_vpt_unival_max[] = {
|
||||
@@ -347,12 +403,12 @@ static const int32_t magnify_fpt_unival_max[] = {
|
||||
|
||||
/*static const int32_t mlaa_vpt_unival_max[] = {
|
||||
//0, 0, 2, 0,
|
||||
0, 2, 0, // 1st removed
|
||||
0, 2, 0, // 0th removed
|
||||
};
|
||||
|
||||
static const int32_t mlaa_fpt_unival_max[] = {
|
||||
//1, 1, 2, 2,
|
||||
1, 2, 2, // 1st removed
|
||||
1, 2, 2, // 0th removed
|
||||
};*/
|
||||
|
||||
static const int32_t mlaa_edge_vpt_unival_max[] = {
|
||||
@@ -387,20 +443,68 @@ static const int32_t contour_fpt_unival_max[] = {
|
||||
1, 1,
|
||||
};
|
||||
|
||||
static const int32_t exposure_vpt_unival_max[] = {
|
||||
static const int32_t contour_npr_vpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t contour_npr_fpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
/*static const int32_t exposure_vpt_unival_max[] = {
|
||||
2,
|
||||
};
|
||||
|
||||
static const int32_t exposure_fpt_unival_max[] = {
|
||||
2,
|
||||
};*/
|
||||
|
||||
static const int32_t exposure_minify_vpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t pp_gauss_vpt_unival_max[] = {
|
||||
static const int32_t exposure_minify_fpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t exposure_measure_vpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t exposure_measure_fpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t exposure_average_vpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t exposure_average_fpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
/*static const int32_t pp_gauss_vpt_unival_max[] = {
|
||||
1,
|
||||
};
|
||||
|
||||
static const int32_t pp_gauss_fpt_unival_max[] = {
|
||||
1,
|
||||
};*/
|
||||
|
||||
static const int32_t pp_gauss_usual_vpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t pp_gauss_usual_fpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t pp_gauss_cone_vpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t pp_gauss_cone_fpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t sun_vpt_unival_max[] = {
|
||||
@@ -467,12 +571,28 @@ static const int32_t leaf_particle_fpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t star_vpt_unival_max[] = {
|
||||
/*static const int32_t star_vpt_unival_max[] = {
|
||||
1,
|
||||
};
|
||||
|
||||
static const int32_t star_fpt_unival_max[] = {
|
||||
1,
|
||||
};*/
|
||||
|
||||
static const int32_t star_vpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t star_fpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t star_milky_way_vpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t star_milky_way_fpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t snow_ring_vpt_unival_max[] = {
|
||||
@@ -512,7 +632,7 @@ static const int32_t floor_vpt_unival_max[] = {
|
||||
};
|
||||
|
||||
static const int32_t floor_fpt_unival_max[] = {
|
||||
2, 1, 1, 1, 3, 0, 0, 1, // 7th Added
|
||||
2, 1, 1, 1, 3, 0, 0, 1, // 7th added
|
||||
};
|
||||
|
||||
static const int32_t puddle_vpt_unival_max[] = {
|
||||
@@ -700,7 +820,7 @@ static const shader_sub_table SSS_SKIN_table[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static const shader_sub_table SSS_FILT_table[] = {
|
||||
/*static const shader_sub_table SSS_FILT_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SSS_FILTER,
|
||||
sss_filter_vpt_unival_max,
|
||||
@@ -708,6 +828,33 @@ static const shader_sub_table SSS_FILT_table[] = {
|
||||
"sss_filter",
|
||||
"sss_filter",
|
||||
},
|
||||
};*/
|
||||
|
||||
static const shader_sub_table SSS_FILT_MIN_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SSS_FILTER_MIN,
|
||||
sss_filter_min_vpt_unival_max,
|
||||
sss_filter_min_fpt_unival_max,
|
||||
"sss_filter_min",
|
||||
"sss_filter_min",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_SSS_FILTER_MIN_NPR,
|
||||
sss_filter_min_npr_vpt_unival_max,
|
||||
sss_filter_min_npr_fpt_unival_max,
|
||||
"sss_filter_min",
|
||||
"sss_filter_min_npr",
|
||||
},
|
||||
};
|
||||
|
||||
static const shader_sub_table SSS_FILT_GAUSS_2D_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SSS_FILTER_GAUSS_2D,
|
||||
sss_filter_gauss_2d_vpt_unival_max,
|
||||
sss_filter_gauss_2d_fpt_unival_max,
|
||||
"sss_filter_gauss_2d",
|
||||
"sss_filter_gauss_2d",
|
||||
},
|
||||
};
|
||||
|
||||
static const shader_sub_table HAIR_table[] = {
|
||||
@@ -848,7 +995,7 @@ static const shader_sub_table ESMGAUSS_table[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static const shader_sub_table ESMFILT_table[] = {
|
||||
/*static const shader_sub_table ESMFILT_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_ESM_FILTER,
|
||||
esm_filter_vpt_unival_max,
|
||||
@@ -856,6 +1003,26 @@ static const shader_sub_table ESMFILT_table[] = {
|
||||
"esm_filter",
|
||||
"esm_filter",
|
||||
},
|
||||
};*/
|
||||
|
||||
static const shader_sub_table ESMFILT_MIN_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_ESM_FILTER_MIN,
|
||||
esm_filter_min_vpt_unival_max,
|
||||
esm_filter_min_fpt_unival_max,
|
||||
"esm_filter_min",
|
||||
"esm_filter_min",
|
||||
},
|
||||
};
|
||||
|
||||
static const shader_sub_table ESMFILT_EROSION_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_ESM_FILTER_EROSION,
|
||||
esm_filter_erosion_vpt_unival_max,
|
||||
esm_filter_erosion_fpt_unival_max,
|
||||
"esm_filter_erosion",
|
||||
"esm_filter_erosion",
|
||||
},
|
||||
};
|
||||
|
||||
static const shader_sub_table LITPROJ_table[] = {
|
||||
@@ -1005,7 +1172,17 @@ static const shader_sub_table CONTOUR_table[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static const shader_sub_table EXPOSURE_table[] = {
|
||||
static const shader_sub_table CONTOUR_NPR_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_CONTOUR_NPR,
|
||||
contour_npr_vpt_unival_max,
|
||||
contour_npr_fpt_unival_max,
|
||||
"contour_npr",
|
||||
"contour_npr",
|
||||
},
|
||||
};
|
||||
|
||||
/*static const shader_sub_table EXPOSURE_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_EXPOSURE,
|
||||
exposure_vpt_unival_max,
|
||||
@@ -1013,9 +1190,39 @@ static const shader_sub_table EXPOSURE_table[] = {
|
||||
"exposure",
|
||||
"exposure",
|
||||
},
|
||||
};*/
|
||||
|
||||
static const shader_sub_table EXPOSURE_MINIFY_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_EXPOSURE_MINIFY,
|
||||
exposure_minify_vpt_unival_max,
|
||||
exposure_minify_fpt_unival_max,
|
||||
"exposure_minify",
|
||||
"exposure_minify",
|
||||
},
|
||||
};
|
||||
|
||||
static const shader_sub_table GAUSS_table[] = {
|
||||
static const shader_sub_table EXPOSURE_MEASURE_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_EXPOSURE_MEASURE,
|
||||
exposure_measure_vpt_unival_max,
|
||||
exposure_measure_fpt_unival_max,
|
||||
"exposure_measure",
|
||||
"exposure_measure",
|
||||
},
|
||||
};
|
||||
|
||||
static const shader_sub_table EXPOSURE_AVERAGE_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_EXPOSURE_AVERAGE,
|
||||
exposure_average_vpt_unival_max,
|
||||
exposure_average_fpt_unival_max,
|
||||
"exposure_average",
|
||||
"exposure_average",
|
||||
},
|
||||
};
|
||||
|
||||
/*static const shader_sub_table GAUSS_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_PP_GAUSS,
|
||||
pp_gauss_vpt_unival_max,
|
||||
@@ -1023,6 +1230,26 @@ static const shader_sub_table GAUSS_table[] = {
|
||||
"pp_gauss",
|
||||
"pp_gauss",
|
||||
},
|
||||
};*/
|
||||
|
||||
static const shader_sub_table GAUSS_USUAL_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_PP_GAUSS_USUAL,
|
||||
pp_gauss_usual_vpt_unival_max,
|
||||
pp_gauss_usual_fpt_unival_max,
|
||||
"pp_gauss_usual",
|
||||
"pp_gauss_usual",
|
||||
},
|
||||
};
|
||||
|
||||
static const shader_sub_table GAUSS_CONE_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_PP_GAUSS_CONE,
|
||||
pp_gauss_cone_vpt_unival_max,
|
||||
pp_gauss_cone_fpt_unival_max,
|
||||
"pp_gauss_cone",
|
||||
"pp_gauss_cone",
|
||||
},
|
||||
};
|
||||
|
||||
static const shader_sub_table SUN_table[] = {
|
||||
@@ -1115,6 +1342,16 @@ static const shader_sub_table STAR_table[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static const shader_sub_table STAR_MILKY_WAY_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_STAR_MILKY_WAY,
|
||||
star_milky_way_vpt_unival_max,
|
||||
star_milky_way_fpt_unival_max,
|
||||
"star_milky_way",
|
||||
"star_milky_way",
|
||||
},
|
||||
};
|
||||
|
||||
static const shader_sub_table SNORING_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SNOW_RING,
|
||||
@@ -1396,10 +1633,18 @@ static const uniform_name SSS_SKIN_uniform[] = {
|
||||
U26,
|
||||
};
|
||||
|
||||
static const uniform_name SSS_FILT_uniform[] = {
|
||||
/*static const uniform_name SSS_FILT_uniform[] = {
|
||||
U16,
|
||||
U_SSS_FILTER,
|
||||
U_NPR,
|
||||
};*/
|
||||
|
||||
static const uniform_name SSS_FILT_MIN_uniform[] = {
|
||||
U_INVALID,
|
||||
};
|
||||
|
||||
static const uniform_name SSS_FILT_GAUSS_2D_uniform[] = {
|
||||
U16,
|
||||
};
|
||||
|
||||
static const uniform_name HAIR_uniform[] = {
|
||||
@@ -1417,7 +1662,7 @@ static const uniform_name HAIR_uniform[] = {
|
||||
U_NPR,
|
||||
U_CHARA_COLOR,
|
||||
U_TONE_CURVE,
|
||||
U_ALPHA_TEST, // 14th Added
|
||||
U_ALPHA_TEST, // 14th added
|
||||
};
|
||||
|
||||
static const uniform_name CLOTH_uniform[] = {
|
||||
@@ -1509,8 +1754,16 @@ static const uniform_name ESMGAUSS_uniform[] = {
|
||||
U_LIGHT_PROJ,
|
||||
};
|
||||
|
||||
static const uniform_name ESMFILT_uniform[] = {
|
||||
/*static const uniform_name ESMFILT_uniform[] = {
|
||||
U_ESM_FILTER,
|
||||
};*/
|
||||
|
||||
static const uniform_name ESMFILT_MIN_uniform[] = {
|
||||
U_INVALID,
|
||||
};
|
||||
|
||||
static const uniform_name ESMFILT_EROSION_uniform[] = {
|
||||
U_INVALID,
|
||||
};
|
||||
|
||||
static const uniform_name LITPROJ_uniform[] = {
|
||||
@@ -1578,7 +1831,7 @@ static const uniform_name TONEMAP_uniform[] = {
|
||||
U_AET_BACK,
|
||||
U_LIGHT_PROJ,
|
||||
U_NPR,
|
||||
U25,
|
||||
//U25, 7th removed
|
||||
};
|
||||
|
||||
static const uniform_name REDUCE_uniform[] = {
|
||||
@@ -1591,7 +1844,7 @@ static const uniform_name MAGNIFY_uniform[] = {
|
||||
};
|
||||
|
||||
/*static const uniform_name MLAA_uniform[] = {
|
||||
//U16, // 1st removed
|
||||
//U16, // 0th removed
|
||||
U_ALPHA_MASK,
|
||||
U_MLAA,
|
||||
U_MLAA_SEARCH,
|
||||
@@ -1614,12 +1867,36 @@ static const uniform_name CONTOUR_uniform[] = {
|
||||
U24,
|
||||
};
|
||||
|
||||
static const uniform_name EXPOSURE_uniform[] = {
|
||||
U_EXPOSURE,
|
||||
static const uniform_name CONTOUR_NPR_uniform[] = {
|
||||
U_INVALID,
|
||||
};
|
||||
|
||||
static const uniform_name GAUSS_uniform[] = {
|
||||
/*static const uniform_name EXPOSURE_uniform[] = {
|
||||
U_EXPOSURE,
|
||||
};*/
|
||||
|
||||
static const uniform_name EXPOSURE_MINIFY_uniform[] = {
|
||||
U_INVALID,
|
||||
};
|
||||
|
||||
static const uniform_name EXPOSURE_MEASURE_uniform[] = {
|
||||
U_INVALID,
|
||||
};
|
||||
|
||||
static const uniform_name EXPOSURE_AVERAGE_uniform[] = {
|
||||
U_INVALID,
|
||||
};
|
||||
|
||||
/*static const uniform_name GAUSS_uniform[] = {
|
||||
U_GAUSS,
|
||||
};*/
|
||||
|
||||
static const uniform_name GAUSS_USUAL_uniform[] = {
|
||||
U_INVALID,
|
||||
};
|
||||
|
||||
static const uniform_name GAUSS_CONE_uniform[] = {
|
||||
U_INVALID,
|
||||
};
|
||||
|
||||
static const uniform_name SUN_uniform[] = {
|
||||
@@ -1663,8 +1940,16 @@ static const uniform_name LEAF_PT_uniform[] = {
|
||||
U_INVALID,
|
||||
};
|
||||
|
||||
static const uniform_name STAR_uniform[] = {
|
||||
/*static const uniform_name STAR_uniform[] = {
|
||||
U_STAR,
|
||||
};*/
|
||||
|
||||
static const uniform_name STAR_uniform[] = {
|
||||
U_INVALID,
|
||||
};
|
||||
|
||||
static const uniform_name STAR_MILKY_WAY_uniform[] = {
|
||||
U_INVALID,
|
||||
};
|
||||
|
||||
static const uniform_name SNORING_uniform[] = {
|
||||
@@ -1695,7 +1980,7 @@ static const uniform_name FLOOR_uniform[] = {
|
||||
U_FOG_HEIGHT,
|
||||
U_MORPH,
|
||||
U_MORPH_COLOR,
|
||||
U_ALPHA_TEST, // 7th Added
|
||||
U_ALPHA_TEST, // 7th added
|
||||
};
|
||||
|
||||
static const uniform_name PUDDLE_uniform[] = {
|
||||
@@ -1796,7 +2081,7 @@ static const bool BLINN_permut[] = {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false, // 11th Added
|
||||
false, // 11th added
|
||||
};
|
||||
|
||||
static const bool ITEM_permut[] = {
|
||||
@@ -1855,10 +2140,18 @@ static const bool SSS_SKIN_permut[] = {
|
||||
false,
|
||||
};
|
||||
|
||||
static const bool SSS_FILT_permut[] = {
|
||||
/*static const bool SSS_FILT_permut[] = {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
};*/
|
||||
|
||||
static const bool SSS_FILT_MIN_permut[] = {
|
||||
false,
|
||||
};
|
||||
|
||||
static const bool SSS_FILT_GAUSS_2D_permut[] = {
|
||||
true,
|
||||
};
|
||||
|
||||
static const bool HAIR_permut[] = {
|
||||
@@ -1876,7 +2169,7 @@ static const bool HAIR_permut[] = {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false, // 14th Added
|
||||
false, // 14th added
|
||||
};
|
||||
|
||||
static const bool CLOTH_permut[] = {
|
||||
@@ -1965,10 +2258,18 @@ static const bool ESM_permut[] = {
|
||||
};
|
||||
|
||||
static const bool ESMGAUSS_permut[] = {
|
||||
true,
|
||||
};
|
||||
|
||||
/*static const bool ESMFILT_permut[] = {
|
||||
true,
|
||||
};*/
|
||||
|
||||
static const bool ESMFILT_MIN_permut[] = {
|
||||
false,
|
||||
};
|
||||
|
||||
static const bool ESMFILT_permut[] = {
|
||||
static const bool ESMFILT_EROSION_permut[] = {
|
||||
false,
|
||||
};
|
||||
|
||||
@@ -2029,7 +2330,7 @@ static const bool PEEL_permut[] = {
|
||||
};
|
||||
|
||||
static const bool TONEMAP_permut[] = {
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
@@ -2049,7 +2350,7 @@ static const bool MAGNIFY_permut[] = {
|
||||
};
|
||||
|
||||
/*static const bool MLAA_permut[] = {
|
||||
//true, // 1st removed
|
||||
//true, // 0th removed
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
@@ -2072,12 +2373,36 @@ static const bool CONTOUR_permut[] = {
|
||||
false,
|
||||
};
|
||||
|
||||
static const bool EXPOSURE_permut[] = {
|
||||
true,
|
||||
static const bool CONTOUR_NPR_permut[] = {
|
||||
false,
|
||||
};
|
||||
|
||||
static const bool GAUSS_permut[] = {
|
||||
/*static const bool EXPOSURE_permut[] = {
|
||||
true,
|
||||
};*/
|
||||
|
||||
static const bool EXPOSURE_MINIFY_permut[] = {
|
||||
false,
|
||||
};
|
||||
|
||||
static const bool EXPOSURE_MEASURE_permut[] = {
|
||||
false,
|
||||
};
|
||||
|
||||
static const bool EXPOSURE_AVERAGE_permut[] = {
|
||||
false,
|
||||
};
|
||||
|
||||
/*static const bool GAUSS_permut[] = {
|
||||
true,
|
||||
};*/
|
||||
|
||||
static const bool GAUSS_USUAL_permut[] = {
|
||||
false,
|
||||
};
|
||||
|
||||
static const bool GAUSS_CONE_permut[] = {
|
||||
false,
|
||||
};
|
||||
|
||||
static const bool SUN_permut[] = {
|
||||
@@ -2114,17 +2439,25 @@ static const bool W_PTCL_permut[] = {
|
||||
};
|
||||
|
||||
static const bool SNOW_PT_permut[] = {
|
||||
false,
|
||||
true,
|
||||
};
|
||||
|
||||
static const bool LEAF_PT_permut[] = {
|
||||
false,
|
||||
};
|
||||
|
||||
/*static const bool STAR_permut[] = {
|
||||
false,
|
||||
};*/
|
||||
|
||||
static const bool STAR_permut[] = {
|
||||
false,
|
||||
};
|
||||
|
||||
static const bool STAR_MILKY_WAY_permut[] = {
|
||||
false,
|
||||
};
|
||||
|
||||
static const bool SNORING_permut[] = {
|
||||
false,
|
||||
false,
|
||||
@@ -2153,7 +2486,7 @@ static const bool FLOOR_permut[] = {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false, // 7th Added
|
||||
false, // 7th added
|
||||
};
|
||||
|
||||
static const bool PUDDLE_permut[] = {
|
||||
@@ -2225,7 +2558,7 @@ static const bool SHOWVEC_permut[] = {
|
||||
};
|
||||
|
||||
static const bool FONT_permut[] = {
|
||||
false,
|
||||
true,
|
||||
};
|
||||
|
||||
static const bool MOVIE_permut[] = {
|
||||
@@ -2282,7 +2615,7 @@ struct glass_eye_struct {
|
||||
n##_permut, \
|
||||
}
|
||||
|
||||
static const shader_table shader_ft_table[] = {
|
||||
const shader_table shader_ft_table[] = {
|
||||
{
|
||||
"SHADER_FFP",
|
||||
SHADER_FT_FFP,
|
||||
@@ -2297,7 +2630,9 @@ static const shader_table shader_ft_table[] = {
|
||||
shader_table_struct(STAGE),
|
||||
shader_table_struct(SKIN),
|
||||
shader_table_struct(SSS_SKIN),
|
||||
shader_table_struct(SSS_FILT),
|
||||
//shader_table_struct(SSS_FILT),
|
||||
shader_table_struct(SSS_FILT_MIN),
|
||||
shader_table_struct(SSS_FILT_GAUSS_2D),
|
||||
shader_table_struct(HAIR),
|
||||
shader_table_struct(CLOTH),
|
||||
shader_table_struct(TIGHTS),
|
||||
@@ -2309,7 +2644,9 @@ static const shader_table shader_ft_table[] = {
|
||||
shader_table_struct(SHDMAP),
|
||||
shader_table_struct(ESM),
|
||||
shader_table_struct(ESMGAUSS),
|
||||
shader_table_struct(ESMFILT),
|
||||
//shader_table_struct(ESMFILT),
|
||||
shader_table_struct(ESMFILT_MIN),
|
||||
shader_table_struct(ESMFILT_EROSION),
|
||||
shader_table_struct(LITPROJ),
|
||||
shader_table_struct(SIMPLE),
|
||||
shader_table_struct(SIL),
|
||||
@@ -2324,8 +2661,14 @@ static const shader_table shader_ft_table[] = {
|
||||
shader_table_struct(MLAA_AREA),
|
||||
shader_table_struct(MLAA_BLEND),
|
||||
shader_table_struct(CONTOUR),
|
||||
shader_table_struct(EXPOSURE),
|
||||
shader_table_struct(GAUSS),
|
||||
shader_table_struct(CONTOUR_NPR),
|
||||
//shader_table_struct(EXPOSURE),
|
||||
shader_table_struct(EXPOSURE_MINIFY),
|
||||
shader_table_struct(EXPOSURE_MEASURE),
|
||||
shader_table_struct(EXPOSURE_AVERAGE),
|
||||
//shader_table_struct(GAUSS),
|
||||
shader_table_struct(GAUSS_USUAL),
|
||||
shader_table_struct(GAUSS_CONE),
|
||||
shader_table_struct(SUN),
|
||||
shader_table_struct(FADE),
|
||||
shader_table_struct(WATER01),
|
||||
@@ -2335,6 +2678,7 @@ static const shader_table shader_ft_table[] = {
|
||||
shader_table_struct(SNOW_PT),
|
||||
shader_table_struct(LEAF_PT),
|
||||
shader_table_struct(STAR),
|
||||
shader_table_struct(STAR_MILKY_WAY),
|
||||
shader_table_struct(SNORING),
|
||||
shader_table_struct(SN_FOOT),
|
||||
shader_table_struct(SN_TSL),
|
||||
@@ -2360,7 +2704,7 @@ static const shader_table shader_ft_table[] = {
|
||||
|
||||
#undef shader_table_struct
|
||||
|
||||
static const size_t shader_ft_table_size =
|
||||
const size_t shader_ft_table_size =
|
||||
sizeof(shader_ft_table) / sizeof(shader_table);
|
||||
|
||||
static void glass_eye_calc(glass_eye_struct* glass_eye);
|
||||
@@ -2371,8 +2715,9 @@ static void shader_bind_hair(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_membrane(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_eye_ball(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_tone_map(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_sss_filter_min(shader_set_data* set, shader* shad);
|
||||
|
||||
static const shader_bind_func shader_ft_bind_func_table[] = {
|
||||
const shader_bind_func shader_ft_bind_func_table[] = {
|
||||
{
|
||||
SHADER_FT_BLINN,
|
||||
shader_bind_blinn,
|
||||
@@ -2397,9 +2742,13 @@ static const shader_bind_func shader_ft_bind_func_table[] = {
|
||||
SHADER_FT_TONEMAP,
|
||||
shader_bind_tone_map,
|
||||
},
|
||||
{
|
||||
SHADER_FT_SSS_FILT_MIN,
|
||||
shader_bind_sss_filter_min,
|
||||
},
|
||||
};
|
||||
|
||||
static const size_t shader_ft_bind_func_table_size =
|
||||
const size_t shader_ft_bind_func_table_size =
|
||||
sizeof(shader_ft_bind_func_table) / sizeof(shader_bind_func);
|
||||
|
||||
shader_set_data shaders_ft;
|
||||
@@ -2433,11 +2782,6 @@ glass_eye_struct glass_eye = {
|
||||
0,
|
||||
};
|
||||
|
||||
void shader_ft_load(shader_set_data* set, farc* f, bool ignore_cache) {
|
||||
set->load(f, false, false, "ft", shader_ft_table, shader_ft_table_size,
|
||||
shader_ft_bind_func_table, shader_ft_bind_func_table_size);
|
||||
}
|
||||
|
||||
static void glass_eye_calc(glass_eye_struct* glass_eye) {
|
||||
float_t v2 = glass_eye->field_28;
|
||||
glass_eye->field_64 = glass_eye->field_2C / v2;
|
||||
@@ -2447,7 +2791,7 @@ static void glass_eye_calc(glass_eye_struct* glass_eye) {
|
||||
glass_eye->field_80 = glass_eye->field_48 * v2;
|
||||
glass_eye->field_8C = glass_eye->field_54 * v2;
|
||||
if (glass_eye->field_B0 == 0) {
|
||||
glass_eye->field_A0 = vec4_null;
|
||||
glass_eye->field_A0 = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2577,3 +2921,8 @@ static void shader_bind_tone_map(shader_set_data* set, shader* shad) {
|
||||
shad->bind(set, uniform_value[U_NPR] == 1
|
||||
? SHADER_FT_SUB_TONEMAP_NPR1 : SHADER_FT_SUB_TONEMAP);
|
||||
}
|
||||
|
||||
static void shader_bind_sss_filter_min(shader_set_data* set, shader* shad) {
|
||||
shad->bind(set, uniform_value[U_NPR]
|
||||
? SHADER_FT_SUB_SSS_FILTER_MIN_NPR : SHADER_FT_SUB_SSS_FILTER_MIN);
|
||||
}
|
||||
|
||||
+20
-6
@@ -15,7 +15,9 @@ enum shader_ft_enum {
|
||||
SHADER_FT_STAGE,
|
||||
SHADER_FT_SKIN,
|
||||
SHADER_FT_SSS_SKIN,
|
||||
SHADER_FT_SSS_FILT,
|
||||
//SHADER_FT_SSS_FILT,
|
||||
SHADER_FT_SSS_FILT_MIN,
|
||||
SHADER_FT_SSS_FILT_GAUSS_2D,
|
||||
SHADER_FT_HAIR,
|
||||
SHADER_FT_CLOTH,
|
||||
SHADER_FT_TIGHTS,
|
||||
@@ -27,7 +29,9 @@ enum shader_ft_enum {
|
||||
SHADER_FT_SHDMAP,
|
||||
SHADER_FT_ESM,
|
||||
SHADER_FT_ESMGAUSS,
|
||||
SHADER_FT_ESMFILT,
|
||||
//SHADER_FT_ESMFILT,
|
||||
SHADER_FT_ESMFILT_MIN,
|
||||
SHADER_FT_ESMFILT_EROSION,
|
||||
SHADER_FT_LITPROJ,
|
||||
SHADER_FT_SIMPLE,
|
||||
SHADER_FT_SIL,
|
||||
@@ -42,8 +46,14 @@ enum shader_ft_enum {
|
||||
SHADER_FT_MLAA_AREA,
|
||||
SHADER_FT_MLAA_BLEND,
|
||||
SHADER_FT_CONTOUR,
|
||||
SHADER_FT_EXPOSURE,
|
||||
SHADER_FT_GAUSS,
|
||||
SHADER_FT_CONTOUR_NPR,
|
||||
//SHADER_FT_EXPOSURE,
|
||||
SHADER_FT_EXPOSURE_MINIFY,
|
||||
SHADER_FT_EXPOSURE_MEASURE,
|
||||
SHADER_FT_EXPOSURE_AVERAGE,
|
||||
//SHADER_FT_GAUSS,
|
||||
SHADER_FT_GAUSS_USUAL,
|
||||
SHADER_FT_GAUSS_CONE,
|
||||
SHADER_FT_SUN,
|
||||
SHADER_FT_FADE,
|
||||
SHADER_FT_WATER01,
|
||||
@@ -53,6 +63,7 @@ enum shader_ft_enum {
|
||||
SHADER_FT_SNOW_PT,
|
||||
SHADER_FT_LEAF_PT,
|
||||
SHADER_FT_STAR,
|
||||
SHADER_FT_STAR_MILKY_WAY,
|
||||
SHADER_FT_SNORING,
|
||||
SHADER_FT_SN_FOOT,
|
||||
SHADER_FT_SN_TSL,
|
||||
@@ -77,6 +88,9 @@ enum shader_ft_enum {
|
||||
SHADER_FT_END,
|
||||
};
|
||||
|
||||
extern shader_set_data shaders_ft;
|
||||
extern const shader_table shader_ft_table[];
|
||||
extern const size_t shader_ft_table_size;
|
||||
extern const shader_bind_func shader_ft_bind_func_table[];
|
||||
extern const size_t shader_ft_bind_func_table_size;
|
||||
|
||||
extern void shader_ft_load(shader_set_data* set, farc* f, bool ignore_cache);
|
||||
extern shader_set_data shaders_ft;
|
||||
|
||||
+7
-12
@@ -92,9 +92,7 @@ void shader_glsl::load(const char* vert, const char* frag,
|
||||
if (!success) {
|
||||
GLchar* info_log = force_malloc_s(GLchar, 0x10000);
|
||||
glGetProgramInfoLog(program, 0x10000, 0, info_log);
|
||||
printf("Program linking error: %s\n", param->name);
|
||||
printf(info_log);
|
||||
putchar('\n');
|
||||
printf_debug("Program linking error: %s\n%s\n", param->name, info_log);
|
||||
free_def(info_log);
|
||||
}
|
||||
|
||||
@@ -446,9 +444,7 @@ static GLuint shader_compile(GLenum type, const char* data) {
|
||||
if (!success) {
|
||||
GLchar* info_log = force_malloc_s(GLchar, 0x10000);
|
||||
glGetShaderInfoLog(shader, 0x10000, 0, info_log);
|
||||
printf("Shader compile error: ");
|
||||
printf(info_log);
|
||||
putchar('\n');
|
||||
printf_debug("Shader compile error:\n%s\n", info_log);
|
||||
free_def(info_log);
|
||||
}
|
||||
return shader;
|
||||
@@ -464,10 +460,10 @@ static GLint shader_get_uniform_block_index(GLint program, GLchar* name,
|
||||
GLint index = glGetUniformBlockIndex(program, name);
|
||||
if (index == GL_INVALID_INDEX) {
|
||||
if (program_log != program) {
|
||||
printf("Program %d:\n", program);
|
||||
printf_debug("Program %d:\n", program);
|
||||
program_log = program;
|
||||
}
|
||||
printf(" Block Index for \"%s\" not found\n", name);
|
||||
printf_debug(" Block Index for \"%s\" not found\n", name);
|
||||
}
|
||||
uniform_block->push_back({ hash, index });
|
||||
return index;
|
||||
@@ -483,10 +479,10 @@ static GLint shader_get_uniform_location(GLint program, GLchar* name,
|
||||
GLint location = glGetUniformLocation(program, name);
|
||||
if (location == GL_INVALID_INDEX) {
|
||||
if (program_log != program) {
|
||||
printf("Program %d:\n", program);
|
||||
printf_debug("Program %d:\n", program);
|
||||
program_log = program;
|
||||
}
|
||||
printf(" Location for \"%s\" not found\n", name);
|
||||
printf_debug(" Location for \"%s\" not found\n", name);
|
||||
}
|
||||
uniform->push_back({ hash, location });
|
||||
return location;
|
||||
@@ -529,8 +525,7 @@ static char* shader_parse_define(char* data, shader_glsl_param* param) {
|
||||
const size_t s = SHADER_PARAM_NUM_PARAMS;
|
||||
|
||||
size_t temp_len[SHADER_PARAM_NUM_PARAMS];
|
||||
char temp[0x100];
|
||||
memset(temp, 0, 0x100);
|
||||
char temp[0x100] = {};
|
||||
|
||||
for (size_t i = 0; i < s; i++)
|
||||
if (param->param[i]) {
|
||||
|
||||
+514
-138
@@ -9,6 +9,7 @@
|
||||
#include "../KKdLib/str_utils.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "data.hpp"
|
||||
#include "ogg_vorbis.hpp"
|
||||
#include "timer.hpp"
|
||||
#include <functiondiscoverykeys_devpkey.h>
|
||||
#include <timeapi.h>
|
||||
@@ -27,13 +28,54 @@ struct SoundCueQueueVolume {
|
||||
float_t max;
|
||||
};
|
||||
|
||||
struct sound_stream {
|
||||
std::string path;
|
||||
OggPlayback* ogg_playback;
|
||||
float_t current_volume;
|
||||
float_t duration;
|
||||
float_t time;
|
||||
bool pause;
|
||||
uint32_t file_loading_frames;
|
||||
uint32_t file_ready_frames;
|
||||
float_t time_seek;
|
||||
int32_t volume_trans;
|
||||
float_t target_volume;
|
||||
int32_t state;
|
||||
int32_t play_state;
|
||||
|
||||
sound_stream();
|
||||
~sound_stream();
|
||||
|
||||
bool check_state();
|
||||
void ctrl();
|
||||
void ctrl_playback();
|
||||
void reset();
|
||||
void set_current_volume(float_t value);
|
||||
bool set_path(const char* path, bool pause = false);
|
||||
bool set_path(const char* path, float_t time, bool pause = false);
|
||||
bool set_path_playback();
|
||||
bool set_pause(bool value);
|
||||
void set_target_volume(float_t value, int32_t frames);
|
||||
bool stop();
|
||||
bool stop_playback();
|
||||
};
|
||||
|
||||
static void sound_stream_array_init();
|
||||
static void sound_stream_array_ctrl();
|
||||
static sound_stream* sound_stream_array_get(int32_t index);
|
||||
static void sound_stream_array_reset();
|
||||
static void sound_stream_array_free();
|
||||
|
||||
SoundWork* sound_work;
|
||||
sound::wasapi::System* sound_wasapi_system_data;
|
||||
std::map<std::string, WaveAudio> wave_audio_storage;
|
||||
std::map<std::string, WaveAudio> wave_audio_storage_data;
|
||||
|
||||
static int32_t sound_cue_counter = 0;
|
||||
static int32_t sound_wasapi_system_counter = 0;
|
||||
|
||||
static sound_stream* sound_stream_array;
|
||||
static float_t sound_stream_volume = 1.0f;
|
||||
|
||||
static const int8_t ima_index_table[] = {
|
||||
-1, -1, -1, -1, 2, 4, 6, 8,
|
||||
-1, -1, -1, -1, 2, 4, 6, 8,
|
||||
@@ -106,7 +148,7 @@ namespace sound {
|
||||
}
|
||||
|
||||
if (mix_format->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE
|
||||
&& !memcmp(&wave_format.SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, sizeof(GUID))) {
|
||||
&& wave_format.SubFormat == KSDATAFORMAT_SUBTYPE_IEEE_FLOAT) {
|
||||
bit_depth = 32;
|
||||
format = AUDIO_FORMAT_F32;
|
||||
wave_format.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
|
||||
@@ -159,7 +201,8 @@ namespace sound {
|
||||
return;
|
||||
|
||||
if (pAudioClient->Initialize(AUDCLNT_SHAREMODE_SHARED,
|
||||
AUDCLNT_STREAMFLAGS_RATEADJUST | AUDCLNT_STREAMFLAGS_EVENTCALLBACK,
|
||||
AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY
|
||||
| AUDCLNT_STREAMFLAGS_RATEADJUST | AUDCLNT_STREAMFLAGS_EVENTCALLBACK,
|
||||
hnsPeriod, 0, &wave_format.Format, 0) == AUDCLNT_ERR(0x019)) {
|
||||
if (FAILED(pAudioClient->GetBufferSize(&samples_count)))
|
||||
return;
|
||||
@@ -173,7 +216,8 @@ namespace sound {
|
||||
* 10000000.0 / (double_t)sample_rate + 0.5);
|
||||
|
||||
if (FAILED(pAudioClient->Initialize(AUDCLNT_SHAREMODE_SHARED,
|
||||
AUDCLNT_STREAMFLAGS_RATEADJUST | AUDCLNT_STREAMFLAGS_EVENTCALLBACK,
|
||||
AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY
|
||||
| AUDCLNT_STREAMFLAGS_RATEADJUST | AUDCLNT_STREAMFLAGS_EVENTCALLBACK,
|
||||
hnsPeriod, 0, &wave_format.Format, 0)))
|
||||
return;
|
||||
}
|
||||
@@ -182,22 +226,17 @@ namespace sound {
|
||||
return;
|
||||
|
||||
// Rounding to prev base 2
|
||||
while (true) {
|
||||
uint32_t _samples_count = samples_count;
|
||||
_samples_count--;
|
||||
_samples_count |= _samples_count >> 1;
|
||||
_samples_count |= _samples_count >> 2;
|
||||
_samples_count |= _samples_count >> 4;
|
||||
_samples_count |= _samples_count >> 8;
|
||||
_samples_count |= _samples_count >> 16;
|
||||
_samples_count++;
|
||||
uint32_t _samples_count = samples_count;
|
||||
_samples_count--;
|
||||
_samples_count |= _samples_count >> 1;
|
||||
_samples_count |= _samples_count >> 2;
|
||||
_samples_count |= _samples_count >> 4;
|
||||
_samples_count |= _samples_count >> 8;
|
||||
_samples_count |= _samples_count >> 16;
|
||||
_samples_count++;
|
||||
while (_samples_count + (_samples_count >> 1) >= samples_count)
|
||||
_samples_count >>= 1;
|
||||
if (_samples_count + (_samples_count >> 1) < samples_count) {
|
||||
samples_count = _samples_count;
|
||||
break;
|
||||
}
|
||||
samples_count = _samples_count;
|
||||
}
|
||||
samples_count = _samples_count;
|
||||
|
||||
if (!mixer->Init(se_channels_count, streaming_channels_count, samples_count))
|
||||
return;
|
||||
@@ -245,7 +284,7 @@ namespace sound {
|
||||
pClockAdjustment->Release();
|
||||
pClockAdjustment = 0;
|
||||
}
|
||||
|
||||
|
||||
if (pRenderClient) {
|
||||
pRenderClient->Release();
|
||||
pRenderClient = 0;
|
||||
@@ -315,30 +354,17 @@ namespace sound {
|
||||
if (!system)
|
||||
return;
|
||||
|
||||
float_t spk_l_volume = 0.0f;
|
||||
float_t spk_r_volume = 0.0f;
|
||||
float_t hph_l_volume = 0.0f;
|
||||
float_t hph_r_volume = 0.0f;
|
||||
vec4 spk_hph_volume = 0.0f;
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> u_lock(volume_mtx);
|
||||
float_t master_volume = this->master_volume;
|
||||
spk_l_volume = master_volume * channels_volume[0];
|
||||
spk_r_volume = master_volume * channels_volume[1];
|
||||
hph_l_volume = master_volume * channels_volume[2];
|
||||
hph_r_volume = master_volume * channels_volume[3];
|
||||
spk_hph_volume = master_volume * *(vec4*)channels_volume;
|
||||
}
|
||||
|
||||
if (disable_headphones_volume) {
|
||||
hph_l_volume = spk_l_volume;
|
||||
hph_r_volume = spk_r_volume;
|
||||
}
|
||||
else if (invert_phase) {
|
||||
spk_l_volume = -spk_l_volume;
|
||||
spk_l_volume = -spk_l_volume;
|
||||
hph_l_volume = -hph_l_volume;
|
||||
hph_r_volume = -hph_r_volume;
|
||||
}
|
||||
if (disable_headphones_volume)
|
||||
*(vec2*)&spk_hph_volume.z = *(vec2*)&spk_hph_volume.x;
|
||||
else if (invert_phase)
|
||||
spk_hph_volume = -spk_hph_volume;
|
||||
|
||||
memset(mix_buffer, 0, mix_buffer_size);
|
||||
if (streaming_channels)
|
||||
@@ -356,22 +382,20 @@ namespace sound {
|
||||
switch (system->channels) {
|
||||
case 2:
|
||||
for (size_t i = samples_count; i; i--, _mix_buffer++) {
|
||||
int32_t hph_l = (int32_t)(_mix_buffer->hph_l * hph_l_volume * (float_t)0x7FFF);
|
||||
int32_t hph_r = (int32_t)(_mix_buffer->hph_r * hph_r_volume * (float_t)0x7FFF);
|
||||
*_buffer++ = (int16_t)clamp_def(hph_l, -0x8000, 0x7FFF);
|
||||
*_buffer++ = (int16_t)clamp_def(hph_r, -0x8000, 0x7FFF);
|
||||
vec2 hph = *(vec2*)&_mix_buffer->hph_l * *(vec2*)&spk_hph_volume.z * (float_t)0x7FFF;
|
||||
vec2i hph_i32;
|
||||
vec2_to_vec2i(hph, hph_i32);
|
||||
*(vec2i*)_buffer = vec2i::clamp(hph_i32, -0x8000, 0x7FFF);
|
||||
_buffer += 2;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (size_t i = samples_count; i; i--, _mix_buffer++) {
|
||||
int32_t spk_l = (int32_t)(_mix_buffer->spk_l * spk_l_volume * (float_t)0x7FFF);
|
||||
int32_t spk_r = (int32_t)(_mix_buffer->spk_r * spk_r_volume * (float_t)0x7FFF);
|
||||
int32_t hph_l = (int32_t)(_mix_buffer->hph_l * hph_l_volume * (float_t)0x7FFF);
|
||||
int32_t hph_r = (int32_t)(_mix_buffer->hph_r * hph_r_volume * (float_t)0x7FFF);
|
||||
*_buffer++ = (int16_t)clamp_def(spk_l, -0x8000, 0x7FFF);
|
||||
*_buffer++ = (int16_t)clamp_def(spk_r, -0x8000, 0x7FFF);
|
||||
*_buffer++ = (int16_t)clamp_def(hph_l, -0x8000, 0x7FFF);
|
||||
*_buffer++ = (int16_t)clamp_def(hph_r, -0x8000, 0x7FFF);
|
||||
vec4 spk_hph = *(vec4*)_mix_buffer * spk_hph_volume * (float_t)0x7FFF;
|
||||
vec4i spk_hph_i32;
|
||||
vec4_to_vec4i(spk_hph, spk_hph_i32);
|
||||
*(vec4i*)_buffer = vec4i::clamp(spk_hph_i32, -0x8000, 0x7FFF);
|
||||
_buffer += 4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -381,35 +405,31 @@ namespace sound {
|
||||
switch (system->channels) {
|
||||
case 2:
|
||||
for (size_t i = samples_count; i; i--, _mix_buffer++) {
|
||||
int32_t hph_l = (int32_t)(_mix_buffer->hph_l * hph_l_volume * (float_t)0x7FFFFF);
|
||||
int32_t hph_r = (int32_t)(_mix_buffer->hph_r * hph_r_volume * (float_t)0x7FFFFF);
|
||||
hph_l = clamp_def(hph_l, -0x800000, 0x7FFFFF);
|
||||
hph_r = clamp_def(hph_r, -0x800000, 0x7FFFFF);
|
||||
*(uint16_t*)&_buffer[0] = (uint16_t)hph_l;
|
||||
*(uint8_t*)&_buffer[2] = (uint8_t)(hph_l >> 16);
|
||||
*(uint16_t*)&_buffer[3] = (uint16_t)hph_r;
|
||||
*(uint8_t*)&_buffer[5] = (uint8_t)(hph_r >> 16);
|
||||
vec2 hph = *(vec2*)&_mix_buffer->hph_l * *(vec2*)&spk_hph_volume.z * (float_t)0x7FFFFF;
|
||||
vec2i hph_i32;
|
||||
vec2_to_vec2i(hph, hph_i32);
|
||||
hph_i32 = vec2i::clamp(hph_i32, -0x800000, 0x7FFFFF);
|
||||
*(uint16_t*)&_buffer[0] = (uint16_t)hph_i32.x;
|
||||
*(uint8_t*)&_buffer[2] = (uint8_t)(hph_i32.x >> 16);
|
||||
*(uint16_t*)&_buffer[3] = (uint16_t)hph_i32.y;
|
||||
*(uint8_t*)&_buffer[5] = (uint8_t)(hph_i32.y >> 16);
|
||||
_buffer += 6;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (size_t i = samples_count; i; i--, _mix_buffer++) {
|
||||
int32_t spk_l = (int32_t)(_mix_buffer->spk_l * spk_l_volume * (float_t)0x7FFFFF);
|
||||
int32_t spk_r = (int32_t)(_mix_buffer->spk_r * spk_r_volume * (float_t)0x7FFFFF);
|
||||
int32_t hph_l = (int32_t)(_mix_buffer->hph_l * hph_l_volume * (float_t)0x7FFFFF);
|
||||
int32_t hph_r = (int32_t)(_mix_buffer->hph_r * hph_r_volume * (float_t)0x7FFFFF);
|
||||
spk_l = clamp_def(spk_l, -0x800000, 0x7FFFFF);
|
||||
spk_r = clamp_def(spk_r, -0x800000, 0x7FFFFF);
|
||||
hph_l = clamp_def(hph_l, -0x800000, 0x7FFFFF);
|
||||
hph_r = clamp_def(hph_r, -0x800000, 0x7FFFFF);
|
||||
*(uint16_t*)&_buffer[0] = (uint16_t)spk_l;
|
||||
*(uint8_t*)&_buffer[2] = (uint8_t)(spk_l >> 16);
|
||||
*(uint16_t*)&_buffer[3] = (uint16_t)spk_r;
|
||||
*(uint8_t*)&_buffer[5] = (uint8_t)(spk_r >> 16);
|
||||
*(uint16_t*)&_buffer[6] = (uint16_t)hph_l;
|
||||
*(uint8_t*)&_buffer[8] = (uint8_t)(hph_l >> 16);
|
||||
*(uint16_t*)&_buffer[9] = (uint16_t)hph_r;
|
||||
*(uint8_t*)&_buffer[11] = (uint8_t)(hph_r >> 16);
|
||||
vec4 spk_hph = *(vec4*)_mix_buffer * spk_hph_volume * (float_t)0x7FFFFF;
|
||||
vec4i spk_hph_i32;
|
||||
vec4_to_vec4i(spk_hph, spk_hph_i32);
|
||||
spk_hph_i32 = vec4i::clamp(spk_hph_i32, -0x800000, 0x7FFFFF);
|
||||
*(uint16_t*)&_buffer[0] = (uint16_t)spk_hph_i32.x;
|
||||
*(uint8_t*)&_buffer[2] = (uint8_t)(spk_hph_i32.x >> 16);
|
||||
*(uint16_t*)&_buffer[3] = (uint16_t)spk_hph_i32.y;
|
||||
*(uint8_t*)&_buffer[5] = (uint8_t)(spk_hph_i32.y >> 16);
|
||||
*(uint16_t*)&_buffer[6] = (uint16_t)spk_hph_i32.z;
|
||||
*(uint8_t*)&_buffer[8] = (uint8_t)(spk_hph_i32.z >> 16);
|
||||
*(uint16_t*)&_buffer[9] = (uint16_t)spk_hph_i32.w;
|
||||
*(uint8_t*)&_buffer[11] = (uint8_t)(spk_hph_i32.w >> 16);
|
||||
_buffer += 12;
|
||||
}
|
||||
break;
|
||||
@@ -420,18 +440,20 @@ namespace sound {
|
||||
switch (system->channels) {
|
||||
case 2:
|
||||
for (size_t i = samples_count; i; i--, _mix_buffer++) {
|
||||
int64_t hph_l = (int64_t)((double_t)_mix_buffer->hph_l * hph_l_volume * (double_t)0x7FFFFFFF);
|
||||
int64_t hph_r = (int64_t)((double_t)_mix_buffer->hph_r * hph_r_volume * (double_t)0x7FFFFFFF);
|
||||
vec2 hph = *(vec2*)&_mix_buffer->hph_l * *(vec2*)&spk_hph_volume.z;
|
||||
int64_t hph_l = (int64_t)((double_t)hph.x * (double_t)0x7FFFFFFF);
|
||||
int64_t hph_r = (int64_t)((double_t)hph.y * (double_t)0x7FFFFFFF);
|
||||
*_buffer++ = (int32_t)clamp_def(hph_l, -0x80000000LL, 0x7FFFFFFFLL);
|
||||
*_buffer++ = (int32_t)clamp_def(hph_r, -0x80000000LL, 0x7FFFFFFFLL);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (size_t i = samples_count; i; i--, _mix_buffer++) {
|
||||
int64_t spk_l = (int64_t)((double_t)_mix_buffer->spk_l * spk_l_volume * (double_t)0x7FFFFFFF);
|
||||
int64_t spk_r = (int64_t)((double_t)_mix_buffer->spk_r * spk_r_volume * (double_t)0x7FFFFFFF);
|
||||
int64_t hph_l = (int64_t)((double_t)_mix_buffer->hph_l * hph_l_volume * (double_t)0x7FFFFFFF);
|
||||
int64_t hph_r = (int64_t)((double_t)_mix_buffer->hph_r * hph_r_volume * (double_t)0x7FFFFFFF);
|
||||
vec4 spk_hph = *(vec4*)_mix_buffer * spk_hph_volume;
|
||||
int64_t spk_l = (int64_t)((double_t)spk_hph.x * (double_t)0x7FFFFFFF);
|
||||
int64_t spk_r = (int64_t)((double_t)spk_hph.y * (double_t)0x7FFFFFFF);
|
||||
int64_t hph_l = (int64_t)((double_t)spk_hph.z * (double_t)0x7FFFFFFF);
|
||||
int64_t hph_r = (int64_t)((double_t)spk_hph.w * (double_t)0x7FFFFFFF);
|
||||
*_buffer++ = (int32_t)clamp_def(spk_l, -0x80000000LL, 0x7FFFFFFFLL);
|
||||
*_buffer++ = (int32_t)clamp_def(spk_r, -0x80000000LL, 0x7FFFFFFFLL);
|
||||
*_buffer++ = (int32_t)clamp_def(hph_l, -0x80000000LL, 0x7FFFFFFFLL);
|
||||
@@ -444,18 +466,12 @@ namespace sound {
|
||||
float_t* _buffer = (float_t*)buffer;
|
||||
switch (system->channels) {
|
||||
case 2:
|
||||
for (size_t i = samples_count; i; i--, _mix_buffer++) {
|
||||
*_buffer++ = _mix_buffer->hph_l * hph_l_volume;
|
||||
*_buffer++ = _mix_buffer->hph_r * hph_r_volume;
|
||||
}
|
||||
for (size_t i = samples_count; i; i--, _mix_buffer++, _buffer += 2)
|
||||
*(vec2*)_buffer = *(vec2*)&_mix_buffer->hph_l * *(vec2*)&spk_hph_volume.z;
|
||||
break;
|
||||
case 4:
|
||||
for (size_t i = samples_count; i; i--, _mix_buffer++) {
|
||||
*_buffer++ = _mix_buffer->spk_l * spk_l_volume;
|
||||
*_buffer++ = _mix_buffer->spk_r * spk_r_volume;
|
||||
*_buffer++ = _mix_buffer->hph_l * hph_l_volume;
|
||||
*_buffer++ = _mix_buffer->hph_r * hph_r_volume;
|
||||
}
|
||||
for (size_t i = samples_count; i; i--, _mix_buffer++, _buffer += 4)
|
||||
*(vec4*)_buffer = *(vec4*)&_mix_buffer * spk_hph_volume;
|
||||
break;
|
||||
}
|
||||
} break;
|
||||
@@ -578,36 +594,43 @@ namespace sound {
|
||||
|
||||
vec4 channels_volume(spk_l_volume, spk_r_volume, hph_l_volume, hph_r_volume);
|
||||
|
||||
float_t* se_buffer = this->buffer;
|
||||
size_t _samples_count = this->samples_count;
|
||||
size_t loop_start = this->loop_start;
|
||||
size_t loop_end = this->loop_end;
|
||||
size_t current_sample = this->current_sample;
|
||||
bool loop = !!(loop_start || loop_end);
|
||||
if (channels == 1)
|
||||
for (size_t i = samples_count; i && current_sample < _samples_count; i--, buffer++) {
|
||||
float_t* _buffer = this->buffer + current_sample;
|
||||
float_t* _buffer = se_buffer + current_sample;
|
||||
*(vec4*)buffer = channels_volume * _buffer[0] + *(vec4*)buffer;
|
||||
|
||||
current_sample++;
|
||||
if ((loop_start || loop_end) && current_sample > loop_end)
|
||||
if (loop && current_sample > loop_end)
|
||||
current_sample = loop_start;
|
||||
}
|
||||
if (channels == 2)
|
||||
else if (channels == 2)
|
||||
for (size_t i = samples_count; i && current_sample < _samples_count; i--, buffer++) {
|
||||
float_t* _buffer = this->buffer + current_sample * 2;
|
||||
float_t* _buffer = se_buffer + current_sample * 2;
|
||||
*(vec4*)buffer = channels_volume * vec4(_buffer[0], _buffer[1],
|
||||
_buffer[0], _buffer[1]) + *(vec4*)buffer;
|
||||
|
||||
current_sample++;
|
||||
if ((loop_start || loop_end) && current_sample > loop_end)
|
||||
if (loop && current_sample > loop_end)
|
||||
current_sample = loop_start;
|
||||
}
|
||||
else if (channels == 4)
|
||||
for (size_t i = samples_count; i && current_sample < _samples_count; i--, buffer++) {
|
||||
float_t* _buffer = this->buffer + current_sample * 4;
|
||||
float_t* _buffer = se_buffer + current_sample * 4;
|
||||
*(vec4*)buffer = channels_volume * *(vec4*)_buffer + *(vec4*)buffer;
|
||||
|
||||
current_sample++;
|
||||
if ((loop_start || loop_end) && current_sample > loop_end)
|
||||
if (loop && current_sample > loop_end)
|
||||
current_sample = loop_start;
|
||||
}
|
||||
|
||||
this->current_sample = current_sample;
|
||||
|
||||
if (current_sample >= _samples_count)
|
||||
ResetData();
|
||||
}
|
||||
@@ -677,7 +700,7 @@ namespace sound {
|
||||
loop_end = 0;
|
||||
current_sample = 0;
|
||||
}
|
||||
|
||||
|
||||
void SEChannel::ResetDataProt() {
|
||||
if (!play_state.get())
|
||||
return;
|
||||
@@ -743,7 +766,14 @@ namespace sound {
|
||||
vec4 channels_volume(spk_l_volume, spk_r_volume, hph_l_volume, hph_r_volume);
|
||||
|
||||
sound_buffer_data* _buffer = this->buffer;
|
||||
for (size_t i = samples_count; i; i--, buffer++, _buffer++)
|
||||
for (size_t i = samples_count / 4; i; i--, buffer += 4, _buffer += 4) {
|
||||
((vec4*)buffer)[0] = channels_volume * ((vec4*)_buffer)[0] + ((vec4*)buffer)[0];
|
||||
((vec4*)buffer)[1] = channels_volume * ((vec4*)_buffer)[1] + ((vec4*)buffer)[1];
|
||||
((vec4*)buffer)[2] = channels_volume * ((vec4*)_buffer)[2] + ((vec4*)buffer)[2];
|
||||
((vec4*)buffer)[3] = channels_volume * ((vec4*)_buffer)[3] + ((vec4*)buffer)[3];
|
||||
}
|
||||
|
||||
for (size_t i = samples_count % 4; i; i--, buffer++, _buffer++)
|
||||
*(vec4*)buffer = channels_volume * *(vec4*)_buffer + *(vec4*)buffer;
|
||||
}
|
||||
|
||||
@@ -1192,9 +1222,25 @@ bool WaveAudio::Read(sound_db_farc* farc, const char* file_name) {
|
||||
float_t* buffer = this->buffer;
|
||||
size_t channels = data.channels;
|
||||
size_t samples_count = data.samples_count;
|
||||
for (size_t i = samples_count; i; i--)
|
||||
for (size_t j = channels; j; j--)
|
||||
*buffer++ = (float_t)*_buf++ * (float_t)(1.0 / (double_t)0x7FFF);
|
||||
if (channels == 1)
|
||||
for (size_t i = samples_count; i; i--, buffer++, _buf++)
|
||||
*buffer = (float_t)*_buf * (float_t)(1.0 / (double_t)0x7FFF);
|
||||
else if (channels == 2)
|
||||
for (size_t i = samples_count; i; i--, buffer += 2, _buf += 2) {
|
||||
vec2 value;
|
||||
vec2i16_to_vec2(*(vec2i16*)_buf, value);
|
||||
*(vec2*)buffer = value * (float_t)(1.0 / (double_t)0x7FFF);
|
||||
}
|
||||
else if (channels == 4)
|
||||
for (size_t i = samples_count; i; i--, buffer += 4, _buf += 4) {
|
||||
vec4 value;
|
||||
vec4i16_to_vec4(*(vec4i16*)_buf, value);
|
||||
*(vec4*)buffer = value * (float_t)(1.0 / (double_t)0x7FFF);
|
||||
}
|
||||
else
|
||||
for (size_t i = samples_count; i; i--)
|
||||
for (size_t j = channels; j; j--, buffer++, _buf++)
|
||||
*buffer++ = (float_t)*_buf++ * (float_t)(1.0 / (double_t)0x7FFF);
|
||||
|
||||
free(buf);
|
||||
ret = true;
|
||||
@@ -1216,7 +1262,7 @@ void WaveAudio::Reset() {
|
||||
data.Reset();
|
||||
}
|
||||
|
||||
SoundWork::SoundWork() : se_queue_enable(), streaming_enable(), se_queue_volume() {
|
||||
SoundWork::SoundWork() : se_queue_enable(), stream_enable(), se_queue_volume() {
|
||||
counter = 1;
|
||||
speakers_volume = get_max_speakers_volume();
|
||||
speakers_volume_changed = true;
|
||||
@@ -1227,7 +1273,7 @@ SoundWork::SoundWork() : se_queue_enable(), streaming_enable(), se_queue_volume(
|
||||
for (bool& i : se_queue_enable)
|
||||
i = true;
|
||||
|
||||
for (bool& i : streaming_enable)
|
||||
for (bool& i : stream_enable)
|
||||
i = true;
|
||||
|
||||
for (int32_t i = 0; i < SOUND_WORK_SE_QUEUE_COUNT; i++)
|
||||
@@ -1319,19 +1365,27 @@ bool SoundWork::UnloadProperty(const char* file_path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
extern float_t get_min_headphones_volume() {
|
||||
sound_stream_info::sound_stream_info() : duration(), time() {
|
||||
|
||||
}
|
||||
|
||||
sound_stream_info::~sound_stream_info() {
|
||||
|
||||
}
|
||||
|
||||
float_t get_min_headphones_volume() {
|
||||
return 1.0f;//0.02f;
|
||||
}
|
||||
|
||||
extern float_t get_max_headphones_volume() {
|
||||
float_t get_max_headphones_volume() {
|
||||
return 0.45f;
|
||||
}
|
||||
|
||||
extern float_t get_min_speakers_volume() {
|
||||
float_t get_min_speakers_volume() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
extern float_t get_max_speakers_volume() {
|
||||
float_t get_max_speakers_volume() {
|
||||
return 0.8f;
|
||||
}
|
||||
|
||||
@@ -1374,7 +1428,7 @@ void sound_init() {
|
||||
|
||||
PropVariantInit(&pv);
|
||||
if (SUCCEEDED(store->GetValue(PKEY_Device_FriendlyName, &pv)))
|
||||
printf("%ls\n", pv.pwszVal);
|
||||
printf_debug("%ls\n", pv.pwszVal);
|
||||
PropVariantClear(&pv);
|
||||
|
||||
store->Release();
|
||||
@@ -1391,7 +1445,7 @@ void sound_init() {
|
||||
|
||||
if (!sound_work)
|
||||
sound_work = new SoundWork;
|
||||
|
||||
|
||||
if (!sound_wasapi_system_data)
|
||||
sound_wasapi_system_data = new sound::wasapi::System;
|
||||
|
||||
@@ -1426,7 +1480,7 @@ void sound_init() {
|
||||
}
|
||||
}
|
||||
|
||||
//sub_140622E00();
|
||||
sound_stream_array_init();
|
||||
}
|
||||
|
||||
void sound_ctrl() {
|
||||
@@ -1462,12 +1516,14 @@ void sound_ctrl() {
|
||||
i.ReleaseProt(true);
|
||||
}
|
||||
|
||||
//sub_140622AD0();
|
||||
sound_stream_array_ctrl();
|
||||
|
||||
sound_work->names_list.clear();
|
||||
}
|
||||
|
||||
void sound_free() {
|
||||
sound_stream_array_free();
|
||||
|
||||
if (sound_work) {
|
||||
delete sound_work;
|
||||
sound_work = 0;
|
||||
@@ -1479,25 +1535,18 @@ void sound_free() {
|
||||
}
|
||||
}
|
||||
|
||||
bool sound_work_cue_can_play(int32_t queue_index, const char* name) {
|
||||
if (!name)
|
||||
bool sound_work_check_stream_state(int32_t index) {
|
||||
if (index < 0 || index >= SOUND_WORK_STREAM_COUNT || !sound_work->stream_enable[index])
|
||||
return false;
|
||||
|
||||
SoundCue* cue = sound_work_get_cue(queue_index, name);
|
||||
if (cue)
|
||||
return cue->CanPlay();
|
||||
return false;
|
||||
sound_stream* stream = sound_stream_array_get(index);
|
||||
if (!stream)
|
||||
return false;
|
||||
|
||||
return stream->check_state();
|
||||
}
|
||||
|
||||
SoundCue* sound_work_get_cue(int32_t queue_index, const char* name) {
|
||||
for (SoundCue& i : sound_work->cues)
|
||||
if ((!i.se_channel || i.property) && i.queue_index == queue_index
|
||||
&& !i.name.compare(name))
|
||||
return &i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool sound_work_get_cue_release(int32_t queue_index, const char* name, bool force_release) {
|
||||
bool sound_work_cue_release(int32_t queue_index, const char* name, bool force_release) {
|
||||
if (!name)
|
||||
return false;
|
||||
|
||||
@@ -1509,6 +1558,24 @@ bool sound_work_get_cue_release(int32_t queue_index, const char* name, bool forc
|
||||
return false;
|
||||
}
|
||||
|
||||
SoundCue* sound_work_get_cue(int32_t queue_index, const char* name) {
|
||||
for (SoundCue& i : sound_work->cues)
|
||||
if ((!i.se_channel || i.property) && i.queue_index == queue_index
|
||||
&& !i.name.compare(name))
|
||||
return &i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool sound_work_get_cue_can_play(int32_t queue_index, const char* name) {
|
||||
if (!name)
|
||||
return false;
|
||||
|
||||
SoundCue* cue = sound_work_get_cue(queue_index, name);
|
||||
if (cue)
|
||||
return cue->CanPlay();
|
||||
return false;
|
||||
}
|
||||
|
||||
sound_db_farc* sound_work_get_farc(const char* file_path) {
|
||||
for (sound_db_farc& i : sound_work->farcs)
|
||||
if (!i.file_path.compare(file_path))
|
||||
@@ -1516,6 +1583,31 @@ sound_db_farc* sound_work_get_farc(const char* file_path) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool sound_work_get_stream_info(sound_stream_info& info, int32_t index) {
|
||||
if (index < 0 || index >= SOUND_WORK_STREAM_COUNT || !sound_work->stream_enable[index])
|
||||
return false;
|
||||
|
||||
sound_stream* stream = sound_stream_array_get(index);
|
||||
if (!stream)
|
||||
return false;
|
||||
|
||||
info.duration = stream->duration;
|
||||
info.time = stream->time;
|
||||
info.path.assign(stream->path);
|
||||
return true;
|
||||
}
|
||||
|
||||
float_t sound_work_get_stream_volume(int32_t index) {
|
||||
if (index < 0 || index >= SOUND_WORK_STREAM_COUNT || !sound_work->stream_enable[index])
|
||||
return false;
|
||||
|
||||
sound_stream* stream = sound_stream_array_get(index);
|
||||
if (!stream)
|
||||
return 1.0f;
|
||||
|
||||
return stream->current_volume;
|
||||
}
|
||||
|
||||
float_t sound_work_get_headphones_volume() {
|
||||
return sound_work->headphones_volume;
|
||||
}
|
||||
@@ -1592,6 +1684,28 @@ int32_t sound_work_play_se(int32_t queue_index, const char* name, float_t volume
|
||||
return counter;
|
||||
}
|
||||
|
||||
bool sound_work_play_stream(int32_t index, const char* path, bool pause) {
|
||||
if (index < 0 || index >= SOUND_WORK_STREAM_COUNT || !sound_work->stream_enable[index])
|
||||
return false;
|
||||
|
||||
sound_stream* stream = sound_stream_array_get(index);
|
||||
if (!stream)
|
||||
return false;
|
||||
|
||||
return stream->set_path(path, pause);
|
||||
}
|
||||
|
||||
bool sound_work_play_stream(int32_t index, const char* path, float_t time, bool pause) {
|
||||
if (index < 0 || index >= SOUND_WORK_STREAM_COUNT || !sound_work->stream_enable[index])
|
||||
return false;
|
||||
|
||||
sound_stream* stream = sound_stream_array_get(index);
|
||||
if (!stream)
|
||||
return false;
|
||||
|
||||
return stream->set_path(path, time, pause);
|
||||
}
|
||||
|
||||
bool sound_work_read_farc(const char* file_path) {
|
||||
if (!file_path || sound_work_get_farc(file_path))
|
||||
return false;
|
||||
@@ -1638,6 +1752,28 @@ bool sound_work_release_se(const char* name, bool release) {
|
||||
return found;
|
||||
}
|
||||
|
||||
bool sound_work_release_stream(int32_t index) {
|
||||
if (index < 0 || index >= SOUND_WORK_STREAM_COUNT || !sound_work->stream_enable[index])
|
||||
return false;
|
||||
|
||||
sound_stream* stream = sound_stream_array_get(index);
|
||||
if (!stream)
|
||||
return false;
|
||||
|
||||
return stream->stop();
|
||||
}
|
||||
|
||||
bool sound_work_stream_set_pause(int32_t index, bool value) {
|
||||
if (index < 0 || index >= SOUND_WORK_STREAM_COUNT || !sound_work->stream_enable[index])
|
||||
return false;
|
||||
|
||||
sound_stream* stream = sound_stream_array_get(index);
|
||||
if (!stream)
|
||||
return false;
|
||||
|
||||
return stream->set_pause(value);
|
||||
}
|
||||
|
||||
float_t sound_cue_queue_volume_array_get_max(int32_t queue_index) {
|
||||
if (queue_index >= 0 && queue_index < SOUND_WORK_SE_QUEUE_COUNT)
|
||||
return sound_cue_queue_volume_array[queue_index].max;
|
||||
@@ -1682,6 +1818,30 @@ void sound_work_set_speakers_volume(float_t value) {
|
||||
}
|
||||
}
|
||||
|
||||
bool sound_work_set_stream_current_volume(int32_t index, float_t value) {
|
||||
if (index < 0 || index >= SOUND_WORK_STREAM_COUNT || !sound_work->stream_enable[index])
|
||||
return false;
|
||||
|
||||
sound_stream* stream = sound_stream_array_get(index);
|
||||
if (!stream)
|
||||
return false;
|
||||
|
||||
stream->set_current_volume(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool sound_work_set_stream_target_volume(int32_t index, float_t value, int32_t frames) {
|
||||
if (index < 0 || index >= SOUND_WORK_STREAM_COUNT || !sound_work->stream_enable[index])
|
||||
return false;
|
||||
|
||||
sound_stream* stream = sound_stream_array_get(index);
|
||||
if (!stream)
|
||||
return false;
|
||||
|
||||
stream->set_target_volume(value, frames);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool sound_work_unload_farc(const char* file_path) {
|
||||
if (!file_path)
|
||||
return false;
|
||||
@@ -1693,16 +1853,16 @@ bool sound_work_unload_farc(const char* file_path) {
|
||||
}
|
||||
|
||||
void wave_audio_storage_init() {
|
||||
wave_audio_storage = {};
|
||||
wave_audio_storage_data = {};
|
||||
}
|
||||
|
||||
void wave_audio_storage_clear() {
|
||||
wave_audio_storage.clear();
|
||||
wave_audio_storage_data.clear();
|
||||
}
|
||||
|
||||
WaveAudio* wave_audio_storage_get_wave_audio(std::string& name) {
|
||||
auto elem = wave_audio_storage.find(name);
|
||||
if (elem != wave_audio_storage.end())
|
||||
auto elem = wave_audio_storage_data.find(name);
|
||||
if (elem != wave_audio_storage_data.end())
|
||||
return &elem->second;
|
||||
return 0;
|
||||
}
|
||||
@@ -1716,22 +1876,22 @@ bool wave_audio_storage_load_wave_audio(std::string& name) {
|
||||
|
||||
WaveAudio wave_audio;
|
||||
if (wave_audio.Read(property->farc, property->file_name.c_str())) {
|
||||
wave_audio_storage.insert({ name, wave_audio });
|
||||
wave_audio_storage_data.insert({ name, wave_audio });
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void wave_audio_storage_unload_wave_audio(std::string& name) {
|
||||
auto elem = wave_audio_storage.find(name);
|
||||
if (elem != wave_audio_storage.end()) {
|
||||
auto elem = wave_audio_storage_data.find(name);
|
||||
if (elem != wave_audio_storage_data.end()) {
|
||||
elem->second.Reset();
|
||||
wave_audio_storage.erase(elem);
|
||||
wave_audio_storage_data.erase(elem);
|
||||
}
|
||||
}
|
||||
|
||||
void wave_audio_storage_free() {
|
||||
wave_audio_storage.clear();
|
||||
wave_audio_storage_data.clear();
|
||||
}
|
||||
|
||||
static size_t ima_decode(int16_t* dst, size_t dst_size, uint8_t* data, size_t samples_count,
|
||||
@@ -1772,4 +1932,220 @@ static size_t ima_decode(int16_t* dst, size_t dst_size, uint8_t* data, size_t sa
|
||||
}
|
||||
}
|
||||
return act_samp_count;
|
||||
}
|
||||
}
|
||||
|
||||
sound_stream::sound_stream() : ogg_playback(), duration(), pause(), file_loading_frames(),
|
||||
file_ready_frames(), time_seek(), volume_trans(), state(), play_state(), time() {
|
||||
current_volume = 1.0f;
|
||||
target_volume = 1.0f;
|
||||
}
|
||||
|
||||
sound_stream::~sound_stream() {
|
||||
|
||||
}
|
||||
|
||||
bool sound_stream::check_state() {
|
||||
if (play_state == 1)
|
||||
return true;
|
||||
return state == 1;
|
||||
}
|
||||
|
||||
void sound_stream::ctrl() {
|
||||
if (!check_state())
|
||||
return;
|
||||
|
||||
if (play_state == 1 && volume_trans > 0) {
|
||||
current_volume += (target_volume - current_volume) / (float_t)volume_trans;
|
||||
volume_trans--;
|
||||
}
|
||||
|
||||
if (path.size() < 4)
|
||||
return;
|
||||
|
||||
std::string ext;
|
||||
ext.assign(path.c_str() + (path.size() - 4), 4);
|
||||
for (char& c : ext)
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
c += 0x20;
|
||||
|
||||
if (ext.compare(".ogg"))
|
||||
return;
|
||||
|
||||
if (!ogg_playback) {
|
||||
size_t index = 0;
|
||||
for (size_t i = 0; i < SOUND_WORK_STREAM_COUNT; i++)
|
||||
if (&sound_stream_array[i] == this) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
|
||||
ogg_playback = ogg_playback_data_get(index);
|
||||
}
|
||||
|
||||
if (ogg_playback)
|
||||
ctrl_playback();
|
||||
}
|
||||
|
||||
void sound_stream::ctrl_playback() {
|
||||
OggFileHandlerFileState file_state = OGG_FILE_HANDLER_FILE_STATE_NONE;
|
||||
if (ogg_playback) {
|
||||
file_state = ogg_playback->GetFileState();
|
||||
ogg_playback->SetMasterVolume(ratio_to_db(current_volume));
|
||||
}
|
||||
|
||||
duration = 0.0f;
|
||||
time = 0.0f;
|
||||
play_state = 0;
|
||||
|
||||
if (file_state == OGG_FILE_HANDLER_FILE_STATE_NONE
|
||||
|| (file_state >= OGG_FILE_HANDLER_FILE_STATE_STOPPED
|
||||
&& file_state <= OGG_FILE_HANDLER_FILE_STATE_MAX)) {
|
||||
play_state = 0;
|
||||
file_loading_frames = 0;
|
||||
file_ready_frames = 0;
|
||||
duration = 0.0f;
|
||||
time = 0.0f;
|
||||
if (state != 1) {
|
||||
state = 0;
|
||||
stop_playback();
|
||||
}
|
||||
else if (set_path_playback()) {
|
||||
play_state = 1;
|
||||
state = 0;
|
||||
}
|
||||
else
|
||||
stop_playback();
|
||||
}
|
||||
else if (file_state >= OGG_FILE_HANDLER_FILE_STATE_LOADING
|
||||
&& file_state <= OGG_FILE_HANDLER_FILE_STATE_STOPPING) {
|
||||
play_state = 1;
|
||||
if (ogg_playback) {
|
||||
if (ogg_playback->GetPauseState() == OGG_FILE_HANDLER_PAUSE_STATE_PLAY) {
|
||||
file_loading_frames += file_state == OGG_FILE_HANDLER_FILE_STATE_LOADING;
|
||||
file_ready_frames += file_state == OGG_FILE_HANDLER_FILE_STATE_READY;
|
||||
}
|
||||
float_t _duration = ogg_playback->GetDuration();
|
||||
float_t _time = ogg_playback->GetTime();
|
||||
duration = _duration;
|
||||
if (_duration > 0.0f && _time > _duration)
|
||||
do
|
||||
_time -= _duration;
|
||||
while (_time > _duration);
|
||||
time = _time;
|
||||
}
|
||||
|
||||
if (state)
|
||||
stop_playback();
|
||||
}
|
||||
|
||||
OggPlayback::SetChannelPairVolumePan(ogg_playback);
|
||||
}
|
||||
|
||||
void sound_stream::reset() {
|
||||
state = 0;
|
||||
play_state = 0;
|
||||
}
|
||||
|
||||
void sound_stream::set_current_volume(float_t value) {
|
||||
current_volume = clamp_def(value, 0.0f, 1.0f);
|
||||
volume_trans = 0;
|
||||
}
|
||||
|
||||
bool sound_stream::set_path(const char* path, bool pause) {
|
||||
if (!pause) {
|
||||
bool paused = false;
|
||||
if (ogg_playback)
|
||||
paused = ogg_playback->GetPauseState() == OGG_FILE_HANDLER_PAUSE_STATE_PAUSE;
|
||||
|
||||
if (!(this->path.compare(path) || !check_state() || !paused)) {
|
||||
if (ogg_playback)
|
||||
ogg_playback->SetPauseState(OGG_FILE_HANDLER_PAUSE_STATE_PLAY);
|
||||
pause = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
this->path.assign(path);
|
||||
state = 1;
|
||||
this->pause = pause;
|
||||
current_volume = sound_stream_volume;
|
||||
time_seek = 0.0f;
|
||||
volume_trans = 0;
|
||||
target_volume = sound_stream_volume;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool sound_stream::set_path(const char* path, float_t time, bool pause) {
|
||||
bool res = set_path(path, pause);
|
||||
if (res)
|
||||
time_seek = time;
|
||||
return res;
|
||||
}
|
||||
|
||||
bool sound_stream::set_path_playback() {
|
||||
if (!ogg_playback)
|
||||
return false;
|
||||
|
||||
ogg_playback->SetPauseState(pause
|
||||
? OGG_FILE_HANDLER_PAUSE_STATE_PAUSE : OGG_FILE_HANDLER_PAUSE_STATE_PLAY);
|
||||
ogg_playback->SetTimeSeek(time_seek);
|
||||
ogg_playback->SetPath(path);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool sound_stream::set_pause(bool value) {
|
||||
if (!ogg_playback)
|
||||
return false;
|
||||
|
||||
pause = value;
|
||||
ogg_playback->SetPauseState(value
|
||||
? OGG_FILE_HANDLER_PAUSE_STATE_PAUSE : OGG_FILE_HANDLER_PAUSE_STATE_PLAY);
|
||||
return true;
|
||||
}
|
||||
|
||||
void sound_stream::set_target_volume(float_t value, int32_t frames) {
|
||||
target_volume = value;
|
||||
volume_trans = max_def(frames, 1);
|
||||
}
|
||||
|
||||
bool sound_stream::stop() {
|
||||
state = 2;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool sound_stream::stop_playback() {
|
||||
if (!ogg_playback)
|
||||
return false;
|
||||
|
||||
ogg_playback->SetPlaybackState(OGG_FILE_HANDLER_PLAYBACK_STATE_STOP);
|
||||
ogg_playback->SetPauseState(OGG_FILE_HANDLER_PAUSE_STATE_PLAY);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void sound_stream_array_init() {
|
||||
if (!sound_stream_array)
|
||||
sound_stream_array = new sound_stream[SOUND_WORK_STREAM_COUNT];
|
||||
}
|
||||
|
||||
static void sound_stream_array_ctrl() {
|
||||
for (size_t i = 0; i < SOUND_WORK_STREAM_COUNT; i++)
|
||||
sound_stream_array[i].ctrl();
|
||||
}
|
||||
|
||||
static sound_stream* sound_stream_array_get(int32_t index) {
|
||||
if (index >= 0 && index < SOUND_WORK_STREAM_COUNT)
|
||||
return &sound_stream_array[index];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sound_stream_array_reset() {
|
||||
for (size_t i = 0; i < SOUND_WORK_STREAM_COUNT; i++)
|
||||
sound_stream_array[i].reset();
|
||||
}
|
||||
|
||||
static void sound_stream_array_free() {
|
||||
if (sound_stream_array) {
|
||||
delete[] sound_stream_array;
|
||||
sound_stream_array = 0;
|
||||
}
|
||||
}
|
||||
|
||||
+21
-2
@@ -285,7 +285,7 @@ struct WaveAudio {
|
||||
};
|
||||
|
||||
#define SOUND_WORK_SE_QUEUE_COUNT 5
|
||||
#define SOUND_WORK_STREAMING_COUNT 3
|
||||
#define SOUND_WORK_STREAM_COUNT 3
|
||||
|
||||
struct SoundWork {
|
||||
std::map<std::string, sound_db_property> properties;
|
||||
@@ -294,7 +294,7 @@ struct SoundWork {
|
||||
int32_t counter;
|
||||
std::vector<std::string> names_list;
|
||||
bool se_queue_enable[SOUND_WORK_SE_QUEUE_COUNT];
|
||||
bool streaming_enable[SOUND_WORK_STREAMING_COUNT];
|
||||
bool stream_enable[SOUND_WORK_STREAM_COUNT];
|
||||
float_t speakers_volume;
|
||||
bool speakers_volume_changed;
|
||||
float_t headphones_volume;
|
||||
@@ -310,8 +310,18 @@ struct SoundWork {
|
||||
bool UnloadProperty(const char* file_path);
|
||||
};
|
||||
|
||||
struct sound_stream_info {
|
||||
float_t duration;
|
||||
float_t time;
|
||||
std::string path;
|
||||
|
||||
sound_stream_info();
|
||||
~sound_stream_info();
|
||||
};
|
||||
|
||||
extern float_t get_min_headphones_volume();
|
||||
extern float_t get_max_headphones_volume();
|
||||
extern float_t get_min_speakers_volume();
|
||||
extern float_t get_max_speakers_volume();
|
||||
|
||||
extern float_t db_to_ratio(int32_t value);
|
||||
@@ -324,24 +334,33 @@ extern void sound_free();
|
||||
extern float_t sound_cue_queue_volume_array_get_max(int32_t queue_index);
|
||||
extern float_t sound_cue_queue_volume_array_get_min(int32_t queue_index);
|
||||
|
||||
extern bool sound_work_check_stream_state(int32_t index);
|
||||
extern bool sound_work_cue_release(int32_t queue_index, const char* name, bool force_release = true);
|
||||
extern SoundCue* sound_work_get_cue(int32_t queue_index, const char* name);
|
||||
extern bool sound_work_get_cue_can_play(int32_t queue_index, const char* name);
|
||||
extern sound_db_farc* sound_work_get_farc(const char* file_path);
|
||||
extern bool sound_work_get_stream_info(sound_stream_info& info, int32_t index);
|
||||
extern float_t sound_work_get_stream_volume(int32_t index);
|
||||
extern float_t sound_work_get_headphones_volume();
|
||||
extern float_t sound_work_get_speakers_volume();
|
||||
extern bool sound_work_has_property(const char* name);
|
||||
extern bool sound_work_load_farc(const char* file_path);
|
||||
extern int32_t sound_work_play_se(int32_t queue_index, const char* name, float_t volume);
|
||||
extern bool sound_work_play_stream(int32_t index, const char* path, bool pause = false);
|
||||
extern bool sound_work_play_stream(int32_t index, const char* path, float_t time, bool pause = false);
|
||||
extern bool sound_work_read_farc(const char* file_path);
|
||||
extern void sound_work_release_farc_se(const char* file_path);
|
||||
extern bool sound_work_release_se(const char* name, bool force_release = true);
|
||||
extern bool sound_work_release_stream(int32_t index);
|
||||
extern bool sound_work_stream_set_pause(int32_t index, bool value);
|
||||
extern float_t sound_cue_queue_volume_array_get_max(int32_t queue_index);
|
||||
extern float_t sound_cue_queue_volume_array_get_min(int32_t queue_index);
|
||||
extern sound::wasapi::System* sound_wasapi_system_data_get();
|
||||
extern void sound_work_set_headphones_volume(float_t value);
|
||||
extern void sound_work_set_se_queue_volume(int32_t queue_index, float_t value);
|
||||
extern void sound_work_set_speakers_volume(float_t value);
|
||||
extern bool sound_work_set_stream_current_volume(int32_t index, float_t value);
|
||||
extern bool sound_work_set_stream_target_volume(int32_t index, float_t value, int32_t frames);
|
||||
extern bool sound_work_unload_farc(const char* file_path);
|
||||
|
||||
extern void wave_audio_storage_init();
|
||||
|
||||
+85
-88
@@ -11,6 +11,7 @@
|
||||
#include "draw_task.hpp"
|
||||
#include "light_param.hpp"
|
||||
#include "render_context.hpp"
|
||||
#include "task_effect.hpp"
|
||||
|
||||
namespace stage_detail {
|
||||
static void TaskStage_CtrlInner(stage_detail::TaskStage* a1);
|
||||
@@ -23,7 +24,8 @@ namespace stage_detail {
|
||||
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_Load(stage_detail::TaskStage* a1);
|
||||
static bool TaskStage_LoadTask(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);
|
||||
@@ -117,11 +119,11 @@ void task_stage_current_set_sky(bool value) {
|
||||
task_stage_set_sky(&stg_info, value);
|
||||
}
|
||||
|
||||
void task_stage_current_set_stage_display(bool value) {
|
||||
void task_stage_current_set_stage_display(bool value, bool effect_enable) {
|
||||
task_stage_info stg_info;
|
||||
task_stage_get_current_stage_info(&stg_info);
|
||||
if (task_stage_has_stage_info(&stg_info))
|
||||
task_stage_set_stage_display(&stg_info, value);
|
||||
task_stage_set_stage_display(&stg_info, value, effect_enable);
|
||||
}
|
||||
|
||||
void task_stage_disp_shadow() {
|
||||
@@ -163,9 +165,9 @@ bool task_stage_has_stage_info(task_stage_info* stg_info) {
|
||||
return task_stage_get_stage(*stg_info) != 0;
|
||||
}
|
||||
|
||||
bool task_stage_load(const char* name) {
|
||||
bool task_stage_load_task(const char* name) {
|
||||
task_stage_is_modern = false;
|
||||
return stage_detail::TaskStage_Load(task_stage, name);
|
||||
return stage_detail::TaskStage_LoadTask(task_stage, name);
|
||||
}
|
||||
|
||||
void task_stage_set_effect_display(task_stage_info* stg_info, bool value) {
|
||||
@@ -200,10 +202,13 @@ void task_stage_set_stage(task_stage_info* stg_info) {
|
||||
stage_detail::TaskStage_SetStage(task_stage, *stg_info);
|
||||
}
|
||||
|
||||
void task_stage_set_stage_display(task_stage_info* stg_info, bool value) {
|
||||
void task_stage_set_stage_display(task_stage_info* stg_info, bool value, bool effect_enable) {
|
||||
stage* stg = task_stage_get_stage(*stg_info);
|
||||
if (stg)
|
||||
if (stg) {
|
||||
stg->stage_display = value;
|
||||
if (effect_enable)
|
||||
task_effect_parent_set_enable(value);
|
||||
}
|
||||
}
|
||||
|
||||
void task_stage_set_stage_index(int32_t stage_index) {
|
||||
@@ -219,12 +224,12 @@ void task_stage_set_stage_index(int32_t stage_index) {
|
||||
stage_indices.begin(), stage_indices.end());
|
||||
}
|
||||
|
||||
void task_stage_set_stage_indices(std::vector<int32_t>* stage_indices) {
|
||||
void task_stage_set_stage_indices(std::vector<int32_t>& stage_indices) {
|
||||
task_stage->load_stage_indices.insert(task_stage->load_stage_indices.end(),
|
||||
stage_indices->begin(), stage_indices->end());
|
||||
stage_indices.begin(), stage_indices.end());
|
||||
}
|
||||
|
||||
bool task_stage_unload() {
|
||||
bool task_stage_unload_task() {
|
||||
return task_stage->SetDest();
|
||||
}
|
||||
|
||||
@@ -249,49 +254,10 @@ static void stage_detail::TaskStage_CtrlInner(stage_detail::TaskStage* a1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (a1->state == 3) {
|
||||
//sub_140229F30("rom/STGTST_COLI.000.bin");
|
||||
light_param_data_storage_data_load_stages(&a1->stage_indices);
|
||||
a1->state = 4;
|
||||
}
|
||||
else if (a1->state == 4 && !light_param_data_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();
|
||||
}
|
||||
}
|
||||
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]);
|
||||
|
||||
stage* s = stage_detail::TaskStage_GetStage(a1, vec[0]);
|
||||
data_struct* aft_data = &data_list[DATA_AFT];
|
||||
auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db;
|
||||
for (int32_t& i : s->stage_data->auth_3d_ids) {
|
||||
int32_t id = auth_3d_data_load_uid(i, aft_auth_3d_db);
|
||||
if (id == -1)
|
||||
continue;
|
||||
|
||||
auth_3d_data_read_file(&id, aft_auth_3d_db);
|
||||
s->auth_3d_ids.push_back(id);
|
||||
}
|
||||
}
|
||||
a1->state = 6;
|
||||
}
|
||||
else if (a1->state >= 7 && a1->state <= 9) {
|
||||
if (a1->state >= 3 && a1->state <= 5)
|
||||
stage_detail::TaskStage_Load(a1);
|
||||
else if (a1->state >= 7 && a1->state <= 9)
|
||||
stage_detail::TaskStage_Unload(a1);
|
||||
}
|
||||
}
|
||||
|
||||
static void stage_detail::TaskStage_DispShadow(stage_detail::TaskStage* a1) {
|
||||
@@ -341,7 +307,45 @@ static void stage_detail::TaskStage_GetLoadedStageInfos(stage_detail::TaskStage*
|
||||
}
|
||||
}
|
||||
|
||||
static bool stage_detail::TaskStage_Load(stage_detail::TaskStage* a1, const char* name) {
|
||||
static void stage_detail::TaskStage_Load(stage_detail::TaskStage* a1) {
|
||||
switch (a1->state) {
|
||||
case 3: {
|
||||
//sub_140229F30("rom/STGTST_COLI.000.bin");
|
||||
light_param_data_storage_data_load_stages(a1->stage_indices);
|
||||
a1->state = 4;
|
||||
} break;
|
||||
case 4: {
|
||||
if (light_param_data_storage_data_load_file()/* || sub_14022A380()*/)
|
||||
break;
|
||||
|
||||
bool wait_load = false;
|
||||
for (int32_t i = 0; i < TASK_STAGE_STAGE_COUNT; i++)
|
||||
if (a1->stages[i].index != -1 && a1->stages[i].state != 6) {
|
||||
wait_load = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!wait_load) {
|
||||
task_effect_parent_set_stage_indices(a1->stage_indices);
|
||||
task_effect_parent_set_enable(a1->stage_display);
|
||||
a1->state = 5;
|
||||
//sub_14064DC10();
|
||||
}
|
||||
} break;
|
||||
case 5: {
|
||||
if (task_effect_parent_load())
|
||||
break;
|
||||
|
||||
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;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
static bool stage_detail::TaskStage_LoadTask(stage_detail::TaskStage* a1, const char* name) {
|
||||
if (app::TaskWork::AppendTask(a1, name)) {
|
||||
stage_detail::TaskStage_Reset(a1);
|
||||
stage_detail::TaskStage_TaskWindAppend(a1);
|
||||
@@ -401,11 +405,11 @@ static void stage_detail::TaskStage_Unload(stage_detail::TaskStage* a1) {
|
||||
}
|
||||
|
||||
if (a1->state == 7) {
|
||||
//sub_140343C30();
|
||||
task_effect_parent_dest();
|
||||
a1->state = 8;
|
||||
}
|
||||
else if (a1->state == 8) {
|
||||
//if (!sub_140344700())
|
||||
if (!task_effect_parent_unload())
|
||||
a1->state = 9;
|
||||
}
|
||||
else if (a1->state == 9) {
|
||||
@@ -578,7 +582,7 @@ static void stage_free(stage* s) {
|
||||
rctx_ptr->post_process.movie_texture_free(
|
||||
texture_storage_get_texture(s->stage_data->movie_texture));
|
||||
|
||||
draw_pass->shadow = true;
|
||||
draw_pass->set_shadow_true();
|
||||
//rctx_ptr->post_process.field_14 = 0;
|
||||
//rctx_ptr->post_process.field_ED8 = 1;
|
||||
npr_spec_color.w = 1.0f;
|
||||
@@ -672,44 +676,43 @@ static void stage_set(stage* s, stage* other) {
|
||||
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->set_enable(DRAW_PASS_REFLECT, false);
|
||||
draw_pass->set_reflect(false);
|
||||
draw_pass->set_enable(DRAW_PASS_REFRACT, false);
|
||||
draw_pass->set_refract(true);
|
||||
draw_pass->field_31D = false;
|
||||
draw_pass->field_31E = false;
|
||||
draw_pass->field_31F = false;
|
||||
draw_pass->field_320 = 0;
|
||||
draw_pass->shadow = true;
|
||||
draw_pass->field_320 = false;
|
||||
draw_pass->set_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;
|
||||
draw_pass->set_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;
|
||||
draw_pass->set_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;
|
||||
draw_pass->set_enable(DRAW_PASS_REFLECT, true);
|
||||
draw_pass->set_reflect_blur(reflect->blur_num, (blur_filter_mode)reflect->blur_filter);
|
||||
draw_pass->set_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);*/
|
||||
draw_pass->set_refract_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;
|
||||
draw_pass->set_enable(DRAW_PASS_REFRACT, true);
|
||||
draw_pass->set_refract_resolution_mode((reflect_refract_resolution_mode)refract->mode);
|
||||
draw_pass->set_refract(true);
|
||||
}
|
||||
|
||||
if (other->stage_data->flags & STAGE_DATA_FLAG_1)
|
||||
@@ -723,23 +726,17 @@ static void stage_set(stage* s, stage* other) {
|
||||
//if (stru_14CC92630.pv_id == 421)
|
||||
//draw_pass->field_31F = true;
|
||||
//sub_14064DC10();
|
||||
//sub_140344160(other->index);
|
||||
task_effect_parent_set_current_stage_index(other->index);
|
||||
}
|
||||
//else
|
||||
//sub_140344160(-1);
|
||||
else
|
||||
task_effect_parent_set_current_stage_index(-1);
|
||||
|
||||
if (other)
|
||||
light_param_data_storage_data_set_stage(other->index);
|
||||
else
|
||||
light_param_data_storage_data_set_default_light_param();
|
||||
|
||||
if (s)
|
||||
for (int32_t& i : s->auth_3d_ids)
|
||||
auth_3d_data_set_req_frame(&i, 0.0f);
|
||||
|
||||
if (other)
|
||||
for (int32_t& i : other->auth_3d_ids)
|
||||
auth_3d_data_set_req_frame(&i, 0.0f);
|
||||
task_effect_parent_set_frame(0);
|
||||
|
||||
//sub_140344180(0);
|
||||
|
||||
@@ -747,7 +744,7 @@ static void stage_set(stage* s, stage* 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);
|
||||
//rob_chara_set_stage_data_ring(rob_chr, &other->index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -849,7 +846,7 @@ DtmStg::~DtmStg() {
|
||||
}
|
||||
|
||||
bool DtmStg::Init() {
|
||||
task_stage_load("DATA_TEST_STG_STAGE");
|
||||
task_stage_load_task("DATA_TEST_STG_STAGE");
|
||||
task_stage_set_stage_index(stage_index);
|
||||
return true;
|
||||
}
|
||||
@@ -867,6 +864,6 @@ bool DtmStg::Ctrl() {
|
||||
}
|
||||
|
||||
bool DtmStg::Dest() {
|
||||
task_stage_unload();
|
||||
task_stage_unload_task();
|
||||
return true;
|
||||
}
|
||||
|
||||
+5
-5
@@ -95,7 +95,7 @@ extern void task_stage_current_set_effect_display(bool value);
|
||||
extern void task_stage_current_set_ground(bool value);
|
||||
extern void task_stage_current_set_ring(bool value);
|
||||
extern void task_stage_current_set_sky(bool value);
|
||||
extern void task_stage_current_set_stage_display(bool value);
|
||||
extern void task_stage_current_set_stage_display(bool value, bool effect_enable);
|
||||
extern void task_stage_disp_shadow();
|
||||
extern stage* task_stage_get_current_stage();
|
||||
int32_t task_stage_get_current_stage_index();
|
||||
@@ -104,15 +104,15 @@ extern void task_stage_get_loaded_stage_infos(std::vector<task_stage_info>* vec)
|
||||
extern stage* task_stage_get_stage(task_stage_info stg_info);
|
||||
int32_t task_stage_get_stage_index(task_stage_info* stg_info);
|
||||
extern bool task_stage_has_stage_info(task_stage_info* stg_info);
|
||||
extern bool task_stage_load(const char* name);
|
||||
extern bool task_stage_load_task(const char* name);
|
||||
extern void task_stage_set_effect_display(task_stage_info* stg_info, bool value);
|
||||
extern void task_stage_set_ground(task_stage_info* stg_info, bool value);
|
||||
extern void task_stage_set_mat(mat4* mat);
|
||||
extern void task_stage_set_ring(task_stage_info* stg_info, bool value);
|
||||
extern void task_stage_set_sky(task_stage_info* stg_info, bool value);
|
||||
extern void task_stage_set_stage(task_stage_info* stg_info);
|
||||
extern void task_stage_set_stage_display(task_stage_info* stg_info, bool value);
|
||||
extern void task_stage_set_stage_display(task_stage_info* stg_info, bool value, bool effect_enable);
|
||||
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();
|
||||
extern void task_stage_set_stage_indices(std::vector<int32_t>& stage_indices);
|
||||
extern bool task_stage_unload_task();
|
||||
extern void task_stage_free();
|
||||
|
||||
+86
-85
@@ -11,6 +11,7 @@
|
||||
#include "draw_task.hpp"
|
||||
#include "light_param.hpp"
|
||||
#include "render_context.hpp"
|
||||
#include "task_effect.hpp"
|
||||
|
||||
namespace stage_detail {
|
||||
static void TaskStageModern_CtrlInner(stage_detail::TaskStageModern* a1);
|
||||
@@ -23,7 +24,8 @@ namespace stage_detail {
|
||||
task_stage_modern_info* stg_info);
|
||||
static void TaskStageModern_GetLoadedStageInfos(stage_detail::TaskStageModern* a1,
|
||||
std::vector<task_stage_modern_info>* vec);
|
||||
static bool TaskStageModern_Load(stage_detail::TaskStageModern* a1, const char* name);
|
||||
static void TaskStageModern_Load(stage_detail::TaskStageModern* a1);
|
||||
static bool TaskStageModern_LoadTask(stage_detail::TaskStageModern* a1, const char* name);
|
||||
static void TaskStageModern_Reset(stage_detail::TaskStageModern* a1);
|
||||
static void TaskStageModern_SetStage(stage_detail::TaskStageModern* a1, task_stage_modern_info stg_info);
|
||||
static void TaskStageModern_TaskWindAppend(stage_detail::TaskStageModern* a1);
|
||||
@@ -63,6 +65,10 @@ bool task_stage_modern_check_not_loaded() {
|
||||
return task_stage_modern->load_stage_hashes.size() || task_stage_modern->state != 6;
|
||||
}
|
||||
|
||||
bool task_stage_modern_check_task_ready() {
|
||||
return app::TaskWork::CheckTaskReady(task_stage_modern);
|
||||
}
|
||||
|
||||
void task_stage_modern_current_set_effect_display(bool value) {
|
||||
task_stage_modern_info stg_info;
|
||||
task_stage_modern_get_current_stage_info(&stg_info);
|
||||
@@ -84,11 +90,11 @@ void task_stage_modern_current_set_sky(bool value) {
|
||||
task_stage_modern_set_sky(&stg_info, value);
|
||||
}
|
||||
|
||||
void task_stage_modern_current_set_stage_display(bool value) {
|
||||
void task_stage_modern_current_set_stage_display(bool value, bool effect_enable) {
|
||||
task_stage_modern_info stg_info;
|
||||
task_stage_modern_get_current_stage_info(&stg_info);
|
||||
if (task_stage_modern_has_stage_info(&stg_info))
|
||||
task_stage_modern_set_stage_display(&stg_info, value);
|
||||
task_stage_modern_set_stage_display(&stg_info, value, effect_enable);
|
||||
}
|
||||
|
||||
void task_stage_modern_disp_shadow() {
|
||||
@@ -130,9 +136,9 @@ bool task_stage_modern_has_stage_info(task_stage_modern_info* stg_info) {
|
||||
return task_stage_modern_get_stage(*stg_info) != 0;
|
||||
}
|
||||
|
||||
bool task_stage_modern_load(const char* name) {
|
||||
bool task_stage_modern_load_task(const char* name) {
|
||||
task_stage_is_modern = true;
|
||||
return stage_detail::TaskStageModern_Load(task_stage_modern, name);
|
||||
return stage_detail::TaskStageModern_LoadTask(task_stage_modern, name);
|
||||
}
|
||||
|
||||
void task_stage_modern_set_data(void* data,
|
||||
@@ -169,10 +175,13 @@ void task_stage_modern_set_stage(task_stage_modern_info* stg_info) {
|
||||
stage_detail::TaskStageModern_SetStage(task_stage_modern, *stg_info);
|
||||
}
|
||||
|
||||
void task_stage_modern_set_stage_display(task_stage_modern_info* stg_info, bool value) {
|
||||
void task_stage_modern_set_stage_display(task_stage_modern_info* stg_info, bool value, bool effect_enable) {
|
||||
stage_modern* stg = task_stage_modern_get_stage(*stg_info);
|
||||
if (stg)
|
||||
if (stg) {
|
||||
stg->stage_display = value;
|
||||
if (effect_enable)
|
||||
task_effect_parent_set_enable(value);
|
||||
}
|
||||
}
|
||||
|
||||
void task_stage_modern_set_stage_hash(uint32_t stage_hash, stage_data_modern* stg_data) {
|
||||
@@ -187,15 +196,15 @@ void task_stage_modern_set_stage_hash(uint32_t stage_hash, stage_data_modern* st
|
||||
stages_data.begin(), stages_data.end());
|
||||
}
|
||||
|
||||
void task_stage_modern_set_stage_hashes(std::vector<uint32_t>* stage_hashes,
|
||||
std::vector<stage_data_modern*>* load_stage_data) {
|
||||
void task_stage_modern_set_stage_hashes(std::vector<uint32_t>& stage_hashes,
|
||||
std::vector<stage_data_modern*>& load_stage_data) {
|
||||
task_stage_modern->load_stage_hashes.insert(task_stage_modern->load_stage_hashes.end(),
|
||||
stage_hashes->begin(), stage_hashes->end());
|
||||
stage_hashes.begin(), stage_hashes.end());
|
||||
task_stage_modern->load_stages_data.insert(task_stage_modern->load_stages_data.end(),
|
||||
load_stage_data->begin(), load_stage_data->end());
|
||||
load_stage_data.begin(), load_stage_data.end());
|
||||
}
|
||||
|
||||
bool task_stage_modern_unload() {
|
||||
bool task_stage_modern_unload_task() {
|
||||
return task_stage_modern->SetDest();
|
||||
}
|
||||
|
||||
@@ -222,51 +231,10 @@ static void stage_detail::TaskStageModern_CtrlInner(stage_detail::TaskStageModer
|
||||
return;
|
||||
}
|
||||
|
||||
if (a1->state == 3) {
|
||||
//sub_140229F30("rom/STGTST_COLI.000.bin");
|
||||
light_param_data_storage_data_load_stages(&a1->stage_hashes, a1->stage_data);
|
||||
a1->state = 4;
|
||||
}
|
||||
else if (a1->state == 4 && !light_param_data_storage_data_load_file()/* && !sub_14022A380()*/) {
|
||||
bool v5 = 0;
|
||||
for (int32_t i = 0; i < TASK_STAGE_STAGE_COUNT; i++)
|
||||
if (a1->stages[i].hash != -1 && a1->stages[i].hash != hash_murmurhash_empty
|
||||
&& a1->stages[i].state != 6) {
|
||||
v5 = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!v5) {
|
||||
//sub_140343B20(&a1->stage_hashes);
|
||||
//task_stage_modern_current_set_effect_display(a1->stage_display);
|
||||
a1->state = 5;
|
||||
//sub_14064DC10();
|
||||
}
|
||||
}
|
||||
else if (a1->state == 5/* && !sub_1403446E0()*/) {
|
||||
std::vector<task_stage_modern_info> vec;
|
||||
stage_detail::TaskStageModern_GetLoadedStageInfos(a1, &vec);
|
||||
if (vec.size()) {
|
||||
stage_detail::TaskStageModern_SetStage(a1, vec[0]);
|
||||
|
||||
stage_modern* s = stage_detail::TaskStageModern_GetStage(a1, vec[0]);
|
||||
for (uint32_t& i : s->stage_data->auth_3d_ids) {
|
||||
int32_t id = auth_3d_data_load_hash(i, a1->data, a1->obj_db, a1->tex_db);
|
||||
if (id == -1)
|
||||
continue;
|
||||
|
||||
auth_3d_data_read_file_modern(&id);
|
||||
auth_3d_data_set_enable(&id, true);
|
||||
auth_3d_data_set_paused(&id, false);
|
||||
auth_3d_data_set_frame_rate(&id, 0);
|
||||
s->auth_3d_ids.push_back(id);
|
||||
}
|
||||
}
|
||||
a1->state = 6;
|
||||
}
|
||||
else if (a1->state >= 7 && a1->state <= 9) {
|
||||
if (a1->state >= 3 && a1->state <= 5)
|
||||
stage_detail::TaskStageModern_Load(a1);
|
||||
else if (a1->state >= 7 && a1->state <= 9)
|
||||
stage_detail::TaskStageModern_Unload(a1);
|
||||
}
|
||||
}
|
||||
|
||||
static void stage_detail::TaskStageModern_DispShadow(stage_detail::TaskStageModern* a1) {
|
||||
@@ -317,7 +285,46 @@ static void stage_detail::TaskStageModern_GetLoadedStageInfos(stage_detail::Task
|
||||
}
|
||||
}
|
||||
|
||||
static bool stage_detail::TaskStageModern_Load(stage_detail::TaskStageModern* a1, const char* name) {
|
||||
static void stage_detail::TaskStageModern_Load(stage_detail::TaskStageModern* a1) {
|
||||
switch (a1->state) {
|
||||
case 3: {
|
||||
//sub_140229F30("rom/STGTST_COLI.000.bin");
|
||||
light_param_data_storage_data_load_stages(a1->stage_hashes, a1->stage_data);
|
||||
a1->state = 4;
|
||||
} break;
|
||||
case 4: {
|
||||
if (light_param_data_storage_data_load_file()/* || sub_14022A380()*/)
|
||||
break;
|
||||
|
||||
bool wait_load = false;
|
||||
for (int32_t i = 0; i < TASK_STAGE_STAGE_COUNT; i++)
|
||||
if (a1->stages[i].hash != -1 && a1->stages[i].hash != hash_murmurhash_empty
|
||||
&& a1->stages[i].state != 6) {
|
||||
wait_load = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!wait_load) {
|
||||
task_effect_parent_set_stage_hashes(a1->stage_hashes);
|
||||
task_effect_parent_set_enable(a1->stage_display);
|
||||
a1->state = 5;
|
||||
//sub_14064DC10();
|
||||
}
|
||||
} break;
|
||||
case 5: {
|
||||
if (task_effect_parent_load())
|
||||
break;
|
||||
|
||||
std::vector<task_stage_modern_info> vec;
|
||||
stage_detail::TaskStageModern_GetLoadedStageInfos(a1, &vec);
|
||||
if (vec.size())
|
||||
stage_detail::TaskStageModern_SetStage(a1, vec[0]);
|
||||
a1->state = 6;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
static bool stage_detail::TaskStageModern_LoadTask(stage_detail::TaskStageModern* a1, const char* name) {
|
||||
if (app::TaskWork::AppendTask(a1, name)) {
|
||||
stage_detail::TaskStageModern_Reset(a1);
|
||||
stage_detail::TaskStageModern_TaskWindAppend(a1);
|
||||
@@ -378,11 +385,11 @@ static void stage_detail::TaskStageModern_Unload(stage_detail::TaskStageModern*
|
||||
}
|
||||
|
||||
if (a1->state == 7) {
|
||||
//sub_140343C30();
|
||||
task_effect_parent_dest();
|
||||
a1->state = 8;
|
||||
}
|
||||
else if (a1->state == 8) {
|
||||
//if (!sub_140344700())
|
||||
if (!task_effect_parent_unload())
|
||||
a1->state = 9;
|
||||
}
|
||||
else if (a1->state == 9) {
|
||||
@@ -463,11 +470,11 @@ static void stage_modern_disp(stage_modern* s) {
|
||||
mat4 mat;
|
||||
mat4_rotate_y(s->rot_y, &mat);
|
||||
|
||||
if (s->stage_data->object_ground.not_null() && s->ground)
|
||||
if (s->stage_data->object_ground.not_null_modern() && 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_reflect.not_null()) {
|
||||
if (s->stage_data->object_reflect.not_null_modern()) {
|
||||
object_data->set_draw_task_flags(
|
||||
(draw_task_flags)(DRAW_TASK_NO_TRANSLUCENCY | DRAW_TASK_REFRACT));
|
||||
draw_task_add_draw_object_by_object_info(rctx_ptr,
|
||||
@@ -475,7 +482,7 @@ static void stage_modern_disp(stage_modern* s) {
|
||||
object_data->set_draw_task_flags();
|
||||
}
|
||||
|
||||
if (s->stage_data->object_refract.not_null()) {
|
||||
if (s->stage_data->object_refract.not_null_modern()) {
|
||||
object_data->set_draw_task_flags(
|
||||
(draw_task_flags)(DRAW_TASK_NO_TRANSLUCENCY | DRAW_TASK_REFRACT));
|
||||
draw_task_add_draw_object_by_object_info(rctx_ptr,
|
||||
@@ -483,7 +490,7 @@ static void stage_modern_disp(stage_modern* s) {
|
||||
object_data->set_draw_task_flags();
|
||||
}
|
||||
|
||||
if (s->stage_data->object_sky.not_null() && s->sky) {
|
||||
if (s->stage_data->object_sky.not_null_modern() && s->sky) {
|
||||
mat4 t = s->mat;
|
||||
mat4_mult(&t, &mat, &t);
|
||||
draw_task_add_draw_object_by_object_info(rctx_ptr,
|
||||
@@ -497,7 +504,7 @@ static void stage_modern_disp_shadow(stage_modern* s) {
|
||||
|
||||
mat4 mat;
|
||||
mat4_rotate_y(s->rot_y, &mat);
|
||||
if (s->stage_data->object_shadow.not_null())
|
||||
if (s->stage_data->object_shadow.not_null_modern())
|
||||
stage_modern_disp_shadow_object(s->stage_data->object_shadow, &mat);
|
||||
}
|
||||
|
||||
@@ -538,7 +545,7 @@ static void stage_modern_free(stage_modern* s) {
|
||||
rctx_ptr->post_process.movie_texture_free(
|
||||
texture_storage_get_texture(s->stage_data->movie_texture));
|
||||
|
||||
draw_pass->shadow = true;
|
||||
draw_pass->set_shadow_true();
|
||||
//rctx_ptr->post_process.field_14 = 0;
|
||||
//rctx_ptr->post_process.field_ED8 = 1;
|
||||
npr_spec_color.w = 1.0f;
|
||||
@@ -625,19 +632,19 @@ static void stage_modern_set(stage_modern* s, stage_modern* other) {
|
||||
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->set_enable(DRAW_PASS_REFLECT, false);
|
||||
draw_pass->set_reflect(false);
|
||||
draw_pass->set_enable(DRAW_PASS_REFRACT, false);
|
||||
draw_pass->set_refract(true);
|
||||
draw_pass->field_31D = false;
|
||||
draw_pass->field_31E = false;
|
||||
draw_pass->field_31F = false;
|
||||
draw_pass->field_320 = 0;
|
||||
draw_pass->shadow = true;
|
||||
draw_pass->field_320 = false;
|
||||
draw_pass->set_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;
|
||||
draw_pass->set_npr_param(0);
|
||||
light_chara_ambient = false;
|
||||
}
|
||||
|
||||
@@ -645,23 +652,17 @@ static void stage_modern_set(stage_modern* s, stage_modern* other) {
|
||||
//if (stru_14CC92630.pv_id == 421)
|
||||
//draw_pass->field_31F = true;
|
||||
//sub_14064DC10();
|
||||
//sub_140344160(other->index);
|
||||
task_effect_parent_set_current_stage_hash(other->hash);
|
||||
}
|
||||
//else
|
||||
//sub_140344160(-1);
|
||||
else
|
||||
task_effect_parent_set_current_stage_hash(hash_murmurhash_empty);
|
||||
|
||||
if (other)
|
||||
light_param_data_storage_data_set_stage(other->hash);
|
||||
else
|
||||
light_param_data_storage_data_set_default_light_param();
|
||||
|
||||
if (s)
|
||||
for (int32_t& i : s->auth_3d_ids)
|
||||
auth_3d_data_set_req_frame(&i, 0.0f);
|
||||
|
||||
if (other)
|
||||
for (int32_t& i : other->auth_3d_ids)
|
||||
auth_3d_data_set_req_frame(&i, 0.0f);
|
||||
task_effect_parent_set_frame(0);
|
||||
|
||||
//sub_140344180(0);
|
||||
|
||||
@@ -669,7 +670,7 @@ static void stage_modern_set(stage_modern* s, stage_modern* 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);
|
||||
//rob_chara_set_stage_data_ring(rob_chr, &other->index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,10 +75,11 @@ struct task_stage_modern_info {
|
||||
|
||||
extern void task_stage_modern_init();
|
||||
extern bool task_stage_modern_check_not_loaded();
|
||||
extern bool task_stage_modern_check_task_ready();
|
||||
extern void task_stage_modern_current_set_effect_display(bool value);
|
||||
extern void task_stage_modern_current_set_ground(bool value);
|
||||
extern void task_stage_modern_current_set_sky(bool value);
|
||||
extern void task_stage_modern_current_set_stage_display(bool value);
|
||||
extern void task_stage_modern_current_set_stage_display(bool value, bool effect_enable);
|
||||
extern void task_stage_modern_disp_shadow();
|
||||
extern stage_modern* task_stage_modern_get_current_stage();
|
||||
extern uint32_t task_stage_modern_get_current_stage_hash();
|
||||
@@ -87,7 +88,7 @@ extern void task_stage_modern_get_loaded_stage_infos(std::vector<task_stage_mode
|
||||
extern stage_modern* task_stage_modern_get_stage(task_stage_modern_info stg_info);
|
||||
extern uint32_t task_stage_modern_get_stage_hash(task_stage_modern_info* stg_info);
|
||||
extern bool task_stage_modern_has_stage_info(task_stage_modern_info* stg_info);
|
||||
extern bool task_stage_modern_load(const char* name);
|
||||
extern bool task_stage_modern_load_task(const char* name);
|
||||
extern void task_stage_modern_set_data(void* data,
|
||||
object_database* obj_db, texture_database* tex_db, stage_database* stage_data);
|
||||
extern void task_stage_modern_set_effect_display(task_stage_modern_info* stg_info, bool value);
|
||||
@@ -95,9 +96,9 @@ extern void task_stage_modern_set_ground(task_stage_modern_info* stg_info, bool
|
||||
extern void task_stage_modern_set_mat(mat4* mat);
|
||||
extern void task_stage_modern_set_sky(task_stage_modern_info* stg_info, bool value);
|
||||
extern void task_stage_modern_set_stage(task_stage_modern_info* stg_info);
|
||||
extern void task_stage_modern_set_stage_display(task_stage_modern_info* stg_info, bool value);
|
||||
extern void task_stage_modern_set_stage_display(task_stage_modern_info* stg_info, bool value, bool effect_enable);
|
||||
extern void task_stage_modern_set_stage_hash(uint32_t stage_hash, stage_data_modern* stg_data);
|
||||
extern void task_stage_modern_set_stage_hashes(std::vector<uint32_t>* stage_hashes,
|
||||
std::vector<stage_data_modern*>* load_stage_data);
|
||||
extern bool task_stage_modern_unload();
|
||||
extern void task_stage_modern_set_stage_hashes(std::vector<uint32_t>& stage_hashes,
|
||||
std::vector<stage_data_modern*>& load_stage_data);
|
||||
extern bool task_stage_modern_unload_task();
|
||||
extern void task_stage_modern_free();
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "stage_param.hpp"
|
||||
|
||||
template<typename T>
|
||||
static T& stage_param_data_storage_get_value(std::map<int32_t, T>& map, int32_t key);
|
||||
|
||||
std::map<int32_t, stage_param_fog_ring> stage_param_data_fog_ring_storage;
|
||||
std::map<int32_t, stage_param_leaf> stage_param_data_leaf_storage;
|
||||
std::map<int32_t, stage_param_litproj> stage_param_data_litproj_storage;
|
||||
std::map<int32_t, stage_param_rain> stage_param_data_rain_storage;
|
||||
std::map<int32_t, stage_param_ripple> stage_param_data_ripple_storage;
|
||||
std::map<int32_t, stage_param_snow> stage_param_data_snow_storage;
|
||||
std::map<int32_t, stage_param_splash> stage_param_data_splash_storage;
|
||||
std::map<int32_t, stage_param_star> stage_param_data_star_storage;
|
||||
|
||||
void stage_param_data_storage_init() {
|
||||
stage_param_data_fog_ring_storage = {};
|
||||
stage_param_data_leaf_storage = {};
|
||||
stage_param_data_litproj_storage = {};
|
||||
stage_param_data_rain_storage = {};
|
||||
stage_param_data_ripple_storage = {};
|
||||
stage_param_data_snow_storage = {};
|
||||
stage_param_data_splash_storage = {};
|
||||
stage_param_data_star_storage = {};
|
||||
}
|
||||
|
||||
void stage_param_data_storage_free() {
|
||||
stage_param_data_fog_ring_storage.clear();
|
||||
stage_param_data_leaf_storage.clear();
|
||||
stage_param_data_litproj_storage.clear();
|
||||
stage_param_data_rain_storage.clear();
|
||||
stage_param_data_ripple_storage.clear();
|
||||
stage_param_data_snow_storage.clear();
|
||||
stage_param_data_splash_storage.clear();
|
||||
stage_param_data_star_storage.clear();
|
||||
}
|
||||
|
||||
void stage_param_data_fog_ring_storage_clear() {
|
||||
stage_param_data_fog_ring_storage.clear();
|
||||
}
|
||||
|
||||
stage_param_fog_ring* stage_param_data_fog_ring_storage_get_value(int32_t stage_index) {
|
||||
auto elem = stage_param_data_fog_ring_storage.find(stage_index);
|
||||
if (elem != stage_param_data_fog_ring_storage.end())
|
||||
return &elem->second;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void stage_param_data_fog_ring_storage_set_stage_data(int32_t stage_index, stage_param_fog_ring* value) {
|
||||
if (value)
|
||||
stage_param_data_storage_get_value<stage_param_fog_ring>(
|
||||
stage_param_data_fog_ring_storage, stage_index) = *value;
|
||||
}
|
||||
|
||||
void stage_param_data_leaf_storage_clear() {
|
||||
stage_param_data_leaf_storage.clear();
|
||||
}
|
||||
|
||||
stage_param_leaf* stage_param_data_leaf_storage_get_value(int32_t stage_index) {
|
||||
auto elem = stage_param_data_leaf_storage.find(stage_index);
|
||||
if (elem != stage_param_data_leaf_storage.end())
|
||||
return &elem->second;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void stage_param_data_leaf_storage_set_stage_data(int32_t stage_index, stage_param_leaf* value) {
|
||||
if (value)
|
||||
stage_param_data_storage_get_value<stage_param_leaf>(
|
||||
stage_param_data_leaf_storage, stage_index) = *value;
|
||||
}
|
||||
|
||||
void stage_param_data_litproj_storage_clear() {
|
||||
stage_param_data_litproj_storage.clear();
|
||||
}
|
||||
|
||||
stage_param_litproj* stage_param_data_litproj_storage_get_value(int32_t stage_index) {
|
||||
auto elem = stage_param_data_litproj_storage.find(stage_index);
|
||||
if (elem != stage_param_data_litproj_storage.end())
|
||||
return &elem->second;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void stage_param_data_litproj_storage_set_stage_data(int32_t stage_index, stage_param_litproj* value) {
|
||||
if (value)
|
||||
stage_param_data_storage_get_value<stage_param_litproj>(
|
||||
stage_param_data_litproj_storage, stage_index) = *value;
|
||||
}
|
||||
|
||||
void stage_param_data_rain_storage_clear() {
|
||||
stage_param_data_rain_storage.clear();
|
||||
}
|
||||
|
||||
stage_param_rain* stage_param_data_rain_storage_get_value(int32_t stage_index) {
|
||||
auto elem = stage_param_data_rain_storage.find(stage_index);
|
||||
if (elem != stage_param_data_rain_storage.end())
|
||||
return &elem->second;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void stage_param_data_rain_storage_set_stage_data(int32_t stage_index, stage_param_rain* value) {
|
||||
if (value)
|
||||
stage_param_data_storage_get_value<stage_param_rain>(
|
||||
stage_param_data_rain_storage, stage_index) = *value;
|
||||
}
|
||||
|
||||
void stage_param_data_ripple_storage_clear() {
|
||||
stage_param_data_ripple_storage.clear();
|
||||
}
|
||||
|
||||
stage_param_ripple* stage_param_data_ripple_storage_get_value(int32_t stage_index) {
|
||||
auto elem = stage_param_data_ripple_storage.find(stage_index);
|
||||
if (elem != stage_param_data_ripple_storage.end())
|
||||
return &elem->second;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void stage_param_data_ripple_storage_set_stage_data(int32_t stage_index, stage_param_ripple* value) {
|
||||
if (value)
|
||||
stage_param_data_storage_get_value<stage_param_ripple>(
|
||||
stage_param_data_ripple_storage, stage_index) = *value;
|
||||
}
|
||||
|
||||
void stage_param_data_snow_storage_clear() {
|
||||
stage_param_data_snow_storage.clear();
|
||||
}
|
||||
|
||||
stage_param_snow* stage_param_data_snow_storage_get_value(int32_t stage_index) {
|
||||
auto elem = stage_param_data_snow_storage.find(stage_index);
|
||||
if (elem != stage_param_data_snow_storage.end())
|
||||
return &elem->second;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void stage_param_data_snow_storage_set_stage_data(int32_t stage_index, stage_param_snow* value) {
|
||||
if (value)
|
||||
stage_param_data_storage_get_value<stage_param_snow>(
|
||||
stage_param_data_snow_storage, stage_index) = *value;
|
||||
}
|
||||
|
||||
void stage_param_data_splash_storage_clear() {
|
||||
stage_param_data_splash_storage.clear();
|
||||
}
|
||||
|
||||
stage_param_splash* stage_param_data_splash_storage_get_value(int32_t stage_index) {
|
||||
auto elem = stage_param_data_splash_storage.find(stage_index);
|
||||
if (elem != stage_param_data_splash_storage.end())
|
||||
return &elem->second;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void stage_param_data_splash_storage_set_stage_data(int32_t stage_index, stage_param_splash* value) {
|
||||
if (value)
|
||||
stage_param_data_storage_get_value<stage_param_splash>(
|
||||
stage_param_data_splash_storage, stage_index) = *value;
|
||||
}
|
||||
|
||||
void stage_param_data_star_storage_clear() {
|
||||
stage_param_data_star_storage.clear();
|
||||
}
|
||||
|
||||
stage_param_star* stage_param_data_star_storage_get_value(int32_t stage_index) {
|
||||
auto elem = stage_param_data_star_storage.find(stage_index);
|
||||
if (elem != stage_param_data_star_storage.end())
|
||||
return &elem->second;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void stage_param_data_star_storage_set_stage_data(int32_t stage_index, stage_param_star* value) {
|
||||
if (value)
|
||||
stage_param_data_storage_get_value<stage_param_star>(
|
||||
stage_param_data_star_storage, stage_index) = *value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static T& stage_param_data_storage_get_value(std::map<int32_t, T>& map, int32_t key) {
|
||||
auto elem = map.find(key);
|
||||
if (elem != map.end())
|
||||
return elem->second;
|
||||
|
||||
return map.insert({ key, {} }).first->second;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include "../KKdLib/stage_param/fog_ring.hpp"
|
||||
#include "../KKdLib/stage_param/leaf.hpp"
|
||||
#include "../KKdLib/stage_param/litproj.hpp"
|
||||
#include "../KKdLib/stage_param/rain.hpp"
|
||||
#include "../KKdLib/stage_param/ripple.hpp"
|
||||
#include "../KKdLib/stage_param/snow.hpp"
|
||||
#include "../KKdLib/stage_param/splash.hpp"
|
||||
#include "../KKdLib/stage_param/star.hpp"
|
||||
|
||||
extern void stage_param_data_storage_init();
|
||||
extern void stage_param_data_storage_free();
|
||||
|
||||
extern void stage_param_data_fog_ring_storage_clear();
|
||||
extern stage_param_fog_ring* stage_param_data_fog_ring_storage_get_value(int32_t stage_index);
|
||||
extern void stage_param_data_fog_ring_storage_set_stage_data(int32_t stage_index, stage_param_fog_ring* value);
|
||||
extern void stage_param_data_leaf_storage_clear();
|
||||
extern stage_param_leaf* stage_param_data_leaf_storage_get_value(int32_t stage_index);
|
||||
extern void stage_param_data_leaf_storage_set_stage_data(int32_t stage_index, stage_param_leaf* value);
|
||||
extern void stage_param_data_litproj_storage_clear();
|
||||
extern stage_param_litproj* stage_param_data_litproj_storage_get_value(int32_t stage_index);
|
||||
extern void stage_param_data_litproj_storage_set_stage_data(int32_t stage_index, stage_param_litproj* value);
|
||||
extern void stage_param_data_rain_storage_clear();
|
||||
extern stage_param_rain* stage_param_data_rain_storage_get_value(int32_t stage_index);
|
||||
extern void stage_param_data_rain_storage_set_stage_data(int32_t stage_index, stage_param_rain* value);
|
||||
extern void stage_param_data_ripple_storage_clear();
|
||||
extern stage_param_ripple* stage_param_data_ripple_storage_get_value(int32_t stage_index);
|
||||
extern void stage_param_data_ripple_storage_set_stage_data(int32_t stage_index, stage_param_ripple* value);
|
||||
extern void stage_param_data_snow_storage_clear();
|
||||
extern stage_param_snow* stage_param_data_snow_storage_get_value(int32_t stage_index);
|
||||
extern void stage_param_data_snow_storage_set_stage_data(int32_t stage_index, stage_param_snow* value);
|
||||
extern void stage_param_data_splash_storage_clear();
|
||||
extern stage_param_splash* stage_param_data_splash_storage_get_value(int32_t stage_index);
|
||||
extern void stage_param_data_splash_storage_set_stage_data(int32_t stage_index, stage_param_splash* value);
|
||||
extern void stage_param_data_star_storage_clear();
|
||||
extern stage_param_star* stage_param_data_star_storage_get_value(int32_t stage_index);
|
||||
extern void stage_param_data_star_storage_set_stage_data(int32_t stage_index, stage_param_star* value);
|
||||
+17
-21
@@ -13,20 +13,18 @@ extern float_t delta_frame_history;
|
||||
extern int32_t delta_frame_history_int;
|
||||
|
||||
namespace app {
|
||||
static void Task_add_base_calc_time(Task* t, uint32_t calc_time);
|
||||
static void Task_add_base_calc_time(Task* t, uint32_t value);
|
||||
static void Task_do_basic(Task* t);
|
||||
static void Task_do_ctrl(Task* t);
|
||||
static void Task_do_ctrl_frames(int32_t frames, bool frame_skip);
|
||||
static void Task_do_disp(Task* t);
|
||||
static void Task_set_base_calc_time(Task* t, uint32_t base_calc_time);
|
||||
static void Task_set_base_calc_time(Task* t, uint32_t value);
|
||||
static void Task_set_calc_time(Task* t);
|
||||
static void Task_set_disp_time(Task* t, uint32_t disp_time);
|
||||
static void Task_set_disp_time(Task* t, uint32_t value);
|
||||
static bool Task_sub_14019B810(Task* t, int32_t a2);
|
||||
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);
|
||||
|
||||
TaskWork* task_work;
|
||||
|
||||
TaskInterface::TaskInterface() {
|
||||
@@ -126,7 +124,7 @@ namespace app {
|
||||
}
|
||||
|
||||
bool Task::sub_14019C3B0() {
|
||||
if (!app::TaskWork::HasTask(this) || !Task_sub_14019B810(this, 5))
|
||||
if (!TaskWork::HasTask(this) || !Task_sub_14019B810(this, 5))
|
||||
return false;
|
||||
|
||||
Task_sub_14019C480(this, 5);
|
||||
@@ -134,7 +132,7 @@ namespace app {
|
||||
}
|
||||
|
||||
bool Task::sub_14019C540() {
|
||||
if (!app::TaskWork::HasTask(this) || !Task_sub_14019B810(this, 4))
|
||||
if (!TaskWork::HasTask(this) || !Task_sub_14019B810(this, 4))
|
||||
return false;
|
||||
|
||||
Task_sub_14019C480(this, 4);
|
||||
@@ -184,6 +182,10 @@ namespace app {
|
||||
Task_do_basic(j);
|
||||
}
|
||||
|
||||
bool TaskWork::CheckTaskCtrl(Task* t) {
|
||||
return app::TaskWork::HasTask(t) && t->field_1C == 1 && t->field_18 == Task::Enum::Ctrl;
|
||||
}
|
||||
|
||||
bool TaskWork::CheckTaskReady(Task* t) {
|
||||
return TaskWork::HasTask(t) && (t->field_18 == Task::Enum::None || t->field_1C);
|
||||
}
|
||||
@@ -198,7 +200,7 @@ namespace app {
|
||||
for (std::list<Task*>::iterator j = task_work->tasks.end(); j != task_work->tasks.begin(); ) {
|
||||
--j;
|
||||
Task* tsk = *j;
|
||||
if (tsk->priority != i || !TaskWork_has_task_dest(tsk))
|
||||
if (tsk->priority != i || !HasTaskDest(tsk))
|
||||
continue;
|
||||
|
||||
time_struct t;
|
||||
@@ -301,8 +303,8 @@ namespace app {
|
||||
delete task_work;
|
||||
}
|
||||
|
||||
static void Task_add_base_calc_time(Task* t, uint32_t calc_time) {
|
||||
t->base_calc_time += calc_time;
|
||||
static void Task_add_base_calc_time(Task* t, uint32_t value) {
|
||||
t->base_calc_time += value;
|
||||
}
|
||||
|
||||
static void Task_do_basic(Task* t) {
|
||||
@@ -337,7 +339,7 @@ namespace app {
|
||||
for (int32_t i = 0; i < 3; i++)
|
||||
for (Task*& j : task_work->tasks) {
|
||||
Task* tsk = j;
|
||||
if (tsk->priority != i || TaskWork_has_task_dest(tsk))
|
||||
if (tsk->priority != i || TaskWork::HasTaskDest(tsk))
|
||||
continue;
|
||||
else if (tsk->is_frame_dependent) {
|
||||
if (frames <= 0)
|
||||
@@ -360,8 +362,8 @@ namespace app {
|
||||
t->Disp();
|
||||
}
|
||||
|
||||
static void Task_set_base_calc_time(Task* t, uint32_t base_calc_time) {
|
||||
t->base_calc_time = base_calc_time;
|
||||
static void Task_set_base_calc_time(Task* t, uint32_t value) {
|
||||
t->base_calc_time = value;
|
||||
}
|
||||
|
||||
static void Task_set_calc_time(Task* t) {
|
||||
@@ -372,8 +374,8 @@ namespace app {
|
||||
t->calc_time = max_def(t->calc_time, t->calc_time_max);
|
||||
}
|
||||
|
||||
static void Task_set_disp_time(Task* t, uint32_t disp_time) {
|
||||
t->disp_time = disp_time;
|
||||
static void Task_set_disp_time(Task* t, uint32_t value) {
|
||||
t->disp_time = value;
|
||||
uint32_t frame_counter = get_frame_counter();
|
||||
if (frame_counter == (frame_counter / 300) * 300)
|
||||
t->disp_time_max = 0;
|
||||
@@ -433,10 +435,4 @@ namespace app {
|
||||
t->field_18 = t->field_24;
|
||||
t->field_1C = t->field_28;
|
||||
}
|
||||
|
||||
static bool TaskWork_has_task_dest(Task* t) {
|
||||
if (TaskWork::HasTask(t))
|
||||
return t->field_18 == Task::Enum::Dest;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -50,7 +50,7 @@ namespace app {
|
||||
uint32_t disp_time_max;
|
||||
|
||||
Task();
|
||||
virtual ~Task();
|
||||
virtual ~Task() override;
|
||||
|
||||
uint32_t GetCalcTime();
|
||||
uint32_t GetCalcTimeMax();
|
||||
@@ -80,9 +80,10 @@ namespace app {
|
||||
|
||||
static bool AppendTask(Task* t,
|
||||
const char* name = "(unknown)", int32_t priority = 1);
|
||||
static bool AppendTask(Task* t, Task* parent_task = task_work->current,
|
||||
static bool AppendTask(Task* t, Task* parent_task,
|
||||
const char* name = "(unknown)", int32_t priority = 1);
|
||||
static void Basic();
|
||||
static bool CheckTaskCtrl(Task* t);
|
||||
static bool CheckTaskReady(Task* t);
|
||||
static void Ctrl();
|
||||
static void Dest();
|
||||
|
||||
+2774
-67
File diff suppressed because it is too large
Load Diff
+157
-271
@@ -10,6 +10,7 @@
|
||||
#include "../KKdLib/database/object.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "rob/rob.hpp"
|
||||
#include "frame_rate_control.hpp"
|
||||
#include "render_texture.hpp"
|
||||
#include "stage.hpp"
|
||||
@@ -40,21 +41,32 @@ enum TaskEffectType {
|
||||
TASK_EFFECT_STAR = 0x14,
|
||||
};
|
||||
|
||||
struct particle_init_data {
|
||||
float_t field_0;
|
||||
float_t field_4;
|
||||
float_t field_8;
|
||||
vec3 trans;
|
||||
float_t scale_y;
|
||||
};
|
||||
|
||||
class TaskEffect : public app::Task {
|
||||
public:
|
||||
TaskEffect();
|
||||
virtual ~TaskEffect() override;
|
||||
|
||||
virtual void PreInit(int32_t stage_index);
|
||||
virtual void SetStageHashes(std::vector<uint32_t>& stage_hashes, void* data,
|
||||
object_database* obj_db, texture_database* tex_db, stage_database* stage_data); // Added
|
||||
virtual void SetStageIndices(std::vector<int32_t>& stage_indices);
|
||||
virtual void SetFrame(int32_t value);
|
||||
virtual void Field_48();
|
||||
virtual void SetEnable(bool);
|
||||
virtual void SetStageIndex(int32_t value);
|
||||
virtual void SetEnable(bool value);
|
||||
virtual void SetCurrentStageHash(uint32_t value); // Added
|
||||
virtual void SetCurrentStageIndex(int32_t value);
|
||||
virtual void SetFrameRateControl(FrameRateControl* value);
|
||||
virtual void Field_68();
|
||||
virtual void Reset();
|
||||
virtual void Field_78();
|
||||
virtual void Event(int32_t event_type, void* data);
|
||||
virtual void Field_80();
|
||||
virtual void Field_88();
|
||||
virtual void Field_90();
|
||||
@@ -64,11 +76,16 @@ public:
|
||||
};
|
||||
|
||||
struct struc_621 {
|
||||
uint32_t stage_hash; // Added
|
||||
int32_t stage_index;
|
||||
std::vector<int32_t> auth_3d_ids;
|
||||
|
||||
struc_621();
|
||||
~struc_621();
|
||||
};
|
||||
|
||||
struct TaskEffectAuth3D : public TaskEffect {
|
||||
public:
|
||||
struct Stage {
|
||||
size_t count;
|
||||
size_t max_count;
|
||||
@@ -79,8 +96,10 @@ struct TaskEffectAuth3D : public TaskEffect {
|
||||
} stage;
|
||||
bool enable;
|
||||
std::vector<struc_621> field_120;
|
||||
int32_t stage_index;
|
||||
uint32_t current_stage_hash; // Added
|
||||
int32_t current_stage_index;
|
||||
int32_t field_13C;
|
||||
std::vector<uint32_t> stage_hashes;
|
||||
std::vector<int32_t> stage_indices;
|
||||
int8_t field_158;
|
||||
int8_t field_159;
|
||||
@@ -96,10 +115,13 @@ struct TaskEffectAuth3D : public TaskEffect {
|
||||
virtual void Disp() override;
|
||||
|
||||
virtual void PreInit(int32_t stage_index) override;
|
||||
virtual void SetStageHashes(std::vector<uint32_t>& stage_hashes, void* data,
|
||||
object_database* obj_db, texture_database* tex_db, stage_database* stage_data) override; // Added
|
||||
virtual void SetStageIndices(std::vector<int32_t>& stage_indices) override;
|
||||
virtual void SetFrame(int32_t value) override;
|
||||
virtual void SetEnable(bool value) override;
|
||||
virtual void SetStageIndex(int32_t value) override;
|
||||
virtual void SetCurrentStageHash(uint32_t value) override; // Added
|
||||
virtual void SetCurrentStageIndex(int32_t value) override;
|
||||
virtual void SetFrameRateControl(FrameRateControl* value) override;
|
||||
virtual void Reset() override;
|
||||
|
||||
@@ -108,6 +130,7 @@ struct TaskEffectAuth3D : public TaskEffect {
|
||||
};
|
||||
|
||||
struct TaskEffectFogAnim : public TaskEffect {
|
||||
public:
|
||||
struct Data {
|
||||
bool field_0;
|
||||
int32_t field_4;
|
||||
@@ -133,203 +156,106 @@ struct TaskEffectFogAnim : public TaskEffect {
|
||||
virtual bool Ctrl() override;
|
||||
virtual bool Dest() override;
|
||||
virtual void Disp() override;
|
||||
virtual void Basic() override;
|
||||
|
||||
virtual void PreInit(int32_t stage_index) override;
|
||||
virtual void SetStageIndices(std::vector<int32_t>& stage_indices) override;
|
||||
virtual void SetFrame(int32_t value) override;
|
||||
virtual void Field_48() override;
|
||||
virtual void SetEnable(bool) override;
|
||||
virtual void SetStageIndex(int32_t value) override;
|
||||
virtual void SetFrameRateControl(FrameRateControl* value) override;
|
||||
virtual void Field_68() override;
|
||||
virtual void Reset() override;
|
||||
virtual void Field_78() override;
|
||||
virtual void Field_80() override;
|
||||
virtual void Field_88() override;
|
||||
virtual void Field_90() override;
|
||||
virtual void Field_98(int32_t a2, int32_t* a3) override;
|
||||
virtual void Field_A0(int32_t a2, int32_t* a3) override;
|
||||
virtual void Field_A8(int32_t a2, int8_t* a3) override;
|
||||
};
|
||||
|
||||
struct fog_ring_data {
|
||||
vec3 position;
|
||||
vec3 direction;
|
||||
vec3 field_18;
|
||||
float_t size;
|
||||
float_t density;
|
||||
|
||||
fog_ring_data();
|
||||
};
|
||||
|
||||
struct particle_event_data {
|
||||
float_t type;
|
||||
float_t count;
|
||||
float_t size;
|
||||
vec3 trans;
|
||||
float_t force;
|
||||
|
||||
particle_event_data();
|
||||
};
|
||||
|
||||
struct point_particle_data {
|
||||
vec3 position;
|
||||
vec2 position;
|
||||
vec4 color;
|
||||
float_t size;
|
||||
};
|
||||
|
||||
struct struc_371 {
|
||||
vec3 field_0;
|
||||
float_t field_C;
|
||||
int32_t field_10;
|
||||
int32_t field_14;
|
||||
int32_t field_18;
|
||||
int32_t field_1C;
|
||||
int32_t field_20;
|
||||
int32_t field_24;
|
||||
int32_t field_0;
|
||||
vec3 position;
|
||||
float_t field_10;
|
||||
float_t field_14;
|
||||
vec3 direction;
|
||||
float_t field_24;
|
||||
|
||||
struc_371();
|
||||
};
|
||||
|
||||
struct struc_573 {
|
||||
int32_t chara_index;
|
||||
rob_bone_index bone_index;
|
||||
vec3 position;
|
||||
|
||||
struc_573();
|
||||
};
|
||||
|
||||
|
||||
struct TaskEffectFogRing : public TaskEffect {
|
||||
public:
|
||||
struct Data {
|
||||
bool enable;
|
||||
float_t delta_frame;
|
||||
int8_t field_8;
|
||||
bool field_8;
|
||||
float_t ring_size;
|
||||
vec3 wind_dir;
|
||||
int32_t tex_id;
|
||||
vec4 color;
|
||||
float_t point_size;
|
||||
float_t ptcl_size;
|
||||
int32_t max_ptcls;
|
||||
int32_t num_ptcls;
|
||||
float_t density;
|
||||
float_t density_offset;
|
||||
int32_t field_44;
|
||||
int64_t field_48;
|
||||
point_particle_data* data;
|
||||
int32_t count;
|
||||
int32_t field_5C;
|
||||
int32_t field_60;
|
||||
int32_t field_64;
|
||||
int32_t field_68;
|
||||
int32_t field_6C;
|
||||
int32_t field_70;
|
||||
int32_t field_74;
|
||||
int32_t field_78;
|
||||
int32_t field_7C;
|
||||
int32_t field_80;
|
||||
int32_t field_84;
|
||||
int32_t field_88;
|
||||
int32_t field_8C;
|
||||
int32_t field_90;
|
||||
int32_t field_94;
|
||||
int32_t field_98;
|
||||
int32_t field_9C;
|
||||
int32_t field_A0;
|
||||
int32_t field_A4;
|
||||
int32_t field_A8;
|
||||
int32_t field_AC;
|
||||
int32_t field_B0;
|
||||
int32_t field_B4;
|
||||
int32_t field_B8;
|
||||
int32_t field_BC;
|
||||
int32_t field_C0;
|
||||
int32_t field_C4;
|
||||
int32_t field_C8;
|
||||
int32_t field_CC;
|
||||
int32_t field_D0;
|
||||
int32_t field_D4;
|
||||
int32_t field_D8;
|
||||
int32_t field_DC;
|
||||
int32_t field_E0;
|
||||
int32_t field_E4;
|
||||
int32_t field_E8;
|
||||
int32_t field_EC;
|
||||
int32_t field_F0;
|
||||
int32_t field_F4;
|
||||
int32_t field_F8;
|
||||
int32_t field_FC;
|
||||
int32_t field_100;
|
||||
int32_t field_104;
|
||||
int32_t field_108;
|
||||
int32_t field_10C;
|
||||
int32_t field_110;
|
||||
int32_t field_114;
|
||||
int32_t field_118;
|
||||
int32_t field_11C;
|
||||
int32_t field_120;
|
||||
fog_ring_data* ptcl_data;
|
||||
int32_t num_vtx;
|
||||
struc_573 field_5C[2][5];
|
||||
int32_t field_124;
|
||||
int8_t field_128[4];
|
||||
float_t field_12C[2];
|
||||
int32_t field_134;
|
||||
float_t field_138[2];
|
||||
struc_371 field_140[2];
|
||||
int32_t field_190;
|
||||
int32_t field_194;
|
||||
int32_t field_198;
|
||||
int32_t field_19C;
|
||||
int32_t field_1A0;
|
||||
int32_t field_1A4;
|
||||
int32_t field_1A8;
|
||||
int32_t field_1AC;
|
||||
int32_t field_1B0;
|
||||
int32_t field_1B4;
|
||||
int32_t field_1B8;
|
||||
int32_t field_1BC;
|
||||
int32_t field_1C0;
|
||||
int32_t field_1C4;
|
||||
int32_t field_1C8;
|
||||
int32_t field_1CC;
|
||||
int32_t field_1D0;
|
||||
int32_t field_1D4;
|
||||
int32_t field_1D8;
|
||||
int32_t field_1DC;
|
||||
int32_t field_1E0;
|
||||
int32_t field_1E4;
|
||||
int32_t field_1E8;
|
||||
int32_t field_1EC;
|
||||
int32_t field_1F0;
|
||||
int32_t field_1F4;
|
||||
int32_t field_1F8;
|
||||
int32_t field_1FC;
|
||||
int32_t field_200;
|
||||
int32_t field_204;
|
||||
int32_t field_208;
|
||||
int32_t field_20C;
|
||||
int32_t field_210;
|
||||
int32_t field_214;
|
||||
int32_t field_218;
|
||||
int32_t field_21C;
|
||||
int32_t field_220;
|
||||
int32_t field_224;
|
||||
int32_t field_228;
|
||||
int32_t field_22C;
|
||||
int32_t field_230;
|
||||
int32_t field_234;
|
||||
int32_t field_238;
|
||||
int32_t field_23C;
|
||||
int32_t field_240;
|
||||
int32_t field_244;
|
||||
int32_t field_248;
|
||||
int32_t field_24C;
|
||||
int32_t field_250;
|
||||
int32_t field_254;
|
||||
int32_t field_258;
|
||||
int32_t field_25C;
|
||||
int32_t field_260;
|
||||
int32_t field_264;
|
||||
int32_t field_268;
|
||||
int32_t field_26C;
|
||||
int32_t field_270;
|
||||
int32_t field_274;
|
||||
int32_t field_278;
|
||||
int32_t field_27C;
|
||||
int32_t field_280;
|
||||
int32_t field_284;
|
||||
int32_t field_288;
|
||||
int32_t field_28C;
|
||||
int32_t field_290;
|
||||
int32_t field_294;
|
||||
int32_t field_298;
|
||||
int32_t field_29C;
|
||||
int32_t field_2A0;
|
||||
int32_t field_2A4;
|
||||
int64_t field_2A8;
|
||||
int32_t field_2B0;
|
||||
int32_t field_2B4;
|
||||
struc_371 field_128[10];
|
||||
int8_t field_2B8;
|
||||
int8_t field_2B9;
|
||||
bool disp;
|
||||
int32_t stage_index;
|
||||
int32_t current_stage_index;
|
||||
std::vector<int32_t> stage_indices;
|
||||
FrameRateControl* frame_rate_control;
|
||||
int64_t field_2E0;
|
||||
GLuint vao;
|
||||
GLuint vbo;
|
||||
GLuint ebo;
|
||||
|
||||
Data();
|
||||
~Data();
|
||||
|
||||
void CalcPtcl(float_t delta_time);
|
||||
void CalcVert();
|
||||
void Ctrl();
|
||||
void CtrlInner(float_t delta_time);
|
||||
void Dest();
|
||||
void Disp();
|
||||
void Draw();
|
||||
void InitParticleData();
|
||||
void Reset();
|
||||
void SetStageIndices(std::vector<int32_t>& stage_indices);
|
||||
|
||||
static void DrawStatic(void* data);
|
||||
static float_t PtclRandom(float_t value);
|
||||
|
||||
void sub_140347B40(float_t delta_time);
|
||||
|
||||
static void sub_140347860(fog_ring_data* a1, int32_t a2, struc_371* a3, float_t a4);
|
||||
} data;
|
||||
|
||||
TaskEffectFogRing();
|
||||
@@ -342,19 +268,18 @@ struct TaskEffectFogRing : public TaskEffect {
|
||||
|
||||
virtual void PreInit(int32_t stage_index) override;
|
||||
virtual void SetStageIndices(std::vector<int32_t>& stage_indices) override;
|
||||
virtual void SetEnable(bool) override;
|
||||
virtual void SetStageIndex(int32_t value) override;
|
||||
virtual void SetEnable(bool value) override;
|
||||
virtual void SetCurrentStageIndex(int32_t value) override;
|
||||
virtual void SetFrameRateControl(FrameRateControl* value) override;
|
||||
virtual void Reset() override;
|
||||
};
|
||||
|
||||
struct TaskEffectLeaf : public TaskEffect {
|
||||
public:
|
||||
FrameRateControl* frame_rate_control;
|
||||
int32_t stage_index;
|
||||
int32_t current_stage_index;
|
||||
std::vector<int32_t> stage_indices;
|
||||
int32_t field_90;
|
||||
int32_t field_94;
|
||||
int64_t field_98;
|
||||
int32_t wait_frames;
|
||||
|
||||
TaskEffectLeaf();
|
||||
virtual ~TaskEffectLeaf() override;
|
||||
@@ -363,33 +288,23 @@ struct TaskEffectLeaf : public TaskEffect {
|
||||
virtual bool Ctrl() override;
|
||||
virtual bool Dest() override;
|
||||
virtual void Disp() override;
|
||||
virtual void Basic() override;
|
||||
|
||||
virtual void PreInit(int32_t stage_index) override;
|
||||
virtual void SetStageIndices(std::vector<int32_t>& stage_indices) override;
|
||||
virtual void SetFrame(int32_t value) override;
|
||||
virtual void Field_48() override;
|
||||
virtual void SetEnable(bool) override;
|
||||
virtual void SetStageIndex(int32_t value) override;
|
||||
virtual void SetEnable(bool value) override;
|
||||
virtual void SetCurrentStageIndex(int32_t value) override;
|
||||
virtual void SetFrameRateControl(FrameRateControl* value) override;
|
||||
virtual void Field_68() override;
|
||||
virtual void Reset() override;
|
||||
virtual void Field_78() override;
|
||||
virtual void Field_80() override;
|
||||
virtual void Field_88() override;
|
||||
virtual void Field_90() override;
|
||||
virtual void Field_98(int32_t a2, int32_t* a3) override;
|
||||
virtual void Field_A0(int32_t a2, int32_t* a3) override;
|
||||
virtual void Field_A8(int32_t a2, int8_t* a3) override;
|
||||
};
|
||||
|
||||
struct TaskEffectLitproj : public TaskEffect {
|
||||
int32_t stage_index;
|
||||
public:
|
||||
int32_t current_stage_index;
|
||||
std::vector<int32_t> stage_indices;
|
||||
int32_t field_88;
|
||||
int32_t wait_frames;
|
||||
vec4 diffuse;
|
||||
vec4 specular;
|
||||
int32_t field_AC;
|
||||
int32_t frame;
|
||||
|
||||
TaskEffectLitproj();
|
||||
virtual ~TaskEffectLitproj() override;
|
||||
@@ -398,31 +313,18 @@ struct TaskEffectLitproj : public TaskEffect {
|
||||
virtual bool Ctrl() override;
|
||||
virtual bool Dest() override;
|
||||
virtual void Disp() override;
|
||||
virtual void Basic() override;
|
||||
|
||||
virtual void PreInit(int32_t stage_index) override;
|
||||
virtual void SetStageIndices(std::vector<int32_t>& stage_indices) override;
|
||||
virtual void SetFrame(int32_t value) override;
|
||||
virtual void Field_48() override;
|
||||
virtual void SetEnable(bool) override;
|
||||
virtual void SetStageIndex(int32_t value) override;
|
||||
virtual void SetFrameRateControl(FrameRateControl* value) override;
|
||||
virtual void Field_68() override;
|
||||
virtual void SetEnable(bool value) override;
|
||||
virtual void SetCurrentStageIndex(int32_t value) override;
|
||||
virtual void Reset() override;
|
||||
virtual void Field_78() override;
|
||||
virtual void Field_80() override;
|
||||
virtual void Field_88() override;
|
||||
virtual void Field_90() override;
|
||||
virtual void Field_98(int32_t a2, int32_t* a3) override;
|
||||
virtual void Field_A0(int32_t a2, int32_t* a3) override;
|
||||
virtual void Field_A8(int32_t a2, int8_t* a3) override;
|
||||
};
|
||||
|
||||
struct TaskEffectParticle : public TaskEffect {
|
||||
public:
|
||||
FrameRateControl* frame_rate_control;
|
||||
int32_t field_70;
|
||||
int32_t field_74;
|
||||
int64_t field_78;
|
||||
int32_t current_stage_index;
|
||||
|
||||
TaskEffectParticle();
|
||||
virtual ~TaskEffectParticle() override;
|
||||
@@ -431,29 +333,18 @@ struct TaskEffectParticle : public TaskEffect {
|
||||
virtual bool Ctrl() override;
|
||||
virtual bool Dest() override;
|
||||
virtual void Disp() override;
|
||||
virtual void Basic() override;
|
||||
|
||||
virtual void PreInit(int32_t stage_index) override;
|
||||
virtual void SetStageIndices(std::vector<int32_t>& stage_indices) override;
|
||||
virtual void SetFrame(int32_t value) override;
|
||||
virtual void Field_48() override;
|
||||
virtual void SetEnable(bool) override;
|
||||
virtual void SetStageIndex(int32_t value) override;
|
||||
virtual void SetEnable(bool value) override;
|
||||
virtual void SetFrameRateControl(FrameRateControl* value) override;
|
||||
virtual void Field_68() override;
|
||||
virtual void Reset() override;
|
||||
virtual void Field_78() override;
|
||||
virtual void Field_80() override;
|
||||
virtual void Field_88() override;
|
||||
virtual void Field_90() override;
|
||||
virtual void Field_98(int32_t a2, int32_t* a3) override;
|
||||
virtual void Field_A0(int32_t a2, int32_t* a3) override;
|
||||
virtual void Field_A8(int32_t a2, int8_t* a3) override;
|
||||
virtual void Event(int32_t event_type, void* data) override;
|
||||
};
|
||||
|
||||
struct TaskEffectRain : public TaskEffect {
|
||||
public:
|
||||
FrameRateControl* frame_rate_control;
|
||||
int32_t stage_index;
|
||||
int32_t current_stage_index;
|
||||
std::vector<int32_t> stage_indices;
|
||||
|
||||
TaskEffectRain();
|
||||
@@ -463,24 +354,13 @@ struct TaskEffectRain : public TaskEffect {
|
||||
virtual bool Ctrl() override;
|
||||
virtual bool Dest() override;
|
||||
virtual void Disp() override;
|
||||
virtual void Basic() override;
|
||||
|
||||
virtual void PreInit(int32_t stage_index) override;
|
||||
virtual void SetStageIndices(std::vector<int32_t>& stage_indices) override;
|
||||
virtual void SetFrame(int32_t value) override;
|
||||
virtual void Field_48() override;
|
||||
virtual void SetEnable(bool) override;
|
||||
virtual void SetStageIndex(int32_t value) override;
|
||||
virtual void SetEnable(bool value) override;
|
||||
virtual void SetCurrentStageIndex(int32_t value) override;
|
||||
virtual void SetFrameRateControl(FrameRateControl* value) override;
|
||||
virtual void Field_68() override;
|
||||
virtual void Reset() override;
|
||||
virtual void Field_78() override;
|
||||
virtual void Field_80() override;
|
||||
virtual void Field_88() override;
|
||||
virtual void Field_90() override;
|
||||
virtual void Field_98(int32_t a2, int32_t* a3) override;
|
||||
virtual void Field_A0(int32_t a2, int32_t* a3) override;
|
||||
virtual void Field_A8(int32_t a2, int8_t* a3) override;
|
||||
};
|
||||
|
||||
struct color4u8 {
|
||||
@@ -490,22 +370,16 @@ struct color4u8 {
|
||||
uint8_t a;
|
||||
};
|
||||
|
||||
struct struc_101 {
|
||||
struct struc_101 {
|
||||
int32_t ripple_uniform;
|
||||
int32_t ripple_emit_uniform;
|
||||
int32_t count;
|
||||
int32_t field_C;
|
||||
vec3* vertex;
|
||||
color4u8* color;
|
||||
float_t size;
|
||||
int32_t field_24;
|
||||
};
|
||||
|
||||
struct struc_202 {
|
||||
vec2 field_0;
|
||||
float_t field_8;
|
||||
};
|
||||
|
||||
struct ripple_emit_draw_data {
|
||||
struc_101 data;
|
||||
vec3 vertex[16];
|
||||
@@ -537,7 +411,7 @@ struct ripple_emit {
|
||||
int32_t field_30;
|
||||
float_t rob_emitter_size;
|
||||
size_t emitter_num;
|
||||
struc_202* emitter_list;
|
||||
vec3* emitter_list;
|
||||
float_t emitter_size;
|
||||
int32_t field_4C;
|
||||
ripple_emit_draw_data field_50;
|
||||
@@ -551,18 +425,19 @@ struct ripple_emit {
|
||||
int32_t field_BE8;
|
||||
int8_t field_BEC;
|
||||
float_t wake_attn;
|
||||
float speed;
|
||||
float field_BF8;
|
||||
float field_BFC;
|
||||
float_t speed;
|
||||
float_t field_BF8;
|
||||
float_t field_BFC;
|
||||
int8_t field_C00;
|
||||
int32_t stage_index;
|
||||
int32_t current_stage_index;
|
||||
std::vector<int32_t> stage_indices;
|
||||
};
|
||||
|
||||
struct TaskEffectRipple : public TaskEffect {
|
||||
public:
|
||||
int64_t field_68;
|
||||
FrameRateControl* frame_rate_control;
|
||||
ripple_emit* emit_struct;
|
||||
ripple_emit* emit;
|
||||
|
||||
TaskEffectRipple();
|
||||
virtual ~TaskEffectRipple() override;
|
||||
@@ -571,29 +446,18 @@ struct TaskEffectRipple : public TaskEffect {
|
||||
virtual bool Ctrl() override;
|
||||
virtual bool Dest() override;
|
||||
virtual void Disp() override;
|
||||
virtual void Basic() override;
|
||||
|
||||
virtual void PreInit(int32_t stage_index) override;
|
||||
virtual void SetStageIndices(std::vector<int32_t>& stage_indices) override;
|
||||
virtual void SetFrame(int32_t value) override;
|
||||
virtual void Field_48() override;
|
||||
virtual void SetEnable(bool) override;
|
||||
virtual void SetStageIndex(int32_t value) override;
|
||||
virtual void SetCurrentStageIndex(int32_t value) override;
|
||||
virtual void SetFrameRateControl(FrameRateControl* value) override;
|
||||
virtual void Field_68() override;
|
||||
virtual void Reset() override;
|
||||
virtual void Field_78() override;
|
||||
virtual void Field_80() override;
|
||||
virtual void Field_88() override;
|
||||
virtual void Field_90() override;
|
||||
virtual void Field_98(int32_t a2, int32_t* a3) override;
|
||||
virtual void Field_A0(int32_t a2, int32_t* a3) override;
|
||||
virtual void Field_A8(int32_t a2, int8_t* a3) override;
|
||||
};
|
||||
|
||||
struct TaskEffectSnow : public TaskEffect {
|
||||
public:
|
||||
FrameRateControl* frame_rate_control;
|
||||
int32_t stage_index;
|
||||
int32_t current_stage_index;
|
||||
std::vector<int32_t> stage_indices;
|
||||
|
||||
TaskEffectSnow();
|
||||
@@ -609,12 +473,11 @@ struct TaskEffectSnow : public TaskEffect {
|
||||
virtual void SetStageIndices(std::vector<int32_t>& stage_indices) override;
|
||||
virtual void SetFrame(int32_t value) override;
|
||||
virtual void Field_48() override;
|
||||
virtual void SetEnable(bool) override;
|
||||
virtual void SetStageIndex(int32_t value) override;
|
||||
virtual void SetEnable(bool value) override;
|
||||
virtual void SetCurrentStageIndex(int32_t value) override;
|
||||
virtual void SetFrameRateControl(FrameRateControl* value) override;
|
||||
virtual void Field_68() override;
|
||||
virtual void Reset() override;
|
||||
virtual void Field_78() override;
|
||||
virtual void Field_80() override;
|
||||
virtual void Field_88() override;
|
||||
virtual void Field_90() override;
|
||||
@@ -697,6 +560,7 @@ struct ParticleDispObj {
|
||||
};
|
||||
|
||||
struct TaskEffectSplash : public TaskEffect {
|
||||
public:
|
||||
struct Data {
|
||||
struct Sub {
|
||||
int32_t field_0;
|
||||
@@ -730,7 +594,7 @@ struct TaskEffectSplash : public TaskEffect {
|
||||
int8_t field_8;
|
||||
Sub field_10;
|
||||
int8_t field_110;
|
||||
int32_t stage_index;
|
||||
int32_t current_stage_index;
|
||||
std::vector<int32_t> stage_indices;
|
||||
FrameRateControl* frame_rate_control;
|
||||
int64_t field_138;
|
||||
@@ -752,12 +616,11 @@ struct TaskEffectSplash : public TaskEffect {
|
||||
virtual void SetStageIndices(std::vector<int32_t>& stage_indices) override;
|
||||
virtual void SetFrame(int32_t value) override;
|
||||
virtual void Field_48() override;
|
||||
virtual void SetEnable(bool) override;
|
||||
virtual void SetStageIndex(int32_t value) override;
|
||||
virtual void SetEnable(bool value) override;
|
||||
virtual void SetCurrentStageIndex(int32_t value) override;
|
||||
virtual void SetFrameRateControl(FrameRateControl* value) override;
|
||||
virtual void Field_68() override;
|
||||
virtual void Reset() override;
|
||||
virtual void Field_78() override;
|
||||
virtual void Field_80() override;
|
||||
virtual void Field_88() override;
|
||||
virtual void Field_90() override;
|
||||
@@ -767,8 +630,9 @@ struct TaskEffectSplash : public TaskEffect {
|
||||
};
|
||||
|
||||
struct TaskEffectStar : public TaskEffect {
|
||||
public:
|
||||
FrameRateControl* frame_rate_control;
|
||||
int32_t stage_index;
|
||||
int32_t current_stage_index;
|
||||
float_t delta_frame;
|
||||
std::vector<int32_t> stage_indices;
|
||||
|
||||
@@ -785,12 +649,11 @@ struct TaskEffectStar : public TaskEffect {
|
||||
virtual void SetStageIndices(std::vector<int32_t>& stage_indices) override;
|
||||
virtual void SetFrame(int32_t value) override;
|
||||
virtual void Field_48() override;
|
||||
virtual void SetEnable(bool) override;
|
||||
virtual void SetStageIndex(int32_t value) override;
|
||||
virtual void SetEnable(bool value) override;
|
||||
virtual void SetCurrentStageIndex(int32_t value) override;
|
||||
virtual void SetFrameRateControl(FrameRateControl* value) override;
|
||||
virtual void Field_68() override;
|
||||
virtual void Reset() override;
|
||||
virtual void Field_78() override;
|
||||
virtual void Field_80() override;
|
||||
virtual void Field_88() override;
|
||||
virtual void Field_90() override;
|
||||
@@ -798,3 +661,26 @@ struct TaskEffectStar : public TaskEffect {
|
||||
virtual void Field_A0(int32_t a2, int32_t* a3) override;
|
||||
virtual void Field_A8(int32_t a2, int8_t* a3) override;
|
||||
};
|
||||
|
||||
extern void leaf_particle_draw();
|
||||
extern void rain_particle_draw();
|
||||
extern void particle_draw();
|
||||
extern void snow_particle_draw();
|
||||
|
||||
extern void task_effect_init();
|
||||
extern void task_effect_free();
|
||||
|
||||
extern void task_effect_parent_event(TaskEffectType type, int32_t event_type, void* data);
|
||||
extern void task_effect_parent_dest();
|
||||
extern bool task_effect_parent_load();
|
||||
extern void task_effect_parent_reset();
|
||||
extern void task_effect_parent_set_current_stage_hash(uint32_t stage_hash);
|
||||
extern void task_effect_parent_set_current_stage_index(int32_t stage_index);
|
||||
extern void task_effect_parent_set_data(void* data,
|
||||
object_database* obj_db, texture_database* tex_db, stage_database* stage_data);
|
||||
extern void task_effect_parent_set_enable(bool value);
|
||||
extern void task_effect_parent_set_frame(int32_t value);
|
||||
extern void task_effect_parent_set_frame_rate_control(FrameRateControl* value);
|
||||
extern void task_effect_parent_set_stage_hashes(std::vector<uint32_t>& stage_hashes);
|
||||
extern void task_effect_parent_set_stage_indices(std::vector<int32_t>& stage_indices);
|
||||
extern bool task_effect_parent_unload();
|
||||
|
||||
+22
-92
@@ -11,13 +11,6 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
struct texture_params {
|
||||
GLenum target;
|
||||
GLint wrap_s;
|
||||
GLint wrap_t;
|
||||
GLint wrap_r;
|
||||
};
|
||||
|
||||
static void texture_get_format_type_by_internal_format(GLenum internal_format, GLenum* format, GLenum* type);
|
||||
static uint32_t texture_get_height_align_mip_level(texture* tex, int32_t mip_level);
|
||||
static uint32_t texture_get_height_mip_level(texture* tex, int32_t mip_level);
|
||||
@@ -34,7 +27,6 @@ static void texture_set_params(GLuint texture, GLenum target, int32_t max_mipmap
|
||||
static GLenum texture_txp_get_internal_format(txp* t);
|
||||
|
||||
std::vector<texture*> texture_storage;
|
||||
std::map<GLuint, texture_params> texture_params_storage;
|
||||
|
||||
texture_id::texture_id() : id(0), index(0) {
|
||||
|
||||
@@ -49,6 +41,22 @@ tex(), target(), internal_format(), max_mipmap_level(), size() {
|
||||
|
||||
}
|
||||
|
||||
uint32_t texture::get_height_align_mip_level(uint8_t mip_level) {
|
||||
uint32_t height = this->height >> mip_level;
|
||||
if (flags & TEXTURE_BLOCK_COMPRESSION)
|
||||
return max_def(height, 4);
|
||||
else
|
||||
return max_def(height, 1);
|
||||
}
|
||||
|
||||
uint32_t texture::get_width_align_mip_level(uint8_t mip_level) {
|
||||
uint32_t width = this->width >> mip_level;
|
||||
if (flags & TEXTURE_BLOCK_COMPRESSION)
|
||||
return max_def(width, 4);
|
||||
else
|
||||
return max_def(width, 1);
|
||||
}
|
||||
|
||||
texture* texture_init(texture_id id) {
|
||||
return texture_storage_create_texture(id);
|
||||
}
|
||||
@@ -202,7 +210,6 @@ bool texture_txp_set_load(txp_set* t, texture*** texs, texture_id* ids) {
|
||||
|
||||
inline void texture_storage_init() {
|
||||
texture_storage = {};
|
||||
texture_params_storage = {};
|
||||
}
|
||||
|
||||
inline texture* texture_storage_create_texture(texture_id id) {
|
||||
@@ -252,7 +259,6 @@ inline void texture_storage_delete_texture(texture_id id) {
|
||||
break;
|
||||
}
|
||||
|
||||
texture_params_storage.erase(tex->tex);
|
||||
glDeleteTextures(1, &tex->tex);
|
||||
delete tex;
|
||||
i = texture_storage.erase(i);
|
||||
@@ -260,90 +266,12 @@ inline void texture_storage_delete_texture(texture_id id) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void texture_storage_set_texture_wrap(GLuint texture, GLint wrap_s, GLint wrap_t) {
|
||||
auto elem = texture_params_storage.find(texture);
|
||||
if (elem == texture_params_storage.end())
|
||||
return;
|
||||
|
||||
texture_params& params = elem->second;
|
||||
if (params.wrap_s != wrap_s) {
|
||||
glTexParameteri(params.target, GL_TEXTURE_WRAP_S, wrap_s);
|
||||
params.wrap_s = wrap_s;
|
||||
}
|
||||
|
||||
if (params.wrap_t != wrap_t) {
|
||||
glTexParameteri(params.target, GL_TEXTURE_WRAP_T, wrap_t);
|
||||
params.wrap_t = wrap_t;
|
||||
}
|
||||
}
|
||||
|
||||
inline void texture_storage_set_texture_wrap(GLuint texture, GLint wrap_s, GLint wrap_t, GLint wrap_r) {
|
||||
auto elem = texture_params_storage.find(texture);
|
||||
if (elem == texture_params_storage.end())
|
||||
return;
|
||||
|
||||
texture_params& params = elem->second;
|
||||
if (params.wrap_s != wrap_s) {
|
||||
glTexParameteri(params.target, GL_TEXTURE_WRAP_S, wrap_s);
|
||||
params.wrap_s = wrap_s;
|
||||
}
|
||||
|
||||
if (params.wrap_t != wrap_t) {
|
||||
glTexParameteri(params.target, GL_TEXTURE_WRAP_T, wrap_t);
|
||||
params.wrap_t = wrap_t;
|
||||
}
|
||||
|
||||
if (params.wrap_r != wrap_r) {
|
||||
glTexParameteri(params.target, GL_TEXTURE_WRAP_R, wrap_r);
|
||||
params.wrap_r = wrap_r;
|
||||
}
|
||||
}
|
||||
|
||||
inline void texture_storage_set_texture_wrap_s(GLuint texture, GLint wrap) {
|
||||
auto elem = texture_params_storage.find(texture);
|
||||
if (elem == texture_params_storage.end())
|
||||
return;
|
||||
|
||||
texture_params& params = elem->second;
|
||||
if (params.wrap_s != wrap) {
|
||||
glTexParameteri(params.target, GL_TEXTURE_WRAP_S, wrap);
|
||||
params.wrap_s = wrap;
|
||||
}
|
||||
}
|
||||
|
||||
inline void texture_storage_set_texture_wrap_t(GLuint texture, GLint wrap) {
|
||||
auto elem = texture_params_storage.find(texture);
|
||||
if (elem == texture_params_storage.end())
|
||||
return;
|
||||
|
||||
texture_params& params = elem->second;
|
||||
if (params.wrap_t != wrap) {
|
||||
glTexParameteri(params.target, GL_TEXTURE_WRAP_T, wrap);
|
||||
params.wrap_t = wrap;
|
||||
}
|
||||
}
|
||||
|
||||
inline void texture_storage_set_texture_wrap_r(GLuint texture, GLint wrap) {
|
||||
auto elem = texture_params_storage.find(texture);
|
||||
if (elem == texture_params_storage.end())
|
||||
return;
|
||||
|
||||
texture_params& params = elem->second;
|
||||
if (params.wrap_r != wrap) {
|
||||
glTexParameteri(params.target, GL_TEXTURE_WRAP_R, wrap);
|
||||
params.wrap_r = wrap;
|
||||
}
|
||||
}
|
||||
|
||||
inline void texture_storage_free() {
|
||||
for (texture*& i : texture_storage) {
|
||||
if (i) {
|
||||
texture_params_storage.erase(i->tex);
|
||||
if (i)
|
||||
glDeleteTextures(1, &i->tex);
|
||||
}
|
||||
delete i;
|
||||
}
|
||||
texture_params_storage.clear();
|
||||
texture_storage.clear();
|
||||
texture_storage.shrink_to_fit();
|
||||
}
|
||||
@@ -568,7 +496,6 @@ static texture* texture_load_tex(texture_id id, GLenum target,
|
||||
return tex;
|
||||
|
||||
glGenTextures(1, &tex->tex);
|
||||
texture_params_storage.insert({ tex->tex, { target } });
|
||||
switch (target) {
|
||||
case GL_TEXTURE_2D:
|
||||
gl_state_bind_texture_2d(tex->tex);
|
||||
@@ -703,8 +630,11 @@ fail:
|
||||
}
|
||||
|
||||
static void texture_set_params(GLuint texture, GLenum target, int32_t max_mipmap_level, bool use_high_anisotropy) {
|
||||
texture_storage_set_texture_wrap(target, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, (float_t*)&vec4_null);
|
||||
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||
static const vec4 border_color = 0.0f;
|
||||
glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, (GLfloat*)&border_color);
|
||||
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
|
||||
max_mipmap_level > 0 ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
|
||||
|
||||
+3
-5
@@ -59,6 +59,9 @@ struct texture {
|
||||
int32_t size;
|
||||
|
||||
texture();
|
||||
|
||||
uint32_t get_height_align_mip_level(uint8_t mip_level = 0);
|
||||
uint32_t get_width_align_mip_level(uint8_t mip_level = 0);
|
||||
};
|
||||
|
||||
extern texture* texture_init(texture_id id);
|
||||
@@ -82,9 +85,4 @@ extern texture* texture_storage_get_texture(texture_id id);
|
||||
extern size_t texture_storage_get_texture_count();
|
||||
extern texture* texture_storage_get_texture_by_index(size_t index);
|
||||
extern void texture_storage_delete_texture(texture_id id);
|
||||
extern void texture_storage_set_texture_wrap(GLuint texture, GLint wrap_s, GLint wrap_t);
|
||||
extern void texture_storage_set_texture_wrap(GLuint texture, GLint wrap_s, GLint wrap_t, GLint wrap_r);
|
||||
extern void texture_storage_set_texture_wrap_s(GLuint texture, GLint wrap);
|
||||
extern void texture_storage_set_texture_wrap_t(GLuint texture, GLint wrap);
|
||||
extern void texture_storage_set_texture_wrap_r(GLuint texture, GLint wrap);
|
||||
extern void texture_storage_free();
|
||||
|
||||
+128
-132
@@ -5,32 +5,32 @@
|
||||
|
||||
#include "bone_data.hpp"
|
||||
|
||||
typedef enum HeapCMallocType {
|
||||
enum HeapCMallocType {
|
||||
HeapCMallocSystem = 0x00,
|
||||
HeapCMallocTemp = 0x01,
|
||||
HeapCMallocMode = 0x02,
|
||||
HeapCMallocEvent = 0x03,
|
||||
HeapCMallocDebug = 0x04,
|
||||
HeapCMallocMax = 0x05,
|
||||
} HeapCMallocType;
|
||||
};
|
||||
|
||||
typedef struct skeleton_rotation_offset {
|
||||
struct skeleton_rotation_offset {
|
||||
bool x;
|
||||
bool y;
|
||||
bool z;
|
||||
vec3 rotation;
|
||||
} skeleton_rotation_offset;
|
||||
};
|
||||
|
||||
typedef struct struc_403 {
|
||||
struct struc_403 {
|
||||
int32_t field_0;
|
||||
int32_t field_4;
|
||||
int32_t field_8;
|
||||
} struc_403;
|
||||
};
|
||||
|
||||
typedef struct struc_404 {
|
||||
struct struc_404 {
|
||||
int32_t field_0;
|
||||
int32_t field_4;
|
||||
} struc_404;
|
||||
};
|
||||
|
||||
ExNodeBlock_vtbl* ExClothBlock_vftable = (ExNodeBlock_vtbl*)0x0000000140A82FF0;
|
||||
ExNodeBlock_vtbl* ExOsageBlock_vftable = (ExNodeBlock_vtbl*)0x0000000140A82F88;
|
||||
@@ -60,20 +60,20 @@ static void bone_node_expression_data_set_position_rotation(bone_node_expression
|
||||
data->rotation.x = rotation_x;
|
||||
data->rotation.z = rotation_z;
|
||||
data->rotation.y = rotation_y;
|
||||
data->scale = vec3_identity;
|
||||
data->parent_scale = vec3_identity;
|
||||
data->scale = 1.0f;
|
||||
data->parent_scale = 1.0f;
|
||||
}
|
||||
|
||||
static void bone_node_expression_data_reset_scale(bone_node_expression_data* data) {
|
||||
data->scale = vec3_identity;
|
||||
data->parent_scale = vec3_identity;
|
||||
data->scale = 1.0f;
|
||||
data->parent_scale = 1.0f;
|
||||
}
|
||||
|
||||
static void bone_node_data_reset_position_rotation(bone_node_expression_data* data) {
|
||||
data->position = vec3_null;
|
||||
data->rotation = vec3_null;
|
||||
data->scale = vec3_identity;
|
||||
data->parent_scale = vec3_identity;
|
||||
data->position = 0.0f;
|
||||
data->rotation = 0.0f;
|
||||
data->scale = 1.0f;
|
||||
data->parent_scale = 1.0f;
|
||||
}
|
||||
|
||||
static bone_data* bone_data_init(bone_data* bone) {
|
||||
@@ -88,16 +88,16 @@ static bone_data* bone_data_init(bone_data* bone) {
|
||||
bone->frame = 0;
|
||||
|
||||
for (int32_t i = 0; i < 2; i++)
|
||||
bone->base_translation[i] = vec3_null;
|
||||
bone->base_translation[i] = 0.0f;
|
||||
|
||||
bone->rotation = vec3_null;
|
||||
bone->ik_target = vec3_null;
|
||||
bone->trans = vec3_null;
|
||||
bone->rotation = 0.0f;
|
||||
bone->ik_target = 0.0f;
|
||||
bone->trans = 0.0f;
|
||||
for (int32_t i = 0; i < 2; i++)
|
||||
bone->rot_mat[i] = mat4_null;
|
||||
|
||||
for (int32_t i = 0; i < 2; i++)
|
||||
bone->trans_prev[i] = vec3_null;
|
||||
bone->trans_prev[i] = 0.0f;
|
||||
|
||||
for (int32_t i = 0; i < 2; i++)
|
||||
for (int32_t j = 0; j < 3; j++)
|
||||
@@ -237,10 +237,10 @@ static void rob_chara_bone_data_reserve(rob_chara_bone_data* rob_bone_data) {
|
||||
i->name = 0;
|
||||
i->mat = 0;
|
||||
i->parent = 0;
|
||||
i->exp_data.position = vec3_null;
|
||||
i->exp_data.rotation = vec3_null;
|
||||
i->exp_data.scale = vec3_identity;
|
||||
i->exp_data.parent_scale = vec3_identity;
|
||||
i->exp_data.position = 0.0f;
|
||||
i->exp_data.rotation = 0.0f;
|
||||
i->exp_data.scale = 1.0f;
|
||||
i->exp_data.parent_scale = 1.0f;
|
||||
i->ex_data_mat = 0;
|
||||
}
|
||||
}
|
||||
@@ -304,15 +304,15 @@ static void rob_chara_bone_data_set_mats(rob_chara_bone_data* rob_bone_data,
|
||||
i->ex_data_mat = i->mat;
|
||||
|
||||
if (total_bone_count != rob_bone_data->total_bone_count)
|
||||
printf("Node mismatch\n");
|
||||
printf_debug("Node mismatch\n");
|
||||
if (mats - rob_bone_data->mats.begin != rob_bone_data->object_bone_count)
|
||||
printf("Matrix mismatch\n");
|
||||
printf_debug("Matrix mismatch\n");
|
||||
if (mats2 - rob_bone_data->mats2.begin != rob_bone_data->total_bone_count - rob_bone_data->object_bone_count)
|
||||
printf("Matrix2 mismatch\n");
|
||||
printf_debug("Matrix2 mismatch\n");
|
||||
if (ik_bone_count != rob_bone_data->ik_bone_count)
|
||||
printf("LeafPos mismatch\n");
|
||||
printf_debug("LeafPos mismatch\n");
|
||||
if (chain_pos != rob_bone_data->chain_pos)
|
||||
printf("ChainPos mismatch\n");
|
||||
printf_debug("ChainPos mismatch\n");
|
||||
}
|
||||
|
||||
static void rob_chara_bone_data_set_parent_mats(rob_chara_bone_data* rob_bone_data,
|
||||
@@ -1234,12 +1234,12 @@ static void bone_data_mult_0(bone_data* a1, int32_t skeleton_select) {
|
||||
mat = mat4_identity;
|
||||
|
||||
if (a1->type == BONE_DATABASE_BONE_POSITION) {
|
||||
mat4_translate_mult(&mat, a1->trans.x, a1->trans.y, a1->trans.z, &mat);
|
||||
mat4_translate_mult(&mat, &a1->trans, &mat);
|
||||
a1->rot_mat[0] = mat4_identity;
|
||||
}
|
||||
else if (a1->type == BONE_DATABASE_BONE_TYPE_1) {
|
||||
mat4_mult_vec3_inv_trans(&mat, &a1->trans, &a1->trans);
|
||||
mat4_translate_mult(&mat, a1->trans.x, a1->trans.y, a1->trans.z, &mat);
|
||||
mat4_translate_mult(&mat, &a1->trans, &mat);
|
||||
a1->rot_mat[0] = mat4_identity;
|
||||
}
|
||||
else {
|
||||
@@ -1264,7 +1264,7 @@ static void bone_data_mult_0(bone_data* a1, int32_t skeleton_select) {
|
||||
}
|
||||
|
||||
mat4_rotate_x_mult(&rot_mat, a1->rotation.x, &rot_mat);
|
||||
mat4_translate_mult(&mat, a1->trans.x, a1->trans.y, a1->trans.z, &mat);
|
||||
mat4_translate_mult(&mat, &a1->trans, &mat);
|
||||
mat4_mult(&rot_mat, &mat, &mat);
|
||||
mat4_transpose(&rot_mat, &a1->rot_mat[0]);
|
||||
}
|
||||
@@ -1286,16 +1286,15 @@ void bone_data_mult_1(bone_data* a1, mat4* parent_mat, bone_data* a3, bool a4) {
|
||||
if (a1->type != BONE_DATABASE_BONE_POSITION_ROTATION)
|
||||
a1->trans = a1->base_translation[1];
|
||||
|
||||
mat4_translate_mult(&mat, a1->trans.x, a1->trans.y, a1->trans.z, &mat);
|
||||
mat4_translate_mult(&mat, &a1->trans, &mat);
|
||||
if (a4) {
|
||||
a1->node[0].exp_data.rotation = vec3_null;
|
||||
a1->node[0].exp_data.rotation = 0.0f;
|
||||
if (!a1->flags) {
|
||||
mat4_transpose(&a1->rot_mat[0], &rot_mat);
|
||||
mat4_get_rotation(&rot_mat, &a1->node[0].exp_data.rotation);
|
||||
}
|
||||
else if (bone_data_mult_1_exp_data(a1, &a1->node[0].exp_data, a3)) {
|
||||
vec3 rotation = a1->node[0].exp_data.rotation;
|
||||
mat4_rotate(rotation.x, rotation.y, rotation.z, &rot_mat);
|
||||
mat4_rotate(&a1->node[0].exp_data.rotation, &rot_mat);
|
||||
mat4_transpose(&rot_mat, &a1->rot_mat[0]);
|
||||
}
|
||||
else {
|
||||
@@ -1320,9 +1319,9 @@ void bone_data_mult_1(bone_data* a1, mat4* parent_mat, bone_data* a3, bool a4) {
|
||||
|
||||
}
|
||||
else {
|
||||
mat4_translate_mult(&mat, a1->trans.x, a1->trans.y, a1->trans.z, &mat);
|
||||
mat4_translate_mult(&mat, &a1->trans, &mat);
|
||||
if (a4)
|
||||
a1->node[0].exp_data.rotation = vec3_null;
|
||||
a1->node[0].exp_data.rotation = 0.0f;
|
||||
}
|
||||
|
||||
mat4_transpose(&mat, a1->node[0].mat);
|
||||
@@ -1344,7 +1343,7 @@ void bone_data_mult_1(bone_data* a1, mat4* parent_mat, bone_data* a3, bool a4) {
|
||||
if (!a4)
|
||||
return;
|
||||
|
||||
a1->node[1].exp_data.position = vec3_null;
|
||||
a1->node[1].exp_data.position = 0.0f;
|
||||
mat4_transpose(&a1->rot_mat[1], &rot_mat);
|
||||
mat4_get_rotation(&rot_mat, &a1->node[1].exp_data.rotation);
|
||||
bone_node_expression_data_reset_scale(&a1->node[1].exp_data);
|
||||
@@ -1360,12 +1359,12 @@ void bone_data_mult_1(bone_data* a1, mat4* parent_mat, bone_data* a3, bool a4) {
|
||||
if (!a4)
|
||||
return;
|
||||
|
||||
a1->node[1].exp_data.position = vec3_null;
|
||||
a1->node[1].exp_data.position = 0.0f;
|
||||
mat4_transpose(&a1->rot_mat[1], &rot_mat);
|
||||
mat4_get_rotation(&rot_mat, &a1->node[1].exp_data.rotation);
|
||||
bone_node_expression_data_reset_scale(&a1->node[1].exp_data);
|
||||
a1->node[2].exp_data.position.x = a1->ik_segment_length[1];
|
||||
*(vec2*)&a1->node[2].exp_data.position.y = vec2_null;
|
||||
*(vec2*)&a1->node[2].exp_data.position.y = 0.0f;
|
||||
mat4_transpose(&a1->rot_mat[2], &rot_mat);
|
||||
mat4_get_rotation(&rot_mat, &a1->node[2].exp_data.rotation);
|
||||
bone_node_expression_data_reset_scale(&a1->node[2].exp_data);
|
||||
@@ -1398,7 +1397,7 @@ static void sub_14040FBF0(motion_blend_mot* a1, float_t a2) {
|
||||
bone_data* b_kg_hara_y = &a1->bone_data.bones.begin[MOTION_BONE_KG_HARA_Y];
|
||||
bone_data* b_kl_hara_xz = &a1->bone_data.bones.begin[MOTION_BONE_KL_HARA_XZ];
|
||||
bone_data* b_kl_hara_etc = &a1->bone_data.bones.begin[MOTION_BONE_KL_HARA_ETC];
|
||||
a1->field_4F8.field_90 = vec3_null;
|
||||
a1->field_4F8.field_90 = 0.0f;
|
||||
|
||||
mat4 rot_mat;
|
||||
mat4 mat;
|
||||
@@ -1544,7 +1543,7 @@ static void sub_1404182B0(rob_chara_bone_data* rob_bone_data) {
|
||||
v3->field_4F8.field_9C = b_n_hara_cp->trans;
|
||||
if (v3->field_4F8.field_0 & 2) {
|
||||
v3->field_4F8.field_90 = b_n_hara_cp->trans;
|
||||
b_n_hara_cp->trans = vec3_null;
|
||||
b_n_hara_cp->trans = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1937,7 +1936,7 @@ static void rob_chara_motion_reset(rob_chara_motion* a1) {
|
||||
parts_adjust->enable = false;
|
||||
parts_adjust->frame = 0.0f;
|
||||
parts_adjust->transition_frame = 0.0f;
|
||||
parts_adjust->curr_external_force = vec3_null;
|
||||
parts_adjust->curr_external_force = 0.0f;
|
||||
parts_adjust->curr_force = 1.0f;
|
||||
parts_adjust->curr_strength = 1.0f;
|
||||
parts_adjust->motion_id = -1;
|
||||
@@ -1946,9 +1945,9 @@ static void rob_chara_motion_reset(rob_chara_motion* a1) {
|
||||
parts_adjust->type = 6;
|
||||
parts_adjust->cycle_type = 0;
|
||||
parts_adjust->ignore_gravity = false;
|
||||
parts_adjust->external_force = vec3_null;
|
||||
parts_adjust->external_force_cycle_strength = vec3_null;
|
||||
parts_adjust->external_force_cycle = vec3_null;
|
||||
parts_adjust->external_force = 0.0f;
|
||||
parts_adjust->external_force_cycle_strength = 0.0f;
|
||||
parts_adjust->external_force_cycle = 0.0f;
|
||||
parts_adjust->cycle = 1.0f;
|
||||
parts_adjust->phase = 0.0f;
|
||||
parts_adjust->force = 1.0f;
|
||||
@@ -1957,7 +1956,7 @@ static void rob_chara_motion_reset(rob_chara_motion* a1) {
|
||||
parts_adjust_prev->enable = false;
|
||||
parts_adjust_prev->frame = 0.0f;
|
||||
parts_adjust_prev->transition_frame = 0.0f;
|
||||
parts_adjust_prev->curr_external_force = vec3_null;
|
||||
parts_adjust_prev->curr_external_force = 0.0f;
|
||||
parts_adjust_prev->curr_force = 1.0f;
|
||||
parts_adjust_prev->curr_strength = 1.0f;
|
||||
parts_adjust_prev->motion_id = -1;
|
||||
@@ -1966,9 +1965,9 @@ static void rob_chara_motion_reset(rob_chara_motion* a1) {
|
||||
parts_adjust_prev->type = 6;
|
||||
parts_adjust_prev->cycle_type = 0;
|
||||
parts_adjust_prev->ignore_gravity = false;
|
||||
parts_adjust_prev->external_force = vec3_null;
|
||||
parts_adjust_prev->external_force_cycle_strength = vec3_null;
|
||||
parts_adjust_prev->external_force_cycle = vec3_null;
|
||||
parts_adjust_prev->external_force = 0.0f;
|
||||
parts_adjust_prev->external_force_cycle_strength = 0.0f;
|
||||
parts_adjust_prev->external_force_cycle = 0.0f;
|
||||
parts_adjust_prev->cycle = 1.0f;
|
||||
parts_adjust_prev->phase = 0.0f;
|
||||
parts_adjust_prev->force = 1.0f;
|
||||
@@ -1986,7 +1985,7 @@ static void rob_chara_motion_reset(rob_chara_motion* a1) {
|
||||
v7->enable = false;
|
||||
v7->frame = 0.0f;
|
||||
v7->transition_frame = 0.0f;
|
||||
v7->curr_external_force = vec3_null;
|
||||
v7->curr_external_force = 0.0f;
|
||||
v7->curr_force = 1.0f;
|
||||
v7->curr_strength = 1.0f;
|
||||
v7->motion_id = -1;
|
||||
@@ -1995,9 +1994,9 @@ static void rob_chara_motion_reset(rob_chara_motion* a1) {
|
||||
v7->type = 6;
|
||||
v7->cycle_type = 0;
|
||||
v7->ignore_gravity = false;
|
||||
v7->external_force = vec3_null;
|
||||
v7->external_force_cycle_strength = vec3_null;
|
||||
v7->external_force_cycle = vec3_null;
|
||||
v7->external_force = 0.0f;
|
||||
v7->external_force_cycle_strength = 0.0f;
|
||||
v7->external_force_cycle = 0.0f;
|
||||
v7->cycle = 1.0f;
|
||||
v7->phase = 0.0f;
|
||||
v7->force = 1.0f;
|
||||
@@ -2022,8 +2021,8 @@ static void rob_chara_motion_reset(rob_chara_motion* a1) {
|
||||
hand_adjust->disable_x = false;
|
||||
hand_adjust->disable_y = false;
|
||||
hand_adjust->disable_z = false;
|
||||
hand_adjust->offset = vec3_null;
|
||||
hand_adjust->field_30 = vec3_null;
|
||||
hand_adjust->offset = 0.0f;
|
||||
hand_adjust->field_30 = 0.0f;
|
||||
hand_adjust->arm_length = 0;
|
||||
hand_adjust_prev->enable = false;
|
||||
hand_adjust_prev->scale_select = 0;
|
||||
@@ -2038,8 +2037,8 @@ static void rob_chara_motion_reset(rob_chara_motion* a1) {
|
||||
hand_adjust_prev->disable_x = false;
|
||||
hand_adjust_prev->disable_y = false;
|
||||
hand_adjust_prev->disable_z = false;
|
||||
hand_adjust_prev->offset = vec3_null;
|
||||
hand_adjust_prev->field_30 = vec3_null;
|
||||
hand_adjust_prev->offset = 0.0f;
|
||||
hand_adjust_prev->field_30 = 0.0f;
|
||||
hand_adjust_prev->arm_length = 0;
|
||||
v7++;
|
||||
v8++;
|
||||
@@ -2114,8 +2113,8 @@ static void bone_data_parent_reset(bone_data_parent* a1) {
|
||||
a1->field_8 = false;
|
||||
a1->field_9 = false;
|
||||
a1->motion_bone_count = 0;
|
||||
a1->global_trans = vec3_null;
|
||||
a1->global_rotation = vec3_null;
|
||||
a1->global_trans = 0.0f;
|
||||
a1->global_rotation = 0.0f;
|
||||
a1->ik_bone_count = 0;
|
||||
a1->chain_pos = 0;
|
||||
a1->bone_key_set_count = 0;
|
||||
@@ -2134,14 +2133,14 @@ static void sub_140413470(struc_308* a1) {
|
||||
a1->field_8C = false;
|
||||
a1->rot_y = 0.0f;
|
||||
a1->prev_rot_y = 0.0f;
|
||||
a1->field_90 = vec3_identity;
|
||||
a1->field_9C = vec3_identity;
|
||||
a1->field_A8 = vec3_identity;
|
||||
a1->field_90 = 1.0f;
|
||||
a1->field_9C = 1.0f;
|
||||
a1->field_A8 = 1.0f;
|
||||
a1->field_BC = 0;
|
||||
a1->field_BD = 0;
|
||||
a1->field_C0 = 1.0f;
|
||||
a1->field_C4 = 1.0f;
|
||||
a1->field_C8 = vec3_null;
|
||||
a1->field_C8 = 0.0f;
|
||||
}
|
||||
|
||||
static void motion_blend_mot_reset(motion_blend_mot* a1) {
|
||||
@@ -2254,8 +2253,8 @@ static void sub_1404198D0(struc_258* a1) {
|
||||
a1->field_A8 = 0;
|
||||
a1->field_AC = 0;
|
||||
a1->field_B0 = 0.0f;
|
||||
a1->field_B4 = vec3_null;
|
||||
a1->field_C0 = vec3_null;
|
||||
a1->field_B4 = 0.0f;
|
||||
a1->field_C0 = 0.0f;
|
||||
a1->field_CC = mat4_identity;
|
||||
a1->field_10C = mat4_identity;
|
||||
a1->field_14C = 0;
|
||||
@@ -2287,7 +2286,7 @@ static void sub_1404198D0(struc_258* a1) {
|
||||
a1->field_1B4 = 0;
|
||||
a1->field_1B8 = 0;
|
||||
a1->field_1C8 = 0;
|
||||
a1->field_1BC = vec2_identity;
|
||||
a1->field_1BC = 1.0f;
|
||||
a1->field_1C4 = 0;
|
||||
}
|
||||
|
||||
@@ -2299,7 +2298,7 @@ static void sub_1403FAEF0(struc_312* a1) {
|
||||
a1->field_0.field_10 = 0;
|
||||
a1->field_0.field_14 = 0;
|
||||
a1->field_0.field_18 = 0;
|
||||
a1->field_0.field_1C = vec3_null;
|
||||
a1->field_0.field_1C = 0.0f;
|
||||
a1->field_0.field_28 = 0;
|
||||
a1->field_2C.field_0 = 0;
|
||||
a1->field_2C.field_4 = 0;
|
||||
@@ -2308,16 +2307,16 @@ static void sub_1403FAEF0(struc_312* a1) {
|
||||
a1->field_2C.field_10 = 0;
|
||||
a1->field_2C.field_14 = 0;
|
||||
a1->field_2C.field_18 = 0;
|
||||
a1->field_2C.field_1C = vec3_null;
|
||||
a1->field_2C.field_1C = 0.0f;
|
||||
a1->field_2C.field_28 = 0;
|
||||
a1->field_58 = 0;
|
||||
a1->field_8C = 1.0f;
|
||||
a1->bones = 0;
|
||||
a1->step = 1.0f;
|
||||
a1->field_5C = vec3_null;
|
||||
a1->field_68 = vec3_null;
|
||||
a1->field_74 = vec3_null;
|
||||
a1->field_80 = vec3_null;
|
||||
a1->field_5C = 0.0f;
|
||||
a1->field_68 = 0.0f;
|
||||
a1->field_74 = 0.0f;
|
||||
a1->field_80 = 0.0f;
|
||||
}
|
||||
|
||||
static void rob_chara_bone_data_reset(rob_chara_bone_data* rob_bone_data) {
|
||||
@@ -2365,8 +2364,8 @@ static void rob_chara_bone_data_reset(rob_chara_bone_data* rob_bone_data) {
|
||||
rob_bone_data->ik_scale.ratio1 = 1.0f;
|
||||
rob_bone_data->ik_scale.ratio2 = 1.0f;
|
||||
rob_bone_data->ik_scale.ratio3 = 1.0f;
|
||||
rob_bone_data->field_76C = vec3_null;
|
||||
rob_bone_data->field_778 = vec3_null;
|
||||
rob_bone_data->field_76C = 0.0f;
|
||||
rob_bone_data->field_778 = 0.0f;
|
||||
sub_1404198D0(&rob_bone_data->field_788);
|
||||
sub_1403FAEF0(&rob_bone_data->field_958);
|
||||
}
|
||||
@@ -2535,12 +2534,12 @@ static bool motion_blend_mot_interpolate_get_reverse(int32_t* a1) {
|
||||
|
||||
static void sub_140415430(motion_blend_mot* a1) {
|
||||
float_t rot_y = a1->bone_data.rot_y;
|
||||
vec3 global_trans = a1->bone_data.global_trans;
|
||||
vec3 global_rotation = a1->bone_data.global_rotation;
|
||||
vec3& global_trans = a1->bone_data.global_trans;
|
||||
vec3& global_rotation = a1->bone_data.global_rotation;
|
||||
mat4 mat;
|
||||
mat4_rotate_y(rot_y, &mat);
|
||||
mat4_translate_mult(&mat, global_trans.x, global_trans.y, global_trans.z, &mat);
|
||||
mat4_rotate_mult(&mat, global_rotation.x, global_rotation.y, global_rotation.z, &mat);
|
||||
mat4_translate_mult(&mat, &global_trans, &mat);
|
||||
mat4_rotate_mult(&mat, &global_rotation, &mat);
|
||||
for (bone_data* i = a1->bone_data.bones.begin; i != a1->bone_data.bones.end; i++)
|
||||
switch (i->type) {
|
||||
case BONE_DATABASE_BONE_TYPE_1:
|
||||
@@ -2983,7 +2982,7 @@ static void sub_140412BB0(motion_blend_mot* a1, vector_old_bone_data* a2) {
|
||||
|
||||
static void sub_1403FBF10(MotionBlend* a1, float_t a2) {
|
||||
a1->blend = clamp_def(a2, 0.0f, 1.0f);
|
||||
a1->field_8 = 1;
|
||||
a1->enable = true;
|
||||
a1->rot_y = true;
|
||||
}
|
||||
|
||||
@@ -3322,14 +3321,14 @@ static void rob_chara_bone_data_set_rot_y(rob_chara_bone_data* rob_bone_data, fl
|
||||
|
||||
static void sub_1403FBED0(MotionBlend* a1, float_t duration, float_t step, float_t offset) {
|
||||
if (duration < 0.0f) {
|
||||
a1->field_8 = false;
|
||||
a1->enable = false;
|
||||
a1->duration = 0.0f;
|
||||
a1->frame = 0.0f;
|
||||
a1->step = step;
|
||||
a1->offset = offset;
|
||||
}
|
||||
else {
|
||||
a1->field_8 = true;
|
||||
a1->enable = true;
|
||||
a1->duration = duration;
|
||||
a1->frame = 0.0f;
|
||||
a1->step = step;
|
||||
@@ -3539,7 +3538,7 @@ static void rob_chara_bone_data_get_ik_scale(rob_chara_bone_data* a1) {
|
||||
float_t ratio0 = a1->ik_scale.ratio0;
|
||||
v2->field_4F8.field_C0 = ratio0;
|
||||
v2->field_4F8.field_C4 = ratio0;
|
||||
v2->field_4F8.field_C8 = vec3_null;
|
||||
v2->field_4F8.field_C8 = 0.0f;
|
||||
}
|
||||
|
||||
static float_t rob_chara_bone_data_get_ik_scale_ratio0(rob_chara_bone_data* a1) {
|
||||
@@ -3717,23 +3716,23 @@ static void rob_osage_node_init(rob_osage_node* node) {
|
||||
void (*sub_14021DCC0)(vector_old_opd_vec3_data * vec, size_t size)
|
||||
= (void (*)(vector_old_opd_vec3_data*, size_t))0x000000014021DCC0;
|
||||
node->length = 0.0f;
|
||||
node->trans = vec3_null;
|
||||
node->trans_orig = vec3_null;
|
||||
node->trans_diff = vec3_null;
|
||||
node->field_28 = vec3_null;
|
||||
node->trans = 0.0f;
|
||||
node->trans_orig = 0.0f;
|
||||
node->trans_diff = 0.0f;
|
||||
node->field_28 = 0.0f;
|
||||
node->child_length = 0.0f;
|
||||
node->bone_node_ptr = 0;
|
||||
node->bone_node_mat = 0;
|
||||
node->sibling_node = 0;
|
||||
node->distance = 0.0f;
|
||||
node->field_94 = vec3_null;
|
||||
node->reset_data.trans = vec3_null;
|
||||
node->reset_data.trans_diff = vec3_null;
|
||||
node->reset_data.rotation = vec3_null;
|
||||
node->field_94 = 0.0f;
|
||||
node->reset_data.trans = 0.0f;
|
||||
node->reset_data.trans_diff = 0.0f;
|
||||
node->reset_data.rotation = 0.0f;
|
||||
node->reset_data.length = 0.0f;
|
||||
node->field_C8 = 0.0f;
|
||||
node->field_CC = 1.0f;
|
||||
node->external_force = vec3_null;
|
||||
node->external_force = 0.0f;
|
||||
node->force = 1.0f;
|
||||
rob_osage_node_data_init(&node->data);
|
||||
node->data_ptr = &node->data;
|
||||
@@ -3756,7 +3755,7 @@ static void rob_osage_init(rob_osage* rob_osg) {
|
||||
vector_old_rob_osage_node_clear(&rob_osg->nodes, rob_osg->nodes.begin, rob_osg->nodes.end);
|
||||
rob_osg->nodes.end = rob_osg->nodes.begin;
|
||||
rob_osage_node_init(&rob_osg->node);
|
||||
rob_osg->wind_direction = vec3_null;
|
||||
rob_osg->wind_direction = 0.0f;
|
||||
rob_osg->field_1EB4 = 0.0f;
|
||||
rob_osg->yz_order = 0;
|
||||
rob_osg->field_2A0 = true;
|
||||
@@ -3787,7 +3786,7 @@ static void rob_osage_init(rob_osage* rob_osg) {
|
||||
rob_osg->field_2A4 = 0.0f;
|
||||
rob_osg->field_2A1 = 0;
|
||||
rob_osg->set_external_force = false;
|
||||
rob_osg->external_force = vec3_null;
|
||||
rob_osg->external_force = 0.0f;
|
||||
rob_osg->parent_mat_ptr = 0;
|
||||
rob_osg->parent_mat = mat4_null;
|
||||
}
|
||||
@@ -3898,18 +3897,15 @@ static void sub_14047EE90(rob_osage* rob_osg, mat4* mat) {
|
||||
|
||||
static void sub_14047F110(rob_osage* rob_osg, mat4* mat, vec3* parent_scale, bool init_rot) {
|
||||
mat4_transpose(mat, mat);
|
||||
vec3 position;
|
||||
vec3_mult(rob_osg->exp_data.position, *parent_scale, position);
|
||||
mat4_translate_mult(mat, position.x, position.y, position.z, mat);
|
||||
|
||||
vec3 rotation = rob_osg->exp_data.rotation;
|
||||
mat4_rotate_mult(mat, rotation.x, rotation.y, rotation.z, mat);
|
||||
vec3 position = rob_osg->exp_data.position * *parent_scale;
|
||||
mat4_translate_mult(mat, &position, mat);
|
||||
mat4_rotate_mult(mat, &rob_osg->exp_data.rotation, mat);
|
||||
|
||||
skin_param* skin_param = rob_osg->skin_param_ptr;
|
||||
vec3 rot = skin_param->rot;
|
||||
if (init_rot)
|
||||
vec3_add(rot, skin_param->init_rot, rot);
|
||||
mat4_rotate_mult(mat, rot.x, rot.y, rot.z, mat);
|
||||
rot = skin_param->init_rot + rot;
|
||||
mat4_rotate_mult(mat, &rot, mat);
|
||||
mat4_transpose(mat, mat);
|
||||
}
|
||||
|
||||
@@ -4058,7 +4054,7 @@ static void rob_osage_set_wind_direction(rob_osage* osg_block_data, vec3* wind_d
|
||||
if (wind_direction)
|
||||
osg_block_data->wind_direction = *wind_direction;
|
||||
else
|
||||
osg_block_data->wind_direction = vec3_null;
|
||||
osg_block_data->wind_direction = 0.0f;
|
||||
}
|
||||
|
||||
static void ExOsageBlock__SetWindDirection(ExOsageBlock* osg) {
|
||||
@@ -4126,7 +4122,7 @@ static void sub_140482180(rob_osage_node* node, float_t a2) {
|
||||
vec3_normalize(v3, v3);
|
||||
vec3_mult_scalar(v3, node->length, v3);
|
||||
vec3_add(node[-1].trans, v3, node->trans);
|
||||
node->trans_diff = vec3_null;
|
||||
node->trans_diff = 0.0f;
|
||||
node->field_C8 += 1.0f;
|
||||
}
|
||||
|
||||
@@ -4545,7 +4541,7 @@ static int32_t sub_140485000(vec3* a1, vec3* a2, skin_param_osage_node* a3, osag
|
||||
int32_t v8 = 0;
|
||||
while (a4->type) {
|
||||
int32_t type = a4->type;
|
||||
vec3 v21 = vec3_null;
|
||||
vec3 v21 = 0.0f;
|
||||
switch (a4->type) {
|
||||
case 1: {
|
||||
vec3 v22 = a4->bone0_pos;
|
||||
@@ -4600,9 +4596,9 @@ static void osage_coli_ring_set(osage_coli* osg_coli, vector_old_skin_param_osag
|
||||
if (vec_skp_root_coli->begin == vec_skp_root_coli->end) {
|
||||
osg_coli->type = 0;
|
||||
osg_coli->radius = 0.0f;
|
||||
osg_coli->bone0_pos = vec3_null;
|
||||
osg_coli->bone1_pos = vec3_null;
|
||||
osg_coli->bone_pos_diff = vec3_null;
|
||||
osg_coli->bone0_pos = 0.0f;
|
||||
osg_coli->bone1_pos = 0.0f;
|
||||
osg_coli->bone_pos_diff = 0.0f;
|
||||
osg_coli->bone_pos_diff_length = 0.0f;
|
||||
osg_coli->bone_pos_diff_length_squared = 0.0f;
|
||||
osg_coli->field_34 = 1.0f;
|
||||
@@ -4649,9 +4645,9 @@ static int32_t sub_140483B30(vec3* a1, vec3* a2, osage_coli* a3, float_t radius)
|
||||
return 0;
|
||||
}
|
||||
|
||||
vec3 v28 = vec3_null;
|
||||
vec3 v32 = vec3_null;
|
||||
vec3 v27 = vec3_identity;
|
||||
vec3 v28 = 0.0f;
|
||||
vec3 v32 = 0.0f;
|
||||
vec3 v27 = 1.0f;
|
||||
|
||||
float_t v16 = 0.0f;
|
||||
for (int32_t i = 0; i < 3; i++) {
|
||||
@@ -4703,7 +4699,7 @@ static int32_t sub_140485220(vec3* a1, skin_param_osage_node* a2, osage_coli* co
|
||||
int32_t v8 = 0;
|
||||
for (osage_coli* v9 = coli; v9->type; v9++) {
|
||||
int32_t v11 = 0;
|
||||
vec3 v31 = vec3_null;
|
||||
vec3 v31 = 0.0f;
|
||||
switch (v9->type) {
|
||||
case 1:
|
||||
v11 = sub_140483DE0(&v31, a1, &v9->bone0_pos, v9->radius + a2->coli_r);
|
||||
@@ -4850,7 +4846,7 @@ static void sub_14047D8C0(rob_osage* rob_osg, mat4* mat, vec3* parent_scale, flo
|
||||
rob_osage_node* v27 = rob_osg->nodes.begin + 1;
|
||||
for (rob_osage_node* v25 = rob_osg->nodes.begin + 1;
|
||||
v25 != rob_osg->nodes.end; v25++, v27++) {
|
||||
vec3 v62 = vec3_null;
|
||||
vec3 v62 = 0.0f;
|
||||
for (rob_osage_node* v30 = v24->begin + 1; v30 != v26; v30++)
|
||||
sub_140483DE0(&v62, &v27->trans, &v30->trans,
|
||||
v27->data_ptr->skp_osg_node.coli_r + v30->data_ptr->skp_osg_node.coli_r);
|
||||
@@ -4885,7 +4881,7 @@ static void sub_14047D8C0(rob_osage* rob_osg, mat4* mat, vec3* parent_scale, flo
|
||||
|
||||
if (v35->bone_node_mat) {
|
||||
mat4* v41 = v35->bone_node_mat;
|
||||
mat4_scale_rot(&v64, parent_scale->x, parent_scale->y, parent_scale->z, v41);
|
||||
mat4_scale_rot(&v64, parent_scale, v41);
|
||||
mat4_transpose(v41, v41);
|
||||
}
|
||||
|
||||
@@ -4933,7 +4929,7 @@ static void sub_14047D8C0(rob_osage* rob_osg, mat4* mat, vec3* parent_scale, flo
|
||||
mat4_transpose(&v65, &v65);
|
||||
*rob_osg->node.bone_node_ptr->ex_data_mat = v65;
|
||||
mat4_transpose(&v65, &v65);
|
||||
mat4_scale_rot(&v65, parent_scale->x, parent_scale->y, parent_scale->z, &v65);
|
||||
mat4_scale_rot(&v65, parent_scale, &v65);
|
||||
mat4_transpose(&v65, &v65);
|
||||
*rob_osg->node.bone_node_mat = v65;
|
||||
rob_osg->node.bone_node_ptr->exp_data.parent_scale = *parent_scale;
|
||||
@@ -4945,7 +4941,7 @@ static void sub_140480F40(rob_osage* rob_osg, vec3* external_force, float_t a3)
|
||||
if (external_force)
|
||||
v4 = *external_force;
|
||||
else
|
||||
v4 = vec3_null;
|
||||
v4 = 0.0f;
|
||||
|
||||
ssize_t v7 = rob_osg->osage_setting.parts;
|
||||
ssize_t v8 = 0;
|
||||
@@ -4977,7 +4973,7 @@ static void sub_140480260(rob_osage* rob_osg, mat4* mat, vec3* parent_scale, flo
|
||||
sub_140480F40(rob_osg, 0, 1.0f);
|
||||
rob_osage_set_nodes_force(rob_osg, 1.0f);
|
||||
rob_osg->set_external_force = false;
|
||||
rob_osg->external_force = vec3_null;
|
||||
rob_osg->external_force = 0.0f;
|
||||
}
|
||||
|
||||
for (rob_osage_node* v6 = rob_osg->nodes.begin; v6 != rob_osg->nodes.end; v6++) {
|
||||
@@ -5063,9 +5059,9 @@ void ExOsageBlock__Field_20(ExOsageBlock* osg) {
|
||||
|
||||
mat4 mat = *parent_node->ex_data_mat;
|
||||
if (scale.x != 1.0f || scale.y != 1.0f || scale.z != 1.0f) {
|
||||
vec3_div(vec3_identity, scale, scale);
|
||||
vec3_div(1.0f, scale, scale);
|
||||
mat4_transpose(&mat, &mat);
|
||||
mat4_scale_rot(&mat, scale.x, scale.y, scale.z, &mat);
|
||||
mat4_scale_rot(&mat, &scale, &mat);
|
||||
mat4_transpose(&mat, &mat);
|
||||
}
|
||||
ExOsageBlock__SetWindDirection(osg);
|
||||
@@ -5091,19 +5087,19 @@ void sub_140482100(struc_476* a1, opd_blend_data* a2, struc_477* a3) {
|
||||
sub_140482DF0(&a1->field_0, &a1->field_0, a3, a2->blend);
|
||||
}
|
||||
|
||||
void sub_14047E240(rob_osage* rob_osg, mat4* a2, vec3* a3, vector_old_opd_blend_data* a4) {
|
||||
void sub_14047E240(rob_osage* rob_osg, mat4* a2, vec3* parent_scale, vector_old_opd_blend_data* a4) {
|
||||
if (!vector_old_length(*a4))
|
||||
return;
|
||||
|
||||
vec3 v63;
|
||||
vec3_mult(rob_osg->exp_data.position, *a3, v63);
|
||||
vec3_mult(rob_osg->exp_data.position, *parent_scale, v63);
|
||||
|
||||
mat4 v85;
|
||||
mat4_transpose(a2, &v85);
|
||||
mat4_mult_vec3_trans(&v85, &v63, &rob_osg->nodes.begin[0].trans);
|
||||
mat4_transpose(&v85, &v85);
|
||||
|
||||
sub_14047F110(rob_osg, &v85, a3, 0);
|
||||
sub_14047F110(rob_osg, &v85, parent_scale, 0);
|
||||
*rob_osg->nodes.begin[0].bone_node_mat = v85;
|
||||
*rob_osg->nodes.begin[0].bone_node_ptr->ex_data_mat = v85;
|
||||
mat4_transpose(&v85, &v85);
|
||||
@@ -5163,7 +5159,7 @@ void sub_14047E240(rob_osage* rob_osg, mat4* a2, vec3* a3, vector_old_opd_blend_
|
||||
mat4_mult_vec3_inv_trans(&v87, &v82, &v86);
|
||||
mat4_transpose(&v87, &v87);
|
||||
|
||||
vec3 v64 = vec3_null;
|
||||
vec3 v64 = 0.0f;
|
||||
sub_140482FF0(&v87, &v86, 0, &v64, &rob_osg->yz_order);
|
||||
mat4_transpose(&v87, &v87);
|
||||
mat4_set_translation(&v87, &v82);
|
||||
@@ -5193,12 +5189,12 @@ void sub_14047E240(rob_osage* rob_osg, mat4* a2, vec3* a3, vector_old_opd_blend_
|
||||
mat4_rotate_z_mult(&v85, v55, &v85);
|
||||
mat4_rotate_y_mult(&v85, v54, &v85);
|
||||
mat4_transpose(&v85, &v85);
|
||||
i->bone_node_ptr->exp_data.parent_scale = *a3;
|
||||
i->bone_node_ptr->exp_data.parent_scale = *parent_scale;
|
||||
*i->bone_node_ptr->ex_data_mat = v85;
|
||||
mat4_transpose(&v85, &v85);
|
||||
if (i->bone_node_mat) {
|
||||
mat4 mat = v85;
|
||||
mat4_scale_rot(&mat, a3->x, a3->y, a3->z, &mat);
|
||||
mat4_scale_rot(&mat, parent_scale, &mat);
|
||||
mat4_transpose(&mat, i->bone_node_mat);
|
||||
}
|
||||
mat4_translate_mult(&v85, i->field_1B0.field_0.length, 0.0f, 0.0f, &v85);
|
||||
@@ -5209,15 +5205,15 @@ void sub_14047E240(rob_osage* rob_osg, mat4* a2, vec3* a3, vector_old_opd_blend_
|
||||
if (vector_old_length(rob_osg->nodes) && rob_osg->node.bone_node_mat) {
|
||||
mat4 v87 = *rob_osg->nodes.end[-1].bone_node_ptr->ex_data_mat;
|
||||
mat4_transpose(&v87, &v87);
|
||||
mat4_translate_mult(&v87, rob_osg->node.length * a3->x, 0.0f, 0.0f, &v87);
|
||||
mat4_translate_mult(&v87, rob_osg->node.length * parent_scale->x, 0.0f, 0.0f, &v87);
|
||||
mat4_transpose(&v87, &v87);
|
||||
*rob_osg->node.bone_node_ptr->ex_data_mat = v87;
|
||||
|
||||
mat4_transpose(&v87, &v87);
|
||||
mat4_scale_rot(&v87, a3->x, a3->y, a3->z, &v87);
|
||||
mat4_scale_rot(&v87, parent_scale, &v87);
|
||||
mat4_transpose(&v87, &v87);
|
||||
*rob_osg->node.bone_node_mat = v87;
|
||||
rob_osg->node.bone_node_ptr->exp_data.parent_scale = *a3;
|
||||
rob_osg->node.bone_node_ptr->exp_data.parent_scale = *parent_scale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5338,7 +5334,7 @@ void sub_14053CE30(rob_osage_node_data_normal_ref* normal_ref, mat4* a2) {
|
||||
}
|
||||
}
|
||||
|
||||
void sub_14047E1C0(rob_osage* rob_osg, vec3* a2) {
|
||||
void sub_14047E1C0(rob_osage* rob_osg, vec3* parent_scale) {
|
||||
for (rob_osage_node* i = rob_osg->nodes.begin + 1; i != rob_osg->nodes.end; ++i) {
|
||||
if (!i->data_ptr->normal_ref.field_0)
|
||||
continue;
|
||||
@@ -5347,7 +5343,7 @@ void sub_14047E1C0(rob_osage* rob_osg, vec3* a2) {
|
||||
|
||||
mat4 mat;
|
||||
mat4_transpose(i->bone_node_mat, &mat);
|
||||
mat4_scale_rot(&mat, a2->x, a2->y, a2->z, &mat);
|
||||
mat4_scale_rot(&mat, parent_scale, &mat);
|
||||
mat4_transpose(&mat, i->bone_node_mat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2708,7 +2708,7 @@ struct /*VFT*/ MotionBlend_vtbl {
|
||||
|
||||
struct MotionBlend {
|
||||
MotionBlend_vtbl* __vftable;
|
||||
bool field_8;
|
||||
bool enable;
|
||||
bool rot_y;
|
||||
float_t duration;
|
||||
float_t frame;
|
||||
|
||||
@@ -17,12 +17,6 @@ bool APIENTRY DllMain(HMODULE handle, DWORD ul_reason_for_call, LPVOID lpReserve
|
||||
printf_divagl("Patching memory");
|
||||
inject_patches();
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
printf_divagl("Detach");
|
||||
printf_divagl("Restore memory");
|
||||
inject_restore();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+17
-50
@@ -10,56 +10,44 @@
|
||||
#include "shader_table.hpp"
|
||||
#include <Windows.h>
|
||||
|
||||
typedef struct patch_struct {
|
||||
struct patch_struct {
|
||||
void* address;
|
||||
size_t func_ptr;
|
||||
void* orig_data;
|
||||
} patch_struct;
|
||||
};
|
||||
|
||||
void* inject_data(void* address, void* data, size_t count) {
|
||||
void inject_data(void* address, void* data, size_t count) {
|
||||
DWORD old_protect;
|
||||
VirtualProtect(address, count, PAGE_EXECUTE_READWRITE, &old_protect);
|
||||
void* orig_data = force_malloc(count);
|
||||
memcpy(orig_data, (const void*)address, count);
|
||||
memcpy(address, (const void*)data, count);
|
||||
memmove(address, data, count);
|
||||
VirtualProtect(address, count, old_protect, &old_protect);
|
||||
return orig_data;
|
||||
}
|
||||
|
||||
uint8_t inject_uint8_t(void* address, uint8_t data) {
|
||||
void inject_uint8_t(void* address, uint8_t data) {
|
||||
DWORD old_protect;
|
||||
VirtualProtect(address, sizeof(uint8_t), PAGE_EXECUTE_READWRITE, &old_protect);
|
||||
uint8_t value = *(uint8_t*)address;
|
||||
*(uint8_t*)address = data;
|
||||
VirtualProtect(address, sizeof(uint8_t), old_protect, &old_protect);
|
||||
return value;
|
||||
}
|
||||
|
||||
uint16_t inject_uint16_t(void* address, uint16_t data) {
|
||||
void inject_uint16_t(void* address, uint16_t data) {
|
||||
DWORD old_protect;
|
||||
VirtualProtect(address, sizeof(uint16_t), PAGE_EXECUTE_READWRITE, &old_protect);
|
||||
uint16_t value = *(uint16_t*)address;
|
||||
*(uint16_t*)address = data;
|
||||
VirtualProtect(address, sizeof(uint16_t), old_protect, &old_protect);
|
||||
return value;
|
||||
}
|
||||
|
||||
uint32_t inject_uint32_t(void* address, uint32_t data) {
|
||||
void inject_uint32_t(void* address, uint32_t data) {
|
||||
DWORD old_protect;
|
||||
VirtualProtect(address, sizeof(uint32_t), PAGE_EXECUTE_READWRITE, &old_protect);
|
||||
uint32_t value = *(uint32_t*)address;
|
||||
*(uint32_t*)address = data;
|
||||
VirtualProtect(address, sizeof(uint32_t), old_protect, &old_protect);
|
||||
return value;
|
||||
}
|
||||
|
||||
uint64_t inject_uint64_t(void* address, uint64_t data) {
|
||||
void inject_uint64_t(void* address, uint64_t data) {
|
||||
DWORD old_protect;
|
||||
VirtualProtect(address, sizeof(uint64_t), PAGE_EXECUTE_READWRITE, &old_protect);
|
||||
uint64_t value = *(uint64_t*)address;
|
||||
*(uint64_t*)address = data;
|
||||
VirtualProtect(address, sizeof(uint64_t), old_protect, &old_protect);
|
||||
return value;
|
||||
}
|
||||
|
||||
static patch_struct patch_data[] = {
|
||||
@@ -89,8 +77,6 @@ static patch_struct patch_data[] = {
|
||||
//{ (void*)0x00000001405F48F0, (uint64_t)&ExOsageBlock__Field_58, },
|
||||
};
|
||||
|
||||
static uint64_t shader_bind_func_orig_data[6];
|
||||
|
||||
void inject_patches() {
|
||||
uint8_t buf[12];
|
||||
buf[0] = 0x48;
|
||||
@@ -100,36 +86,17 @@ void inject_patches() {
|
||||
|
||||
for (int32_t i = 0; i < sizeof(patch_data) / sizeof(patch_struct); i++)
|
||||
if (patch_data[i].func_ptr) {
|
||||
free_def(patch_data[i].orig_data);
|
||||
memcpy(&buf[2], &patch_data[i].func_ptr, sizeof(uint64_t));
|
||||
patch_data[i].orig_data = inject_data(patch_data[i].address, buf, 12);
|
||||
inject_data(patch_data[i].address, buf, 12);
|
||||
}
|
||||
|
||||
glutMainLoop = (void (*)())inject_uint64_t((void*)0x0000000140966008, (uint64_t)&gl_get_func_pointers);
|
||||
glutMainLoop = (void (FASTCALL*)())*(size_t*)0x0000000140966008;
|
||||
inject_uint64_t((void*)0x0000000140966008, (uint64_t)&gl_get_func_pointers);
|
||||
|
||||
shader_bind_func_orig_data[0] = inject_uint64_t(
|
||||
(void*)&shader_name_bind_func_table[0].bind_func, (uint64_t)&shader_bind_blinn);
|
||||
shader_bind_func_orig_data[1] = inject_uint64_t(
|
||||
(void*)&shader_name_bind_func_table[1].bind_func, (uint64_t)&shader_bind_cloth);
|
||||
shader_bind_func_orig_data[2] = inject_uint64_t(
|
||||
(void*)&shader_name_bind_func_table[2].bind_func, (uint64_t)&shader_bind_hair);
|
||||
shader_bind_func_orig_data[3] = inject_uint64_t(
|
||||
(void*)&shader_name_bind_func_table[3].bind_func, (uint64_t)&shader_bind_membrane);
|
||||
shader_bind_func_orig_data[4] = inject_uint64_t(
|
||||
(void*)&shader_name_bind_func_table[4].bind_func, (uint64_t)&shader_bind_eye_ball);
|
||||
shader_bind_func_orig_data[5] = inject_uint64_t(
|
||||
(void*)&shader_name_bind_func_table[5].bind_func, (uint64_t)&shader_bind_tone_map);
|
||||
}
|
||||
|
||||
void inject_restore() {
|
||||
for (int32_t i = 0; i < sizeof(patch_data) / sizeof(patch_struct); i++)
|
||||
if (patch_data[i].func_ptr) {
|
||||
void* data = inject_data(patch_data[i].address, patch_data[i].orig_data, 12);
|
||||
free_def(data);
|
||||
}
|
||||
|
||||
inject_uint64_t((void*)0x0000000140966008, (uint64_t)glutMainLoop);
|
||||
|
||||
for (int32_t i = 0; i < 6; i++)
|
||||
inject_uint64_t(shader_name_bind_func_table[i].bind_func, shader_bind_func_orig_data[i]);
|
||||
inject_uint64_t((void*)&shader_name_bind_func_table[0].bind_func, (uint64_t)&shader_bind_blinn);
|
||||
inject_uint64_t((void*)&shader_name_bind_func_table[1].bind_func, (uint64_t)&shader_bind_cloth);
|
||||
inject_uint64_t((void*)&shader_name_bind_func_table[2].bind_func, (uint64_t)&shader_bind_hair);
|
||||
inject_uint64_t((void*)&shader_name_bind_func_table[3].bind_func, (uint64_t)&shader_bind_membrane);
|
||||
inject_uint64_t((void*)&shader_name_bind_func_table[4].bind_func, (uint64_t)&shader_bind_eye_ball);
|
||||
inject_uint64_t((void*)&shader_name_bind_func_table[5].bind_func, (uint64_t)&shader_bind_tone_map);
|
||||
}
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
|
||||
extern void* inject_data(void* address, void* data, size_t count);
|
||||
extern uint8_t inject_uint8_t(void* address, uint8_t data);
|
||||
extern uint16_t inject_uint16_t(void* address, uint16_t data);
|
||||
extern uint32_t inject_uint32_t(void* address, uint32_t data);
|
||||
extern uint64_t inject_uint64_t(void* address, uint64_t data);
|
||||
extern void inject_data(void* address, const void* data, size_t count);
|
||||
extern void inject_uint8_t(void* address, uint8_t data);
|
||||
extern void inject_uint16_t(void* address, uint16_t data);
|
||||
extern void inject_uint32_t(void* address, uint32_t data);
|
||||
extern void inject_uint64_t(void* address, uint64_t data);
|
||||
extern void inject_patches();
|
||||
extern void inject_restore();
|
||||
|
||||
+10
-10
@@ -199,13 +199,13 @@ extern shader_bind_func* shader_name_bind_func_table;
|
||||
extern int32_t* current_vp;
|
||||
extern int32_t* current_fp;
|
||||
|
||||
extern void FASTCALL shader_set(shader_enum name); // 0x00000001405E4CE0
|
||||
extern void FASTCALL shader_bind_blinn(shader* shader); // 0x00000001405E4320
|
||||
extern void FASTCALL shader_bind_cloth(shader* shader); // 0x00000001405E4340
|
||||
extern void FASTCALL shader_bind_hair(shader* shader); // 0x00000001405E4370
|
||||
extern void FASTCALL shader_bind_membrane(shader* shader); // 0x00000001405E43A0
|
||||
extern void FASTCALL shader_bind_eye_ball(shader* shader); // 0x00000001405E4530
|
||||
extern void FASTCALL shader_bind_tone_map(shader* shader); // 0x00000001405E4580
|
||||
extern int32_t FASTCALL shader_bind(shader* shader, shader_sub_enum name); // 0x00000001405E4B50
|
||||
extern void FASTCALL shader_unbind(); // 0x00000001405E5660
|
||||
extern void FASTCALL shader_load_all_shaders(); // 0x00000001405E4FC0
|
||||
extern void FASTCALL shader_set(shader_enum name); // 0x00000001405E4CE0
|
||||
extern void FASTCALL shader_bind_blinn(shader* shader); // 0x00000001405E4320
|
||||
extern void FASTCALL shader_bind_cloth(shader* shader); // 0x00000001405E4340
|
||||
extern void FASTCALL shader_bind_hair(shader* shader); // 0x00000001405E4370
|
||||
extern void FASTCALL shader_bind_membrane(shader* shader); // 0x00000001405E43A0
|
||||
extern void FASTCALL shader_bind_eye_ball(shader* shader); // 0x00000001405E4530
|
||||
extern void FASTCALL shader_bind_tone_map(shader* shader); // 0x00000001405E4580
|
||||
extern int32_t FASTCALL shader_bind(shader* shader, shader_sub_enum name); // 0x00000001405E4B50
|
||||
extern void FASTCALL shader_unbind(); // 0x00000001405E5660
|
||||
extern void FASTCALL shader_load_all_shaders(); // 0x00000001405E4FC0
|
||||
|
||||
@@ -129,8 +129,7 @@ inline void string_replace_wstring(wstring* src, string* dst) {
|
||||
inline bool string_compare(string* str0, string* str1) {
|
||||
if (str0->length != str1->length)
|
||||
return false;
|
||||
return !memcmp(string_data(str0), string_data(str1),
|
||||
str0->length) ? true : false;
|
||||
return !memcmp(string_data(str0), string_data(str1), str0->length);
|
||||
}
|
||||
|
||||
inline void string_free(string* s) {
|
||||
@@ -238,8 +237,7 @@ inline void wstring_replace_string(string* src, wstring* dst) {
|
||||
inline bool wstring_compare(wstring* str0, wstring* str1) {
|
||||
if (str0->length != str1->length)
|
||||
return false;
|
||||
return !memcmp(wstring_data(str0), wstring_data(str1),
|
||||
sizeof(wchar_t) * str0->length) ? true : false;
|
||||
return !memcmp(wstring_data(str0), wstring_data(str1), sizeof(wchar_t) * str0->length);
|
||||
}
|
||||
|
||||
inline void wstring_free(wstring* s) {
|
||||
|
||||
+8
-9
@@ -176,7 +176,9 @@ bool a3da::load_file(void* data, const char* path, const char* file, uint32_t ha
|
||||
if (t)
|
||||
file_len = t - file;
|
||||
|
||||
std::string s = path + std::string(file, file_len);
|
||||
std::string s;
|
||||
s.assign(path);
|
||||
s.append(file, file_len);
|
||||
|
||||
a3da* a = (a3da*)data;
|
||||
a->read(s.c_str());
|
||||
@@ -387,8 +389,7 @@ a3da_post_process::~a3da_post_process() {
|
||||
}
|
||||
|
||||
static void a3da_read_inner(a3da* a, stream& s) {
|
||||
a3dc_header header;
|
||||
memset(&header, 0, sizeof(a3dc_header));
|
||||
a3dc_header header = {};
|
||||
|
||||
a->format = A3DA_FORMAT_F;
|
||||
uint32_t signature = s.read_uint32_t();
|
||||
@@ -487,8 +488,7 @@ static void a3da_write_inner(a3da* a, stream& s) {
|
||||
}
|
||||
|
||||
if (a3dc) {
|
||||
a3dc_header header;
|
||||
memset(&header, 0, sizeof(a3dc_header));
|
||||
a3dc_header header = {};
|
||||
|
||||
header.string_offset = (uint32_t)0x40;
|
||||
header.string_length = (uint32_t)a3da_data_length;
|
||||
@@ -740,7 +740,7 @@ static void a3da_read_text(a3da* a, void* data, size_t size) {
|
||||
kv.read("clip_end", e->clip_end);
|
||||
kv.read("end", e->end);
|
||||
kv.read("name", e->name);
|
||||
kv.read("param1", e->param_1);
|
||||
kv.read("param1", e->param1);
|
||||
kv.read("ref", e->ref);
|
||||
kv.read("time_ref_scale", e->time_ref_scale);
|
||||
|
||||
@@ -1321,7 +1321,7 @@ static void a3da_write_text(a3da* a, void** data, size_t* size, bool a3dc) {
|
||||
kv.write(s, "clip_en", e->clip_end);
|
||||
kv.write(s, "end", e->end);
|
||||
kv.write(s, "name", e->name);
|
||||
kv.write(s, "param1", e->param_1);
|
||||
kv.write(s, "param1", e->param1);
|
||||
kv.write(s, "ref", e->ref);
|
||||
kv.write(s, "time_ref_scale", e->time_ref_scale);
|
||||
kv.write(s, "type", e->type);
|
||||
@@ -2883,8 +2883,7 @@ static void a3dc_write_a3da_key_f16(stream& s, a3da_key& value, a3da_compress_f1
|
||||
|
||||
uint32_t len = (uint32_t)value.keys.size();
|
||||
|
||||
a3dc_key_header head;
|
||||
memset(&head, 0, sizeof(a3dc_key_header));
|
||||
a3dc_key_header head = {};
|
||||
head.type = value.type;
|
||||
head.ep_type_pre = value.ep_type_pre;
|
||||
head.ep_type_post = value.ep_type_post;
|
||||
|
||||
+1
-1
@@ -301,7 +301,7 @@ struct a3da_event {
|
||||
float_t clip_end;
|
||||
float_t end;
|
||||
std::string name;
|
||||
std::string param_1;
|
||||
std::string param1;
|
||||
std::string ref;
|
||||
float_t time_ref_scale;
|
||||
a3da_event_type type;
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "alloc_data.hpp"
|
||||
|
||||
alloc_data::alloc_data() : next() {
|
||||
size = 4000;
|
||||
}
|
||||
|
||||
alloc_data::~alloc_data() {
|
||||
deallocate();
|
||||
}
|
||||
|
||||
void* alloc_data::allocate(size_t size) {
|
||||
alloc_node* node = next;
|
||||
size = max_def(size, 1);
|
||||
size = (size + 7) / 8 * 8;
|
||||
|
||||
bool allocate = true;
|
||||
if (node) {
|
||||
alloc_node* last_node = 0;
|
||||
while (node) {
|
||||
if ((size_t)(node->capacity - node->size) >= size)
|
||||
last_node = node;
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
if (last_node) {
|
||||
node = last_node;
|
||||
allocate = false;
|
||||
}
|
||||
else
|
||||
node = next;
|
||||
}
|
||||
|
||||
if (allocate) {
|
||||
size_t data_size = this->size;
|
||||
size_t _size = size + sizeof(alloc_node);
|
||||
size_t mults = 0;
|
||||
while (data_size < _size) {
|
||||
data_size *= 2;
|
||||
if (data_size >= _size)
|
||||
break;
|
||||
|
||||
mults++;
|
||||
data_size *= 2;
|
||||
|
||||
if (mults >= 16) {
|
||||
if (data_size < _size)
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
alloc_node* new_node = (alloc_node*)malloc(data_size);
|
||||
if (!new_node)
|
||||
return 0;
|
||||
|
||||
next = new_node;
|
||||
|
||||
new_node->next = node;
|
||||
new_node->size = 0;
|
||||
new_node->capacity = data_size - sizeof(alloc_node);
|
||||
node = new_node;
|
||||
}
|
||||
|
||||
uint8_t* data = node->data + node->size;
|
||||
memset(data, 0, size);
|
||||
node->size += size;
|
||||
return data;
|
||||
}
|
||||
|
||||
void alloc_data::deallocate() {
|
||||
alloc_node* node = next;
|
||||
while (node) {
|
||||
alloc_node* next_node = node->next;
|
||||
free(node);
|
||||
node = next_node;
|
||||
}
|
||||
|
||||
next = 0;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "default.hpp"
|
||||
|
||||
struct alloc_node {
|
||||
alloc_node* next;
|
||||
size_t size;
|
||||
size_t capacity;
|
||||
#pragma warning(suppress: 4200)
|
||||
uint8_t data[];
|
||||
};
|
||||
|
||||
struct alloc_data {
|
||||
size_t size;
|
||||
alloc_node* next;
|
||||
|
||||
alloc_data();
|
||||
~alloc_data();
|
||||
|
||||
void* allocate(size_t size);
|
||||
void deallocate();
|
||||
|
||||
template <typename T>
|
||||
inline T* allocate() {
|
||||
return new((T*)allocate(sizeof(T))) T;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T* allocate(size_t size) {
|
||||
return new((T*)allocate(sizeof(T) * size)) T;
|
||||
}
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user