comparison Actor.cpp @ 1864:b6258f64e313

Actor::GetDirectionInfo some minor changes
author Grumpy7
date Mon, 14 Oct 2013 08:00:30 +0200
parents 97b75e6100ff
children e622546c8f0c
comparison
equal deleted inserted replaced
1863:97b75e6100ff 1864:b6258f64e313
945 // // objectType == 5 - Decoration 945 // // objectType == 5 - Decoration
946 // // 946 // //
947 // // originally this function had following prototype: 947 // // originally this function had following prototype:
948 // // struct DirectionInfo GetDirectionInfo(signed int object1, signed int object2, signed int a4) 948 // // struct DirectionInfo GetDirectionInfo(signed int object1, signed int object2, signed int a4)
949 // // but compiler converts functions returning structures by value in the such way 949 // // but compiler converts functions returning structures by value in the such way
950 AIDirection *__fastcall Actor::GetDirectionInfo(unsigned int uObj1ID, unsigned int uObj2ID, AIDirection *pOut, int a4) 950 struct AIDirection * Actor::GetDirectionInfo( unsigned int uObj1ID, unsigned int uObj2ID, struct AIDirection *pOut, int a4 )
951 { 951 {
952 signed int v4; // eax@1 952 signed int v4; // eax@1
953 signed int v5; // ecx@1 953 signed int v5; // ecx@1
954 //unsigned int v6; // ebx@1
955 int v7; // ecx@2
956 int v8; // ecx@3
957 int v9; // ecx@4
958 //BLVFace *v10; // eax@8
959 //unsigned int v11; // ecx@8
960 //signed int v12; // eax@9
961 //int v13; // ecx@9
962 //int v14; // eax@9
963 int v15; // eax@11
964 int v16; // eax@12
965 int v17; // eax@13
966 int v18; // edx@15 954 int v18; // edx@15
967 //signed int v19; // eax@25 955 float v31; // st7@45
968 //signed int v20; // eax@28 956 float v32; // st6@45
969 //int v21; // ebx@28 957 float v33; // st7@45
970 //signed int v22; // eax@28
971 //BLVFace *v23; // eax@35
972 //int v24; // edx@35
973 //unsigned int v25; // ecx@35
974 //signed int v26; // eax@36
975 //int v27; // ecx@36
976 //int v28; // eax@36
977 //int v29; // eax@37
978 //signed int v30; // eax@42
979 double v31; // st7@45
980 double v32; // st6@45
981 double v33; // st7@45
982 AIDirection *result; // eax@48 958 AIDirection *result; // eax@48
983 //int v35; // [sp-18h] [bp-64h]@17
984 //int v36; // [sp-14h] [bp-60h]@17
985 Vec3_int_ v37; // [sp-10h] [bp-5Ch]@15 959 Vec3_int_ v37; // [sp-10h] [bp-5Ch]@15
986 //int *v38; // [sp-4h] [bp-50h]@15
987 //int *v39; // [sp+0h] [bp-4Ch]@15
988 //int *v40; // [sp+4h] [bp-48h]@15
989 AIDirection v41; // [sp+14h] [bp-38h]@46 960 AIDirection v41; // [sp+14h] [bp-38h]@46
990 float v42; // [sp+30h] [bp-1Ch]@23
991 float v43; // [sp+34h] [bp-18h]@45
992 float outy2; // [sp+38h] [bp-14h]@33 961 float outy2; // [sp+38h] [bp-14h]@33
993 float outx2; // [sp+3Ch] [bp-10h]@33 962 float outx2; // [sp+3Ch] [bp-10h]@33
994 int outz; // [sp+40h] [bp-Ch]@6 963 int outz; // [sp+40h] [bp-Ch]@6
995 int outy; // [sp+44h] [bp-8h]@6 964 int outy; // [sp+44h] [bp-8h]@6
996 int outx; // [sp+48h] [bp-4h]@6 965 int outx; // [sp+48h] [bp-4h]@6
1026 } 995 }
1027 if ( v4 == 4 ) 996 if ( v4 == 4 )
1028 { 997 {
1029 v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; 998 v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi;
1030 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; 999 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
1031 *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x; 1000 v37.x = pParty->vPosition.x;
1001 v37.y = pParty->vPosition.y;
1032 Vec3_int_::Rotate(24, v18, 0, v37, &outx, &outy, &outz); 1002 Vec3_int_::Rotate(24, v18, 0, v37, &outx, &outy, &outz);
1033 break; 1003 break;
1034 } 1004 }
1035 if ( v4 == 3 ) 1005 if ( v4 == 3 )
1036 { 1006 {
1037 v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; 1007 v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi;
1038 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; 1008 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
1039 *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x; 1009 v37.x = pParty->vPosition.x;
1010 v37.y = pParty->vPosition.y;
1040 Vec3_int_::Rotate(8, v18, 0, v37, &outx, &outy, &outz); 1011 Vec3_int_::Rotate(8, v18, 0, v37, &outx, &outy, &outz);
1041 break; 1012 break;
1042 } 1013 }
1043 if ( v4 == 2 ) 1014 if ( v4 == 2 )
1044 { 1015 {
1045 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; 1016 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
1046 v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; 1017 v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY;
1047 *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x; 1018 v37.x = pParty->vPosition.x;
1019 v37.y = pParty->vPosition.y;
1048 Vec3_int_::Rotate(8, v18, 0, v37, &outx, &outy, &outz); 1020 Vec3_int_::Rotate(8, v18, 0, v37, &outx, &outy, &outz);
1049 break; 1021 break;
1050 } 1022 }
1051 if ( v4 == 1 ) 1023 if ( v4 == 1 )
1052 { 1024 {
1053 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; 1025 v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
1054 v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; 1026 v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY;
1055 *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x; 1027 v37.x = pParty->vPosition.x;
1028 v37.y = pParty->vPosition.y;
1056 Vec3_int_::Rotate(24, v18, 0, v37, &outx, &outy, &outz); 1029 Vec3_int_::Rotate(24, v18, 0, v37, &outx, &outy, &outz);
1057 break; 1030 break;
1058 } 1031 }
1059 } 1032 }
1060 case OBJECT_Decoration: 1033 case OBJECT_Decoration:
1085 1058
1086 switch( PID_TYPE(uObj2ID) ) 1059 switch( PID_TYPE(uObj2ID) )
1087 { 1060 {
1088 case OBJECT_Item: 1061 case OBJECT_Item:
1089 { 1062 {
1090 outx2 = pSpriteObjects[v5].vPosition.x; 1063 outx2 = (float)pSpriteObjects[v5].vPosition.x;
1091 outy2 = pSpriteObjects[v5].vPosition.y; 1064 outy2 =(float) pSpriteObjects[v5].vPosition.y;
1092 a4 = pSpriteObjects[v5].vPosition.z; 1065 a4 = pSpriteObjects[v5].vPosition.z;
1093 break; 1066 break;
1094 } 1067 }
1095 case OBJECT_Actor: 1068 case OBJECT_Actor:
1096 { 1069 {
1097 outx2 = pActors[v5].vPosition.x; 1070 outx2 = (float)pActors[v5].vPosition.x;
1098 outy2 = pActors[v5].vPosition.y; 1071 outy2 = (float)pActors[v5].vPosition.y;
1099 a4 = pActors[v5].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v5].uActorHeight * -0.75); 1072 a4 = pActors[v5].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v5].uActorHeight * -0.75);
1100 break; 1073 break;
1101 } 1074 }
1102 case OBJECT_Player: 1075 case OBJECT_Player:
1103 { 1076 {
1104 outx2 = pParty->vPosition.x; 1077 outx2 = (float)pParty->vPosition.x;
1105 outy2 = pParty->vPosition.y; 1078 outy2 = (float)pParty->vPosition.y;
1106 if ( !a4 ) 1079 if ( !a4 )
1107 a4 = pParty->sEyelevel; 1080 a4 = pParty->sEyelevel;
1108 a4 = pParty->vPosition.z + a4; 1081 a4 = pParty->vPosition.z + a4;
1109 break; 1082 break;
1110 } 1083 }
1111 case OBJECT_Decoration: 1084 case OBJECT_Decoration:
1112 { 1085 {
1113 outx2 = pLevelDecorations[v5].vPosition.x; 1086 outx2 = (float)pLevelDecorations[v5].vPosition.x;
1114 outy2 = pLevelDecorations[v5].vPosition.y; 1087 outy2 = (float)pLevelDecorations[v5].vPosition.y;
1115 a4 = pLevelDecorations[v5].vPosition.z; 1088 a4 = pLevelDecorations[v5].vPosition.z;
1116 break; 1089 break;
1117 } 1090 }
1118 default: 1091 default:
1119 { 1092 {
1124 } 1097 }
1125 case OBJECT_BModel: 1098 case OBJECT_BModel:
1126 { 1099 {
1127 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 1100 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
1128 { 1101 {
1129 outx2 = (pIndoor->pFaces[v5].pBounding.x1 + pIndoor->pFaces[v5].pBounding.x2) >> 1; 1102 outx2 = (float)((pIndoor->pFaces[v5].pBounding.x1 + pIndoor->pFaces[v5].pBounding.x2) >> 1);
1130 outy2 = (pIndoor->pFaces[v5].pBounding.y1 + pIndoor->pFaces[v5].pBounding.y2) >> 1; 1103 outy2 = (float)((pIndoor->pFaces[v5].pBounding.y1 + pIndoor->pFaces[v5].pBounding.y2) >> 1);
1131 a4 = (pIndoor->pFaces[v5].pBounding.z1 + pIndoor->pFaces[v5].pBounding.z2) >> 1; 1104 a4 = (pIndoor->pFaces[v5].pBounding.z1 + pIndoor->pFaces[v5].pBounding.z2) >> 1;
1132 } 1105 }
1133 break; 1106 break;
1134 } 1107 }
1135 } 1108 }
1136 1109
1137 v31 = (double)outx2 - (double)outx; 1110 v31 = (float)outx2 - (float)outx;
1138 v42 = v31; 1111 v32 = (float)outy2 - (float)outy;
1139 v32 = (double)outy2 - (double)outy; 1112 a4a = (float)a4 - (float)outz;
1140 v43 = v32;
1141 a4a = (double)a4 - (double)outz;
1142 outx2 = v32 * v32; 1113 outx2 = v32 * v32;
1143 outy2 = v31 * v31; 1114 outy2 = v31 * v31;
1144 v33 = sqrt(a4a * a4a + outy2 + outx2); 1115 v33 = sqrt(a4a * a4a + outy2 + outx2);
1145 if ( v33 <= 1.0 ) 1116 if ( v33 <= 1.0 )
1146 { 1117 {
1152 v41.uYawAngle = 0; 1123 v41.uYawAngle = 0;
1153 v41.uPitchAngle = 0; 1124 v41.uPitchAngle = 0;
1154 } 1125 }
1155 else 1126 else
1156 { 1127 {
1157 v41.vDirection.x = (signed __int64)(1.0 / v33 * v42 * 65536.0); 1128 v41.vDirection.x = (int32_t)(1.0 / v33 * v31 * 65536.0);
1158 v41.vDirection.y = (signed __int64)(1.0 / v33 * v43 * 65536.0); 1129 v41.vDirection.y = (int32_t)(1.0 / v33 * v32 * 65536.0);
1159 v41.vDirection.z = (signed __int64)(1.0 / v33 * a4a * 65536.0); 1130 v41.vDirection.z = (int32_t)(1.0 / v33 * a4a * 65536.0);
1160 v41.uDistance = (signed __int64)v33; 1131 v41.uDistance = (uint)v33;
1161 v41.uDistanceXZ = sqrt(outy2 + outx2); 1132 v41.uDistanceXZ = (uint)sqrt(outy2 + outx2);
1162 v41.uYawAngle = stru_5C6E00->Atan2((signed __int64)v42, (signed __int64)v43); 1133 v41.uYawAngle = stru_5C6E00->Atan2((signed __int64)v31, (signed __int64)v32);
1163 v41.uPitchAngle = stru_5C6E00->Atan2(v41.uDistanceXZ, (signed __int64)a4a); 1134 v41.uPitchAngle = stru_5C6E00->Atan2(v41.uDistanceXZ, (signed __int64)a4a);
1164 } 1135 }
1165 result = pOut; 1136 result = pOut;
1166 memcpy(pOut, &v41, sizeof(AIDirection)); 1137 memcpy(pOut, &v41, sizeof(AIDirection));
1167 return result; 1138 return result;