I'm having real REAL trouble here. When the camera shakes and the player attempts to go to the next room (sometimes they don't even need to do that) the camera position flies off and then the game freezes.
From what I've found the game freezes because of a mixture of bump.lua (kikito's collision lib) and when I use getVisible on the Stalker-X camera. Apparently the camera x (or y sometimes) goes to a really high value like 1.29472929e+17, so bump.lua does its best to iterate from something like 0 to that number, which understandabley takes forever hence freezing/slowing down the game
The camera shakes when the player gets hit. So movement with w-up, s-down, d-right, a-left.
The main suspects I've narrowed it down to are:
toybox/libs/camera.lua (update method is where camera shake is updated)
soulp/level.lua (lines 151 - 239, update method)
soulp/level.lua (last lines, ~729 where camera shake is called)
This happens when follow_style of the camera is "LOCK_ON" (and anything besides"none","",any other unspecific style and "no_deadzone"(I think) which don't allow shaking.)
The camera also follows something called cameraMan in level.lua not the player directly (for a zelda like room-by-room camera).
Not that important, but soulp/game.lua has the player and soulp/entity.lua is the class most things are derived from.
The love file might error with "free" or something like "5,6" at first, but please just run it again....and again...and again until it will eventually work.
Camera goes off to infinity
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Gunroar:Cannon()
- Party member
- Posts: 1144
- Joined: Thu Dec 10, 2020 1:57 am
Camera goes off to infinity
- Attachments
-
- janky_jank.love
- (2.95 MiB) Downloaded 83 times
Re: Camera goes off to infinity
Code: Select all
Error: toybox/libs/tools.lua:12: module 'soulp.Gun' not found:
I can't follow the program flow. This does not follow standard Löve conventions. You don't expect most people to try to learn your coding conventions and the LGML library in order to help you, right? I don't even know where the main loop is.
I had to disable fullscreen to make it easier to switch windows. After doing that, camera shake crashed less often. But what did crash, almost always, was changing screens.
The crash in this case is an infinite loop, but I can't tell where because I can't narrow it down. I tried disabling JIT and that made no difference, so it does not appear to be a LuaJIT bug.
- Gunroar:Cannon()
- Party member
- Posts: 1144
- Joined: Thu Dec 10, 2020 1:57 am
Re: Camera goes off to infinity
Thanks for fixing . Normally the when I run the love file it tells me these errors.pgimeno wrote: ↑Fri Aug 05, 2022 6:06 pmThe file is in lower case.Code: Select all
Error: toybox/libs/tools.lua:12: module 'soulp.Gun' not found:
What do you mean ? Is it the way I packed the love.load,draw,update,etc ?I can't follow the program flow. This does not follow standard Löve conventions.
Thanks for looking.You don't expect most people to try to learn your coding conventions and the LGML library in order to help you, right? I don't even know where the main loop is.
I had to disable fullscreen to make it easier to switch windows. After doing that, camera shake crashed less often. But what did crash, almost always, was changing screens.
The crash in this case is an infinite loop, but I can't tell where because I can't narrow it down. I tried disabling JIT and that made no difference, so it does not appear to be a LuaJIT bug.
Sorry for all that (the LGML lib is kind of my lib, just that one thing is named LGML). I wouldn't have asked if I didn't try really hard before. I pinned down the problem and where the issues come from.
I also tried to pin down where the problem came from 'cause I can understand it's hard to look through someone else's code (especially mine )
Gunroar:Cannon() wrote: ↑Thu Aug 04, 2022 11:56 am
From what I've found the game freezes because of a mixture of bump.lua (kikito's collision lib) and when I use getVisible on the Stalker-X camera. Apparently the camera x (or y sometimes) goes to a really high value like 1.29472929e+17, so bump.lua does its best to iterate from something like 0 to that number, which understandabley takes forever hence freezing/slowing down the game
The main suspects I've narrowed it down to are:
toybox/libs/camera.lua (update method is where camera shake is updated)
soulp/level.lua (lines 151 - 239, update method)
soulp/level.lua (last lines, ~729 where camera shake is called)
This happens when follow_style of the camera is "LOCK_ON" (and anything besides"none","",any other unspecific style and "no_deadzone"(I think) which don't allow shaking.)
The camera also follows something called cameraMan in level.lua not the player directly (for a zelda like room-by-room camera).
Not that important, but soulp/game.lua has the player and soulp/entity.lua is the class most things are derived from.
- Gunroar:Cannon()
- Party member
- Posts: 1144
- Joined: Thu Dec 10, 2020 1:57 am
Re: Camera goes off to infinity
I think I'll just make shake a different function so the camera doesn't mess it up.
Re: Camera goes off to infinity
What confused the hell out of me was the redefinition of print(). Once that was sorted out I was able to see where it crashed and why. Your diagnosis was more or less correct, poor bump.lua can't deal with numbers that big. This patch makes it throw an error instead of hanging:
I dont' think the only problem is camera shake. Changing rooms also triggers the problem.
Code: Select all
--- toybox/libs/bump.lua.orig 2022-08-04 13:39:34.000000000 +0200
+++ toybox/libs/bump.lua 2022-08-07 19:24:25.803285165 +0200
@@ -367,9 +367,11 @@
local function getDictItemsInCellRect(self, cl,ct,cw,ch)
local items_dict = {}
for cy=ct,ct+ch-1 do
+ assert(cy < cy + 1)
local row = self.rows[cy]
if row then
for cx=cl,cl+cw-1 do
+ assert(cx < cx + 1)
local cell = row[cx]
if cell and cell.itemCount > 0 then -- no cell.itemCount > 1 because tunneling
for item,_ in pairs(cell.items) do
- Gunroar:Cannon()
- Party member
- Posts: 1144
- Joined: Thu Dec 10, 2020 1:57 am
Re: Camera goes off to infinity
Oh, I changed print to log into a file, sorry.
Thanks for looking deeper.
And yes, it happens when rooms are changed (though a rare few times just when you get hit) so shaking itself is not the problem but from what I can tell if shaking is disabled and you change rooms everything works fine so I believe it's the root of the problem when I try to move the cameraMan.
Thanks for looking deeper.
And yes, it happens when rooms are changed (though a rare few times just when you get hit) so shaking itself is not the problem but from what I can tell if shaking is disabled and you change rooms everything works fine so I believe it's the root of the problem when I try to move the cameraMan.
Also could you explain how the assert works. Shouldn't cx/cy be always smaller than the value + 1?pgimeno wrote: ↑Mon Aug 08, 2022 12:18 pmCode: Select all
for cy=ct,ct+ch-1 do + assert(cy < cy + 1) local row = self.rows[cy] if row then for cx=cl,cl+cw-1 do + assert(cx < cx + 1) local cell = row[cx] if cell and cell.itemCount > 0 then -- no cell.itemCount > 1 because tunneling for item,_ in pairs(cell.items) do
Re: Camera goes off to infinity
Not anymore when the 64-bit floating-point numbers used in Lua are so large that they've lost enough precision that every whole number cannot be represented anymore and gets rounded. The asserts would also trigger if cx/cy was infinite.Gunroar:Cannon() wrote: ↑Mon Aug 08, 2022 1:25 pm Shouldn't cx/cy be always smaller than the value + 1?
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
- Gunroar:Cannon()
- Party member
- Posts: 1144
- Joined: Thu Dec 10, 2020 1:57 am
Re: Camera goes off to infinity
Ah, okay. Thanks for the explanation of the assert.ReFreezed wrote: ↑Mon Aug 08, 2022 3:31 pmNot anymore when the 64-bit floating-point numbers used in Lua are so large that they've lost enough precision that every whole number cannot be represented anymore and gets rounded. The asserts would also trigger if cx/cy was infinite.Gunroar:Cannon() wrote: ↑Mon Aug 08, 2022 1:25 pm Shouldn't cx/cy be always smaller than the value + 1?
Though pgimeno, I did already spot this part of the problem after a long time of observation before I posted. What I'm still wondering is ... why?
Anyways thank you for the assert function and info. It's nice to learn new things.
Re: Camera goes off to infinity
I don't have an answer yet. It's a lot of code to wade through. Maybe with Zerobrane and stepping I can see where one coordinate starts to grow exponentially, because that's what's happening.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], JumboSizedFish and 14 guests