Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For issue #217 and issue #225. #226

Merged
merged 1 commit into from
Nov 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Testbed/Framework/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,13 +708,16 @@ static void AboutTestUI()
for (auto& handledKey: handledKeys)
{
const auto keyID = handledKey.first.key;
const auto mods = handledKey.first.mods;

ImGui::TextUnformatted(GetKeyActionName(handledKey.first.action));
ImGui::NextColumn();

if (std::isgraph(keyID))
{
ImGui::Text("%c", keyID);
const auto shift = mods & GLFW_MOD_SHIFT;
const auto ctrl = mods & GLFW_MOD_CONTROL;
ImGui::Text("%s%s%c", (ctrl? "ctrl-": ""), (shift? "shift-": ""), keyID);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions Testbed/Framework/Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@ void Test::LaunchBomb(const Length2& at, const LinearVelocity2 v)
.UseLocation(at).UseLinearVelocity(v));

auto conf = DiskShape::Conf{};
conf.vertexRadius = 0.3_m;
conf.density = 20_kgpm2;
conf.vertexRadius = m_bombRadius;
conf.density = m_bombDensity;
conf.restitution = 0.0f;
m_bomb->CreateFixture(std::make_shared<DiskShape>(conf));
}
Expand Down Expand Up @@ -1252,7 +1252,7 @@ void Test::KeyboardHandler(KeyID key, KeyAction action, KeyMods mods)
{
continue;
}
if (mods & keyActionMods.mods)
if (mods != keyActionMods.mods)
{
continue;
}
Expand Down
2 changes: 2 additions & 0 deletions Testbed/Framework/Test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ class Test : public ContactListener

std::string m_status;
TextLinePos m_textLine = TextLinePos{30};
AreaDensity m_bombDensity = 20_kgpm2;
Length m_bombRadius = 0.3_m;

private:
void DrawStats(const StepConf& stepConf, UiState& ui);
Expand Down
26 changes: 25 additions & 1 deletion Testbed/Tests/SolarSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class SolarSystem: public Test

auto conf = Test::Conf{};
conf.description = os.str();
conf.worldDef = WorldDef{}.UseMaxVertexRadius(700000_km);
conf.worldDef = WorldDef{}.UseMaxVertexRadius(1e7_km);
conf.neededSettings = 0;
conf.neededSettings |= (1u << NeedLinearSlopField);
conf.neededSettings |= (1u << NeedCameraZoom);
Expand All @@ -111,6 +111,8 @@ class SolarSystem: public Test

SolarSystem(): Test(GetTestConf())
{
m_bombRadius = 100_km;
m_bombDensity = 2e12_kgpm2;
m_world.SetGravity(LinearAcceleration2{});
const auto DynamicBD = BodyDef{}.UseType(BodyType::Dynamic).UseBullet(true);
for (auto& sso: SolarSystemBodies)
Expand Down Expand Up @@ -140,6 +142,26 @@ class SolarSystem: public Test
[&](KeyActionMods) {
m_focalBody = nullptr;
});
RegisterForKey(GLFW_KEY_S, GLFW_PRESS, GLFW_MOD_SHIFT,
"Increases bomb size.",
[&](KeyActionMods) {
m_bombRadius *= 2;
});
RegisterForKey(GLFW_KEY_S, GLFW_PRESS, 0,
"Decreases bomb size.",
[&](KeyActionMods) {
m_bombRadius /= 2;;
});
RegisterForKey(GLFW_KEY_D, GLFW_PRESS, GLFW_MOD_SHIFT,
"Increases bomb density.",
[&](KeyActionMods) {
m_bombDensity *= 2;
});
RegisterForKey(GLFW_KEY_D, GLFW_PRESS, 0,
"Decreases bomb density.",
[&](KeyActionMods) {
m_bombDensity /= 2;;
});
}

void PreStep(const Settings&, Drawer& drawer) override
Expand All @@ -161,6 +183,8 @@ class SolarSystem: public Test
{
os << "Camera unlocked from following any planet.";
}
os << " 'Bomb' size (radial) is now at " << Real{m_bombRadius/1_km} << "km.";
os << " 'Bomb' density (areal) is now at " << Real{m_bombDensity/1_kgpm2} << "kg/m^2.";
m_status = os.str();
}

Expand Down