Added reasons to assertions
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
using namespace Dawn;
|
||||
|
||||
Scene::Scene(DawnGame *game) {
|
||||
assertNotNull(game);
|
||||
assertNotNull(game, "Scene::Scene: Game cannot be null");
|
||||
this->game = game;
|
||||
this->nextId = 0;
|
||||
this->physics = new ScenePhysicsManager(this);
|
||||
|
@ -60,7 +60,7 @@ namespace Dawn {
|
||||
T * createSceneItemOfType() {
|
||||
sceneitemid_t id = this->nextId++;
|
||||
auto item = new T(this, id);
|
||||
assertNotNull(item);
|
||||
assertNotNull(item, "Scene::createSceneItemOfType: Failed to create SceneItem (Memory Filled?)");
|
||||
this->itemsNotInitialized[id] = item;
|
||||
return item;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
using namespace Dawn;
|
||||
|
||||
SceneItem::SceneItem(Scene *scene, sceneitemid_t id) : transform(this) {
|
||||
assertNotNull(scene);
|
||||
assertNotNull(scene, "SceneItem::SceneItem: Scene cannot be null");
|
||||
|
||||
this->id = id;
|
||||
this->scene = scene;
|
||||
|
@ -55,7 +55,7 @@ namespace Dawn {
|
||||
template<class T>
|
||||
T * addComponent() {
|
||||
auto component = new T(this);
|
||||
assertNotNull(component);
|
||||
assertNotNull(component, "SceneItem::addComponent: Component could not be created (Memory filled?)");
|
||||
this->components.push_back(component);
|
||||
return component;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
using namespace Dawn;
|
||||
|
||||
SceneItemComponent::SceneItemComponent(SceneItem *item) {
|
||||
assertNotNull(item);
|
||||
assertNotNull(item, "SceneItemComponent::SceneItemComponent: Item cannot be null");
|
||||
this->item = item;
|
||||
this->transform = &item->transform;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ void FPSLabelComponent::onStart() {
|
||||
if(this->label == nullptr) return;
|
||||
std::string strFps = std::to_string((int32_t)(1.0f / delta));
|
||||
std::string strTick = std::to_string((int32_t)(delta * 1000.0f));
|
||||
assertUnreachable();// Needs updating to new UI Label
|
||||
assertUnreachable("FPSLabelComponent::onStart: Not yet implemented");// Needs updating to new UI Label
|
||||
// label->text = strFps + "FPS (" + strTick + "ms)";
|
||||
}, this->item->scene->eventSceneUnpausedUpdate);
|
||||
}
|
@ -15,7 +15,7 @@ AnimationController::AnimationController(SceneItem *item) :
|
||||
}
|
||||
|
||||
void AnimationController::addAnimation(Animation *animation) {
|
||||
assertNotNull(animation);
|
||||
assertNotNull(animation, "AnimationController::addAnimation: Animation cannot be null");
|
||||
this->animations.push_back(animation);
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ void PixelPerfectCamera::updateDimensions() {
|
||||
break;
|
||||
|
||||
default:
|
||||
assertUnreachable();
|
||||
assertUnreachable("PixelPerfectCamera::updateDimensions: Unknown camera type");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ std::vector<SceneItemComponent*> SimpleRenderTargetQuad::getDependencies() {
|
||||
}
|
||||
|
||||
void SimpleRenderTargetQuad::onStart() {
|
||||
assertNotNull(this->meshHost);
|
||||
assertNotNull(this->meshHost, "SimpleRenderTargetQuad::onStart: MeshHost cannot be null");
|
||||
|
||||
// Create quad mesh
|
||||
this->meshHost->mesh.createBuffers(QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT);
|
||||
|
@ -81,7 +81,7 @@ void TiledSprite::onStart() {
|
||||
}
|
||||
|
||||
default:
|
||||
assertUnreachable();
|
||||
assertUnreachable("TiledSprite::onStart: Size type not implemented");
|
||||
}
|
||||
|
||||
this->meshHost->xy0 = -quadSize;
|
||||
|
@ -25,8 +25,8 @@ bool_t SolidController2D::getCollidingResult(
|
||||
glm::vec2 &entryPoint,
|
||||
glm::vec2 &exitPoint
|
||||
) {
|
||||
assertNotNull(this->collider);
|
||||
assertNotNull(movingObject);
|
||||
assertNotNull(this->collider, "SolidController2D::getCollidingResult: Collider cannot be null");
|
||||
assertNotNull(movingObject, "SolidController2D::getCollidingResult: Moving object cannot be null");
|
||||
if(movement.x == 0 && movement.y == 0) return false;
|
||||
|
||||
auto myPos = physics3Dto2D(movingObject->transform->getWorldPosition());
|
||||
@ -35,13 +35,13 @@ bool_t SolidController2D::getCollidingResult(
|
||||
switch(movingObject->getColliderType()) {
|
||||
case COLLIDER2D_TYPE_BOX: {
|
||||
auto box1 = dynamic_cast<BoxCollider*>(movingObject);
|
||||
assertNotNull(box1);
|
||||
assertNotNull(box1, "SolidController2D::getCollidingResult: Moving object is not a BoxCollider");
|
||||
|
||||
// Box VS (this)?
|
||||
switch(this->collider->getColliderType()) {
|
||||
case COLLIDER2D_TYPE_BOX: {
|
||||
auto box2 = dynamic_cast<BoxCollider*>(this->collider);
|
||||
assertNotNull(box2);
|
||||
assertNotNull(box2, "SolidController2D::getCollidingResult: Collider is not a BoxCollider");
|
||||
auto otherPos = physics3Dto2D(box2->transform->getWorldPosition());
|
||||
|
||||
return boxCheckCollision(
|
||||
@ -53,17 +53,17 @@ bool_t SolidController2D::getCollidingResult(
|
||||
}
|
||||
|
||||
default: {
|
||||
assertUnreachable();
|
||||
assertUnreachable("SolidController2D::getCollidingResult: Collider type not implemented");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
assertUnreachable();
|
||||
assertUnreachable("SolidController2D::getCollidingResult: Moving object type not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
assertUnreachable();
|
||||
assertUnreachable("SolidController2D::getCollidingResult: Should never reach this point");
|
||||
return false;
|
||||
}
|
@ -18,19 +18,19 @@ std::vector<SceneItemComponent*> TriggerController2D::getDependencies() {
|
||||
}
|
||||
|
||||
bool_t TriggerController2D::getCollidingResult(Collider2D* movingObject) {
|
||||
assertNotNull(this->collider);
|
||||
assertNotNull(movingObject);
|
||||
assertNotNull(this->collider, "TriggerController2D::getCollidingResult: Collider cannot be null");
|
||||
assertNotNull(movingObject, "TriggerController2D::getCollidingResult: Moving object cannot be null");
|
||||
|
||||
switch(movingObject->getColliderType()) {
|
||||
case COLLIDER2D_TYPE_BOX: {
|
||||
auto box1 = dynamic_cast<BoxCollider*>(movingObject);
|
||||
assertNotNull(box1);
|
||||
assertNotNull(box1, "TriggerController2D::getCollidingResult: Moving object is not a BoxCollider");
|
||||
|
||||
// Box VS ?
|
||||
switch(collider->getColliderType()) {
|
||||
case COLLIDER2D_TYPE_BOX: {
|
||||
auto box2 = dynamic_cast<BoxCollider*>(collider);
|
||||
assertNotNull(box2);
|
||||
assertNotNull(box2, "TriggerController2D::getCollidingResult: Collider is not a BoxCollider");
|
||||
return boxIsBoxColliding(
|
||||
physics3Dto2D(box1->transform->getWorldPosition()), box1->min, box1->max,
|
||||
physics3Dto2D(box2->transform->getWorldPosition()), box2->min, box2->max
|
||||
@ -38,13 +38,13 @@ bool_t TriggerController2D::getCollidingResult(Collider2D* movingObject) {
|
||||
}
|
||||
|
||||
default: {
|
||||
assertUnreachable();
|
||||
assertUnreachable("TriggerController2D::getCollidingResult: Collider type not implemented");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default: {
|
||||
assertUnreachable();
|
||||
assertUnreachable("TriggerController2D::getCollidingResult: Moving object type not implemented");
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ bool_t CapsuleCollider::performRaycast(
|
||||
struct Collider3DRayResult *result,
|
||||
struct Ray3D ray
|
||||
) {
|
||||
assertNotNull(result);
|
||||
assertNotNull(result, "CapsuleCollider::performRaycast: Result cannot be null");
|
||||
|
||||
return raytestCapsule(
|
||||
ray,
|
||||
|
@ -15,7 +15,7 @@ bool_t Collider3D::raycast(
|
||||
struct Collider3DRayResult *result,
|
||||
struct Ray3D ray
|
||||
) {
|
||||
assertNotNull(result);
|
||||
assertNotNull(result, "Collider3D::raycast: Result cannot be null");
|
||||
if(!this->performRaycast(result, ray)) return false;
|
||||
result->collider = this;
|
||||
return true;
|
||||
|
@ -15,7 +15,7 @@ bool_t CubeCollider::performRaycast(
|
||||
struct Collider3DRayResult *result,
|
||||
struct Ray3D ray
|
||||
) {
|
||||
assertNotNull(result);
|
||||
assertNotNull(result, "CubeCollider::performRaycast: Result cannot be null");
|
||||
|
||||
return Dawn::raytestCube(
|
||||
ray,
|
||||
|
@ -19,7 +19,7 @@ bool_t SphereCollider::performRaycast(
|
||||
struct Collider3DRayResult *result,
|
||||
struct Ray3D ray
|
||||
) {
|
||||
assertNotNull(result);
|
||||
assertNotNull(result, "SphereCollider::performRaycast: Result cannot be null");
|
||||
|
||||
return raytestSphere(
|
||||
ray,
|
||||
|
@ -40,7 +40,7 @@ void UICanvas::rebufferShaderParameters() {
|
||||
break;
|
||||
|
||||
default:
|
||||
assertUnreachable();
|
||||
assertUnreachable("UICanvas::rebufferShaderParameters: Unknown draw type");
|
||||
}
|
||||
|
||||
this->shaderBuffer.buffer(&data);
|
||||
|
@ -25,7 +25,7 @@ UIComponentDimensional * UIComponent::getParentDimensional() {
|
||||
auto parent = this->transform->getParent();
|
||||
if(parent == nullptr) return nullptr;
|
||||
auto dimensional = parent->item->getComponent<UIComponentDimensional>();
|
||||
assertNotNull(dimensional);
|
||||
assertNotNull(dimensional, "UIComponent::getParentDimensional: Parent must have a UIComponentDimensional");
|
||||
return dimensional;
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ void UIComponent::updateAlignment() {
|
||||
auto dimensional = this->getParentDimensional();
|
||||
auto translate = this->transform->getLocalPosition();
|
||||
|
||||
assertNotNull(dimensional);
|
||||
assertNotNull(dimensional, "UIComponent::updateAlignment: Parent must have a UIComponentDimensional");
|
||||
|
||||
parentInnerWidth = dimensional->getContentWidth();
|
||||
parentInnerHeight = dimensional->getContentHeight();
|
||||
@ -89,8 +89,8 @@ void UIComponent::calculateDimensions(
|
||||
float_t innerSize,
|
||||
glm::vec2 alignment
|
||||
) {
|
||||
assertNotNull(position);
|
||||
assertNotNull(size);
|
||||
assertNotNull(position, "UIComponent::calculateDimensions: Position cannot be null");
|
||||
assertNotNull(size, "UIComponent::calculateDimensions: Size cannot be null");
|
||||
|
||||
switch(align) {
|
||||
case UI_COMPONENT_ALIGN_STRETCH: {
|
||||
@ -157,7 +157,7 @@ void UIComponent::calculateDimensions(
|
||||
}
|
||||
|
||||
default:
|
||||
assertUnreachable();
|
||||
assertUnreachable("UIComponent::calculateDimensions: Unknown alignment");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -170,7 +170,7 @@ UICanvas * UIComponent::getCanvas() {
|
||||
if(canvas != nullptr) return canvas;
|
||||
parent = parent->getParent();
|
||||
}
|
||||
assertUnreachable();
|
||||
assertUnreachable("UIComponent::getCanvas: No canvas found");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,8 @@ std::vector<SceneItemComponent*> UISimpleMenu::getDependencies() {
|
||||
void UISimpleMenu::onStart() {
|
||||
if(canvas == nullptr) canvas = getScene()->findComponent<UICanvas>();
|
||||
|
||||
assertNotNull(this->menu);
|
||||
assertNotNull(this->canvas);
|
||||
assertNotNull(this->menu, "UISimpleMenu::onStart: Menu cannot be null");
|
||||
assertNotNull(this->canvas, "UISimpleMenu::onStart: Canvas cannot be null");
|
||||
menuItems = this->item->findChildren<UISimpleMenuItem>();
|
||||
|
||||
auto updateSimpleMenuPos = [&](int32_t x, int32_t y) {
|
||||
@ -59,7 +59,7 @@ void UISimpleMenu::onStart() {
|
||||
}, menu->eventItemSelected);
|
||||
|
||||
useEvent([&](float_t d){
|
||||
assertNotNull(canvas->camera);
|
||||
assertNotNull(canvas->camera, "UISimpleMenu::onStart: Camera cannot be null");
|
||||
if(!this->menu->active) return;
|
||||
|
||||
// Mouse in screen space.
|
||||
@ -121,7 +121,7 @@ void UISimpleMenu::onStart() {
|
||||
}
|
||||
|
||||
default: {
|
||||
assertUnreachable();
|
||||
assertUnreachable("UISimpleMenu::onStart: Draw type not implemented");
|
||||
}
|
||||
}
|
||||
}, getScene()->eventSceneUnpausedUpdate);
|
||||
|
@ -72,7 +72,7 @@ std::vector<struct ShaderPassItem> UILabel::getUIRenderPasses() {
|
||||
break;
|
||||
|
||||
default:
|
||||
assertUnreachable();
|
||||
assertUnreachable("UILabel::getUIRenderPasses: Texture slot not implemented");
|
||||
}
|
||||
|
||||
item.textureSlots[it->second] = &it->first->texture;
|
||||
@ -119,7 +119,7 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
||||
return;
|
||||
}
|
||||
|
||||
assertTrue(newTexts.size() <= FONT_SHADER_PARTS_MAX);
|
||||
assertTrue(newTexts.size() <= FONT_SHADER_PARTS_MAX, "UILabel::rebufferQuads: Too many parts (not supported)");
|
||||
|
||||
int32_t nextTexture = 0;
|
||||
glm::vec2 position(0, 0);
|
||||
@ -161,17 +161,17 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
||||
realText.style = text.style;
|
||||
|
||||
// Lock the font
|
||||
assertNotNull(text.style.font);
|
||||
assertNotNull(text.style.font, "UILabel::rebufferQuads: Font cannot be null");
|
||||
realText.lockId = text.style.font->lock(TrueTypeFaceTextureStyle{
|
||||
text.style.size,
|
||||
text.style.style
|
||||
});
|
||||
assertTrue(realText.lockId != -1);
|
||||
assertTrue(realText.lockId != -1, "UILabel::rebufferQuads: Failed to lock font");
|
||||
realText.texture = text.style.font->getTexture(realText.lockId);
|
||||
|
||||
// Map texture
|
||||
if(textureMap.find(realText.texture) == textureMap.end()) {
|
||||
assertTrue(nextTexture < FONT_SHADER_TEXTURE_MAX);
|
||||
assertTrue(nextTexture < FONT_SHADER_TEXTURE_MAX, "UILabel::rebufferQuads: Too many textures (not supported)");
|
||||
textureMap[realText.texture] = nextTexture++;
|
||||
}
|
||||
|
||||
@ -252,10 +252,10 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
||||
}
|
||||
|
||||
// Validate characters
|
||||
assertTrue(ch >= TRUE_TYPE_CHAR_BEGIN && ch < TRUE_TYPE_CHAR_END);
|
||||
assertTrue(ch != '\r');
|
||||
assertTrue(ch != '\t');
|
||||
assertTrue(ch != '\n');
|
||||
assertTrue(ch >= TRUE_TYPE_CHAR_BEGIN && ch < TRUE_TYPE_CHAR_END, "UILabel::rebufferQuads: Character out of range");
|
||||
assertTrue(ch != '\r', "UILabel::rebufferQuads: Character cannot be a carriage return");
|
||||
assertTrue(ch != '\t', "UILabel::rebufferQuads: Character cannot be a tab");
|
||||
assertTrue(ch != '\n', "UILabel::rebufferQuads: Character cannot be a newline");
|
||||
|
||||
// Get font data.
|
||||
auto charInfo = realText.texture->getCharacterData(ch);
|
||||
@ -357,7 +357,7 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
||||
);
|
||||
|
||||
if(hasDecorations) {
|
||||
assertTrue(vertices.size() == decorations.size());
|
||||
assertTrue(vertices.size() == decorations.size(), "UILabel::rebufferQuads: Decoration count mismatch");
|
||||
this->meshDecorations.createBuffers(
|
||||
QUAD_VERTICE_COUNT * decorations.size(),
|
||||
QUAD_INDICE_COUNT * decorations.size()
|
||||
@ -408,8 +408,8 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
||||
// Finally, release the old locks
|
||||
itText = textsBuffered.begin();
|
||||
while(itText != textsBuffered.end()) {
|
||||
assertTrue(itText->lockId != -1);
|
||||
assertNotNull(itText->style.font);
|
||||
assertTrue(itText->lockId != -1, "UILabel::rebufferQuads: Lock ID cannot be -1");
|
||||
assertNotNull(itText->style.font, "UILabel::rebufferQuads: Font cannot be null");
|
||||
itText->style.font->unlock(itText->lockId);
|
||||
++itText;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ void UIRichTextLabel::onStart() {
|
||||
bufferTexts.push_back(text);
|
||||
} else if(child.nodeType == XML_NODE_TYPE_ELEMENT) {
|
||||
auto node = child.child;
|
||||
assertTrue(node->node == "font");
|
||||
assertTrue(node->node == "font", "UIRichTextLabel::onStart: Unknown node type '" + node->node + "'");
|
||||
|
||||
struct UILabelStyle style;
|
||||
if(node->attributes.contains("font")) {
|
||||
|
Reference in New Issue
Block a user