void ColliderCircle::Render(const Matrix44f& aSpace) const { CU::PoolPointer<GE::Model> model = GE::GfxFactoryWrapper::GetInstance()->GetModelFactory()->GetModel("Sphere"); Matrix44f circleSpace; circleSpace.SetTranslation(myPosition); Matrix44f instance = circleSpace * aSpace; float radius = myRadius; instance.Scale({ radius, radius, radius }); //CU::EventManager::GetInstance()->AddRenderCommand(CU::RenderCommandInstance(&*model, instance, instance)); }
bool ColliderCircle::CheckCollision(const ColliderCircle& aColliderCircle, const CollisionStruct& aCollisionStruct) const { Matrix44f thisCircleSpace; thisCircleSpace.SetTranslation(myPosition); thisCircleSpace = thisCircleSpace * aCollisionStruct.myObjectSpace; Matrix44f secondCircleSpace; secondCircleSpace.SetTranslation(aColliderCircle.myPosition); secondCircleSpace = secondCircleSpace * aCollisionStruct.myArgumentObjectSpace; //Vector3<float> thisCirclePosition = myPosition * aCollisionStruct.myObjectSpace; //Vector3<float> secondCirclePosition = { aColliderCircle.myPosition.x + aCollisionStruct.myArgumentObjectPosition.x, aColliderCircle.myPosition.y + aCollisionStruct.myArgumentObjectPosition.y, aColliderCircle.myPosition.z + aCollisionStruct.myArgumentObjectPosition.z }; if (CU::Intersection::SphereVsSphere(thisCircleSpace.GetTranslation(), myRadius * aCollisionStruct.myObjectScale, secondCircleSpace.GetTranslation(), aColliderCircle.myRadius* aCollisionStruct.myArgumentObjectScale) == true) { bool toReturn = false; if (myColliders.Size() == 0 && aColliderCircle.myColliders.Size() > 0) { for (CU::PoolPointer<CU::Collider> collider : aColliderCircle.myColliders) { toReturn = CheckCollision(*collider, aCollisionStruct); if (toReturn == true) { return true; } } } else if (myColliders.Size() > 0 && aColliderCircle.myColliders.Size() > 0) { for (unsigned short i = 0; i < myColliders.Size(); i++) { for (unsigned short j = 0; j < aColliderCircle.myColliders.Size(); j++) { toReturn = myColliders[i]->CheckCollision(*aColliderCircle.myColliders[j], aCollisionStruct); if (toReturn == true) { return true; } } } } else if (myColliders.Size() > 0 && aColliderCircle.myColliders.Size() == 0) { for (CU::PoolPointer<CU::Collider> collider : myColliders) { toReturn = collider->CheckCollision(aColliderCircle, aCollisionStruct); if (toReturn == true) { return true; } } } else { toReturn = true; } return toReturn; } return false; }