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

Method Init

engine/Poseidon/World/Simulation/Animation/Animation.cpp:398–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396 _shape->InitPlanes();
397 int index = _planes[i];
398 return _shape->GetPlane(index);
399}
400const Poly& ConvexComponent::GetFace(int i) const
401{
402 // note: this function needs BuildFaceIndexToOffset
403 // called on shape before using
404 int index = _planes[i];
405 Offset o = _shape->FaceIndexToOffset(index);
406 return _shape->Face(o);
407}
408
409void ConvexComponent::Init(Shape* shape, const char* name)
410{
411 _shape = shape;
412 _minMax[0] = VZero;
413 _minMax[1] = VZero;
414 int index = shape->FindNamedSel(name);
415 if (index < 0)
416 {
417 return;
418 }
419 _minMax[0] = Vector3(+1e10, +1e10, +1e10);
420 _minMax[1] = Vector3(-1e10, -1e10, -1e10);
421 NamedSelection::DoDestruct();
422 NamedSelection::DoConstruct(shape->NamedSel(index));
423
424 int size = Size();
425 {
426 int index = (*this)[0];
427
428 Vector3Val p = _shape->Pos(index);
429 _minMax[0] = p;
430 _minMax[1] = p;
431
432 for (int si = 1; si < size; si++)
433 {
434 int index = (*this)[si];
435 CheckMinMaxIter(_minMax[0], _minMax[1], _shape->Pos(index));
436 }
437 }
438
439 // find bounding center
440 _center = (_minMax[0] + _minMax[1]) * 0.5;
441 // find bounding sphere radius
442 float maxRadius2 = 0;
443 for (int si = 0; si < size; si++)
444 {
445 int index = (*this)[si];
446 float radius2 = shape->Pos(index).Distance2(_center);
447 saturateMax(maxRadius2, radius2);
448 }
449 _radius = sqrt(maxRadius2);
450 // convert face representation to half space
451 const Selection& faces = Faces();
452 // check first face of the selection
453 int faceIndex = faces[0];

Callers 5

DoConstructMethod · 0.45
SelectionMethod · 0.45
RescanSectionsMethod · 0.45
Animation.cppFile · 0.45
CreateObjectMethod · 0.45

Calls 15

saturateMaxFunction · 0.85
sqrtFunction · 0.85
FacesClass · 0.85
RegisterFunction · 0.85
LevelNameFunction · 0.85
FindNamedSelMethod · 0.80
PosMethod · 0.80
NLevelsMethod · 0.80
LevelMethod · 0.80
MemoryLevelMethod · 0.80
ResolutionMethod · 0.80
GetVertexMethod · 0.80

Tested by

no test coverage detected