AggrorJorn Posted March 16, 2013 Share Posted March 16, 2013 The following code sample will run just fine. However when we uncomment the "SetGravity command", the game will crash. #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } Model* ground; Model* box1; Model* box2; Material* groundMaterial; Material* stoneMaterial; bool App::Start() { //Create a window window = Window::Create("_3_Shapes"); //Create a context context = Context::Create(window); //Create a world world = World::Create(); //Create a camera camera = Camera::Create(); camera->Move(0,2,-5); //Create ground and paint it with material ground = Model::Box(10,0.1,10); groundMaterial = Material::Load("Materials/tile2.mat"); ground->SetMaterial(groundMaterial); Shape* groundShape = Shape::Box(0,0,0 ,0,0,0, 10,0.1,10); ground->SetShape(groundShape); groundShape->Release(); //Create a box box1 = Model::Box(); stoneMaterial = Material::Load("Materials/stone2.mat"); box1->SetMaterial(stoneMaterial); box1->SetPosition(0,2,0); Shape* boxShape = Shape::Box(); box1->SetShape(boxShape); box1->SetMass(1); boxShape->Release(); // Create a second box box2 = Model::Box(); box2->SetMaterial(stoneMaterial); box2->SetPosition(0,1,0); Shape* box2Shape = Shape::Box(); box2->SetShape(box2Shape); box2->SetMass(1); box2Shape->Release(); ///BUG//// //box2->SetGravityMode(false); return true; } bool App::Loop() { //Close the window to end the program if (window->Closed()) return false; Time::Update(); world->Update(); world->Render(); context->Sync(false); return true; } Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 16, 2013 Author Share Posted March 16, 2013 I also get this error when using an array to create many boxes. Something goes wrong when objects intersect. The following program again runs fine. However, when you swap the bug line in the for loop, the programm crashes because objects are intersecting. #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } Model* ground; Model* boxes[100]; Material* groundMaterial; Material* stoneMaterial; bool App::Start() { //Create a window window = Window::Create("_3_Shapes"); //Create a context context = Context::Create(window); //Create a world world = World::Create(); //Create a camera camera = Camera::Create(); camera->Move(0,2,-5); //Create ground and paint it with material ground = Model::Box(10,0.1,10); groundMaterial = Material::Load("Materials/tile2.mat"); ground->SetMaterial(groundMaterial); Shape* groundShape = Shape::Box(0,0,0 ,0,0,0, 10,0.1,10); ground->SetShape(groundShape); groundShape->Release(); ground->SetFriction(0, 10); stoneMaterial = Material::Load("Materials/stone2.mat"); //Create an array Shape* tempShape = Shape::Box(); for(int i = 0; i<100;i++) { // Create a second box boxes[i] = Model::Box(); boxes[i]->SetMaterial(stoneMaterial); /// BUG boxes[i]->SetPosition(0, 5 + (i * 0.2),0); //Crashes //boxes[i]->SetPosition(0, 5 + (i * 1.2),0); //Works fine boxes[i]->SetShape(tempShape); boxes[i]->SetMass(1); } tempShape->Release(); return true; } bool App::Loop() { //Close the window to end the program if (window->Closed()) return false; Time::Update(); world->Update(); world->Render(); context->Sync(false); return true; } Link to comment Share on other sites More sharing options...
YouGroove Posted March 29, 2013 Share Posted March 29, 2013 Yes that error also happens when using the editor without coding : You place models that have physics and they intersect in the editor. When running the game the error will make the game crash. Could it be possible to have LE3 display a warning in the editor ? Stop toying and make games Link to comment Share on other sites More sharing options...
Admin Posted April 1, 2013 Share Posted April 1, 2013 Newton 3 is filled with error checks and it's quite excessive. I did a full project search and replace to get rid of these, which can occur during physics updates. Link to comment Share on other sites More sharing options...
Recommended Posts