Mercurial > mm7
changeset 2486:1e70f8470638
simplified SpriteObject::Create
author | Grumpy7 |
---|---|
date | Sun, 07 Sep 2014 01:36:04 +0200 |
parents | 45102c9132e1 |
children | e8130e8c116f |
files | SpriteObject.cpp |
diffstat | 1 files changed, 43 insertions(+), 121 deletions(-) [+] |
line wrap: on
line diff
--- a/SpriteObject.cpp Sun Sep 07 01:35:33 2014 +0200 +++ b/SpriteObject.cpp Sun Sep 07 01:36:04 2014 +0200 @@ -84,130 +84,52 @@ field_64.z = vPosition.z; assert(sizeof(SpriteObject) == 0x70); - memcpy(&pSpriteObjects[v6], this, sizeof(*this)); - if ( a5 == 0 ) - { - pSpriteObjects[v6].vVelocity.z = 0; - if ( a4 ) - { - v13 = fixpoint_mul(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); - a5a = fixpoint_mul(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); - pSpriteObjects[v6].vVelocity.x = fixpoint_mul(v13, a4); - pSpriteObjects[v6].vVelocity.y = fixpoint_mul(a5a, a4); - pSpriteObjects[v6].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pitch), a4); - } - else - { - pSpriteObjects[v6].vVelocity.y = 0; - pSpriteObjects[v6].vVelocity.x = 0; - } - if ( v6 >= (signed int)uNumSpriteObjects ) - uNumSpriteObjects = v6 + 1; - return v6; - } - if ( a5 == 1 ) - { - v17.x = vPosition.x; - v17.y = vPosition.y; - v17.z = vPosition.z; - Vec3_int_::Rotate(24, stru_5C6E00->uIntegerHalfPi + pSpriteObjects[v6].uFacing, 0, v17, &pSpriteObjects[v6].vPosition.x, - &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); - pSpriteObjects[v6].vVelocity.z = 0; - if ( a4 ) - { - v13 = fixpoint_mul(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); - a5a = fixpoint_mul(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); - pSpriteObjects[v6].vVelocity.x = fixpoint_mul(v13, a4); - pSpriteObjects[v6].vVelocity.y = fixpoint_mul(a5a, a4); - pSpriteObjects[v6].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pitch), a4); - } - else - { - pSpriteObjects[v6].vVelocity.y = 0; - pSpriteObjects[v6].vVelocity.x = 0; - } - if ( v6 >= (signed int)uNumSpriteObjects ) - uNumSpriteObjects = v6 + 1; - return v6; - } - if ( a5 == 2 ) + + switch (a5) { - v17.x = vPosition.x; - v17.y = vPosition.y; - v17.z = vPosition.z; - Vec3_int_::Rotate(8, stru_5C6E00->uIntegerHalfPi + pSpriteObjects[v6].uFacing, 0, v17, &pSpriteObjects[v6].vPosition.x, - &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); - pSpriteObjects[v6].vVelocity.z = 0; - if ( a4 ) - { - v13 = fixpoint_mul(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); - a5a = fixpoint_mul(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); - pSpriteObjects[v6].vVelocity.x = fixpoint_mul(v13, a4); - pSpriteObjects[v6].vVelocity.y = fixpoint_mul(a5a, a4); - pSpriteObjects[v6].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pitch), a4); - } - else - { - pSpriteObjects[v6].vVelocity.y = 0; - pSpriteObjects[v6].vVelocity.x = 0; - } - if ( v6 >= (signed int)uNumSpriteObjects ) - uNumSpriteObjects = v6 + 1; - return v6; - } - if ( a5 == 3 ) - { - v17.x = vPosition.x; - v17.y = vPosition.y; - v17.z = vPosition.z; - Vec3_int_::Rotate(8, pSpriteObjects[v6].uFacing - stru_5C6E00->uIntegerHalfPi, 0, v17, &pSpriteObjects[v6].vPosition.x, - &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); - pSpriteObjects[v6].vVelocity.z = 0; - if ( a4 ) - { - v13 = fixpoint_mul(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); - a5a = fixpoint_mul(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); - pSpriteObjects[v6].vVelocity.x = fixpoint_mul(v13, a4); - pSpriteObjects[v6].vVelocity.y = fixpoint_mul(a5a, a4); - pSpriteObjects[v6].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pitch), a4); - } - else - { - pSpriteObjects[v6].vVelocity.y = 0; - pSpriteObjects[v6].vVelocity.x = 0; - } - if ( v6 >= (signed int)uNumSpriteObjects ) - uNumSpriteObjects = v6 + 1; - return v6; - } - if ( a5 == 4 ) - { - v17.x = vPosition.x; - v17.y = vPosition.y; - v17.z = vPosition.z; - Vec3_int_::Rotate(24, pSpriteObjects[v6].uFacing - stru_5C6E00->uIntegerHalfPi, 0, v17, &pSpriteObjects[v6].vPosition.x, - &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); - pSpriteObjects[v6].vVelocity.z = 0; - if ( a4 ) - { - v13 = fixpoint_mul(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); - a5a = fixpoint_mul(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); - pSpriteObjects[v6].vVelocity.x = fixpoint_mul(v13, a4); - pSpriteObjects[v6].vVelocity.y = fixpoint_mul(a5a, a4); - pSpriteObjects[v6].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pitch), a4); - } - else - { - pSpriteObjects[v6].vVelocity.y = 0; - pSpriteObjects[v6].vVelocity.x = 0; - } - if ( v6 >= (signed int)uNumSpriteObjects ) - uNumSpriteObjects = v6 + 1; - return v6; + case 0: + break; //do nothing + case 1: + Vec3_int_::Rotate(24, stru_5C6E00->uIntegerHalfPi + uFacing, 0, vPosition, &vPosition.x, + &vPosition.y, &vPosition.z); + break; + case 2: + Vec3_int_::Rotate(8, stru_5C6E00->uIntegerHalfPi + uFacing, 0, vPosition, &vPosition.x, + &vPosition.y, &vPosition.z); + break; + case 3: + Vec3_int_::Rotate(8, uFacing - stru_5C6E00->uIntegerHalfPi, 0, vPosition, &vPosition.x, + &vPosition.y, &vPosition.z); + break; + case 4: + Vec3_int_::Rotate(24, uFacing - stru_5C6E00->uIntegerHalfPi, 0, vPosition, &vPosition.x, + &vPosition.y, &vPosition.z); + break; + default: + assert(false); + return 0; + break; } - assert(false); - return 0; + if ( a4 ) + { + v13 = fixpoint_mul(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); + a5a = fixpoint_mul(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); + vVelocity.x = fixpoint_mul(v13, a4); + vVelocity.y = fixpoint_mul(a5a, a4); + vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pitch), a4); + } + else + { + vVelocity.y = 0; + vVelocity.x = 0; + vVelocity.z = 0; + } + + memcpy(&pSpriteObjects[v6], this, sizeof(*this)); + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; } //----- (00471C03) --------------------------------------------------------