Hydrogen Framework  1.3.1
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Hydrogen.Threading.Jobs.MeshCombiner Class Reference

A Multi-Threaded Mesh Combiner that runs in another thread. (Yes! It is just that cool!) More...

+ Inheritance diagram for Hydrogen.Threading.Jobs.MeshCombiner:

Classes

class  BufferedMesh
 A thread safe representation of a Mesh. More...
 
class  MeshInput
 Mesh Input Format More...
 
class  MeshObject
 Mesh Object Format More...
 
class  MeshOutput
 Mesh Output Format More...
 
class  TransitionMesh
 Transition Stage Mesh More...
 
class  TransitionMeshSorter
 A class defining how to sort TransitionMeshes. More...
 

Public Member Functions

int AddMaterial (UnityEngine.Material material)
 Add a Material to the Material reference Dictionary. More...
 
int AddMaterial (int code, UnityEngine.Material material)
 Add a Material to the Material reference Dictionary with a specific code. More...
 
int[] AddMaterials (UnityEngine.Material[] materials)
 Add an array of Material(s) to the reference Dictionary. More...
 
bool AddMesh (MeshFilter meshFilter, Renderer renderer, Matrix4x4 worldMatrix)
 Add a Unity based Mesh into the MeshCombiner. More...
 
bool AddMesh (MeshInput meshInput)
 Adds an existing MeshInput into the MeshCombiner. More...
 
void ClearMaterials ()
 Clear the Material reference Dictionary. More...
 
void ClearMeshes ()
 Clear the all Mesh data inside of the MeshCombiner. More...
 
int Combine (Action< int, MeshOutput[]> onFinished)
 Start the actual threaded process to combine MeshInput data currently added to the MeshCombiner. More...
 
MeshInput CreateMeshInput (MeshFilter meshFilter, Renderer renderer, Matrix4x4 worldMatrix)
 Creates a MeshInput from the passed arguements. More...
 
MeshInput[] CreateMeshInputs (MeshFilter[] meshFilters, Renderer[] renderers, Matrix4x4[] worldMatrices)
 Creates MeshInput(s) from the passed arguement arrays. More...
 
MeshObject CreateMeshObject (MeshOutput meshOutput)
 Creates a MeshObject from the MeshOutput (Instanced Materials). More...
 
MeshObject CreateMeshObject (MeshOutput meshOutput, bool instanceMaterials)
 Creates a MeshObject from the passed MeshOutput. More...
 
MeshObject[] CreateMeshObjects (MeshOutput[] meshOutputs)
 Creates MeshObject(s) from the passed MeshOutput(s) (Instanced Materials). More...
 
MeshObject[] CreateMeshObjects (MeshOutput[] meshOutputs, bool instanceMaterials)
 Creates MeshObject(s) from the passed MeshOutput(s). More...
 
UnityEngine.Material[] GetMaterials (int[] codes)
 Gets an array of Materials. More...
 
UnityEngine.Material[] GetMaterialInstances (int[] codes)
 Gets an array of Materials (Instanced). More...
 
bool RemoveMaterial (UnityEngine.Material material)
 Remove a UnityEngine.Material from the Material reference Dictionary. More...
 
bool RemoveMesh (MeshFilter meshFilter, Renderer renderer, Matrix4x4 worldMatrix)
 Removes a Unity based Mesh from the MeshInput list to be processed. More...
 
bool RemoveMesh (MeshInput meshInput)
 Removes a MeshInput from the MeshInput list to be processed. More...
 
- Public Member Functions inherited from Hydrogen.Threading.ThreadPoolJob
override void Start (bool backgroundThread, System.Threading.ThreadPriority priority)
 Sends the work process to the ThreadPool for starting when resources are available, This needs to initialize the WaitCallback with the Run function. More...
 
- Public Member Functions inherited from Hydrogen.Threading.JobBase
virtual bool Check ()
 Checks if the Job is done, and facilitates calling OnFinished when completed. More...
 

Protected Member Functions

sealed override void ThreadedFunction ()
 This is the main workhorse method which runs in another thread. More...
 
