Last active
September 28, 2022 07:49
-
-
Save AltimorTASDK/60abbc27c93f46ed5e660f2335e8a16c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Physics_UpdateECBBones(Physics *phys,ECBUpdateFlag flags) | |
{ | |
float min_asymmetrical_width; | |
float min_asymmetrical_height; | |
float width; | |
float height; | |
float max_x; | |
float min_x; | |
float max_y; | |
float min_y; | |
Vec bone_pos; | |
float center_y; | |
float pos_x; | |
float pos_y; | |
float bone_x; | |
float bone_y; | |
if ((phys->ecb_flags & ECBFlag_ZeroLastECB) != 0) { | |
phys->ecb.top.x = 0.0; | |
phys->ecb.top.y = 0.0; | |
phys->ecb.bottom.x = 0.0; | |
phys->ecb.bottom.y = 0.0; | |
phys->ecb.right.x = 0.0; | |
phys->ecb.right.y = 0.0; | |
phys->ecb.left.x = 0.0; | |
phys->ecb.left.y = 0.0; | |
phys->ecb_flags = phys->ecb_flags & ~ECBFlag_ZeroLastECB; | |
} | |
phys->last_ecb.top.x = phys->ecb.top.x; | |
phys->last_ecb.top.y = phys->ecb.top.y; | |
phys->last_ecb.bottom.x = phys->ecb.bottom.x; | |
phys->last_ecb.bottom.y = phys->ecb.bottom.y; | |
phys->last_ecb.right.x = phys->ecb.right.x; | |
phys->last_ecb.right.y = phys->ecb.right.y; | |
phys->last_ecb.left.x = phys->ecb.left.x; | |
phys->last_ecb.left.y = phys->ecb.left.y; | |
pos_x = phys->position.x; | |
pos_y = phys->position.y; | |
HSD_JObjTransform(phys->ecb_bones[0], NULL, &bone_pos); | |
max_x = bone_pos.x - pos_x; | |
max_y = bone_pos.y - pos_y; | |
min_x = max_x; | |
min_y = max_y; | |
HSD_JObjTransform(phys->ecb_bones[1], NULL, &bone_pos); | |
bone_x = bone_pos.x - pos_x; | |
bone_y = bone_pos.y - pos_y; | |
if (bone_x < max_x) | |
min_x = bone_x; | |
else if (bone_x > max_x) | |
max_x = bone_x; | |
if (max_y > bone_y) | |
min_y = bone_y; | |
else if (max_y < bone_y) | |
max_y = bone_y; | |
HSD_JObjTransform(phys->ecb_bones[2], NULL, &bone_pos); | |
bone_x = bone_pos.x - pos_x; | |
bone_y = bone_pos.y - pos_y; | |
if (bone_x < min_x) | |
min_x = bone_x; | |
else if (bone_x > max_x) | |
max_x = bone_x; | |
if (bone_y < min_y) | |
min_y = bone_y; | |
else if (bone_y > max_y) | |
max_y = bone_y; | |
HSD_JObjTransform(phys->ecb_bones[3], NULL, &bone_pos); | |
bone_x = bone_pos.x - pos_x; | |
bone_y = bone_pos.y - pos_y; | |
if (bone_x < min_x) | |
min_x = bone_x; | |
else if (bone_x > max_x) | |
max_x = bone_x; | |
if (bone_y < min_y) | |
min_y = bone_y; | |
else if (bone_y > max_y) | |
max_y = bone_y; | |
HSD_JObjTransform(phys->ecb_bones[4], NULL, &bone_pos); | |
bone_x = bone_pos.x - pos_x; | |
bone_y = bone_pos.y - pos_y; | |
if (bone_x < min_x) | |
min_x = bone_x; | |
else if (bone_x > max_x) | |
max_x = bone_x; | |
if (bone_y < min_y) | |
min_y = bone_y; | |
else if (bone_y > max_y) | |
max_y = bone_y; | |
HSD_JObjTransform(phys->ecb_bones[5], NULL, &bone_pos); | |
bone_x = bone_pos.x - pos_x; | |
bone_y = bone_pos.y - pos_y; | |
if (bone_x < min_x) | |
min_x = bone_x; | |
else if (bone_x > max_x) | |
max_x = bone_x; | |
if (bone_y < min_y) | |
min_y = bone_y; | |
else if (bone_y > max_y) | |
max_y = bone_y; | |
if ((flags & ECBUpdateFlag_No2UnitExpansion) == 0) { | |
min_x -= 2.0; | |
max_x += 2.0; | |
min_y -= 2.0; | |
max_y += 2.0; | |
} | |
if (phys->min_asymmetrical_ecb_width < 4.0) | |
min_asymmetrical_width = 4.0; | |
else | |
min_asymmetrical_width = phys->min_asymmetrical_ecb_width; | |
width = max_x - min_x; | |
if (width < 0.0) | |
width = -width; | |
if (min_asymmetrical_width > width) { | |
max_x = width * 0.5; | |
min_x = -max_x; | |
} | |
if (phys->min_asymmetrical_ecb_height < 4.0) | |
min_asymmetrical_height = 4.0; | |
else | |
min_asymmetrical_height = phys->min_asymmetrical_ecb_height; | |
height = max_y - min_y; | |
if (height < 0.0) | |
height = -height; | |
if (min_asymmetrical_height > height) { | |
center_y = (max_y + min_y) * 0.5; | |
max_y = center_y + height * 0.5; | |
min_y = center_y - height * 0.5; | |
} | |
if ((flags & ECBUpdateFlag_SkinnyECB) == 0) { | |
if (max_x < 2.0) | |
max_x = 2.0; | |
if (min_x > -2.0) | |
min_x = -2.0; | |
} else { | |
min_x = -1.0; | |
max_x = 1.0; | |
} | |
if ((flags & ECBUpdateFlag_GroundECB) == 0) { | |
if (min_y < 0.0) | |
min_y = 0.0; | |
if ((flags & ECBUpdateFlag_ShortECB) != 0) { | |
center_y = (min_y + max_y) * 0.5; | |
min_y = center_y - 1.0; | |
max_y = center_y + 1.0; | |
if (min_y < 0.0) { | |
min_y = 0.0; | |
max_y = 2.0; | |
} | |
} | |
} else { | |
min_y = 0.0; | |
if ((flags & ECBUpdateFlag_ShortECB) != 0) | |
max_y = 2.0; | |
} | |
phys->end_ecb.top.x = 0.0; | |
phys->end_ecb.top.y = max_y; | |
phys->end_ecb.bottom.x = 0.0; | |
phys->end_ecb.bottom.y = min_y; | |
phys->end_ecb.right.x = max_x; | |
center_y = (min_y + max_y) * 0.5; | |
phys->end_ecb.right.y = phys->ecb_side_y_offset + center_y; | |
phys->end_ecb.left.x = min_x; | |
phys->end_ecb.left.y = phys->ecb_side_y_offset + center_y; | |
phys->push_flags = phys->push_flags & 0x7f; | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment