Incomplete Render Tweening in POTZ and editor

The Wonderland Open Source Project

Moderators: ILoveWonderland, Sammy_P, Lazy Loof

Post Reply
User avatar
Lazy Loof
Rainbow Wizard
Posts: 460
Joined: Sun Nov 27, 2016 2:37 pm
Contact:

Incomplete Render Tweening in POTZ and editor

Post by Lazy Loof » Mon May 27, 2019 12:31 pm

This is a major bug so imo it needs separate topic.

I'm now talking about a bug in this topic which I always experienced in POTZ and editor. Whenever you play POTZ or even any adventure in the editor, the camera appears to slightly lag while it moves. This does not happen in WA1 and MOFI. In these games, the camera moves smoothly without any lag of any kind.

SHORT EXPLANATION:
This bug is due to a problem in following If block in RenderGame function in player.bb.
Image
As you see here, the If block prevents RenderWorld tween parameter to have essential value 0.0 to have complete Render Tweening (1.0 is the default value for tween parameter). This causes incomplete tweening and thus problems like I stated above. The fix is simple! Replace those lines with:
Image

I have attached the fixed executables of both WA3E and POTZ here in a single zip file so you'll can have it.
https://archive.zbots.space/files/WA_POTZ_v102.zip
WA_Editor_Fix.zip


LONG EXPLANATION:
I initially thought these due to POTZ and editor being compiled in debug mode and debug mode does really make the game slower than usual in lower-end PCs like that of mine. However, when I played the game in release mode, that thing still happened. Then I wondered how that could be? Since all the games were having same engine (just evolved over time), I can't think of any other issue than that.

Just recently when MNIK made topic and discussion about the ancient MAV in adventure select screen, I got a clue from the screenshot he attached.
Here it is, for anyone wondering:
Image
The screenshot shows RenderGame function (in player.bb) which has the function RenderWorld used two times: one with tween (for Render Tweening) and other without it.

Render Tweening is a technique in Blitz3D which makes display smoother. Here is the complete description of RenderWorld from Blitz docs.
Renders the current scene to the BackBuffer onto the rectangle defined by each cameras CameraViewport( ). Every camera not hidden by HideEntity( ) or with a CameraProjMode( ) of 0 is rendered. Rendering to other buffers is currently not supported by Blitz3D.

The optional tween parameter should only be specified when RenderWorld is used in conjunction with CaptureWorld. CaptureWorld is used to store the 'old' position, rotation and scale, alpha and colour of each entity in the game world, and a tween value of < 1 will interpolate between these 'old' values and the 'current' ones. A tween value of 0 will render all entities at their state when CaptureWorld was last called, and a tween value of 1 will render all entities at their current state.

The use of tweening allows you to render more than one frame per game logic update, while still keeping the display smooth. This allows you to cut down on the CPU time that would be required to update your game logic every render. Note, however, that the bottleneck in almost all 3D applications is the graphics card and the CPU time involved in updating game logic is often very little. A good alternative to render tweening is the use of a delta time, that is, moving your entities each frame depending on the time it took for the program to process and render that frame.

Render tweening is quite an advanced technique, and it is not necessary to use it, so don't worry if you don't quite understand it. See the castle demo included in the mak (nickname of Mark Sibly, author of Blitz3D) directory of the Blitz3D samples section for a demonstration of render tweening.
Technically, this bug is related with this.

Looking at the Blitz Docs you'll find that tween argument of RenderWorld supports values between 0.0 and 1.0. It has to be noted that RenderWorld supports both 0.0 and 1.0, 0.0 being rendering all entities in their state when CaptureWorld was called and 1.0 rendering all entites in their current state.

Now look at this block again, most importantly the If block and the compare it with the statement in bold above. You'll get the fault!
Image

Yes! The If block does not let the game render all entities at their state when CaptureWorld was last called (at game loop) thus causing incomplete render tweening. The fix is simple, just replace that complete If...EndIf block with this:
Image
And voila! The game works as smooth as WA1 and MOFI, nothing extra needed!
You do not have the required permissions to view the files attached to this post.
Previously known as Aryan101
User avatar
HumanGamer
Rainbow Wonderlander
Posts: 199
Joined: Fri Apr 16, 2010 2:23 pm

Re: Incomplete Render Tweening in POTZ and editor

Post by HumanGamer » Mon May 27, 2019 9:24 pm

I wonder why MS added that. The fix is literally to remove code he wrote in. :thinking:
WA3 Editor Tools
WOP Research
WA Map Recreation

I was previously known as cooldudepoke.
Post Reply