public void Init() { GetGridVel = GetGridVelFloat; SampleVel = SampleVelFloat; if (gridDim2[2] == 1) { SampleVel = SampleVelFloat; GetGridVel = GetGridVelFloatXY; } else { SampleVel = SampleVelFloat; GetGridVel = GetGridVelFloat; } smoke.Clear(); vel.Clear(); force.Clear(); grid.Clear(); pos.Clear(); psize.Clear(); color.Clear(); rot.Clear(); optvel.Clear(); }
public void Prepare(Matrix4x4 wltm) { if (optimized) { if (gridDim2[2] == 1) { SampleVel = SampleVelOpt; GetGridVel = GetGridVelOptXY; } else { SampleVel = SampleVelOpt; GetGridVel = GetGridVelOpt; } } else { if (gridDim2[2] == 1) { SampleVel = SampleVelFloat; GetGridVel = GetGridVelFloatXY; } else { SampleVel = SampleVelFloat; GetGridVel = GetGridVelFloat; } } //if ( optimized ) //{ //GetGridVel = GetGridVelOpt; //SampleVel = SampleVelOpt; //} //else //{ //GetGridVel = GetGridVelFloat; //SampleVel = SampleVelFloat; //} Matrix4x4 offtm = Matrix4x4.TRS((size * 0.5f) + offset, Quaternion.identity, Vector3.one); tm = offtm * wltm; invtm = tm.inverse; }
public void Optimize() { Vector3 max = Vector3.zero; if ( optvel == null ) optvel = new List<MegaFlowVector>(); optvel.Clear(); for ( int i = 0; i < vel.Count; i++ ) { Vector3 v = vel[i]; if ( Mathf.Abs(v.x) > max.x ) max.x = Mathf.Abs(v.x); if ( Mathf.Abs(v.y) > max.y ) max.y = Mathf.Abs(v.y); if ( Mathf.Abs(v.z) > max.z ) max.z = Mathf.Abs(v.z); } maxval = max; for ( int i = 0; i < vel.Count; i++ ) { MegaFlowVector mv = new MegaFlowVector(); Vector3 v = vel[i]; mv.x = (byte)(((v.x / maxval.x) + 1.0f) * 0.5f * 255.0f); mv.y = (byte)(((v.y / maxval.y) + 1.0f) * 0.5f * 255.0f); mv.z = (byte)(((v.z / maxval.z) + 1.0f) * 0.5f * 255.0f); optvel.Add(mv); } optimized = true; GetGridVel = GetGridVelOpt; SampleVel = SampleVelOpt; maxval *= 2.0f; vel.Clear(); GC.Collect(); }
public void Init() { GetGridVel = GetGridVelFloat; SampleVel = SampleVelFloat; smoke.Clear(); vel.Clear(); force.Clear(); grid.Clear(); pos.Clear(); psize.Clear(); color.Clear(); rot.Clear(); optvel.Clear(); }
public void Prepare(Matrix4x4 wltm) { if ( optimized ) { GetGridVel = GetGridVelOpt; SampleVel = SampleVelOpt; } else { GetGridVel = GetGridVelFloat; SampleVel = SampleVelFloat; } Matrix4x4 offtm = Matrix4x4.TRS((size * 0.5f) + offset, Quaternion.identity, Vector3.one); tm = offtm * wltm; invtm = tm.inverse; }
public void Optimize() { Vector3 max = Vector3.zero; if (optvel == null) { optvel = new List <MegaFlowVector>(); } optvel.Clear(); for (int i = 0; i < vel.Count; i++) { Vector3 v = vel[i]; if (Mathf.Abs(v.x) > max.x) { max.x = Mathf.Abs(v.x); } if (Mathf.Abs(v.y) > max.y) { max.y = Mathf.Abs(v.y); } if (Mathf.Abs(v.z) > max.z) { max.z = Mathf.Abs(v.z); } } maxval = max; for (int i = 0; i < vel.Count; i++) { MegaFlowVector mv = new MegaFlowVector(); Vector3 v = vel[i]; mv.x = (byte)(((v.x / maxval.x) + 1.0f) * 0.5f * 255.0f); mv.y = (byte)(((v.y / maxval.y) + 1.0f) * 0.5f * 255.0f); mv.z = (byte)(((v.z / maxval.z) + 1.0f) * 0.5f * 255.0f); optvel.Add(mv); } optimized = true; //GetGridVel = GetGridVelOpt; //SampleVel = SampleVelOpt; if (gridDim2[2] == 1) { SampleVel = SampleVelOpt; GetGridVel = GetGridVelOptXY; } else { SampleVel = SampleVelOpt; GetGridVel = GetGridVelOpt; } maxval *= 2.0f; vel.Clear(); GC.Collect(); }