Skip to content

Commit

Permalink
do target collision when ball is rolling
Browse files Browse the repository at this point in the history
remove padding from negative stableford scores
  • Loading branch information
fallahn committed Aug 24, 2023
1 parent 0ee1313 commit 1779748
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions samples/golf/buildnumber.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef BUILD_NUMBER_H_
#define BUILD_NUMBER_H_

#define BUILDNUMBER 1376
#define BUILDNUMBER_STR "1376"
#define BUILDNUMBER 1381
#define BUILDNUMBER_STR "1381"

#endif /* BUILD_NUMBER_H_ */
17 changes: 10 additions & 7 deletions samples/golf/src/golf/BallSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ void BallSystem::processEntity(cro::Entity entity, float dt)
newPos.y = terrainContact.intersection.y;
tx.setPosition(newPos);
}

doBullsEyeCollision(tx.getPosition());


const auto resetBall = [&](Ball::State state, std::uint8_t terrain)
Expand Down Expand Up @@ -1186,21 +1186,24 @@ void BallSystem::doBullsEyeCollision(glm::vec3 ballPos)
{
if (m_bullsEye.spawn && m_processFlags != ProcessFlags::Predicting)
{
const glm::vec2 p1(ballPos.x, ballPos.z);
const glm::vec2 p2(m_bullsEye.position.x, m_bullsEye.position.z);
const glm::vec2 p1(ballPos.x, -ballPos.z);
const glm::vec2 p2(m_bullsEye.position.x, -m_bullsEye.position.z);

const float BullRad = m_bullsEye.diametre / 2.f;

if (auto len2 = glm::length2(p2 - p1); len2 < (BullRad * BullRad))
{
auto* msg = postMessage<BullsEyeEvent>(sv::MessageID::BullsEyeMessage);
//unlikely, but will upset sqrt
if (len2 == 0)
{
len2 = 0.000001f;
//len2 = 0.000001f;
msg->accuracy = 1.f;
}
else
{
msg->accuracy = std::clamp(1.f - (std::sqrt(len2) / BullRad), 0.f, 1.f);
}

auto* msg = postMessage<BullsEyeEvent>(sv::MessageID::BullsEyeMessage);
msg->accuracy = std::clamp(1.f - (std::sqrt(len2) / BullRad), 0.f, 1.f);
msg->position = ballPos;
}
}
Expand Down
2 changes: 1 addition & 1 deletion samples/golf/src/golf/GolfStateUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2765,7 +2765,7 @@ void GolfState::updateScoreboard(bool updateParDiff)
case ScoreType::Stableford:
case ScoreType::StablefordPro:
//align with back/total string
if (scores[i].backNine < 10)
if (scores[i].backNine < 10 && scores[i].backNine > -1)
{
totalString += " ";
}
Expand Down
2 changes: 1 addition & 1 deletion samples/golf/src/golf/MenuCreation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4396,7 +4396,7 @@ void MenuState::createPreviousScoreCard()
break;
case ScoreType::Stableford:
case ScoreType::StablefordPro:
if (entry.totalBack < 10)
if (entry.totalBack < 10 && entry.totalBack > -1)
{
str += " ";
}
Expand Down

0 comments on commit 1779748

Please sign in to comment.