sealed override void OnFinished ()
 Executed when the ThreadedFunction is finished (sort of), sending our MeshOutput(s) back to Unity for our coroutine to use. More...
 
- Protected Member Functions inherited from Hydrogen.Threading.JobBase
virtual void Abort ()
 Abort the Job (as best we can). More...
 
virtual void Run (object state)
 The launcher of the ThreadedFunction, used to handle the state as well. More...
 

Properties

Dictionary< int,
UnityEngine.Material > 
MaterialsLookup [get]
 Gets the current Material reference Dictionary. More...
 
List< MeshInputMeshInputs [get]
 Gets the MeshInput(s) list to be used to create TransitionMeshes during the processing. More...
 
int MeshInputCount [get]
 The total number of MeshInput(s) currently in the system. More...
 
List< MeshOutputMeshOutputs [get]
 Gets the MeshOutput(s) list, often used during post processing to create meshes. More...
 
int MeshOutputCount [get]
 The total number of MeshOutput(s) currently generated in the system. More...
 
- Properties inherited from Hydrogen.Threading.JobBase
bool IsBusy [get, set]
 Is the Job busy working? More...
 
bool IsDone [get, set]
 Is the Job done? More...
 
bool FiredOnFinished [get, set]
 Has the OnFinished been called yet? More...
 

Detailed Description

A Multi-Threaded Mesh Combiner that runs in another thread. (Yes! It is just that cool!)

Definition at line 38 of file MeshCombiner.cs.

Member Function Documentation

int Hydrogen.Threading.Jobs.MeshCombiner.AddMaterial ( UnityEngine.Material  material)

Add a Material to the Material reference Dictionary.

This can only be used from within Unity's main thread.

Returns
The DataHashCode
Parameters
materialThe UnityEngine.Material to be added.

Definition at line 114 of file MeshCombiner.cs.

115  {
116  return AddMaterial (material.GetDataHashCode (), material);
117 
118  }
int AddMaterial(UnityEngine.Material material)
Add a Material to the Material reference Dictionary.
int Hydrogen.Threading.Jobs.MeshCombiner.AddMaterial ( int  code,
UnityEngine.Material  material 
)

Add a Material to the Material reference Dictionary with a specific code.

This can only be used from within Unity's main thread.

Returns
The DataHashCode
Parameters
codeThe code to store as the reference for the Material.
materialThe UnityEngine.Material to be added.

Definition at line 127 of file MeshCombiner.cs.

128  {
129  if (!_materialLookup.ContainsKey (code)) {
130  _materialLookup.Add (code, material);
131  }
132  return code;
133  }
int [] Hydrogen.Threading.Jobs.MeshCombiner.AddMaterials ( UnityEngine.Material[]  materials)

Add an array of Material(s) to the reference Dictionary.

Returns
The DataHashCode(s).
Parameters
materialsThe UnityEngine.Material(s) to be added..

Definition at line 140 of file MeshCombiner.cs.

141  {
142  var hashcodes = new int[materials.Length];
143  for (var x = 0; x < materials.Length; x++) {
144  // Add if we need it
145  hashcodes [x] = AddMaterial (materials [x].GetDataHashCode (), materials [x]);
146  }
147  return hashcodes;
148  }
int AddMaterial(UnityEngine.Material material)
Add a Material to the Material reference Dictionary.
bool Hydrogen.Threading.Jobs.MeshCombiner.AddMesh ( MeshFilter  meshFilter,
Renderer  renderer,
Matrix4x4  worldMatrix 
)

Add a Unity based Mesh into the MeshCombiner.

This can only be used from within Unity's main thread.

Returns
true, if mesh was added, false otherwise.

Definition at line 155 of file MeshCombiner.cs.

156  {
157  return AddMesh (CreateMeshInput (meshFilter, renderer, worldMatrix));
158  }
bool AddMesh(MeshFilter meshFilter, Renderer renderer, Matrix4x4 worldMatrix)
Add a Unity based Mesh into the MeshCombiner.
MeshInput CreateMeshInput(MeshFilter meshFilter, Renderer renderer, Matrix4x4 worldMatrix)
Creates a MeshInput from the passed arguements.
bool Hydrogen.Threading.Jobs.MeshCombiner.AddMesh ( MeshInput  meshInput)

