mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-04-04 17:28:05 +00:00
fix a logic error in scrolling textures
This commit is contained in:
parent
efe794d1d8
commit
2b76ba23ff
2 changed files with 18 additions and 15 deletions
|
|
@ -133,16 +133,16 @@ void uv_update_scroll(void) {
|
|||
scroll->hasInterpInit = true;
|
||||
scroll->bhv = bhv;
|
||||
if (bhv < SCROLL_UV_X) {
|
||||
scroll->interpF32 = calloc(scroll->size, sizeof(f32));
|
||||
scroll->prevF32 = calloc(scroll->size, sizeof(f32));
|
||||
scroll->interpF32 = malloc(scroll->size * sizeof(f32));
|
||||
scroll->prevF32 = malloc(scroll->size * sizeof(f32));
|
||||
|
||||
u8 bhvIndex = MIN(bhv, 2);
|
||||
for (u32 k = 0; k < scroll->size; k++) {
|
||||
scroll->interpF32[k] = verts[k]->n.ob[bhvIndex];
|
||||
}
|
||||
} else {
|
||||
scroll->interpS16 = calloc(scroll->size, sizeof(s16));
|
||||
scroll->prevS16 = calloc(scroll->size, sizeof(s16));
|
||||
scroll->interpS16 = malloc(scroll->size * sizeof(s16));
|
||||
scroll->prevS16 = malloc(scroll->size * sizeof(s16));
|
||||
|
||||
u8 bhvIndex = MIN(bhv-SCROLL_UV_X, 1);
|
||||
for (u32 k = 0; k < scroll->size; k++) {
|
||||
|
|
@ -153,15 +153,9 @@ void uv_update_scroll(void) {
|
|||
|
||||
// Prepare for interpolation
|
||||
if (bhv < SCROLL_UV_X) {
|
||||
u8 bhvIndex = MIN(bhv, 2);
|
||||
for (u32 i = 0; i < scroll->size; i++) {
|
||||
scroll->prevF32[i] = verts[i]->n.ob[bhvIndex];
|
||||
}
|
||||
memcpy(scroll->prevF32, scroll->interpF32, scroll->size * sizeof(f32));
|
||||
} else {
|
||||
u8 bhvIndex = MIN(bhv-SCROLL_UV_X, 1);
|
||||
for (u32 i = 0; i < scroll->size; i++) {
|
||||
scroll->prevS16[i] = verts[i]->n.tc[bhvIndex];
|
||||
}
|
||||
memcpy(scroll->prevS16, scroll->interpS16, scroll->size * sizeof(s16));
|
||||
}
|
||||
scroll->needInterp = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ struct ScrollTarget *get_scroll_targets(u32 id, u16 size, u16 offset) {
|
|||
if (size > scroll->size) { size = scroll->size; } // Don't use an invalid size
|
||||
if (size + offset >= scroll->size) { return NULL; } // If the offset is invalid, Abort.
|
||||
scroll->hasOffset = true;
|
||||
Vtx* *newVtx = calloc(size, sizeof(Vtx*));
|
||||
Vtx* *newVtx = malloc(size * sizeof(Vtx*));
|
||||
if (!newVtx) { return NULL; }
|
||||
for (u32 i = 0; i < size; i++) {
|
||||
newVtx[i] = scroll->vertices[i + offset];
|
||||
|
|
@ -51,11 +51,18 @@ struct ScrollTarget* find_or_create_scroll_targets(u32 id, bool hasOffset) {
|
|||
}
|
||||
|
||||
if (scroll == NULL) {
|
||||
scroll = calloc(1, sizeof(struct ScrollTarget));
|
||||
scroll = malloc(sizeof(struct ScrollTarget));
|
||||
scroll->id = id;
|
||||
scroll->size = 0;
|
||||
scroll->vertices = NULL;
|
||||
scroll->hasOffset = hasOffset;
|
||||
scroll->hasInterpInit = false;
|
||||
scroll->needInterp = false;
|
||||
scroll->interpF32 = NULL;
|
||||
scroll->prevF32 = NULL;
|
||||
scroll->interpS16 = NULL;
|
||||
scroll->prevS16 = NULL;
|
||||
scroll->bhv = 0;
|
||||
hmap_put(sScrollTargets, id, scroll);
|
||||
}
|
||||
|
||||
|
|
@ -77,8 +84,10 @@ void add_vtx_scroll_target(u32 id, Vtx *vtx, u32 size, bool hasOffset) {
|
|||
Vtx* *newArray = realloc(scroll->vertices, newSize);
|
||||
|
||||
if (!newArray) {
|
||||
newArray = calloc(1, newSize);
|
||||
newArray = malloc(newSize);
|
||||
if (!newArray) { return; }
|
||||
memcpy(newArray, scroll->vertices, oldSize);
|
||||
memset(newArray + scroll->size, 0, size * sizeof(Vtx*));
|
||||
free(scroll->vertices);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue