Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tipsandtricks [2019/10/03 13:58] – [Polygon count] admintipsandtricks [2019/10/03 14:06] – [Threading] admin
Line 23: Line 23:
 ==== Changing Position, RotationAngle or Scale ==== ==== Changing Position, RotationAngle or Scale ====
  
-Changing one of the transformation settings of a 3D scene object initializes rendering each time.+Changing one of the transformation settings or visual properties of a 3D scene object initializes rendering implicity.
 So, when you're manipulating more than one object or property this could lead to very bad performance. So, when you're manipulating more than one object or property this could lead to very bad performance.
-Due to that, GorillaViewport provides the BeginUpdate and EndUpdate methods.+ 
 +Therefor we need some way of grouping those operations and to prevent FMX from updating each time. 
 + 
 +Due to that, GorillaViewport provides the BeginUpdate() and EndUpdate() methods.
 Encapsulate your transformations to increase performance. Encapsulate your transformations to increase performance.
  
Line 40: Line 43:
 end; end;
 </file> </file>
 +
 +==== Threading ====
 +
 +It is not uncommon to use a thread to compute visual property values. But because FMX (and also Gorilla3D) only runs in main thread, we need to synchronize somehow.
 +
 +Synchronization needs to be threadsafe, so everyone uses TThread.Synchronize(nil, DoSync) inside of its thread.
 +That's okey for many applications, but the better way is to use messaging or TThread.Queue(nil, DoSync) for this job.
 +
 +While "Synchronize" blocks the application to force updating with main thread, "Queue" instead updates the app when there is time for. For further information take a look at: [[http://docwiki.embarcadero.com/Libraries/Rio/en/System.Classes.TThread.Queue]]
 +