mirror of
https://github.com/n64decomp/banjo-kazooie.git
synced 2024-11-26 22:30:22 +00:00
- document coord related functions (mostly unused by the game)
- renamed code_B7B20.c to coords.c - removed the exception for asm/core1/code_1E820.s from .gitignore file (should not be in the work tree)
This commit is contained in:
parent
fbe20325c2
commit
03afd57a54
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,7 +11,6 @@ asm/*/*.s
|
||||
asm/core1/os
|
||||
!asm/ultra
|
||||
!asm/core1/ultra
|
||||
!asm/core1/code_1E820.s
|
||||
build/*
|
||||
build/
|
||||
|
||||
|
@ -823,7 +823,7 @@ segments:
|
||||
# - [0x100C5C0, c, code_B6C60] #DONE
|
||||
# - [0x100C640, c, code_B6CE0] #DONE
|
||||
# - [0x100C800, c, code_B6EA0] #DONE
|
||||
# - [0x100D480, c, code_B7B20] #DONE
|
||||
# - [0x100D480, c, coords] #DONE
|
||||
# - [0x100D8A0, c, code_B7F40] #DONE
|
||||
# - [0x100D980, c, code_B8020] #DONE
|
||||
# - [0x100D9D0, c, code_B8070] #DONE
|
||||
|
@ -823,7 +823,7 @@ segments:
|
||||
- [0x100C5C0, c, code_B6C60] #DONE
|
||||
- [0x100C640, c, code_B6CE0] #DONE
|
||||
- [0x100C800, c, code_B6EA0] #DONE
|
||||
- [0x100D480, c, code_B7B20] #DONE
|
||||
- [0x100D480, c, coords] #DONE
|
||||
- [0x100D8A0, c, code_B7F40] #DONE
|
||||
- [0x100D980, c, code_B8020] #DONE
|
||||
- [0x100D9D0, c, code_B8070] #DONE
|
||||
|
9
include/core2/coords.h
Normal file
9
include/core2/coords.h
Normal file
@ -0,0 +1,9 @@
|
||||
#include <ultra64.h>
|
||||
#include "bool.h"
|
||||
|
||||
void coords_copy(s32 min_out[3], s32 max_out[3], s32 min_in[3], s32 max_in[3]);
|
||||
s32 coords_func_8033EAF8(s32 min[3], s32 max[3], f32 position[3], f32 direction[3]);
|
||||
bool coords_isPointInside(s32 min[3], s32 max[3], s32 point[3]);
|
||||
bool coords_isPointInsideWithOffset(s32 min[3], s32 max[3], s32 point[3], s32 offset);
|
||||
void coords_scale(s32 min[3], s32 max[3], s32 ratio);
|
||||
void coords_translate(s32 min[3], s32 max[3], f32 translation[3]);
|
@ -3,6 +3,7 @@
|
||||
#include "variables.h"
|
||||
#include "core2/nc/camera.h"
|
||||
#include <core1/viewport.h>
|
||||
#include "core2/coords.h"
|
||||
|
||||
extern Actor *func_80328230(enum actor_e, f32[3], f32[3]);
|
||||
extern void func_802BEA4C(f32[3], f32[3], f32, f32[3]);
|
||||
@ -124,7 +125,7 @@ void func_802BBA84(void) {
|
||||
viewport_getPosition_vec3f(vp_position);
|
||||
viewport_getRotation_vec3f(vp_rotation);
|
||||
viewport_getLookVector(sp48);
|
||||
D_8037D8CC = (f32) func_8033EAF8(min, max, vp_position, sp48);
|
||||
D_8037D8CC = (f32) coords_func_8033EAF8(min, max, vp_position, sp48);
|
||||
D_8037D8CC += 100.0f;
|
||||
if (D_8037D8CC < 1000.0f) {
|
||||
D_8037D8CC = 1000.0f;
|
||||
|
@ -1,79 +0,0 @@
|
||||
#include <ultra64.h>
|
||||
#include "functions.h"
|
||||
#include "variables.h"
|
||||
|
||||
|
||||
void func_8033EAB0(s32 arg0[3], s32 arg1[3], s32 arg2[3], s32 arg3[3]) {
|
||||
s32 i;
|
||||
for(i = 0; i < 3; i++){
|
||||
arg0[i] = arg2[i];
|
||||
arg1[i] = arg3[i];
|
||||
}
|
||||
}
|
||||
|
||||
s32 func_8033EAF8(s32 min_coord[3], s32 max_coord[3], f32 position[3], f32 arg3[3]) {
|
||||
f32 dCorner[3];
|
||||
f32 dot_product;
|
||||
f32 max;
|
||||
s32 ix;
|
||||
s32 iy;
|
||||
s32 iz;
|
||||
|
||||
max = 0.0f;
|
||||
for(ix = 0; ix < 2; ix++){
|
||||
for(iy = 0; iy < 2; iy++){
|
||||
for(iz = 0; iz < 2; iz++){
|
||||
dCorner[0] = ((ix) ? min_coord[0] : max_coord[0]) - position[0];
|
||||
dCorner[1] = ((iy) ? min_coord[1] : max_coord[1]) - position[1];
|
||||
dCorner[2] = ((iz) ? min_coord[2] : max_coord[2]) - position[2];
|
||||
dot_product = (arg3[0] * dCorner[0]) + (arg3[1] * dCorner[1]) + (arg3[2] * dCorner[2]);
|
||||
if (max < dot_product) {
|
||||
max = dot_product;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (s32) max;
|
||||
}
|
||||
|
||||
bool func_8033EC10(s32 arg0[3], s32 arg1[3], s32 arg2[3]) {
|
||||
s32 i;
|
||||
for(i = 0; i < 3; i++){
|
||||
if (arg0[i] >= arg2[i]) {
|
||||
return FALSE;
|
||||
}
|
||||
if (arg2[i] >= arg1[i]) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool func_8033EC70(s32 arg0[3], s32 arg1[3], s32 arg2[3], s32 arg3) {
|
||||
s32 i;
|
||||
for(i = 0; i < 3; i++){
|
||||
if (arg0[i] >= (arg2[i] + arg3)) {
|
||||
return FALSE;
|
||||
}
|
||||
if ((arg2[i] - arg3) >= arg1[i]) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void func_8033ECD8(s32 arg0[3], s32 arg1[3], s32 arg2) {
|
||||
s32 i;
|
||||
for(i = 0; i < 3; i++){
|
||||
arg0[i] = (arg0[i] >= 0) ? arg0[i]/ arg2 : arg0[i]/ arg2 - 1;
|
||||
arg1[i] = (arg1[i] >= 0) ? arg1[i]/ arg2 : arg1[i]/ arg2 - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void func_8033EDF0(s32 arg0[3], s32 arg1[3], f32 arg2[3]) {
|
||||
s32 i;
|
||||
for(i = 0; i < 3; i++){
|
||||
arg0[i] += arg2[i];
|
||||
arg1[i] += arg2[i];
|
||||
}
|
||||
}
|
90
src/core2/coords.c
Normal file
90
src/core2/coords.c
Normal file
@ -0,0 +1,90 @@
|
||||
#include <ultra64.h>
|
||||
#include "bool.h"
|
||||
|
||||
void coords_copy(s32 min_out[3], s32 max_out[3], s32 min_in[3], s32 max_in[3]) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
min_out[i] = min_in[i];
|
||||
max_out[i] = max_in[i];
|
||||
}
|
||||
}
|
||||
|
||||
s32 coords_func_8033EAF8(s32 min[3], s32 max[3], f32 position[3], f32 direction[3]) {
|
||||
f32 corner[3];
|
||||
f32 dot_product;
|
||||
f32 result;
|
||||
s32 ix;
|
||||
s32 iy;
|
||||
s32 iz;
|
||||
|
||||
result = 0.0f;
|
||||
|
||||
for(ix = 0; ix < 2; ix++) {
|
||||
for (iy = 0; iy < 2; iy++) {
|
||||
for (iz = 0; iz < 2; iz++) {
|
||||
corner[0] = (ix ? min[0] : max[0]) - position[0];
|
||||
corner[1] = (iy ? min[1] : max[1]) - position[1];
|
||||
corner[2] = (iz ? min[2] : max[2]) - position[2];
|
||||
|
||||
dot_product = (direction[0] * corner[0]) + (direction[1] * corner[1]) + (direction[2] * corner[2]);
|
||||
|
||||
if (result < dot_product) {
|
||||
result = dot_product;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (s32) result;
|
||||
}
|
||||
|
||||
bool coords_isPointInside(s32 min[3], s32 max[3], s32 point[3]) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (min[i] >= point[i]) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (point[i] >= max[i]) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool coords_isPointInsideWithOffset(s32 min[3], s32 max[3], s32 point[3], s32 offset) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (min[i] >= (point[i] + offset)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((point[i] - offset) >= max[i]) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void coords_scale(s32 min[3], s32 max[3], s32 ratio) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
min[i] = (min[i] >= 0) ? min[i] / ratio : min[i] / ratio - 1;
|
||||
max[i] = (max[i] >= 0) ? max[i] / ratio : max[i] / ratio - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void coords_translate(s32 min[3], s32 max[3], f32 translation[3]) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
min[i] += translation[i];
|
||||
max[i] += translation[i];
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
#include "variables.h"
|
||||
|
||||
#include "core2/modelRender.h"
|
||||
#include "core2/coords.h"
|
||||
|
||||
extern UNK_TYPE(s32) func_802E8E88(BKCollisionList *, BKVertexList *, f32[3], f32[3], f32, f32[3], s32, s32);
|
||||
extern UNK_TYPE(s32) func_802E92AC(BKCollisionList *, BKVertexList *, f32[3], f32, f32[3], s32);
|
||||
@ -400,7 +401,7 @@ struct5Bs *func_803097A0(void){
|
||||
|
||||
void mapModel_getCubeBounds(s32 min[3], s32 max[3]) {
|
||||
vtxList_getBounds_s32(model_getVtxList(mapModel.model_bin_opa), min, max);
|
||||
func_8033ECD8(min, max, 1000);
|
||||
coords_scale(min, max, 1000);
|
||||
min[0] = min[0] + mapModel.description->unk6[0];
|
||||
min[1] = min[1] + mapModel.description->unk6[1];
|
||||
min[2] = min[2] + mapModel.description->unk6[2];
|
||||
|
Loading…
Reference in New Issue
Block a user