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

Method UpdateCell

engine/Poseidon/World/Terrain/Visibility.cpp:334–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334int SensorList::UpdateCell(SensorRowID r, SensorColID c)
335{
336 SensorRow& row = _rows[r];
337 Person* fromDriver = row._vehicle;
338 if (!fromDriver)
339 {
340 return 0;
341 }
342 SensorCol& col = _cols[c];
343 EntityAI* to = col._vehicle;
344 if (!to)
345 {
346 return 0;
347 }
348 //
349 AIUnit* fromUnit = fromDriver->CommanderUnit();
350 if (!fromUnit)
351 {
352 return 0;
353 }
354
355 EntityAI* from = fromUnit->GetVehicle();
356
357 // update single
358 SensorUpdate& info = row._info[c];
359 if (from == to)
360 {
361 info.SetVisibility1();
362 info.SetLastVisible(Glob.time);
363 info.rowPos = from->Position();
364 info.colPos = to->Position();
365 info.time = Glob.time;
366 return 0;
367 }
368 float dist2 = from->Position().Distance2(to->Position());
369 float irRange = from->GetType()->GetIRScanRange();
370 if (!to->GetType()->GetIRTarget())
371 {
372 irRange = 0;
373 }
374 float sensorLimit = floatMax(irRange, TACTICAL_VISIBILITY);
375 if (dist2 < Square(sensorLimit))
376 {
377 float defValue = 0;
378 float unimportance = Unimportance(from, to, defValue);
379
380 // unimportant: assume default value
381 if (unimportance > 1e5)
382 {
383 info.SetVisibility(defValue);
384 info.rowPos = from->Position();
385 info.colPos = to->Position();
386 info.time = Glob.time - 30;
387 if (defValue >= 0.02f)
388 {
389 info.SetLastVisible(Glob.time);
390 }
391 // set time in past

Callers

nothing calls this directly

Calls 15

floatMaxFunction · 0.85
SetVisibility1Method · 0.80
SetLastVisibleMethod · 0.80
GetIRScanRangeMethod · 0.80
GetIRTargetMethod · 0.80
SetVisibilityMethod · 0.80
SecondaryAllowSwitchMethod · 0.80
SetVisibility0Method · 0.80
SquareFunction · 0.50
CommanderUnitMethod · 0.45
GetVehicleMethod · 0.45
PositionMethod · 0.45

Tested by

no test coverage detected