Skip to content

Commit

Permalink
squash: rename wait_occ to none state
Browse files Browse the repository at this point in the history
  • Loading branch information
hjanetzek committed Jul 22, 2016
1 parent 7639df1 commit de15719
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
12 changes: 6 additions & 6 deletions core/src/labels/label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Label::Label(Label::Transform _transform, glm::vec2 _size, Type _type, Options _
if (!m_options.collide || m_type == Type::debug){
enterState(State::visible, 1.0);
} else {
m_state = State::wait_occlusion_check;
m_state = State::none;
m_transform.state.alpha = 0.0;
}

Expand Down Expand Up @@ -140,7 +140,7 @@ bool Label::canOcclude() {
}

int occludeFlags = (State::visible |
State::wait_occlusion_check |
State::none |
State::skip_transition |
State::fading_in |
State::sleep |
Expand Down Expand Up @@ -189,7 +189,7 @@ void Label::resetState() {

m_occludedLastFrame = false;
m_occluded = false;
enterState(State::wait_occlusion_check, 0.0);
enterState(State::none, 0.0);
}

void Label::print() const {
Expand All @@ -198,11 +198,11 @@ void Label::print() const {
LOG("\tm_occluded: %d", m_occluded);
std::string state;
switch (m_state) {
case State::none: state = "none"; break;
case State::visible: state = "visible"; break;
case State::anchor_fallback: state = "anchor_fallback"; break;
case State::fading_in: state = "fading_in"; break;
case State::fading_out: state = "fading_out"; break;
case State::wait_occlusion_check: state = "wait_occlusion_check"; break;
case State::skip_transition: state = "skip_transition"; break;
case State::sleep: state = "sleep"; break;
case State::dead: state = "dead"; break;
Expand Down Expand Up @@ -309,7 +309,7 @@ bool Label::evalState(const glm::vec2& _screenSize, float _dt) {
} else {
enterState(State::visible, 1.0);
}

animate = true;
break;
case State::fading_in:
Expand Down Expand Up @@ -337,7 +337,7 @@ bool Label::evalState(const glm::vec2& _screenSize, float _dt) {
enterState(State::sleep, 0.0);
}
break;
case State::wait_occlusion_check:
case State::none:
if (m_occluded) {
if (m_options.anchorFallbacks != 0) {
enterState(State::anchor_fallback, 0.0);
Expand Down
18 changes: 9 additions & 9 deletions core/src/labels/label.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ class Label {
};

enum State {
fading_in = 1 << 0,
fading_out = 1 << 1,
visible = 1 << 2,
sleep = 1 << 3,
out_of_screen = 1 << 4,
anchor_fallback = 1 << 5,
wait_occlusion_check = 1 << 6,
skip_transition = 1 << 7,
dead = 1 << 8,
none = 1 << 0,
fading_in = 1 << 1,
fading_out = 1 << 2,
visible = 1 << 3,
sleep = 1 << 4,
out_of_screen = 1 << 5,
anchor_fallback = 1 << 6,
skip_transition = 1 << 7,
dead = 1 << 8,
};

struct Transform {
Expand Down
2 changes: 1 addition & 1 deletion core/src/labels/labelCollider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void LabelCollider::process() {
if (label->isOccluded()) {
label->enterState(Label::State::dead, 0.0f);
} else {
label->enterState(Label::State::wait_occlusion_check, 0.0f);
label->enterState(Label::State::none, 0.0f);
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/labels/labels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void Labels::skipTransitions(const std::vector<const Style*>& _styles, Tile& _ti

for (auto& l0 : mesh0->getLabels()) {
if (!l0->canOcclude()) { continue; }
if (l0->state() != Label::State::wait_occlusion_check) { continue; }
if (l0->state() != Label::State::none) { continue; }

for (auto& l1 : mesh1->getLabels()) {
if (!l1->visibleState()) { continue; }
Expand Down Expand Up @@ -385,7 +385,7 @@ void Labels::drawDebug(const View& _view) {
case Label::State::visible:
Primitives::setColor(0x000000);
break;
case Label::State::wait_occlusion_check:
case Label::State::none:
Primitives::setColor(0x0000ff);
break;
case Label::State::dead:
Expand Down
18 changes: 9 additions & 9 deletions tests/unit/labelTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ TextLabel makeLabelWithAnchorFallbacks() {
TEST_CASE( "Ensure the transition from wait -> sleep when occlusion happens", "[Core][Label]" ) {
TextLabel l(makeLabel({screenSize/2.f}, Label::Type::point));

REQUIRE(l.state() == Label::State::wait_occ);
REQUIRE(l.state() == Label::State::none);
l.update(glm::ortho(0.f, screenSize.x, screenSize.y, 0.f, -1.f, 1.f), screenSize, 0);

REQUIRE(l.state() != Label::State::sleep);
REQUIRE(l.state() == Label::State::wait_occ);
REQUIRE(l.state() == Label::State::none);
REQUIRE(l.canOcclude());

l.update(glm::ortho(0.f, screenSize.x, screenSize.y, 0.f, -1.f, 1.f), screenSize, 0);
Expand All @@ -64,7 +64,7 @@ TEST_CASE( "Ensure the transition from wait -> sleep when occlusion happens", "[
TEST_CASE( "Ensure the transition from wait -> visible when no occlusion happens", "[Core][Label]" ) {
TextLabel l(makeLabel({screenSize/2.f}, Label::Type::point));

REQUIRE(l.state() == Label::State::wait_occ);
REQUIRE(l.state() == Label::State::none);

l.update(glm::ortho(0.f, screenSize.x, screenSize.y, 0.f, -1.f, 1.f), screenSize, 0);
l.occlude(false);
Expand Down Expand Up @@ -107,7 +107,7 @@ TEST_CASE( "Ensure the end state after occlusion is leep state", "[Core][Label]"
TEST_CASE( "Ensure the out of screen state transition", "[Core][Label]" ) {
TextLabel l(makeLabel({screenSize*2.f}, Label::Type::point));

REQUIRE(l.state() == Label::State::wait_occ);
REQUIRE(l.state() == Label::State::none);

l.update(glm::ortho(0.f, screenSize.x, screenSize.y, 0.f, -1.f, 1.f), screenSize, 0);

Expand All @@ -116,7 +116,7 @@ TEST_CASE( "Ensure the out of screen state transition", "[Core][Label]" ) {

l.update(glm::ortho(0.f, screenSize.x * 4.f, screenSize.y * 4.f, 0.f, -1.f, 1.f), screenSize, 0);
l.evalState(screenSize, 0);
REQUIRE(l.state() != Label::State::wait_occ);
REQUIRE(l.state() != Label::State::none);

REQUIRE(l.state() == Label::State::visible);
REQUIRE(l.canOcclude());
Expand Down Expand Up @@ -202,7 +202,7 @@ TEST_CASE( "Sine interpolation", "[Core][Label][Fade]" ) {
TEST_CASE( "Ensure anchor fallback behavior on first fallback", "[Core][Label]" ) {
TextLabel l = makeLabelWithAnchorFallbacks();

REQUIRE(l.state() == Label::State::wait_occ);
REQUIRE(l.state() == Label::State::none);

l.update(glm::ortho(0.f, screenSize.x, screenSize.y, 0.f, -1.f, 1.f), screenSize, 0);
l.occlude(true);
Expand All @@ -214,9 +214,9 @@ TEST_CASE( "Ensure anchor fallback behavior on first fallback", "[Core][Label]"
TEST_CASE( "Ensure anchor fallback behavior when looping over all fallbacks without finding one", "[Core][Label]" ) {
TextLabel l = makeLabelWithAnchorFallbacks();

// wait_occ -> anchor_fallback
// none -> anchor_fallback
{
REQUIRE(l.state() == Label::State::wait_occ);
REQUIRE(l.state() == Label::State::none);

l.update(glm::ortho(0.f, screenSize.x, screenSize.y, 0.f, -1.f, 1.f), screenSize, 0);
l.occlude(true);
Expand Down Expand Up @@ -253,7 +253,7 @@ TEST_CASE( "Ensure anchor fallback behavior when looping over all fallbacks with
TEST_CASE( "Ensure anchor fallback behavior when looping over all fallback and finding one", "[Core][Label]" ) {
TextLabel l = makeLabelWithAnchorFallbacks();

REQUIRE(l.state() == Label::State::wait_occ);
REQUIRE(l.state() == Label::State::none);

// move to third anchor
for (int i = 0; i < 3; ++i) {
Expand Down

0 comments on commit de15719

Please sign in to comment.