mirror of
https://github.com/krystalgamer/spidey-decomp.git
synced 2024-11-23 05:19:43 +00:00
Utils_TurnTowards
This commit is contained in:
parent
5f85acffed
commit
f24412ed63
3
tips.txt
3
tips.txt
@ -67,3 +67,6 @@ if (x == -1){
|
||||
worse code
|
||||
|
||||
- classes/structures with other inner structures/arrays will have weird indexing (i.e SEntry in CMenu)
|
||||
|
||||
|
||||
using structures/classes can change code gen - check Utils_turnsTowards, it was using eax,cx on the += and -= statements with i16 but when replace with CSVector it fixed it.
|
||||
|
36
utils.cpp
36
utils.cpp
@ -460,10 +460,40 @@ void Utils_VblankProcessing(void)
|
||||
printf("Utils_VblankProcessing(void)");
|
||||
}
|
||||
|
||||
// @SMALLTODO
|
||||
void Utils_TurnTowards(CSVector, CSVector*, CSVector*, CSVector, i32)
|
||||
// @Ok
|
||||
// @Matching
|
||||
void Utils_TurnTowards(
|
||||
CSVector Current,
|
||||
CSVector *AngVel,
|
||||
CSVector *AngAcc,
|
||||
CSVector Ideal,
|
||||
i32 accfactor)
|
||||
{
|
||||
printf("void Utils_TurnTowards(CSVector, CSVector*, CSVector*, CSVector, i32)");
|
||||
|
||||
CSVector angDiff;
|
||||
angDiff.vx = Ideal.vx - Current.vx;
|
||||
angDiff.vy = Ideal.vy - Current.vy;
|
||||
|
||||
if ( angDiff.vx < -2048 )
|
||||
angDiff.vx += 4096;
|
||||
if ( angDiff.vx > 2048 )
|
||||
angDiff.vx -= 4096;
|
||||
|
||||
if ( angDiff.vy < -2048 )
|
||||
angDiff.vy += 4096;
|
||||
if ( angDiff.vy > 2048 )
|
||||
angDiff.vy -= 4096;
|
||||
|
||||
if ( angDiff.vx || angDiff.vy )
|
||||
{
|
||||
AngAcc->vx = (accfactor * angDiff.vx) >> 8;
|
||||
AngAcc->vy = (accfactor * angDiff.vy) >> 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
AngVel->vx = 0;
|
||||
AngVel->vy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// @NotOk
|
||||
|
Loading…
Reference in New Issue
Block a user