Polish based on user testing (#19)
Read me fixes Open NFD in working directory Improve input routing Remove log spam
This commit is contained in:
parent
69037feaba
commit
70ba099709
6 changed files with 41 additions and 26 deletions
13
README.md
13
README.md
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
Box3D is a 3D physics engine for games.
|
||||
|
||||
## Build Status
|
||||
## Build status
|
||||
|
||||
[](https://github.com/erincatto/box3d/actions)
|
||||
|
||||
|
|
@ -43,13 +43,13 @@ Box3D is a 3D physics engine for games.
|
|||
- Graphical user interface with imgui
|
||||
- Many samples to demonstrate features and performance
|
||||
|
||||
## Building All Platforms
|
||||
## Building all platforms
|
||||
|
||||
- Install [CMake](https://cmake.org/)
|
||||
- Install [git](https://git-scm.com/)
|
||||
- Ensure these run from the command line
|
||||
|
||||
## Building with CMake presets
|
||||
## Building with CMake presets (recommended)
|
||||
|
||||
The presets in `CMakePresets.json` give one build flow on every platform and are picked up automatically by Visual Studio, VS Code, and CLion (open the folder and choose a preset). From the command line:
|
||||
|
||||
|
|
@ -59,8 +59,9 @@ The presets in `CMakePresets.json` give one build flow on every platform and are
|
|||
|
||||
Run the samples app (must be in the Box3D directory).
|
||||
|
||||
- Bash: `./build/bin/Release/samples`
|
||||
- Cmd: `.\build\bin\Release\samples.exe`
|
||||
- Windows: `.\build\bin\Release\samples.exe`
|
||||
- Linux: `./build/bin/samples`
|
||||
- macOS: `./build/bin/Release/samples`
|
||||
|
||||
## Building for Visual Studio
|
||||
|
||||
|
|
@ -148,7 +149,7 @@ The user manual lives in [`docs/`](docs/) and is built with Doxygen. Enable the
|
|||
|
||||
Please do not submit pull requests. Instead, please file an issue for bugs or feature requests. For support, please visit the Discord server.
|
||||
|
||||
## Giving Feedback
|
||||
## Giving feedback
|
||||
|
||||
Please file an issue or start a chat on discord. You can also use [GitHub Discussions](https://github.com/erincatto/box3d/discussions).
|
||||
|
||||
|
|
|
|||
|
|
@ -236,7 +236,6 @@ void AppendHighlightSphere( b3Transform transform, float radius, HighlightKind k
|
|||
return;
|
||||
if ( s_sphere.count >= MAX_HIGHLIGHTS_PER_KIND )
|
||||
{
|
||||
fprintf( stderr, "[highlight/error] sphere overflow: dropping (cap=%d)\n", MAX_HIGHLIGHTS_PER_KIND );
|
||||
return;
|
||||
}
|
||||
mask_sphere_instance_t* inst = &s_sphere.cpu[s_sphere.count++];
|
||||
|
|
@ -251,7 +250,6 @@ void AppendHighlightCapsule( b3Transform transform, float halfLength, float radi
|
|||
return;
|
||||
if ( s_capsule.count >= MAX_HIGHLIGHTS_PER_KIND )
|
||||
{
|
||||
fprintf( stderr, "[highlight/error] capsule overflow: dropping (cap=%d)\n", MAX_HIGHLIGHTS_PER_KIND );
|
||||
return;
|
||||
}
|
||||
mask_capsule_instance_t* inst = &s_capsule.cpu[s_capsule.count++];
|
||||
|
|
@ -269,7 +267,6 @@ void AppendHighlightGeometry( MeshHandle handle, b3Transform transform, b3Vec3 s
|
|||
return;
|
||||
if ( s_hull.count >= MAX_HIGHLIGHTS_PER_KIND )
|
||||
{
|
||||
fprintf( stderr, "[highlight/error] hull overflow: dropping (cap=%d)\n", MAX_HIGHLIGHTS_PER_KIND );
|
||||
return;
|
||||
}
|
||||
MeshBuffers gb = { 0 };
|
||||
|
|
|
|||
|
|
@ -193,17 +193,18 @@ bool HandleEvent( const sapp_event* e )
|
|||
return false;
|
||||
}
|
||||
|
||||
bool handled = simgui_handle_event( e );
|
||||
// Always feed the event to ImGui so its input state stays current, but ignore the
|
||||
// return value. simgui_handle_event folds keyboard and mouse capture into one bool,
|
||||
// so a panel merely under the cursor would swallow the global shortcut keys.
|
||||
simgui_handle_event( e );
|
||||
const ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
if ( handled )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( e->type == SAPP_EVENTTYPE_KEY_DOWN || e->type == SAPP_EVENTTYPE_KEY_UP || e->type == SAPP_EVENTTYPE_CHAR )
|
||||
{
|
||||
return io.WantCaptureKeyboard;
|
||||
// Only swallow keys while a text field is being edited. A focused panel raises
|
||||
// WantCaptureKeyboard, which otherwise gates Pause and the other globals behind
|
||||
// clicking the 3D view first.
|
||||
return io.WantTextInput;
|
||||
}
|
||||
|
||||
if ( e->type == SAPP_EVENTTYPE_MOUSE_DOWN || e->type == SAPP_EVENTTYPE_MOUSE_UP || e->type == SAPP_EVENTTYPE_MOUSE_MOVE ||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "box3d/box3d.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <filesystem>
|
||||
#include <nfd.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -1121,6 +1122,11 @@ void Sample::DrawMetrics()
|
|||
|
||||
void Sample::MouseDown( b3Vec2 p, int button, int modifiers )
|
||||
{
|
||||
if ( m_camera->m_thirdPerson )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( button == 0 && modifiers == 0 )
|
||||
{
|
||||
// Plain click selects the body under the cursor, any type. Empty space clears.
|
||||
|
|
@ -1345,7 +1351,11 @@ void OpenReplayFileDialog( SampleContext* context )
|
|||
NFD_Init();
|
||||
nfdu8char_t* outPath = nullptr;
|
||||
nfdu8filteritem_t filter[1] = { { "Box3D recording", "b3rec" } };
|
||||
if ( NFD_OpenDialogU8( &outPath, filter, 1, nullptr ) == NFD_OKAY )
|
||||
|
||||
// Start in the working directory, where recordings are saved by default.
|
||||
std::u8string cwd = std::filesystem::current_path().u8string();
|
||||
const nfdu8char_t* defaultPath = reinterpret_cast<const nfdu8char_t*>( cwd.c_str() );
|
||||
if ( NFD_OpenDialogU8( &outPath, filter, 1, defaultPath ) == NFD_OKAY )
|
||||
{
|
||||
snprintf( context->replayFile, sizeof( context->replayFile ), "%s", outPath );
|
||||
NFD_FreePathU8( outPath );
|
||||
|
|
@ -1597,7 +1607,7 @@ static void DrawMenuBar( SampleContext* context )
|
|||
{
|
||||
context->showUI = false;
|
||||
}
|
||||
if ( ImGui::MenuItem( "Frame Camera", "Home" ) )
|
||||
if ( ImGui::MenuItem( "Frame Camera" ) )
|
||||
{
|
||||
b3AABB aabb = b3World_GetBounds( context->sample->m_worldId );
|
||||
Camera& cam = context->camera;
|
||||
|
|
@ -2036,6 +2046,7 @@ void Sample::ToggleThirdPerson()
|
|||
{
|
||||
sapp_lock_mouse( true );
|
||||
m_camera->m_thirdPerson = true;
|
||||
ClearSelection();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -498,7 +498,7 @@ public:
|
|||
m_camera->SetView( 45.0f, 10.0f, 5.0f, position );
|
||||
}
|
||||
|
||||
m_launchSpeedScale = 1.0f;
|
||||
m_launchSpeedScale = 2.0f;
|
||||
m_mover.Initialize( this, position );
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -231,32 +231,37 @@ b3CastOutput b3RayCastCapsule( const b3Capsule* shape, const b3RayCastInput* inp
|
|||
float det = 1.0f - a12 * a12;
|
||||
if ( det < FLT_EPSILON )
|
||||
{
|
||||
// Ray nearly parallel to the capsule axis. The closest point solve below divides by det,
|
||||
// so it loses all precision here and a slowly converging ray would be missed. Intersect the
|
||||
// ray with the infinite cylinder directly using the components perpendicular to the axis.
|
||||
// The origin is outside the cylinder, so a hit needs the ray to close in on it.
|
||||
// Solve the 2D problem of ray versus circle starting at the ray origin, where the circle is
|
||||
// the axial view of the infinite capsule cylinder. This works well when the ray origin is
|
||||
// not too far from the capsule axis.
|
||||
|
||||
// Instead of a cross product, subtract the parallel part to get a perpendicular vector. Non-dimensional.
|
||||
b3Vec3 perp = b3MulSub( a2, a12, a1 );
|
||||
float perp2 = b3LengthSquared( perp );
|
||||
|
||||
// Project to origin to c1 vector onto the perpendicular vector. beta has length units.
|
||||
// Project to origin to infinite capsule axis vector onto the perpendicular vector. beta has length units.
|
||||
float beta = b3Dot( sc, perp );
|
||||
|
||||
// Setup quadratic root finder.
|
||||
float gamma = sc2 - r * r;
|
||||
|
||||
// Casting away from the axis, or the perpendicular gap never closes to the radius.
|
||||
// Discriminant
|
||||
float disc = beta * beta - perp2 * gamma;
|
||||
|
||||
// Casting away from the axis, or the perpendicular gap never closes to the radius.
|
||||
if ( beta >= 0.0f || disc < 0.0f )
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
// Near root, written to dodge the (-beta - sqrt) cancellation as the ray nears parallel.
|
||||
// Quadratic near root. Expressed in an alternate form to avoid the (-beta - sqrt) cancellation as
|
||||
// the ray nears parallel.
|
||||
tr = gamma / ( -beta + sqrtf( disc ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ray and capsules axes are not parallel.
|
||||
|
||||
// Closest points between the infinite ray and the infinite capsule axis.
|
||||
float invDet = 1.0f / det;
|
||||
float sa1 = u;
|
||||
|
|
|
|||
Loading…
Reference in a new issue