60 eINVALID_SUBSTEP_GROUP = 0xff
64 : mNbComponents(0), mNbSubgroups(1), mNbSubGroupElements(0), mActiveSubgroup(0)
98 mActiveSubgroup = mSubGroups[mActiveSubgroup].parentGroup;
110 PX_ASSERT(subGroupHandle < mNbSubgroups);
111 mSubGroups[subGroupHandle].nbSteps = nbSteps;
124 PX_ASSERT(0 == mActiveSubgroup);
128 updateSubGroup(dt,
context, 0, 1);
133 "PxVehicleComponentSequence::update: The timestep must be positive!");
140 eINVALID_COMPONENT = 0xff,
141 eINVALID_SUB_GROUP_ELEMENT = 0xff
146 struct SubGroupElement
149 : childGroup(eINVALID_SUBSTEP_GROUP),
150 component(eINVALID_COMPONENT),
151 nextElement(eINVALID_SUB_GROUP_ELEMENT)
167 : parentGroup(eINVALID_SUBSTEP_GROUP),
168 firstElement(eINVALID_SUB_GROUP_ELEMENT),
177 PxVehicleComponent* mComponents[PxVehicleComponentSequenceLimits::eMAX_NB_COMPONENTS];
180 Group mSubGroups[PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPS];
183 SubGroupElement mSubGroupElements[PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPELEMENTS];
184 PxU8 mNbSubGroupElements;
186 PxU8 mActiveSubgroup;
188 bool updateSubGroup(
const PxReal dt,
const PxVehicleSimulationContext&
context,
const PxU8 groupId,
const PxU8 parentSepMultiplier)
190 const PxU8 nbSteps = mSubGroups[groupId].nbSteps;
191 const PxU8 stepMultiplier = parentSepMultiplier * nbSteps;
192 const PxReal timestepForGroup = dt / PxReal(stepMultiplier);
193 for (PxU8 k = 0; k < nbSteps; k++)
195 PxU8 nextElement = mSubGroups[groupId].firstElement;
196 while (eINVALID_SUB_GROUP_ELEMENT != nextElement)
198 const SubGroupElement& e = mSubGroupElements[nextElement];
199 PX_ASSERT(e.component != eINVALID_COMPONENT || e.childGroup != eINVALID_SUBSTEP_GROUP);
200 if (eINVALID_COMPONENT != e.component)
202 PxVehicleComponent* c = mComponents[e.component];
203 if (!c->update(timestepForGroup,
context))
208 PX_ASSERT(eINVALID_SUBSTEP_GROUP != e.childGroup);
209 if (!updateSubGroup(dt,
context, e.childGroup, stepMultiplier))
212 nextElement = e.nextElement;
219 PxU8 getLastKnownElementInGroup(
const PxU8 groupId)
const
221 PxU8 currElement = mSubGroups[groupId].firstElement;
222 PxU8 nextElement = mSubGroups[groupId].firstElement;
223 while (nextElement != eINVALID_SUB_GROUP_ELEMENT)
225 currElement = nextElement;
226 nextElement = mSubGroupElements[nextElement].nextElement;
235 if (PxVehicleComponentSequenceLimits::eMAX_NB_COMPONENTS == mNbComponents)
237 if (PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPELEMENTS == mNbSubGroupElements)
241 SubGroupElement& nextElementInGroup = mSubGroupElements[mNbSubGroupElements];
242 nextElementInGroup.childGroup = eINVALID_SUBSTEP_GROUP;
243 nextElementInGroup.component = mNbComponents;
244 nextElementInGroup.nextElement = eINVALID_SUB_GROUP_ELEMENT;
246 if (eINVALID_SUB_GROUP_ELEMENT == mSubGroups[mActiveSubgroup].firstElement)
251 mSubGroups[mActiveSubgroup].firstElement = mNbSubGroupElements;
257 mSubGroupElements[getLastKnownElementInGroup(mActiveSubgroup)].nextElement = mNbSubGroupElements;
261 mNbSubGroupElements++;
264 mComponents[mNbComponents] = c;
272 if (mNbSubgroups == PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPS)
273 return eINVALID_SUBSTEP_GROUP;
274 if (mNbSubGroupElements == PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPELEMENTS)
275 return eINVALID_SUBSTEP_GROUP;
278 const PxU8 parentGroup = mActiveSubgroup;
279 const PxU8 childGroup = mNbSubgroups;
282 mSubGroups[childGroup].parentGroup = parentGroup;
283 mSubGroups[childGroup].firstElement = eINVALID_SUB_GROUP_ELEMENT;
284 mSubGroups[childGroup].nbSteps = nbSubSteps;
287 SubGroupElement& nextElementIInGroup = mSubGroupElements[mNbSubGroupElements];
288 nextElementIInGroup.childGroup = childGroup;
289 nextElementIInGroup.nextElement = eINVALID_SUB_GROUP_ELEMENT;
290 nextElementIInGroup.component = eINVALID_COMPONENT;
293 if (eINVALID_SUB_GROUP_ELEMENT == mSubGroups[parentGroup].firstElement)
298 mSubGroups[parentGroup].firstElement = mNbSubGroupElements;
304 mSubGroupElements[getLastKnownElementInGroup(parentGroup)].nextElement = mNbSubGroupElements;
309 mActiveSubgroup = childGroup;
312 mNbSubGroupElements++;
318 return mActiveSubgroup;
PX_C_EXPORT PX_FOUNDATION_API physx::PxFoundation &PX_CALL_CONV PxGetFoundation()
Retrieves the Foundation SDK after it has been created.
Definition FdFoundation.cpp:279
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
void update(const PxReal dt, const PxVehicleSimulationContext &context)
Update each component in the sequence.
Definition PxVehicleComponentSequence.h:122
void setSubsteps(const PxU8 subGroupHandle, const PxU8 nbSteps)
Set the number of substeps to perform for a specific substepping group.
Definition PxVehicleComponentSequence.h:108
Definition PxVehicleParams.h:672