Canardia Posted January 14 Share Posted January 14 ship = CreateBoxBrush(world, 10, 10, 10); ship->Move(0, 0, 0); auto pivot = CreatePivot(world); pivot->Turn(0, -60, -45); Vec3 normal = pivot->rotation.Normalize(); Plane plane = Plane(normal.x, normal.y, normal.z, 4); auto A = CreateBrush(world); auto B = CreateBrush(world); ship->Slice(plane, A, B); ship = B; pivot->Turn(0, 1, 0); normal = pivot->rotation.Normalize(); plane = Plane(normal.x, normal.y, normal.z, 4); ship->Slice(plane, A, B); // Crash: Assert failed. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Solution Josh Posted January 14 Solution Share Posted January 14 In your example, at the last line ship and B are the same brush. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Canardia Posted January 15 Author Share Posted January 15 This fixed it, thanks! B->CopyTo(ship, 0); 1 Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Josh Posted January 15 Share Posted January 15 Don't use CopyTo. That's actually supposed to be a private method. Use Entity::Copy() and cast the result to a brush. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Canardia Posted January 15 Author Share Posted January 15 45 minutes ago, Josh said: Don't use CopyTo. That's actually supposed to be a private method. Use Entity::Copy() and cast the result to a brush. But this doesn't work: //B->CopyTo(ship, 0); // works ship = B->Copy(world,false,false)->As<Brush>(); // doesn't work Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Josh Posted January 15 Share Posted January 15 How does it "not work"? It doesn't compile? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Canardia Posted January 15 Author Share Posted January 15 The ship vanishes. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Josh Posted January 15 Share Posted January 15 I need a complete example to run please. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Canardia Posted January 15 Author Share Posted January 15 #include "PreComp.h" #include "Factory.h" Factory::Factory(A<World> world) { world = world; ship = CreateBoxBrush(world, 10, 10, 10); ship->Move(0, 0, 0); } void Factory::Cut(double x, double y, double z) { auto pivot = CreatePivot(world); pivot->Turn(x,y,z); Vec3 normal = pivot->rotation.Normalize(); Plane plane = Plane(normal.x, normal.y, normal.z, 4); A<Brush> A, B; A = CreateBrush(world); B = CreateBrush(world); ship->Slice(plane, A, B); B->CopyTo(ship, 0); //ship = B->Copy(world,false,false)->As<Brush>(); } Then in Application.cpp (main.cpp): Factory factory(world); factory.Cut(0, -60, -45); factory.Cut(-60, -60, -45); ship = factory.ship; Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Josh Posted January 15 Share Posted January 15 Can you make it all in one main.cpp file? There are so many things I might do differently if I try to recreate your program. Your plane is extremely strange. A Euler rotation cannot be translated into a normal like that. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Canardia Posted January 15 Author Share Posted January 15 I made an example and now it works. Something wrong in my Factory class must be. #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { // Get the displays auto displays = GetDisplays(); // Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); // Create a framebuffer auto framebuffer = CreateFramebuffer(window); // Create a world auto world = CreateWorld(); // Let there be light and a ship auto camera = CreateCamera(world); camera->Move(0, 20, -20); camera->Turn(30, 0, 0); auto ship = CreateBoxBrush(world, 10, 10, 10); auto light = CreatePointLight(world, 100); light->Move(0, 20, 0); // Slice the dice auto pivot = CreatePivot(world); pivot->Turn(0, -60, 45); Vec3 normal = pivot->rotation.Normalize(); Plane plane = Plane(normal.x, normal.y, normal.z, 4); auto A = CreateBrush(world); auto B = CreateBrush(world); ship->Slice(plane, A, B); //B->CopyTo(ship, 0); // Works beautifully! ship = B->Copy(world,false,false)->As<Brush>(); // Let's slice again like we did last summer pivot = CreatePivot(world); pivot->Turn(-60, -60, -45); normal = pivot->rotation.Normalize(); plane = Plane(normal.x, normal.y, normal.z, 4); A = CreateBrush(world); B = CreateBrush(world); ship->Slice(plane, A, B); //B->CopyTo(ship, 0); ship = B->Copy(world,false,false)->As<Brush>(); // Now this works too, hmm back to the drawingboard // Move the sliced result right ship->Move(20, 0, 0); // Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; } 1 Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Canardia Posted January 15 Author Share Posted January 15 Ok, problem fixed, but I still wonder why this worked with CopyTo: Factory::Factory(A<World> world) { //world = world; // works only with CopyTo this->world = world; // works } Anyway, case closed. 1 Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.