A component holding one or more Joint3D, defining connections between a 3D Physics Body and anchors according to velocity and/or position constraints.
More...
|
void | AddJoint (FrameBase f, ref Joint3D joint) |
| Adds a Joint3D to the component. If the buffer is at full Capacity, a new buffer will be allocated with double the capacity and existing entries are copied over. In that case, the previous buffer is not disposed immediately and cached pointers are still valid, although outdated. More...
|
|
JointsIterator3D | GetIterator (FrameBase f, bool reverseOrder=true) |
| Gets an auxiliary struct to iterate over the joints in this component. See also TryGetJoints and GetJoints to have direct access to the buffer. More...
|
|
Joint3D * | GetJoints (FrameBase f, out Int32 count) |
| Gets the currently allocated buffer for the component joints. See also GetIterator to iterate over the buffer with an auxiliary structure. More...
|
|
void | RemoveAt (FrameBase f, int index) |
| Removes the joint at the specified index of the component's joints buffer, while keeping the order of the remaining objects. If the remaining elements do not need to be kept in order, RemoveAtUnordered is a cheaper option. More...
|
|
void | RemoveAtUnordered (FrameBase f, int index) |
| Removes the joint at the specified index of the component's joints buffer. The order of the elements with indices greater than index is not kept. If the order must be kept, use RemoveAt instead. More...
|
|
bool | RemoveJoints (FrameBase f, int? userTag=null) |
| Removes all joints in the component that have a Joint3D.UserTag field matching the specified userTag . If none is specified, all joints are removed. More...
|
|
bool | TryGetJoints (FrameBase f, out Joint3D *joints, out Int32 count) |
| Gets the currently allocated buffer for the component joints, if it has one. See also GetIterator to iterate over the buffer with an auxiliary structure. More...
|
|
A component holding one or more Joint3D, defining connections between a 3D Physics Body and anchors according to velocity and/or position constraints.
Gets an auxiliary struct to iterate over the joints in this component. See also TryGetJoints and GetJoints to have direct access to the buffer.
If new elements are added while iterating and this causes the buffer to be expanded, the iterator will keep iterating over the previous buffer, which is not immediately disposed (see AddJoint). In this case, further changes to elements in the buffer being iterated will not modify the elements on the new buffer. Hence, the addition of elements while iterating is not recommended, unless the access to the elements are read-only.
- Parameters
-
f | The current frame. |
reverseOrder | If the buffer elements should be iterated in reverse order. If true , allows the removal of elements while iterating without it causing some elements to be skipped. |
- Returns
- A JointsIterator3D for the buffer of joints in this component.
var jointsComponent = f.Unsafe.GetPointer<PhysicsJoints3D>(entity);
var jointsIterator = jointsComponent->GetIterator(f);
while (jointsIterator.MoveNext()) {
jointsIterator.CurrentUnsafe->Enabled = <see langword="true"/>;
var jointCopy = jointsIterator.Current;
Assert.Check(jointCopy.Enabled);
if (jointCopy.Type == Physics3D.JointType3D.None) {
jointsComponent->RemoveAtUnordered(f, jointsIterator.CurrentIndex);
}
}