Adds an existing MeshInput into the MeshCombiner.

This can be done without Unity's main thread, if you have access to the data already. Just need to make sure that the material codes are set correctly.

Returns
true, if MeshInput was added, false otherwise.
Parameters
meshInputThe MeshInput to add.

Definition at line 169 of file MeshCombiner.cs.

170  {
171  if (!_meshInputs.Contains (meshInput)) {
172  _meshInputs.Add (meshInput);
173  return true;
174  }
175  return false;
176  }
void Hydrogen.Threading.Jobs.MeshCombiner.ClearMaterials ( )

Clear the Material reference Dictionary.

Definition at line 181 of file MeshCombiner.cs.

182  {
183  _materialLookup.Clear ();
184  }
void Hydrogen.Threading.Jobs.MeshCombiner.ClearMeshes ( )

Clear the all Mesh data inside of the MeshCombiner.

Definition at line 189 of file MeshCombiner.cs.

190  {
191  _meshInputs.Clear ();
192  _meshOutputs.Clear ();
193  _transitionMeshes.Clear ();
194  }
int Hydrogen.Threading.Jobs.MeshCombiner.Combine ( Action< int, MeshOutput[]>  onFinished)

Start the actual threaded process to combine MeshInput data currently added to the MeshCombiner.

Parameters
onFinishedThe method to call when completed inside of Unity's main thread.

Definition at line 200 of file MeshCombiner.cs.

201  {
202  // Generate Hash Code
203  _hash = (Time.time + UnityEngine.Random.Range (0, 100)).GetHashCode ();
204 
205  // Start the threaded prcess
206  if (onFinished != null) {
207  _callback = onFinished;
208  }
209 
210  // These values mean nothing in this case as we don't assign any of it to the ThreadPool tasks.
211  Start (true, System.Threading.ThreadPriority.Normal);
212 
213  return _hash;
214  }
override void Start(bool backgroundThread, System.Threading.ThreadPriority priority)
Sends the work process to the ThreadPool for starting when resources are available, This needs to initialize the WaitCallback with the Run function.
MeshInput Hydrogen.Threading.Jobs.MeshCombiner.CreateMeshInput ( MeshFilter  meshFilter,
Renderer  renderer,
Matrix4x4  worldMatrix 
)

Creates a MeshInput from the passed arguements.

This can only be used from within Unity's main thread.

Returns
The created MeshInput
Parameters
meshFilterThe source Mesh's MeshFilter.
rendererThe source Mesh's Renderer.
worldMatrixThe source Mesh's World Matrix

Definition at line 224 of file MeshCombiner.cs.

