Skip to content
Draft
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
2 changes: 2 additions & 0 deletions source/FPSciApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,8 @@ void FPSciApp::initPlayer(const shared_ptr<FpsConfig> config, const bool respawn
player->height = &config->player.height;
player->crouchHeight = &config->player.crouchHeight;

player->strafeDivider = &config->render.strafeDivider;

// Respawn player
if (respawn) player->respawn();
updateMouseSensitivity();
Expand Down
6 changes: 5 additions & 1 deletion source/FpsConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ void RenderConfig::load(FPSciAnyTableReader reader, int settingsVersion) {
reader.getIfPresent("frameDelay", frameDelay);
reader.getIfPresent("frameTimeArray", frameTimeArray);
reader.getIfPresent("frameTimeRandomize", frameTimeRandomize);

reader.getIfPresent("strafeDivider", strafeDivider);

reader.getIfPresent("frameTimeMode", frameTimeMode);
frameTimeMode = toLower(frameTimeMode); // Convert to lower case
Expand Down Expand Up @@ -169,7 +171,9 @@ Any RenderConfig::addToAny(Any a, bool forceAll) const {
if (forceAll || def.samplerPrecomposite != samplerPrecomposite) a["samplerPrecomposite"] = samplerPrecomposite;
if (forceAll || def.samplerComposite != samplerComposite) a["samplerComposite"] = samplerComposite;
if (forceAll || def.samplerFinal != samplerFinal) a["samplerFinal"] = samplerFinal;


if (forceAll || def.strafeDivider != strafeDivider) a["strafeDivider"] = strafeDivider;

return a;
}

Expand Down
1 change: 1 addition & 0 deletions source/FpsConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class RenderConfig {
// Rendering parameters
float frameRate = 1000.0f; ///< Target (goal) frame rate (in Hz)
int frameDelay = 0; ///< Integer frame delay (in frames)
int strafeDivider = 1; ///< Integer number of frames between move updates
Array<float> frameTimeArray = { }; ///< Array of target frame times (in seconds)
bool frameTimeRandomize = false; ///< Whether to choose a sequential or random item from frameTimeArray
String frameTimeMode = "always"; ///< Mode to use for frame time selection (can be "always", "taskOnly", or "restartWithTask", case insensitive)
Expand Down
4 changes: 4 additions & 0 deletions source/GuiElements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ RenderControls::RenderControls(FPSciApp* app, FpsConfig& config, bool& drawFps,
auto c = framePane->addNumberBox("Framerate", &(config.render.frameRate), "fps", GuiTheme::LINEAR_SLIDER, minFrameRate, maxFrameRate, 1.0f);
c->setWidth(width*0.95f);
} framePane->endRow();
framePane->beginRow(); {
auto c = framePane->addNumberBox("Strafe every", &(config.render.strafeDivider), "frames", GuiTheme::LINEAR_SLIDER, 1, 360, 1);
c->setWidth(width * 0.95f);
} framePane->endRow();
framePane->beginRow(); {
auto c = framePane->addNumberBox("Display Lag", &(config.render.frameDelay), "f", GuiTheme::LINEAR_SLIDER, 0, maxFrameDelay);
c->setWidth(width*0.95f);
Expand Down
19 changes: 16 additions & 3 deletions source/PlayerEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,13 @@ void PlayerEntity::onSimulation(SimTime absoluteTime, SimTime deltaTime) {
}
simulatePose(absoluteTime, deltaTime);

static G3D::SimTime slideDeltaTime = 0.;
static int callCount = 1;

if (!isNaN(deltaTime)) {
// Accumulate for occasional slide only
slideDeltaTime += deltaTime;

// Apply rotation first
m_yawRadians += m_desiredYawDelta; // Integrate the yaw change into heading
m_yawRadians = mod1((m_yawRadians) / (2 * pif())) * 2 * pif(); // Keep the user's heading value in the [0,2pi) range
Expand All @@ -138,9 +144,16 @@ void PlayerEntity::onSimulation(SimTime absoluteTime, SimTime deltaTime) {
// Set player frame rotation based on the heading and tilt
m_frame.rotation = Matrix3::fromAxisAngle(Vector3::unitY(), -m_yawRadians) * Matrix3::fromAxisAngle(Vector3::unitX(), m_pitchRadians);

// Translation update - in direction after rotating
if (m_motionEnable) {
m_inContact = slideMove(deltaTime);
if (strafeDivider && callCount >= *strafeDivider) {
// Translation update - in direction after rotating
if (m_motionEnable) {
m_inContact = slideMove(slideDeltaTime);
}
slideDeltaTime = 0.;
callCount = 1;
}
else {
callCount += 1;
}

// Check for "off map" condition and reset position here...
Expand Down
2 changes: 2 additions & 0 deletions source/PlayerEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class PlayerEntity : public VisibleEntity {
float m_cameraRadiansPerMouseDot; ///< Player mouse sensitivity
Vector2 turnScale; ///< Player asymmetric mouse scaler - typically near 1:1

int* strafeDivider; ///< Integer how many frames to count between updating strafing

float* moveRate = nullptr; ///< Player movement rate (m/s)
Vector2* moveScale = nullptr; ///< Player X/Y movement scale vector (interpreted as unit vector)
Array<bool>* axisLock = nullptr; ///< World-space axis lock
Expand Down