I’m trying to create a conveyor belt. I added another struct to the body ConveyorSettings,.
At the IntegrateBodiesAndUpdateBoundingBoxes, it sets the velocity.Linear before the PoseIntegration.Integrate most of the time 0 because the conveyor isn’t moving, then set the conveyor velocity to the velocity.Linear to simulate the belt velocity, propagating the movement to other objects. It works but it has a problem, if the conveyor is carrying an object and the belt stop moving the payload will stop and after short amount of time the payload will sleep. If the belt is restarted the payload wouldn’t be affected because it is sleeping.
Is there a better way to implement the conveyor?
For performance it is good that the payload sleeps. Because the payload is sleeping I can’t use collision detection to wake them. What other option do I have to wake up the payload?
Kind Regards
Code: Select all
unsafe void IntegrateBodiesAndUpdateBoundingBoxes(int startIndex, int endIndex, float dt, ref BoundingBoxBatcher boundingBoxBatcher, int workerIndex)
{
…
ref var baseConveyorSettings = ref bodies.ActiveSet.ConveyorSettings[0];
for (int i = startIndex; i < endIndex; ++i)
{
ref var pose = ref Unsafe.Add(ref basePoses, i);
ref var velocity = ref Unsafe.Add(ref baseVelocities, i);
ref var conveyorSettings = ref Unsafe.Add(ref baseConveyorSettings, i);
if (conveyorSettings.IsLinearConveyor)
{
velocity.Linear = conveyorSettings.LinearVelocity;
}
var previousOrientation = pose.Orientation; //This is unused if conservation of angular momentum is disabled... compiler *may* remove it...
PoseIntegration.Integrate(pose, velocity, dt, out pose);
…
inertia.InverseMass = localInertia.InverseMass;
if (conveyorSettings.IsLinearConveyor)
{
velocity.Linear = conveyorSettings.LinearVelocity + conveyorSettings.ConveyorVelocity;
}
...
Note the conveyor is easily implemented in bepu 1 adding an offset at EntityBase-> void IPositionUpdateable.PreUpdatePosition(float dt)
Code: Select all
if (PositionUpdateMode == PositionUpdateMode.Discrete)
{
var velocity = IsLinearConveyor ? linearVelocity - LinearOffset : linearVelocity;