225  {
226  var newMeshInput = new MeshInput ();
227 
228  newMeshInput.Mesh = new BufferedMesh ();
229  newMeshInput.Mesh.Name = meshFilter.name;
230  newMeshInput.Mesh.Vertices = meshFilter.sharedMesh.vertices;
231  newMeshInput.Mesh.Normals = meshFilter.sharedMesh.normals;
232  newMeshInput.Mesh.Colors = meshFilter.sharedMesh.colors;
233  newMeshInput.Mesh.Tangents = meshFilter.sharedMesh.tangents;
234  newMeshInput.Mesh.UV = meshFilter.sharedMesh.uv;
235  newMeshInput.Mesh.UV1 = meshFilter.sharedMesh.uv1;
236  newMeshInput.Mesh.UV2 = meshFilter.sharedMesh.uv2;
237 
238  newMeshInput.Mesh.Topology = new MeshTopology[meshFilter.sharedMesh.subMeshCount];
239 
240  for (var i = 0; i < meshFilter.sharedMesh.subMeshCount; i++) {
241  newMeshInput.Mesh.Topology [i] = meshFilter.sharedMesh.GetTopology (i);
242 
243  // Check for Unsupported Mesh Topology
244  switch (newMeshInput.Mesh.Topology [i]) {
245  case MeshTopology.Lines:
246  case MeshTopology.LineStrip:
247  case MeshTopology.Points:
248  Debug.LogWarning ("The MeshCombiner does not support this meshes (" +
249  newMeshInput.Mesh.Name + "topology (" + newMeshInput.Mesh.Topology [i] + ")");
250  break;
251  }
252  newMeshInput.Mesh.Indexes.Add (meshFilter.sharedMesh.GetIndices (i));
253  }
254 
255  // Create Materials
256  newMeshInput.Materials = AddMaterials (renderer.sharedMaterials);
257 
258 
259  // Determine Inversion of Scale
260  // Don't Scale (NNP, PPP, PNN, NPN)
261  Vector3 scaleTest = meshFilter.gameObject.transform.localScale;
262 
263  bool invertedX = (scaleTest.x < 0f);
264  bool invertedY = (scaleTest.y < 0f);
265  bool invertedZ = (scaleTest.z < 0f);
266 
267  if ((invertedX && invertedY && invertedZ) ||
268  (invertedX && !invertedY && !invertedZ) ||
269  (!invertedX && invertedY && !invertedZ) ||
270  (!invertedX && !invertedY && invertedZ)) {
271  newMeshInput.ScaleInverted = true;
272  }
273  newMeshInput.WorldMatrix = worldMatrix;
274 
275  return newMeshInput;
276  }
int[] AddMaterials(UnityEngine.Material[] materials)
Add an array of Material(s) to the reference Dictionary.
MeshInput [] Hydrogen.Threading.Jobs.MeshCombiner.CreateMeshInputs ( MeshFilter[]  meshFilters,
Renderer[]  renderers,
Matrix4x4[]  worldMatrices 
)

Creates MeshInput(s) from the passed arguement arrays.

This can only be used from within Unity's main thread.

Returns
The created MeshInput(s)
Parameters
meshFiltersThe source Meshes MeshFilters.
renderersThe source Meshes Renderers.
worldMatricesThe source Meshes World Matrices

Definition at line 286 of file MeshCombiner.cs.

287  {
288  // Create our holder
289  var meshInputs = new MeshInput[meshFilters.Length];
290 
291  // Lazy way of making a whole bunch.
292  for (int i = 0; i < meshFilters.Length; i++) {
293  meshInputs [i] = CreateMeshInput (meshFilters [i], renderers [i], worldMatrices [i]);
294  }
295 
296  // Send it back!
297  return meshInputs;
298  }
MeshInput CreateMeshInput(MeshFilter meshFilter, Renderer renderer, Matrix4x4 worldMatrix)
Creates a MeshInput from the passed arguements.
MeshObject Hydrogen.Threading.Jobs.MeshCombiner.CreateMeshObject ( MeshOutput  meshOutput)

Creates a MeshObject from the MeshOutput (Instanced Materials).

Returns
The created MeshObject.
Parameters
meshOutputThe source MeshOutput to use in creating the MeshObject.

Definition at line 305 of file MeshCombiner.cs.

306  {
307  return CreateMeshObject (meshOutput, true);
308  }
MeshObject CreateMeshObject(MeshOutput meshOutput)
Creates a MeshObject from the MeshOutput (Instanced Materials).
MeshObject Hydrogen.Threading.Jobs.MeshCombiner.CreateMeshObject ( MeshOutput  meshOutput,
bool  instanceMaterials 
)

Creates a MeshObject from the passed MeshOutput.

Returns
The created MeshObject.
Parameters
meshOutputThe source MeshOutput to use in creating the MeshObject.
instanceMaterialsIf set to true materials will be instanced.

Definition at line 316 of file MeshCombiner.cs.

