public CollisionLayer(CollisionLayer sourceLayer, Allocator allocator) { worldMin = sourceLayer.worldMin; worldAxisStride = sourceLayer.worldAxisStride; worldBucketCountPerAxis = sourceLayer.worldBucketCountPerAxis; layerType = sourceLayer.layerType; bucketStartsAndCounts = new NativeArray <int2>(sourceLayer.bucketStartsAndCounts, allocator); xmins = new NativeArray <float>(sourceLayer.xmins, allocator); xmaxs = new NativeArray <float>(sourceLayer.xmaxs, allocator); yzminmaxs = new NativeArray <float4>(sourceLayer.yzminmaxs, allocator); bodies = new NativeArray <ColliderBody>(sourceLayer.bodies, allocator); }
//Todo: World settings? internal CollisionLayer(int bodyCount, CollisionLayerSettings settings, Allocator allocator) { worldMin = settings.worldAABB.min; worldAxisStride = (settings.worldAABB.max - worldMin) / settings.worldBucketCountPerAxis; worldBucketCountPerAxis = settings.worldBucketCountPerAxis; layerType = settings.layerType; bucketStartsAndCounts = new NativeArray <int2>(settings.worldBucketCountPerAxis.x * settings.worldBucketCountPerAxis.y * settings.worldBucketCountPerAxis.z + 1, allocator, NativeArrayOptions.UninitializedMemory); xmins = new NativeArray <float>(bodyCount, allocator, NativeArrayOptions.UninitializedMemory); xmaxs = new NativeArray <float>(bodyCount, allocator, NativeArrayOptions.UninitializedMemory); yzminmaxs = new NativeArray <float4>(bodyCount, allocator, NativeArrayOptions.UninitializedMemory); bodies = new NativeArray <ColliderBody>(bodyCount, allocator, NativeArrayOptions.UninitializedMemory); }