Strangeness

Started by JBR, May 01, 2020, 00:52:52

Previous topic - Next topic

JBR

Hi,

I was developing in open3d and hit a strange problem.

I'm using 3d lines, each a unique entity which goes around the craft.

Problem is when building the ship & lines (in a staggered way, one line per vsync). the frame rate reaches 200ms at worst. I'm finding open3d very strange behaviour.

So, I went back to minib3d and everything works as it should. Never more then 3ms all the time.

Only problem is my 3d line routine relies on AlignToVector and I've not found one which works in the same as the open3d one.

i.e. AlignToVector c3, x2-x1, y2-y1, z2-z1, 2

If you want the open3d code to show the slowdown vs the minib3d I'll zip up some files.

Anyone help?
Jim.

Matty

If this is on a handheld device - the android garbage collector can cause stutter with some 3d engines.  Finding ways to overcome it can be interesting to say the least.

Just a guess.

markcwm

Yes, it's strange, I'll take a look at it if you post the files.

JBR

https://www.dropbox.com/sh/ive2ch5kz5s494g/AADqSzA0JMdNwwQyTOQe6Ybwa?dl=0

The 2 files are included.

Just tick the 4 boxes and download.

Thanks, Jim.

JBR

Here is an attached zip.


angros47

Actually, OpenB3D doesn't rely on a garbage collector (being written in C++), but it deallocates all the unused stuff as soon as possible. On the other hand, minib3d uses BlitzMax garbage collector (that actually might make things faster, at the price of some sudden slow-down when memory is full to deallocate everything at once)


markcwm

Thanks for the demo JBR, nice code! I get Openb3d going up to 800ms for about 30sec then it drops to 20ms and stays there, in Minib3d it's about 100ms all the time.

As Angros said, it's the difference in memory management, Openb3d is immediate so you get slowdowns until the memory is released, Minib3d is managed by the GC so you get steadier performance.

I'll see if I can find any AlignToVector code for Minib3d.

TomToad

I ran into the same problem with AlignToVector and miniB3D.  I did find an AlignToVector function https://www.mojolabs.nz/codearcs.php?code=2782
Problem with this function is that it only aligns the z axis.  Good if you are trying to point the camera in a particular direction, but if you need to align the x axis or y axis, then the function needs to be modified.  I tried to modify it, but couldn't get it to work for some reason.
------------------------------------------------
8 rabbits equals 1 rabbyte.

DruggedBunny

Bear in mind Blitz3D itself is open-source and liberally-licensed (zlib/png), so this might help:

https://github.com/blitz-research/blitz3d/blob/master/bbruntime/bbblitz3d.cpp#L1855

JBR

@Mark.

All the Turn code with quaternions was pinched from Krischans star code.

So he probably deserves the credit.

If you can come up with a working AlignToVector for minib3d it would be much appreciated.

Jim

JBR

I used the code by TomToad which only handles the z axis.

So firstly I make the scaled line along y, then rotatemesh c3,90,0,0 so it is pointing in the z axis.

Then I use TomToad's code and it works perfect.

My routine changes the scale of the line dynamically so rather then scaleentity c3,scale,1,scale I use scale,scale,1.

All fixed and many thanks. Jim.