317  {
318  var meshObject = new MeshObject ();
319 
320  meshObject.Materials = instanceMaterials ?
321  GetMaterialInstances (meshOutput.Materials.ToArray ()) :
322  GetMaterials (meshOutput.Materials.ToArray ());
323 
324  meshObject.Mesh = new UnityEngine.Mesh ();
325  meshObject.Mesh.vertices = meshOutput.Vertices.ToArray ();
326  meshObject.Mesh.name = "Combined Mesh (" + meshObject.Mesh.vertices.GetHashCode () + ")";
327 
328  // If there are normals we need to assign them to the mesh.
329  if (meshOutput.Normals != null) {
330  meshObject.Mesh.normals = meshOutput.Normals.ToArray ();
331  }
332 
333  // Much like normals, if we've got tangents lets throw them on there too.
334  if (meshOutput.Tangents != null) {
335  meshObject.Mesh.tangents = meshOutput.Tangents.ToArray ();
336  }
337 
338  // How about some vertex color data? Sounds like a good idea to add that too.
339  if (meshOutput.Colors != null) {
340  meshObject.Mesh.colors = meshOutput.Colors.ToArray ();
341  }
342 
343  // Better make those textures work too while were at it.
344  if (meshOutput.UV != null) {
345  meshObject.Mesh.uv = meshOutput.UV.ToArray ();
346  }
347 
348  // How about some more UV's?
349  if (meshOutput.UV1 != null) {
350  meshObject.Mesh.uv1 = meshOutput.UV1.ToArray ();
351  }
352 
353  // Lightmapping UV's anyone?
354  if (meshOutput.UV2 != null) {
355  meshObject.Mesh.uv2 = meshOutput.UV2.ToArray ();
356  }
357 
358 
359  meshObject.Mesh.subMeshCount = meshOutput.Indexes.Count;
360  for (int i = 0; i < meshOutput.Indexes.Count; i++) {
361  meshObject.Mesh.SetIndices (meshOutput.Indexes [i].ToArray (), MeshTopology.Triangles, i);
362  }
363 
364  // Recalculate mesh's bounds for fun.
365  meshObject.Mesh.RecalculateBounds ();
366 
367 
368  // Return our processed object.
369  return meshObject;
370  }
UnityEngine.Material[] GetMaterials(int[] codes)
Gets an array of Materials.
UnityEngine.Material[] GetMaterialInstances(int[] codes)
Gets an array of Materials (Instanced).
MeshObject [] Hydrogen.Threading.Jobs.MeshCombiner.CreateMeshObjects ( MeshOutput[]  meshOutputs)

Creates MeshObject(s) from the passed MeshOutput(s) (Instanced Materials).

Returns
The created MeshObject(s).
Parameters
meshOutputsThe source MeshOutput(s) to use in creating the MeshObject(s).

Definition at line 377 of file MeshCombiner.cs.

378  {
379  return CreateMeshObjects (meshOutputs, true);
380  }
MeshObject[] CreateMeshObjects(MeshOutput[] meshOutputs)
Creates MeshObject(s) from the passed MeshOutput(s) (Instanced Materials).
MeshObject [] Hydrogen.Threading.Jobs.MeshCombiner.CreateMeshObjects ( MeshOutput[]  meshOutputs,
bool  instanceMaterials 
)

Creates MeshObject(s) from the passed MeshOutput(s).

Returns
The created MeshObject(s).
Parameters
meshOutputsThe source MeshOutput(s) to use in creating the MeshObject(s).
instanceMaterialsIf set to true materials will be instanced.

Definition at line 388 of file MeshCombiner.cs.

389  {
390  MeshObject[] meshObjects = new MeshObject[meshOutputs.Length];
391  for (int i = 0; i < meshOutputs.Length; i++) {
392  meshObjects [i] = CreateMeshObject (meshOutputs [i], instanceMaterials);
393  }
394  return meshObjects;
395  }
MeshObject CreateMeshObject(MeshOutput meshOutput)
Creates a MeshObject from the MeshOutput (Instanced Materials).
UnityEngine.Material [] Hydrogen.Threading.Jobs.MeshCombiner.GetMaterialInstances ( int[]  codes)

Gets an array of Materials (Instanced).

Returns
The referenced Materials instanced.
Parameters
codesAn array of Material DataHashCodes.

Definition at line 416 of file MeshCombiner.cs.

