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;
}