The slope standing issue seems to get fixed just by recreating the wedge. That doesn't explain why it is happening of course.
The disappearing collision issue is much more serious. I recompiled Newton Dynamics as a DLL, which is its default configuration, instead of compiling the source code straight into the engine. Then I ran my test app 100 times and couldn't produce the error.
Originally one of my goals was to eliminate DLLs, but I don't think that's a very good goal. Stay tuned for an update.
Pasting my test code here for later use:
#include "Leadwerks.h"
using namespace Leadwerks;
int main(int argc, const char* argv[])
{
//Get the displays
auto displays = GetDisplays();
//Create a window
auto window = CreateWindow("Leadwerks", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR | WINDOW_HIDDEN);
auto ui = CreateInterface(window);
ui->background->SetColor(0,0,0);
window->SetHidden(false);
window->Activate();
ui = nullptr;
//Create a framebuffer
auto framebuffer = CreateFramebuffer(window);
//Create a world
auto world = CreateWorld();
world->SetGravity(0, -30, 0);
world->SetAmbientLight(0);
//Create the player
auto player = CreatePivot(world);
player->SetPhysicsMode(PHYSICS_PLAYER);
player->SetMass(10);
player->SetCollisionType(COLLISION_PLAYER);
//Create a camera
auto camera = CreateCamera(world);
camera->SetClearColor(0.125);
camera->SetPosition(0, 1, -8);
camera->SetFov(70);
camera->SetPosition(0, 1.6, 0);
camera->SetPosition(player->position + Vec3(0, 1.7, 0));
camera->Turn(0, 180, 0);
camera->SetMouseLook(true);
auto scene = LoadScene(world, "Maps/Testing.map");
Vec3 camrotation = camera->GetRotation();
Vec2 mouseaxis = window->GetMouseAxis().xy();
const float lookspeed = 200;
const float movespeed = 3.5;
const float maxaccel = 40;
const float maxdecel = 15;
const float mousesmoothing = 3;
const float runspeed = 2;
const float jumpstrength = 12;
const float lunge = 1.5;
window->SetCursor(CURSOR_NONE);
//Main loop
while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
{
if (window->KeyHit(KEY_SPACE))
{
//Create the player
player = CreatePivot(world);
player->SetPhysicsMode(PHYSICS_PLAYER);
player->SetMass(10);
player->SetCollisionType(COLLISION_PLAYER);
}
if (ActiveWindow() == window)
{
//Camera look
camrotation = camera->rotation;
//Movement
float accel = maxaccel;
Vec2 movement;
movement.y = (window->KeyDown(KEY_W) - window->KeyDown(KEY_S));
movement.x = (window->KeyDown(KEY_D) - window->KeyDown(KEY_A));
if (movement.x != 0.0f and movement.y != 0.0f)
{
//Adjust speed on each axis if both are in use
movement *= 0.7071f;
}
movement *= movespeed;
float jump = window->KeyHit(KEY_SPACE) * jumpstrength;
bool crouch = window->KeyDown(KEY_C);
if (player->GetAirborne()) jump = 0;
if (crouch == false and window->KeyDown(KEY_SHIFT) and !player->GetAirborne())
{
movement *= runspeed;
}
if (jump > 0 and crouch == false)
{
movement *= lunge;
accel *= 100;
}
//Set input
player->SetInput(camrotation.y, movement.y, movement.x, jump, crouch, accel, maxdecel);
}
world->Update();
//Adjust camera position
float eyeheight = 1.7f;
if (player->GetCrouched())
{
eyeheight = 1.8f * 0.5f - 0.1f;
}
camera->SetPosition(Mix(camera->position.x, player->position.x, 0.5f), MoveTowards(camera->position.y, player->position.y + eyeheight, 0.1f), Mix(camera->position.z, player->position.z, 0.5f));
camera->SetPosition(player->position.x, MoveTowards(camera->position.y, player->position.y + eyeheight, 0.1f), camera->position.z);
world->Render(framebuffer);
}
return 0;
}