public static BuildCollisionLayerConfig BuildCollisionLayer(EntityQuery query, ComponentSystemBase system) { var config = new BuildCollisionLayerConfig(); config.query = query; config.system = system; config.typeGroup = BuildCollisionLayerInternal.BuildLayerChunkTypeGroup(system); config.hasQueryData = true; config.settings = BuildCollisionLayerConfig.defaultSettings; config.count = query.CalculateEntityCount(); return(config); }
public static void RunImmediate(this BuildCollisionLayerConfig config, out CollisionLayer layer, Allocator allocator) { config.ValidateSettings(); if (config.hasQueryData) { ThrowEntityQueryInImmediateMode(); layer = default; } else if (config.hasAabbsArray && config.hasBodiesArray) { layer = new CollisionLayer(config.bodies.Length, config.settings, allocator); if (config.hasRemapSrcIndices) { BuildCollisionLayerInternal.BuildImmediate(layer, config.remapSrcIndices, config.bodies, config.aabbs); } else { var remapArray = new NativeArray <int>(layer.Count, Allocator.Temp, NativeArrayOptions.UninitializedMemory); BuildCollisionLayerInternal.BuildImmediate(layer, remapArray, config.bodies, config.aabbs); } } else if (config.hasBodiesArray) { layer = new CollisionLayer(config.bodies.Length, config.settings, allocator); if (config.hasRemapSrcIndices) { BuildCollisionLayerInternal.BuildImmediate(layer, config.remapSrcIndices, config.bodies, config.aabbs); } else { var remapArray = new NativeArray <int>(layer.Count, Allocator.Temp, NativeArrayOptions.UninitializedMemory); BuildCollisionLayerInternal.BuildImmediate(layer, remapArray, config.bodies, config.aabbs); } } else { ThrowUnknownConfiguration(); layer = default; } }