[Gcblue-commits] gcb_wx/src/sim tcAirObject.cpp,1.17,1.18 tcGameObject.cpp,1.29,1.30 tcHeloObject.cp
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-03-08 00:42:03
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10870/src/sim Modified Files: tcAirObject.cpp tcGameObject.cpp tcHeloObject.cpp tcPositionRegistry.cpp tcSimState.cpp tcSonar.cpp tcSubObject.cpp tcSurfaceObject.cpp tcTorpedoObject.cpp Log Message: Index: tcSubObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSubObject.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcSubObject.cpp 4 Mar 2005 00:46:18 -0000 1.4 --- tcSubObject.cpp 8 Mar 2005 00:41:51 -0000 1.5 *************** *** 106,109 **** --- 106,115 ---- } + bool tcSubObject::IsDestroyed() + { + return (mfDamageLevel >= 1.0f) && doneSinking; + } + + /** * *************** *** 345,348 **** --- 351,384 ---- } + + void tcSubObject::UpdateDestroyed(double t) + { + float dt_s = (float)(t - mfStatusTime); + + if (mcKin.mfSpeed_kts >= 12.0f) + { + mcKin.mfSpeed_kts += 1.0f * dt_s; + } + else + { + mcKin.mfSpeed_kts = 12.0f; + } + + if (mcKin.mfClimbAngle_rad > -0.3f) + { + mcKin.mfClimbAngle_rad -= 0.1f * dt_s; + } + + mcKin.mfPitch_rad = mcKin.mfClimbAngle_rad; + + + if (mcKin.mfAlt_m <= mcTerrain.mfHeight_m + 5.0f) + { + doneSinking = true; + } + + Move(dt_s); + } + /** * *************** *** 461,464 **** --- 497,508 ---- wxASSERT(mpDBObject); + if (mfDamageLevel >= 1.0f) + { + UpdateDestroyed(afStatusTime); + mfStatusTime = afStatusTime; + return; + } + + UpdateFormationGuidance(); // formation heading/speed calculation *************** *** 504,508 **** : tcPlatformObject(obj), maxPitch_rad(0.5), ! periscopeDepth_m(18) { mpDBObject = obj; --- 548,553 ---- : tcPlatformObject(obj), maxPitch_rad(0.5), ! periscopeDepth_m(18), ! doneSinking(false) { mpDBObject = obj; Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** tcSimState.cpp 7 Mar 2005 01:54:19 -0000 1.70 --- tcSimState.cpp 8 Mar 2005 00:41:50 -0000 1.71 *************** *** 477,481 **** float rLon = rLat / cosf(weapon->mcKin.mfLat_rad); ! long blastPlats[16]; tcRect blastRegion; --- 477,481 ---- float rLon = rLat / cosf(weapon->mcKin.mfLat_rad); ! std::vector<long> blastPlats; tcRect blastRegion; *************** *** 488,492 **** blastRegion.Set(west, east, south, north); ! int nPlats = GetPlatformsWithinRegion(blastPlats, 16, &blastRegion); float fDamage = weapon->GetDamage(); --- 488,493 ---- blastRegion.Set(west, east, south, north); ! GetPlatformsWithinRegion(blastPlats, &blastRegion); ! int nPlats = (int)blastPlats.size(); float fDamage = weapon->GetDamage(); *************** *** 884,888 **** { maPlatformState.GetNextAssoc(cmappos, nKey, obj); ! if (obj->mfDamageLevel >= 1.0f) { DeleteObject(nKey); --- 885,889 ---- { maPlatformState.GetNextAssoc(cmappos, nKey, obj); ! if (obj->IsDestroyed()) { DeleteObject(nKey); *************** *** 1127,1130 **** --- 1128,1132 ---- void tcSimState::UpdateSurveillance(tcGameObject *applat, tcSensorState *apSensorState) { + #if 0 tnPoolIndex aTargetKeys[100]; tnPoolIndex nTargetID; *************** *** 1135,1138 **** --- 1137,1141 ---- wxASSERT(false); // deprecated + apSensorState->GetTestArea(region); nCount = GetPlatformsWithinRegion(aTargetKeys, 100, ®ion); *************** *** 1155,1158 **** --- 1158,1162 ---- } } + #endif } *************** *** 1163,1167 **** { wxASSERT(false); // deprecated? ! tnPoolIndex aTargetKeys[N_TARGET_KEYS]; tnPoolIndex aFCKeys[N_FC_KEYS]; --- 1167,1171 ---- { wxASSERT(false); // deprecated? ! #if 0 tnPoolIndex aTargetKeys[N_TARGET_KEYS]; tnPoolIndex aFCKeys[N_FC_KEYS]; *************** *** 1206,1209 **** --- 1210,1214 ---- } } + #endif } *************** *** 1331,1334 **** --- 1336,1340 ---- wxASSERT(false); + #if 0 long nTargetID; GeoPoint currentpos; *************** *** 1435,1438 **** --- 1441,1445 ---- break; } + #endif } *************** *** 2084,2088 **** * */ ! int tcSimState::GetPlatformsWithinRegion(tnPoolIndex *apKeyList, int anLength, tcRect *apRegion) { tcGameObject *pplat; --- 2091,2095 ---- * */ ! void tcSimState::GetPlatformsWithinRegion(std::vector<long>& keyList, tcRect *apRegion) { tcGameObject *pplat; *************** *** 2096,2110 **** if (positionRegistry) { ! std::vector<long>& idVect = positionRegistry->GetAllWithinRegion(apRegion->GetLeft(), apRegion->GetRight(), apRegion->GetBottom(), apRegion->GetTop()); ! for (size_t k=0; k<idVect.size(); k++) ! { ! apKeyList[nListIndex++] = idVect[k]; ! } ! return nListIndex; } ! for (tnPoolIndex i=0;(i<nSize)&&(nListIndex<anLength);i++) { maPlatformState.GetNextAssoc(cmappos,nKey,pplat); --- 2103,2114 ---- if (positionRegistry) { ! keyList = positionRegistry->GetAllWithinRegion(apRegion->GetLeft(), apRegion->GetRight(), apRegion->GetBottom(), apRegion->GetTop()); ! ! return; } ! for (tnPoolIndex i=0; (i<nSize); i++) { maPlatformState.GetNextAssoc(cmappos,nKey,pplat); *************** *** 2113,2120 **** if (GeoWithinRegion(p,apRegion)) { ! apKeyList[nListIndex++]=nKey; } } - return nListIndex; } --- 2117,2123 ---- if (GeoWithinRegion(p,apRegion)) { ! keyList.push_back(nKey); } } } Index: tcAirObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAirObject.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tcAirObject.cpp 16 Feb 2005 23:13:49 -0000 1.17 --- tcAirObject.cpp 8 Mar 2005 00:41:50 -0000 1.18 *************** *** 101,104 **** --- 101,110 ---- } + bool tcAirObject::IsDestroyed() + { + return (mfDamageLevel >= 1.0f) && doneCrashing; + } + + void tcAirObject::RandInitNear(float afLon_deg, float afLat_deg) { *************** *** 259,262 **** --- 265,297 ---- } + + void tcAirObject::UpdateDestroyed(double t) + { + float dt_s = (float)(t - mfStatusTime); + + if (mcKin.mfSpeed_kts >= 450.0f) + { + mcKin.mfSpeed_kts += 20.0f * dt_s; + } + + if (mcKin.mfClimbAngle_rad > -0.3f) + { + mcKin.mfClimbAngle_rad -= 0.1f * dt_s; + } + + mcKin.mfPitch_rad = mcKin.mfClimbAngle_rad; + mcKin.mfRoll_rad += 0.01f * dt_s; + + if (mcKin.mfAlt_m <= mcTerrain.mfHeight_m + 25.0f) + { + doneCrashing = true; + } + + Move(dt_s); + } + + + + void tcAirObject::UpdateEffects() { *************** *** 363,366 **** --- 398,408 ---- wxASSERT(mpDBObject); + if (mfDamageLevel >= 1.0f) + { + UpdateDestroyed(afStatusTime); + mfStatusTime = afStatusTime; + return; + } + UpdateFormationGuidance(); // formation heading/speed calculation *************** *** 400,404 **** */ tcAirObject::tcAirObject(tcGenericDBObject *obj) ! : tcPlatformObject(obj) { mpDBObject = obj; --- 442,447 ---- */ tcAirObject::tcAirObject(tcGenericDBObject *obj) ! : tcPlatformObject(obj), ! doneCrashing(false) { mpDBObject = obj; Index: tcSonar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSonar.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcSonar.cpp 7 Mar 2005 01:54:19 -0000 1.8 --- tcSonar.cpp 8 Mar 2005 00:41:50 -0000 1.9 *************** *** 452,503 **** tcSensorMapTrack *pSMTrack = 0; ! wxASSERT(simState); bool bAccept = simState->mcSensorMap.UpdatePassiveReport(pReport, parent->mnID, target->mnID, pSMTrack, parent->mnAlliance); ! // update passive report if update needed (if bAccept) ! if (bAccept) ! { ! bool bNewReport = pReport->IsNew(); ! bool bNewDetection = pSMTrack->IsNew(); ! if (bNewReport) {pReport->mfStartTime = t;} // new detection report ! double fTrackLife = pReport->mfTimestamp - pReport->mfStartTime; pReport->mfLat_rad = (float)parent->mcKin.mfLat_rad; pReport->mfLon_rad = (float)parent->mcKin.mfLon_rad; pReport->mfHeading_rad = az_rad; ! pReport->mnFlags = TRACK_BEARING_ONLY | TRACK_HEADING_VALID; ! ! pReport->mfTimestamp = t; ! pReport->mnSensorPlatformID = parent->mnID; ! pReport->mnTrackID = target->mnID; ! ! ! if ((!pReport->mbClassified) && (fTrackLife > 20.0)) { ! wxASSERT(target->mpDBObject); ! unsigned int nClassification = target->mpDBObject->mnType; ! nClassification &= 0xFFF0; // leave size field unknown ! teAffiliation eAffil = UNKNOWN; ! if (nClassification & PTYPE_TORPEDO) {eAffil = HOSTILE;} ! pSMTrack->UpdateClassification(nClassification, eAffil, NULL_INDEX); ! pReport->mbClassified = 1; } ! if (bNewDetection) { ! pSMTrack->UpdateTrack(); ! if (simState->mpUserInfo->IsOwnAlliance(parent->mnAlliance)) ! { ! tcSound::Get()->PlayEffect("shishding"); ! } ! fprintf(stdout, "%s (%s): target %d (%s) detected by passive sonar at %3.1f km" ! " at time %.1f (%.1f dB) (a:%d)\n", ! parent->mzUnit.mz, parent->mzClass.mz, target->mnID, target->mzClass.mz, ! range_km, t, last_snr_excess, parent->mnAlliance); } } } --- 452,519 ---- tcSensorMapTrack *pSMTrack = 0; ! wxASSERT(simState); bool bAccept = simState->mcSensorMap.UpdatePassiveReport(pReport, parent->mnID, target->mnID, pSMTrack, parent->mnAlliance); ! if (!bAccept) return; ! ! bool bNewReport = pReport->IsNew(); ! bool bNewDetection = pSMTrack->IsNew(); ! if (bNewReport) {pReport->mfStartTime = t;} // new detection report ! double fTrackLife = pReport->mfTimestamp - pReport->mfStartTime; ! ! bool bTriangulated = (fTrackLife > 60.0f) && (pSMTrack->mnContributors > 1); + if (!bTriangulated) + { pReport->mfLat_rad = (float)parent->mcKin.mfLat_rad; pReport->mfLon_rad = (float)parent->mcKin.mfLon_rad; pReport->mfHeading_rad = az_rad; ! pReport->mnFlags = TRACK_BEARING_ONLY; ! } ! else ! { ! pReport->mfLat_rad = (float)target->mcKin.mfLat_rad; ! pReport->mfLon_rad = (float)target->mcKin.mfLon_rad; ! pReport->mnFlags = TRACK_TRIANGULATED; ! if (fTrackLife > 90.0f) { ! pReport->mfHeading_rad = target->mcKin.mfHeading_rad; ! pReport->mfSpeed_kts = target->mcKin.mfSpeed_kts; ! pReport->mnFlags |= (TRACK_SPEED_VALID | TRACK_HEADING_VALID); } + } + pReport->mfTimestamp = t; + pReport->mnSensorPlatformID = parent->mnID; + pReport->mnTrackID = target->mnID; ! ! if ((!pReport->mbClassified) && (fTrackLife > 20.0)) ! { ! wxASSERT(target->mpDBObject); ! unsigned int nClassification = target->mpDBObject->mnType; ! nClassification &= 0xFFF0; // leave size field unknown ! teAffiliation eAffil = UNKNOWN; ! if (nClassification & PTYPE_TORPEDO) {eAffil = HOSTILE;} ! pSMTrack->UpdateClassification(nClassification, eAffil, NULL_INDEX); ! pReport->mbClassified = 1; ! } ! ! ! if (bNewDetection) ! { ! pSMTrack->UpdateTrack(); ! if (simState->mpUserInfo->IsOwnAlliance(parent->mnAlliance)) { ! tcSound::Get()->PlayEffect("shishding"); } + fprintf(stdout, "%s (%s): target %d (%s) detected by passive sonar at %3.1f km" + " at time %.1f (%.1f dB) (a:%d)\n", + parent->mzUnit.mz, parent->mzClass.mz, target->mnID, target->mzClass.mz, + range_km, t, last_snr_excess, parent->mnAlliance); } + } *************** *** 546,551 **** void tcSonar::UpdateTrack(const tcGameObject* target, double t) { ! if (isPassive) { float bearingRate = parent->mcKin.BearingRateTo(last_range_km, last_az_rad, --- 562,568 ---- void tcSonar::UpdateTrack(const tcGameObject* target, double t) { + bool cheatPassive = last_range_km <= 2.0f; ! if (isPassive && !cheatPassive) { float bearingRate = parent->mcKin.BearingRateTo(last_range_km, last_az_rad, Index: tcSurfaceObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSurfaceObject.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcSurfaceObject.cpp 24 Feb 2005 22:19:16 -0000 1.16 --- tcSurfaceObject.cpp 8 Mar 2005 00:41:51 -0000 1.17 *************** *** 86,89 **** --- 86,96 ---- if (mpDBObject == NULL) {return;} + if (mfDamageLevel >= 1.0f) + { + UpdateDestroyed(afStatusTime); + mfStatusTime = afStatusTime; + return; + } + UpdateFormationGuidance(); // formation heading/speed calculation *************** *** 107,115 **** } void tcSurfaceObject::UpdateEffects() { if (model) { ! if (mfDamageLevel > 0.1f) { model->SetSmokeMode(tcParticleEffect::DAMAGE); --- 114,147 ---- } + void tcSurfaceObject::UpdateDestroyed(double t) + { + float dt_s = (float)(t - mfStatusTime); + + if (mcKin.mfSpeed_kts >= 0.5f) + { + mcKin.mfSpeed_kts -= 1.0f * dt_s; + } + else + { + mcKin.mfSpeed_kts = 0; + } + + mcKin.mfAlt_m -= 0.1f * dt_s; + mcKin.mfRoll_rad += 0.01f * dt_s; + mcKin.mfPitch_rad += 0.001f * dt_s; + + if (mcKin.mfAlt_m <= -20.0f) + { + doneSinking = true; + } + + Move(dt_s); + } + void tcSurfaceObject::UpdateEffects() { if (model) { ! if ((mfDamageLevel > 0.1f) && (mcKin.mfAlt_m > -10.0f)) { model->SetSmokeMode(tcParticleEffect::DAMAGE); *************** *** 125,129 **** /******************************************************************************/ ! void tcSurfaceObject::Clear(void) { tcPlatformObject::Clear(); --- 157,161 ---- /******************************************************************************/ ! void tcSurfaceObject::Clear() { tcPlatformObject::Clear(); *************** *** 131,134 **** --- 163,171 ---- } + bool tcSurfaceObject::IsDestroyed() + { + return (mfDamageLevel >= 1.0f) && doneSinking; + } + /******************************************************************************/ *************** *** 207,211 **** tcSurfaceObject::tcSurfaceObject(tcGenericDBObject *obj) ! : tcPlatformObject(obj) { mpDBObject = obj; --- 244,249 ---- tcSurfaceObject::tcSurfaceObject(tcGenericDBObject *obj) ! : tcPlatformObject(obj), ! doneSinking(false) { mpDBObject = obj; Index: tcHeloObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcHeloObject.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcHeloObject.cpp 31 Jan 2005 01:33:09 -0000 1.3 --- tcHeloObject.cpp 8 Mar 2005 00:41:50 -0000 1.4 *************** *** 178,181 **** --- 178,183 ---- UpdateSensors(afStatusTime); + UpdateAI(afStatusTime); + mfStatusTime = afStatusTime; } Index: tcTorpedoObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcTorpedoObject.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcTorpedoObject.cpp 7 Mar 2005 01:54:19 -0000 1.7 --- tcTorpedoObject.cpp 8 Mar 2005 00:41:51 -0000 1.8 *************** *** 137,141 **** else { ! runToEnable_m = 1000.0f * mcKin.RangeToKm(&waypoint); } --- 137,141 ---- else { ! runToEnable_m = 500.0f * mcKin.RangeToKm(&waypoint); // enable halfway to waypoint } *************** *** 246,259 **** UpdateSpeedSimple(dt_s); ! float speed_mps = C_KTSTOMPS * cosf(mcKin.mfClimbAngle_rad) * mcKin.mfSpeed_kts; float disp_m = speed_mps * dt_s; // distance moved this update float disp_rad = C_MTORAD * disp_m; // distance in equator radians runToEnable_m -= disp_m; float heading_rad = mcKin.mfHeading_rad; ! mcKin.mfLon_rad += disp_rad * (double)(sinf(heading_rad) / cosf((float)mcKin.mfLat_rad)); ! mcKin.mfLat_rad += (double)cosf(heading_rad) * disp_rad; ! mcKin.mfAlt_m += sinf(mcKin.mfClimbAngle_rad) * disp_m; --- 246,261 ---- UpdateSpeedSimple(dt_s); ! float speed_mps = C_KTSTOMPS * mcKin.mfSpeed_kts; float disp_m = speed_mps * dt_s; // distance moved this update float disp_rad = C_MTORAD * disp_m; // distance in equator radians runToEnable_m -= disp_m; + float disp_xy_rad = disp_rad * cosf(mcKin.mfClimbAngle_rad); + float disp_z_m = disp_m * sinf(mcKin.mfClimbAngle_rad); float heading_rad = mcKin.mfHeading_rad; ! mcKin.mfLon_rad += disp_xy_rad * (double)(sinf(heading_rad) / cosf((float)mcKin.mfLat_rad)); ! mcKin.mfLat_rad += (double)cosf(heading_rad) * disp_xy_rad; ! mcKin.mfAlt_m += disp_z_m; Index: tcGameObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObject.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** tcGameObject.cpp 24 Feb 2005 22:19:16 -0000 1.29 --- tcGameObject.cpp 8 Mar 2005 00:41:50 -0000 1.30 *************** *** 176,179 **** --- 176,185 ---- } + bool tcGameObject::IsDestroyed() + { + return (mfDamageLevel >= 1.0f); + } + + /** * Used to decide when to display info messages and play sound Index: tcPositionRegistry.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPositionRegistry.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcPositionRegistry.cpp 4 Mar 2005 00:46:18 -0000 1.1 --- tcPositionRegistry.cpp 8 Mar 2005 00:41:50 -0000 1.2 *************** *** 229,233 **** twopi(6.283185307179586), piovertwo(1.570796326794897), ! binWidth(0.25 * 0.017453293) // 0.25 degrees lon/lat { invBinWidth = 1.0 / binWidth; --- 229,233 ---- twopi(6.283185307179586), piovertwo(1.570796326794897), ! binWidth(0.2 * 0.017453293) // 0.2 degrees lon/lat { invBinWidth = 1.0 / binWidth; |