417  {
418  var materials = new UnityEngine.Material[codes.Length];
419  for (int x = 0; x < codes.Length; x++) {
420  materials [x] = new UnityEngine.Material (_materialLookup [codes [x]]);
421  materials [x].name += " Instance";
422  }
423  return materials;
424  }
UnityEngine.Material [] Hydrogen.Threading.Jobs.MeshCombiner.GetMaterials ( int[]  codes)

Gets an array of Materials.

Returns
The referenced Materials.
Parameters
codesAn array of Material DataHashCodes.

Definition at line 402 of file MeshCombiner.cs.

403  {
404  var materials = new UnityEngine.Material[codes.Length];
405  for (int x = 0; x < codes.Length; x++) {
406  materials [x] = _materialLookup [codes [x]];
407  }
408  return materials;
409  }
sealed override void Hydrogen.Threading.Jobs.MeshCombiner.OnFinished ( )
protectedvirtual

Executed when the ThreadedFunction is finished (sort of), sending our MeshOutput(s) back to Unity for our coroutine to use.

Can use Unity API.

Reimplemented from Hydrogen.Threading.JobBase.

Definition at line 560 of file MeshCombiner.cs.

561  {
562  // Callback
563  if (_callback != null)
564  _callback (_hash, _meshOutputs.ToArray ());
565  }
bool Hydrogen.Threading.Jobs.MeshCombiner.RemoveMaterial ( UnityEngine.Material  material)

Remove a UnityEngine.Material from the Material reference Dictionary.

Returns
true, if UnityEngine.Material was removed, false otherwise.
Parameters
materialThe target UnityEngine.Material to be removed.

Definition at line 431 of file MeshCombiner.cs.

432  {
433  int check = material.GetDataHashCode ();
434  if (_materialLookup.ContainsKey (check)) {
435  _materialLookup.Remove (check);
436  return true;
437  }
438  return false;
439  }
bool Hydrogen.Threading.Jobs.MeshCombiner.RemoveMesh ( MeshFilter  meshFilter,
Renderer  renderer,
Matrix4x4  worldMatrix 
)

Removes a Unity based Mesh from the MeshInput list to be processed.

This is useful if you are caching MeshInputs for future use, and just want to remove a mesh as its no longer being combined. Open worlds may find this very useful. This can only be used from within Unity's main thread.

Returns
true, if the Unity based Mesh was removed, false otherwise.
Parameters
meshFilterThe Mesh's MeshFilter.
rendererThe Mesh's Renderer.
worldMatrixThe Mesh's World Matrix

Definition at line 453 of file MeshCombiner.cs.

454  {
455  return RemoveMesh (CreateMeshInput (meshFilter, renderer, worldMatrix));
456  }
MeshInput CreateMeshInput(MeshFilter meshFilter, Renderer renderer, Matrix4x4 worldMatrix)
Creates a MeshInput from the passed arguements.
bool RemoveMesh(MeshFilter meshFilter, Renderer renderer, Matrix4x4 worldMatrix)
Removes a Unity based Mesh from the MeshInput list to be processed.
bool Hydrogen.Threading.Jobs.MeshCombiner.RemoveMesh ( MeshInput  meshInput)

Removes a MeshInput from the MeshInput list to be processed.

This is useful if you are caching MeshInputs for future use, and just want to remove a mesh as its no longer being combined. Open worlds may find this very useful.

Returns
true, if the MeshInput was removed, false otherwise.
Parameters
meshInputThe MeshInput to be removed.

Definition at line 467 of file MeshCombiner.cs.

468  {
469  if (_meshInputs.Contains (meshInput)) {
470  _meshInputs.Remove (meshInput);
471  return true;
472  }
473  return false;
474 
475  }
sealed override void Hydrogen.Threading.Jobs.MeshCombiner.ThreadedFunction ( )
protectedvirtual

This is the main workhorse method which runs in another thread.

Takes the MeshInput(s) and converts them to TransitionMeshes in parallel. It then creates optimized MeshOutput(s) for use later or through the callback.

