MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / load

Method load

src/Core/Collision/PolygonalCollider.cpp:340–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338 }
339
340 void PolygonalCollider::load(vili::node& data)
341 {
342 auto addTagHelper = [this](ColliderTagType type, vili::node& tag) {
343 if (!tag.is_null())
344 {
345 if (tag.is<vili::string>())
346 {
347 this->addTag(type, tag);
348 }
349 else if (tag.is<vili::array>())
350 {
351 for (vili::node& item : tag)
352 this->addTag(Collision::ColliderTagType::Rejected, item);
353 }
354 else
355 {
356 // TODO: Raise exception
357 }
358 }
359 };
360 const std::string pointsUnit = data.at("unit");
361 bool completePoint = true;
362 double pointBuffer = 0;
363 const Transform::Units pBaseUnit = Transform::stringToUnits(pointsUnit);
364 for (vili::node& colliderPoint : data["points"])
365 {
366 const Transform::UnitVector pVector2 = Transform::UnitVector(
367 colliderPoint["x"], colliderPoint["y"], pBaseUnit);
368 this->addPoint(pVector2);
369 }
370 this->setWorkingUnit(pBaseUnit);
371
372 addTagHelper(ColliderTagType::Tag, data["tag"]);
373 addTagHelper(ColliderTagType::Accepted, data["accept"]);
374 addTagHelper(ColliderTagType::Rejected, data["reject"]);
375 }
376
377 bool PolygonalCollider::checkTags(const PolygonalCollider& collider) const
378 {

Callers

nothing calls this directly

Calls 7

addTagMethod · 0.95
stringToUnitsFunction · 0.85
UnitVectorClass · 0.85
addPointMethod · 0.80
setWorkingUnitMethod · 0.80
is_nullMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected