User talk:Serge Yseron/Archive8

From Guild Wars 2 Wiki
Jump to navigationJump to search

Locky Lock[edit]

Apparently a TryLock() will always be better than a Lock() when it comes to lock a path finding snapshot buffer (that is expanded rather than being rebuilt each time, same goes for the Ogre vertex buffer of the associated debug primitives, that's how i stay above 1000 fps)...

User Serge Yseron zero wanker.jpg
Serge Yseron (talk) 15:37, 8 February 2014 (UTC)

Movie Theater[edit]

Actually, it did get there... Yseron - 90.15.124.120 21:51, 10 February 2014 (UTC)

Unity, united in fear[edit]

I was wondering why we were suffering far more than what we had to with unity c#. After experimenting and reading tons of articles on the subject it appears that it is simply due to the fact that they dont know how to use pointers and banished them as a consequence. The problem is that it's one of the rare developement tool that is correctly multi-platforms, so we are going to get stuck with it for as long as people will believe they are the next to get millions of dollars by releasing a game on iphone or android. Fucking century. Yseron - 90.15.124.120 21:22, 13 February 2014 (UTC)

A* areas selections[edit]

Some programmers are reluctants to use a global array indexing when it comes to reference grid cells. It takes me 1 substraction to eliminate colinear grid path nodes, it takes them at the very least 6 substractions + 1 dot product to do the same...

Since my old ftp was gone when i switched to fiber connection, here is the new link to the location of the 'project' and hence the source code: https://www.sugarsync.com/pf/D2307301_98582733_66787

I am almost done porting it on Unity. Yseron - 90.53.86.194 03:30, 23 February 2014 (UTC)
It's finished. I will post a link later because i must wake up to go to work in a few hours. Yseron - 90.53.86.194 00:43, 24 February 2014 (UTC)
https://www.sugarsync.com/pf/D2307301_98582733_64554. ( still have some work to do like finding why with more than 2 threads in unity perfs go down while in Visual, perfs go up ) Yseron - 90.53.86.194 01:40, 24 February 2014 (UTC)

User Serge Yseron as selections edges marking.jpg
Serge Yseron (talk) 05:15, 16 February 2014 (UTC)

Lost and found[edit]

I thought with the end of vinyl records that i would never retrieve again this particular track. But what could possibly be lost these days on youtube ? Yseron - 90.53.86.194 20:10, 18 February 2014 (UTC)

The guys of C# answered: it's because they dont have time[edit]

Fucking century... Yseron - 90.53.86.194 17:12, 22 February 2014 (UTC)

"By restricting method bodies to always be inside a struct or class, we make it easier to reason about the meaning of an unqualified identifier used in an invocation context; such a thing is always an invocable member of the current type (or a base type).Now, JScript.NET has this feature. (And in fact, JScript.NET goes even further; you can have program statements "at the top level" too.) A reasonable question is "why is this feature good for JScript but bad for C#?" First off, I reject the premise that the feature is "bad" for C#. The feature might well be good for C#, just not good enough compared to its costs".


Resolved.


sealed public class Handle< T > where T : new() {

   internal System.Object m_pOwner    = null;
   
   internal uint          m_iSlot     = uint.MaxValue;
   
   internal T             m_pRef      = default( T );
   
   bool                   m_bConsumed = false;
   
   internal Handle( System.Object pOwner, uint iSlot, T pRef ) { m_pOwner = pOwner; m_iSlot = iSlot; m_pRef = pRef; }
   
   internal bool Consumed { get { return m_bConsumed; } set { m_bConsumed = value; } }
   
   public T      Object   { get { return m_pRef; } }

}

public class Pool< T > where T : new () {

   T[]                 m_pRefs          = null;
   Handle< T >[]       m_pHandles       = null;
   
   uint[]              m_iFreeSlots     = null;
   
   uint                m_iNbFreeSlots   = 0;
   private static bool m_bMonoBehaviour = IsMonoBehaviour( typeof( T ) );
   
   private static bool IsMonoBehaviour( Type oType )
   {
       while( oType.BaseType != null )
       {
           if( oType == typeof( MonoBehaviour ) ) return true;
           
           oType = oType.BaseType;
       }
       
       return false;
   }
   
   private static T CreateInstance()
   {
       if( m_bMonoBehaviour == false )
       {
           return new T();
       }
       else
       {
           GameObject pGameObj = new GameObject( typeof( T ).ToString(), new Type[1]{ typeof( T ) } );
           T          pRef     = ( T )( ( object )pGameObj.GetComponent( typeof( T ).Name ) );
           
           return pRef;
       }
   }
   
   public uint Capacity { get { return( uint )m_pRefs.Length; } }
   
   public Pool( uint iCapacity )
   {
       m_pRefs        = new T        [ iCapacity ];
       
       m_pHandles     = new Handle<T>[ iCapacity ];
       
       m_iFreeSlots   = new uint     [ iCapacity ];
       
       m_iNbFreeSlots = iCapacity;
       
       for( uint iSlot = 0; iSlot < iCapacity; ++iSlot )
       {
           m_pRefs     [ iSlot ] = CreateInstance();
           
           m_pHandles  [ iSlot ] = new Handle< T >( this, iSlot, m_pRefs[ iSlot ] );
           
           m_iFreeSlots[ iSlot ] = iSlot;
       }
   }
   
   public Handle< T > Grab()
   {
       if( m_iNbFreeSlots != 0 )
       {
           uint iFreeSlot = m_iFreeSlots[ --m_iNbFreeSlots ];
           
           m_pHandles[ iFreeSlot ].Consumed = true;
           
           return m_pHandles[ iFreeSlot ];
       }
       
       return null;
   }
   
   public bool Release( Handle< T > pHandle )
   {
       if( m_iNbFreeSlots < Capacity )
       {
           if( ( pHandle != null ) && ( pHandle.m_pOwner == this ) && ( pHandle.Consumed == true ) )
           {
               m_iFreeSlots[ m_iNbFreeSlots++ ] = pHandle.m_iSlot;
               
               pHandle.Consumed = false;
               
               return true;
           }
       }
       
       return false;
   }

}

public static class PoolUnitTest {

   public static void Run< T >() where T : new()
   {
       Pool< T >     oPool    = new Pool< T >( 32 );
       
       Handle< T >[] pHandles = new Handle< T >[ 32 ];
       
       for( uint iIteration = 0; iIteration < 32; ++iIteration )
       {
           pHandles[ iIteration ] = oPool.Grab();
       }
       
       for( uint iIteration = 0; iIteration < 32; ++iIteration )
       {
           oPool.Release( pHandles[ iIteration ] );
       }
   }

}

etc. Yseron - 109.212.58.194 19:41, 1 March 2014 (UTC)


The comparative tests showed a 50% performances increase with a pool 1024 floaters. The pool now support monos instantiating with / without an optional template. I will check it in at the usual link in a few moments. Yseron - 109.212.58.194 13:48, 2 March 2014 (UTC)

Unity 1024 entities pathfinding -> constant 60fps[edit]

I will check in the last version later because i want to rework the threads locks now that i now where critical sections are located in Unity.

The locks work like a charm, and i followed msdn recommendations for c# specific threads termination, version with 1024 entities here:https://www.sugarsync.com/pf/D2307301_98582733_64554

User Serge Yseron unity 1024 entities pathfinding.jpg
Serge Yseron (talk) 19:17, 24 February 2014 (UTC)

UNity bug reporter[edit]

I'm pretty sure i can upload a movie under 10 minutes. So when Unity bug reporter fail to upload only 20 megs strange things emerge in my mind. Then when i hit cancel because the bug reporter uploader did not make any progress for 5 minutes after uploading 70% of the report, the whole jazz crumble... Yseron - 109.212.58.194 01:59, 25 February 2014 (UTC)

ASGrid with height map[edit]

In fact it will always be the same link because SugarSync provide dynamic links that always point to the latest version, here: https://www.sugarsync.com/pf/D2307301_98582733_64554

User Serge Yseron unity 1024 entities pathfinding2.jpg
Serge Yseron (talk) 22:04, 26 February 2014 (UTC)

Flat is flat...[edit]

How to go from flat to facing camera lines ? Two lines... too hard...

User Serge Yseron flat vs facing camera.jpg
Serge Yseron (talk) 22:27, 27 February 2014 (UTC)

Floaters Inferno[edit]

I did add some floaters that are intended for a production. Since i had to test them, i did use them to pop some floaters reflecting the states of game entities in my sample exemple home project here: https://www.sugarsync.com/pf/D2307301_98582733_64554

User Serge Yseron floaters.jpg
Serge Yseron (talk) 10:52, 1 March 2014 (UTC)

Randomly randoms for random trainees[edit]

I did add some style flags for the floaters (popup scale and fade out). I also added a joke (last pic in the screenshot) you can play to new trainees freshly arrived at your studio (i created it in c# but it also work in c++, the magic language where the absence of garbage collector and the availability of pointers does not impede performances by -1000%).

User Serge Yseron random for trainees.jpg
Serge Yseron (talk) 15:55, 1 March 2014 (UTC)