MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / Simulate

Method Simulate

engine/Poseidon/AI/VehicleAICombat.cpp:1066–1194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1064}
1065
1066void EntityAI::Simulate(float deltaT, SimulationImportance prec)
1067{
1068 if (_shape && !_static) // do not lock buildings
1069 {
1070 if (HasGeometry() && (_isStopped || _speed.SquareSize() < Square(1.5)) &&
1071 (!Airborne() || // lock for vehicle that are not airborne
1072 // lock also for low static airborne vehicle
1073 Position().Y() < GLandscape->SurfaceYAboveWater(Position().X(), Position().Z()) + 15))
1074 {
1075 LockPosition();
1076 }
1077 else
1078 {
1079 UnlockPosition();
1080 }
1081 }
1082 float delta;
1083 delta = _avoidAsideWanted - _avoidAside;
1084 if (fabs(_avoidAsideWanted) > fabs(_avoidAside))
1085 {
1086 saturate(delta, -20 * deltaT, +20 * deltaT);
1087 }
1088 else
1089 {
1090 saturate(delta, -0.2 * deltaT, +0.2 * deltaT);
1091 }
1092 _avoidAside += delta;
1093
1094 SimulateWeaponActivity(deltaT, prec);
1095
1096 // simulate flag
1097 Texture* texture = GetFlagTexture();
1098 if (texture)
1099 {
1100 Shape* sShape = _shape->LevelOpaque(0);
1101 if (sShape)
1102 {
1103 for (int i = 0; i < sShape->NProxies(); i++)
1104 {
1105 const ProxyObject& proxy = sShape->Proxy(i);
1106 Entity* veh = dyn_cast<Entity>(proxy.obj.GetRef());
1107 if (veh)
1108 {
1109 LODShapeWithShadow* lodShape = veh->GetShape();
1110 if (strnicmp(lodShape->Name(), "data3d\\flag_", 12) == 0)
1111 {
1112 Matrix4 proxyTransform = AnimateProxyMatrix(0, proxy);
1113
1114 Matrix4Val pTransform = Transform() * proxyTransform;
1115
1116 Vector3 speed(VZero);
1117 if (_flag)
1118 {
1119 speed = (1.0 / deltaT) * (pTransform.Position() - _flag->Position());
1120 }
1121 else
1122 {
1123 _flag = dyn_cast<Flag>(NewNonAIVehicle(veh->GetNonAIType()->GetName(), lodShape->Name()));

Callers

nothing calls this directly

Calls 15

AirborneFunction · 0.85
fabsFunction · 0.85
saturateFunction · 0.85
TransformFunction · 0.85
NewNonAIVehicleFunction · 0.85
SurfaceYAboveWaterMethod · 0.80
LevelOpaqueMethod · 0.80
NProxiesMethod · 0.80
ProxyMethod · 0.80
GetNonAITypeMethod · 0.80
FlagSimulateMethod · 0.80
CameraOnMethod · 0.80

Tested by

no test coverage detected