Reimplemented from Hydrogen.Threading.JobBase.

Definition at line 484 of file MeshCombiner.cs.

485  {
486  // Empty out preexisting parsed data
487  _transitionMeshes.Clear ();
488  _meshOutputs.Clear ();
489 
490  // Clever forker solution since we don't have Parallel.ForEach support available.
491  var parallelTasks = new Forker ();
492  foreach (var meshInput in _meshInputs) {
493  var tempInput = meshInput;
494  parallelTasks.Fork (delegate {
495  CreateTransitionMesh (tempInput);
496  });
497  }
498  parallelTasks.Join ();
499 
500  // Sort the meshes in order
501  _transitionMeshes.Sort (new TransitionMeshSorter ());
502 
503  var meshOutput = new MeshOutput ();
504  int bitmask = _transitionMeshes [0].GetBitMask ();
505 
506 
507  foreach (var transitionMesh in _transitionMeshes) {
508  if (transitionMesh.GetBitMask () != bitmask ||
509  (transitionMesh.VertexCount + meshOutput.VertexCount) > Mesh.VerticesArrayLimit) {
510  _meshOutputs.Add (meshOutput);
511  meshOutput = new MeshOutput ();
512  }
513 
514  var baseIndex = meshOutput.VertexCount;
515  meshOutput.VertexCount += transitionMesh.VertexCount;
516  meshOutput.SortedSources.Add (transitionMesh);
517 
518  meshOutput.Vertices.AddRange (transitionMesh.Vertices);
519 
520  if (transitionMesh.Normals != null) {
521  meshOutput.Normals.AddRange (transitionMesh.Normals);
522  }
523 
524  if (transitionMesh.Colors != null) {
525  meshOutput.Colors.AddRange (transitionMesh.Colors);
526  }
527 
528  if (transitionMesh.Tangents != null) {
529  meshOutput.Tangents.AddRange (transitionMesh.Tangents);
530  }
531 
532  if (transitionMesh.UV != null) {
533  meshOutput.UV.AddRange (transitionMesh.UV);
534  }
535 
536  if (transitionMesh.UV1 != null) {
537  meshOutput.UV1.AddRange (transitionMesh.UV1);
538  }
539 
540  if (transitionMesh.UV2 != null) {
541  meshOutput.UV2.AddRange (transitionMesh.UV2);
542  }
543 
544  var indexes = meshOutput.GetSubMesh (transitionMesh.Material);
545  indexes.Capacity = indexes.Count + transitionMesh.IndexCount;
546  for (var i = 0; i < transitionMesh.IndexCount; i++) {
547  indexes.Add (baseIndex + transitionMesh.Indexes [i]);
548  }
549 
550  bitmask = transitionMesh.GetBitMask ();
551  }
552  _meshOutputs.Add (meshOutput);
553  }

Property Documentation

Dictionary<int, UnityEngine.Material> Hydrogen.Threading.Jobs.MeshCombiner.MaterialsLookup
get

Gets the current Material reference Dictionary.

The Material Reference Dictionary.

Definition at line 72 of file MeshCombiner.cs.

int Hydrogen.Threading.Jobs.MeshCombiner.MeshInputCount
get

The total number of MeshInput(s) currently in the system.

The MeshInput(s) Count.

Definition at line 88 of file MeshCombiner.cs.

List<MeshInput> Hydrogen.Threading.Jobs.MeshCombiner.MeshInputs
get

Gets the MeshInput(s) list to be used to create TransitionMeshes during the processing.

The MeshInput(s)

Definition at line 80 of file MeshCombiner.cs.

int Hydrogen.Threading.Jobs.MeshCombiner.MeshOutputCount
get

The total number of MeshOutput(s) currently generated in the system.

The MeshOutput(s) Count.

Definition at line 104 of file MeshCombiner.cs.

List<MeshOutput> Hydrogen.Threading.Jobs.MeshCombiner.MeshOutputs
get

Gets the MeshOutput(s) list, often used during post processing to create meshes.

The MeshOutput(s)

Definition at line 96 of file MeshCombiner.cs.