Jump to content

Josh

Staff
  • Posts

    23,456
  • Joined

  • Last visited

Everything posted by Josh

  1. This demonstrates that you can call collectgarbage() every frame in Lua with no effect on the framerate: -- Define a function that performs intensive calculations and variable allocation function testGarbageCollection() local iterations = 1 -- Adjust the number of iterations as needed -- Perform calculations and variable allocation in a loop for i = 1, iterations do -- Intensive calculations (e.g., math operations) local result = math.sqrt(i) * math.sin(i) * math.cos(i) -- Allocate tables with random data local table1 = {} for j = 1, 10 do table1[j] = math.random() end -- Create temporary strings local str = "" for j = 1, 10 do str = str .. tostring(math.random()) end -- Let's intentionally create some cyclic references local cyclicTable = {} cyclicTable.circularRef = cyclicTable -- Simulate resource-intensive operations local resourceIntensiveData = {} for j = 1, 10 do resourceIntensiveData[j] = {} for k = 1, 10 do resourceIntensiveData[j][k] = math.random() end end end return "Test completed" -- Return a message when the test is done end -- Call the function to trigger the test print(testGarbageCollection()) --Get the displays local displays = GetDisplays() -- Create a window local window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[1], WINDOW_CENTER | WINDOW_TITLEBAR) -- Create a world local world = CreateWorld() -- Create a framebuffer local framebuffer = CreateFramebuffer(window) -- Create a camera local camera = CreateCamera(world) camera:SetClearColor(0.125) camera:SetPosition(0, 0, -4) -- Create a light local light = CreateBoxLight(world) light:SetRotation(45, 35, 0) light:SetRange(-10, 10) light:SetColor(2) -- Create a model local model = CreateBox(world) model:SetColor(0, 0, 1) -- Main loop while not window:Closed() and not window:KeyDown(KEY_ESCAPE) do model:Turn(0, 1, 0) world:Update() world:Render(framebuffer, false) testGarbageCollection() if window:KeyDown(KEY_SPACE) then collectgarbage() end end
  2. My focus is locked into the Lua API and docs right now, but I will get to this afterwards...
  3. It's ready now: https://www.ultraengine.com/learn/Framebuffer_Capture?lang=cpp
  4. Updated Lua executables and C++ library. Added Framebuffer::GetCaptures Removed World::GetFrameCaptures All Lua documentation finished and working up through the "Graphics" category.
  5. Working on docs: https://www.ultraengine.com/learn/Map_Reload?lang=cpp
  6. Call Framebuffer::Capture to take the screenshot. The result will not be available immediately. In your main loop, call world->GetFrameCaptures() each loop, and handle any results it gives you there. In the next build this will be changed to Framebuffer::GetCaptures(), and it will return a resizable array of pixmaps.
  7. I am looking into this. I fixed something in the event handlers that probably caused it.
  8. As I suspected there is no perfect solution when the target rotation is 180 degrees opposite from the current rotation, because one degree of freedom is lost. I'm not sure at this point what should be done or if this is just the way things work.
  9. Yeah, that's the idea. This appears to be working: auto p = CreatePivot(NULL); p->AddComponent<Mover>(); auto map = std::make_shared<Scene>(); map->AddEntity(p); map->Save("Maps/out.ultra"); Here is the output: { "scene": { "base": [], "entities": [ { "castShadows": false, "collisionType": 0, "extras": { "components": { "Mover": { "globalcoords": false, "movementspeed": [ 0, 0, 0 ], "rotationspeed": [ 0, 0, 0 ] } } }, "pickMode": 0, "reflection": true, "uuid": "ffe028a9-4abe-49de-ba7b-30c2373cf196" } ] } }
  10. This method just creates a scene object and adds the world entities to it. However, the functionality to add all entities into a list of weak pointers was never added! The fastest fix is for me to just remove this method and the user can create a scene and add entities themselves.
  11. The bug is the fact that the event constant is still in there. Use World:GetFrameCaptures() instead of this approach.
  12. Updated C++ library to fix GetEntity() returning NULL in Start method. Lua executables updated, support is finished for all classes in docs up through GamePad.
  13. For the reason you pointed out, the raw pointer is removed and you should use GetEntity() instead.
  14. Hi, A point to a Lua function is just the function name: function loadhook(progress) Print(progress) end LoadMap("Maps/test.map", "loadhook") In Ultra, the Lua binding system I am using provides more control, and the Lua function itself can be passed to functions.
  15. You can create an instance or copy of it in another world. Switching worlds would probably cause a lot of problems.
  16. Yeah, it's fixed, I just have not updated the lib. I'll do it within a couple hours from now.
  17. Newton forum is back up: http://newtondynamics.com/forum/viewtopic.php?f=12&t=9825
  18. Update Lua template executables, functionality is complete up through the terrain class in the documentation.
  19. What would I do without @SpiderPig?
  20. @SpiderPigThe lib has been updated with this fix now.
  21. Lots of functionality added in the Lua API. Not complete, but I have worked through to the Light class in the documentation.
×
×
  • Create New...