devNotes 11-06-16 Pythagorus

———-
r^3

void CSMain ( uint3 Gid : SV_GroupID, uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint GI : SV_GroupIndex )        
{
    int index = DTid.x;
    //int index = DTid.x + DTid.y * thread_group_size_x * 32;
   
    if(app_mode == 0) //Platonics Mode
    {
        float3 velTemp = particles[index].velocity;

        float3 vZero;
        vZero.x = 0;
        vZero.y = 0;
        vZero.z = 0;

        float3 pN_pL_dir = normalize((particles[index].position - particles[index].position_last));
        float  pN_pL_dist = distance(particles[index].position, particles[index].position_last);  
            
        float3 deltVel;
        float dV_Len;
        float dV_Last_Len;   
             
        if(attractor_Count == 1 || attractor_Count == 2 || attractor_Count == 3 )
        {
            float3 att_0_Dir  = normalize((att_0 - particles[index].position));
            float  att_0_dist = distance(att_0, particles[index].position);
            deltVel = targetStrength * att_0_Dir * deltaTime / att_0_dist 
                     - targetStrength * zero_mirror_radius * att_0_Dir * deltaTime/(att_0_dist*att_0_dist);

            velTemp += deltVel;
              

            if(attractor_Count == 2 || attractor_Count == 3 )
            {
                float3 att_1_Dir = normalize((att_1 - particles[index].position));
                float att_1_dist = distance(att_1, particles[index].position);
                deltVel = targetStrength * att_1_Dir * deltaTime / att_1_dist 
                         - targetStrength * zero_mirror_radius * att_1_Dir * deltaTime/(att_1_dist*att_1_dist);

                velTemp += deltVel;

                if(attractor_Count == 3 )
                {
                    float3 att_2_Dir = normalize((att_2 - particles[index].position));
                    float att_2_dist = distance(att_2, particles[index].position);
               
                    deltVel = targetStrength * att_2_Dir * deltaTime / att_2_dist 
                             - targetStrength * zero_mirror_radius * att_2_Dir * deltaTime/(att_2_dist*att_2_dist);

                    velTemp += deltVel;
                }
            }
            //float dotVels = dot(normalize(velTemp), normalize(particles[index].velocity));

	        particles[index].position_last = particles[index].position;
            particles[index].velocity = velTemp;
            particles[index].position += particles[index].velocity * deltaTime;         
        }

 

001a