EngoEngine/engo

Camera LongTasks seems broken

inkeliz opened this issue · 1 comments

Since my workaround to fix texture, I create some Steps []float64, so I can use:

m.MouseZoomer.Steps = []float32{1, 2, 4, 8}

However, the change of zoom and angle is very roughly. In way to prevent it, I make one m.MouseZoomer.Duration = time.Second. The Duration supplies the Duration of CameraMessage.

It was suppose to take 1 second to change the zoom from 1 to 2, another 1 second to change 2 to 4.


However, there's some bugs:

longTask.Duration -= time.Duration(dt)

That doesn't work. The time.Duration is int64. If the game is running at 60 FPS the dt will be 0.16 seconds, which will be 0, since int64(float32(0.16)) is 0. It creates a infinite loop. I think the solution must be:

	const second = float32(time.Second)
	longTask.Duration -= time.Duration(dt * second)

Then, have another problem, which seems to be caused by longTask.speed = longTask.Value / float32(longTask.Duration.Seconds()) when longTask.Incremental = false. It should be false since it is a "steped" zoom.


I'm trying to fix that, but I think it will be very different from the current implementation. 😐

I found the second issue. It's kinda related to longTask.speed = longTask.Value / float32(longTask.Duration.Seconds()). The problem is that the value isn't exactly, for instance you can set to zoom-out 2, but it only zoom-out 1.99.

The fix for that is enforce to set the correct value when longTask.Duration <= time.Duration(0). So, the last step will zoomTo(2).

I'll try to make an pull-request, because I blow-up my fork. 😅