diff --git a/src/MsdfLayer.cpp b/src/MsdfLayer.cpp index b034d3e..517caef 100644 --- a/src/MsdfLayer.cpp +++ b/src/MsdfLayer.cpp @@ -313,7 +313,7 @@ const Layer::BoundingBox & MsdfLayer::getBoundingBox(){ void MsdfLayer::setBoundingBox(const Layer::BoundingBox & boundingBox){ this->boundingBox = boundingBox; } -void MsdfLayer::collectCharacter(const char character, +bool MsdfLayer::collectCharacter(const char character, const ofNode & node, const ofCamera & camera, glm::vec4 color, @@ -351,25 +351,9 @@ void MsdfLayer::collectCharacter(const char character, // FIXME: make sure this does not happen ofLogError("MsdfLayer::draw") << "y smaller 0, this is not good" << endl; } - //double pl_a, pb_a, pr_a, pt_a; - //double pl_b, pb_b, pr_b, pt_b; - //gg_a.getQuadPlaneBounds(pl_a, pb_a, pr_a, pt_a); - //gg_b.getQuadPlaneBounds(pl_b, pb_b, pr_b, pt_b); float w = glm::mix(float(w_a), float(w_b), mix); float h = glm::mix(float(h_a), float(h_b), mix); - //float pl = glm::mix(float(pl_a), float(pl_b), mix); - //float pt = glm::mix(float(pt_a), float(pt_b), mix); - - //float magic = atlas->settings.scale; - //getVFlip(settings.vFlipBehaviour, - //ofGetCurrentOrientationMatrix(), - //vFlip); - //if(vFlip == V_FLIP_OFF){ - //n.move(pl * magic, (pt * magic) + (-1 * h), 0.0f); - //}else{ - //n.move(pl * magic, -1 * pt * magic, 0); - //} glm::vec4 p0 = n.getGlobalTransformMatrix() * glm::vec4(0, 0, 0, 1); glm::vec4 p1 = n.getGlobalTransformMatrix() * glm::vec4(0, h, 0, 1); @@ -433,6 +417,9 @@ void MsdfLayer::collectCharacter(const char character, indices.insert(indices.end(), {base, base + 1, base + 2, base + 2, base + 3, base}); } nElements++; + return true; + }else{ + return false; } } void MsdfLayer::setAtlas(shared_ptr _atlas){ diff --git a/src/MsdfLayer.h b/src/MsdfLayer.h index 7d195db..197c70a 100644 --- a/src/MsdfLayer.h +++ b/src/MsdfLayer.h @@ -56,7 +56,7 @@ class MsdfLayer : public Layer { ofNode & getInnerNode() override; const Layer::BoundingBox & getBoundingBox() override; void setBoundingBox(const Layer::BoundingBox & boundingBox) override; - void collectCharacter(const char character, + bool collectCharacter(const char character, const ofNode & node, const ofCamera & camera, glm::vec4 color = glm::vec4(1, 1, 1, 1), diff --git a/src/Utils.h b/src/Utils.h index 432089c..1b074d2 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -168,13 +168,13 @@ static bool isInside(float px, float py, float x, float y, float w, float h){ return px >= x && px <= x + w && py >= y && py <= y + h; } -static bool isInside(const ofCamera & camera, const glm::vec4 & position){ +static bool isInside(const ofCamera & camera, const glm::vec4 & position, float margin = 0){ OFX_PROFILER_FUNCTION() const auto & viewport = ofGetCurrentRenderer()->getCurrentViewport(); glm::vec3 screenPosition = camera.worldToScreen(position); - if(screenPosition.x >= 0.0f && screenPosition.x <= ofGetWidth() - && screenPosition.y >= 0.0f && screenPosition.y <= ofGetHeight() - && screenPosition.z <= 1.0f){ + if(screenPosition.x >= 0.0f - margin && screenPosition.x <= ofGetWidth() + margin + && screenPosition.y >= 0.0f - margin && screenPosition.y <= ofGetHeight() + margin + && screenPosition.z <= 1.0f){ // z is not in px return true; } return false;