|
|
|
|
|
|
//Will be called by the PhysicsConversionSystem
|
|
|
|
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) |
|
|
|
{ |
|
|
|
//Calculat all initial values
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Add data needed for buoyancy
|
|
|
|
BuoyantData data = new BuoyantData(); |
|
|
|
data.type = _buoyancyType; |
|
|
|
data.voxelResolution = voxelResolution; |
|
|
|
|
|
|
data.baseAngularDrag = baseAngularDrag; |
|
|
|
dstManager.AddComponentData(entity, data); |
|
|
|
|
|
|
|
|
|
|
|
dstManager.AddBuffer<VoxelOffset>(entity); |
|
|
|
dstManager.AddBuffer<VoxelHeight>(entity); |
|
|
|
|
|
|
|
//Add center of mass. This is why we had to use a custom conversion system since we needed the physics stuff to be converted before this step
|
|
|
|
|
|
|
|
dstManager.AddBuffer<VoxelOffset>(entity); |
|
|
|
dstManager.AddBuffer<VoxelHeight>(entity); |
|
|
|
|
|
|
|
//Initialize the voxel and height buffers
|
|
|
|
//Add engine position as first point
|
|
|
|
//offsets.Add(new VoxelOffset { Value = engine.enginePosition - centerOfMass });
|
|
|
|
//heights.Add(new VoxelHeight { Value = float3.zero });
|
|
|
|
|
|
|
|
//Add the rest of the positions
|
|
|
|
offsets.Add(new VoxelOffset { Value = voxels[i] - centerOfMass });// transform.TransformPoint(voxels[i]) - transform.position }); // << Is this right?
|
|
|
|
offsets.Add(new VoxelOffset { Value = voxels[i] - centerOfMass });// transform.TransformPoint(voxels[i]) - transform.position }); // << Is this right?
|
|
|
|
body.Convert(conversionSystem.GetPrimaryEntity(body), dstManager, conversionSystem); |
|
|
|
//if (body)
|
|
|
|
body.Convert(conversionSystem.GetPrimaryEntity(body), dstManager, conversionSystem); |
|
|
|
engine.Convert(conversionSystem.GetPrimaryEntity(engine), dstManager, conversionSystem); |
|
|
|
if (engine) |
|
|
|
engine.Convert(conversionSystem.GetPrimaryEntity(engine), dstManager, conversionSystem); |
|
|
|
} |
|
|
|
|
|
|
|
struct DebugDrawing |
|
|
|