/* Copyright © 2010, 2011, 2012 Vladimír Vondruš This file is part of Magnum. Magnum is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. Magnum is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details. */ #include "ShapeGroup.h" namespace Magnum { namespace Physics { template ShapeGroup::ShapeGroup(ShapeGroup&& other): operation(other.operation), a(other.a), b(other.b) { other.operation = Implementation::GroupOperation::AlwaysFalse; other.a = nullptr; other.b = nullptr; } template ShapeGroup::~ShapeGroup() { if(!(operation & Implementation::GroupOperation::RefA)) delete a; if(!(operation & Implementation::GroupOperation::RefB)) delete b; } template ShapeGroup& ShapeGroup::operator=(ShapeGroup&& other) { if(!(operation & Implementation::GroupOperation::RefA)) delete a; if(!(operation & Implementation::GroupOperation::RefB)) delete b; operation = other.operation; a = other.a; b = other.b; other.operation = Implementation::GroupOperation::AlwaysFalse; other.a = nullptr; other.b = nullptr; return *this; } template void ShapeGroup::applyTransformation(const typename DimensionTraits::MatrixType& transformation) { if(a) a->applyTransformation(transformation); if(b) b->applyTransformation(transformation); } template bool ShapeGroup::collides(const AbstractShape* other) const { switch(operation & ~Implementation::GroupOperation::RefAB) { case Implementation::GroupOperation::And: return a->collides(other) && b->collides(other); case Implementation::GroupOperation::Or: return a->collides(other) || b->collides(other); case Implementation::GroupOperation::Not: return !a->collides(other); case Implementation::GroupOperation::FirstObjectOnly: return a->collides(other); default: return false; } } template class ShapeGroup<2>; template class ShapeGroup<3>; }}