本文整理汇总了C++中hkArray::pushBack方法的典型用法代码示例。如果您正苦于以下问题:C++ hkArray::pushBack方法的具体用法?C++ hkArray::pushBack怎么用?C++ hkArray::pushBack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hkArray
的用法示例。
在下文中一共展示了hkArray::pushBack方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createConvexTranslateShapeAndAddToArray
void DestructibleBridgeUtil::createConvexTranslateShapeAndAddToArray(hkpBoxShape* shape, hkReal posX, hkReal posY, hkReal posZ, hkReal scale, hkArray<hkpShape*>& shapes)
{
hkVector4 position(posX, posY, posZ);
position.mul4(scale);
hkpConvexTranslateShape* translatedShape = new hkpConvexTranslateShape(shape, position);
shapes.pushBack(translatedShape);
}
示例2: buildQueryObects
void WorldLinearCastMultithreadedDemo::buildQueryObects( hkArray<hkpShape*>& shapes, hkArray<QueryObject>& objects )
{
hkpShapeDisplayBuilder::hkpShapeDisplayBuilderEnvironment env;
hkpShapeDisplayBuilder builder(env);
for (int i = 0; i < shapes.getSize(); i++)
{
QueryObject qo;
qo.m_transform = new hkTransform();
qo.m_transform->setIdentity();
qo.m_collidable = new hkpCollidable( shapes[i], qo.m_transform );
objects.pushBack( qo );
hkArray<hkDisplayGeometry*> displayGeometries;
builder.buildDisplayGeometries( shapes[i], displayGeometries );
hkDebugDisplay::getInstance().addGeometry( displayGeometries, hkTransform::getIdentity(), (hkUlong)qo.m_collidable, 0, 0 );
while( displayGeometries.getSize() )
{
delete displayGeometries[0];
displayGeometries.removeAt(0);
}
// Set green color
HK_SET_OBJECT_COLOR((hkUlong)qo.m_collidable, hkColor::rgbFromChars(0,255,0,120));
}
}
示例3: checkFormatCompatibility
bool hkvTextureTransformationSettings::checkFormatCompatibility(
hkArray<hkvAssetLogMessage>& out_messages)
{
// Check if the file and data formats are compatible
if (!hkvTextureFileToDataFormatMapping::getInstance().isMapped(m_targetFileFormat, m_targetDataFormat))
{
hkStringBuf msg;
msg.printf("The target file format (%s) is not compatible with the target data format (%s)",
hkvTextureFileFormatNames[m_targetFileFormat], hkvTextureDataFormatNames[m_targetDataFormat]);
out_messages.pushBack(hkvAssetLogMessage(HKV_MESSAGE_CATEGORY_ASSET_TRANSFORMATION, HKV_MESSAGE_SEVERITY_ERROR, msg));
}
// Check if the platform can handle the target data format
if (m_platform != HKV_TARGET_PLATFORM_ANY)
{
if (!hkvPlatformToTextureDataFormatMapping::getInstance().isMapped(m_platform, m_targetDataFormat))
{
const char* platformName = "";
hkvGetTargetPlatformDefinition().idToString(m_platform, platformName);
hkStringBuf msg;
msg.printf("The target data format (%s) is not compatible with the target platform (%s)",
hkvTextureDataFormatNames[m_targetDataFormat], platformName);
out_messages.pushBack(hkvAssetLogMessage(HKV_MESSAGE_CATEGORY_ASSET_TRANSFORMATION, HKV_MESSAGE_SEVERITY_ERROR, msg));
}
}
// Check if the platform can handle the target file format
if (m_platform != HKV_TARGET_PLATFORM_ANY)
{
if (!hkvPlatformToTextureFileFormatMapping::getInstance().isMapped(m_platform, m_targetFileFormat))
{
const char* platformName = "";
hkvGetTargetPlatformDefinition().idToString(m_platform, platformName);
hkStringBuf msg;
msg.printf("The target file format (%s) is not compatible with the target platform (%s)",
hkvTextureFileFormatNames[m_targetFileFormat], platformName);
out_messages.pushBack(hkvAssetLogMessage(HKV_MESSAGE_CATEGORY_ASSET_TRANSFORMATION, HKV_MESSAGE_SEVERITY_ERROR, msg));
}
}
return true;
}
示例4: collectShapeKeys
void DestructibleHierarchy::collectShapeKeys(int nodeIdx, hkArray<hkpShapeKey>& shapeKeys)
{
Node* node = &m_nodes[nodeIdx];
if (node->m_shapeKey)
{
shapeKeys.pushBack(node->m_shapeKey);
}
for (int c = 0; c < node->m_childrenIdx.getSize(); c++)
{
collectShapeKeys(node->m_childrenIdx[c], shapeKeys);
}
}
示例5: findChildren
void FbxToHkxConverter::findChildren(FbxNode* root, hkArray<FbxNode*>& children, FbxNodeAttribute::EType type)
{
for (int childIndex = 0; childIndex < root->GetChildCount(); childIndex++)
{
FbxNode *node = root->GetChild(childIndex);
if (node->GetNodeAttribute() != NULL &&
node->GetNodeAttribute()->GetAttributeType() == type)
{
children.pushBack(node);
}
findChildren(node, children, type);
}
}
示例6: setupContexts
void hkDefaultPhysicsDemo::setupContexts(hkArray<hkProcessContext*>& contexts)
{
if ( m_world )
{
m_world->markForWrite();
if ( (m_physicsViewersContext->findWorld(m_world) < 0) )
{
m_physicsViewersContext->addWorld(m_world);
}
m_world->unmarkForWrite();
}
contexts.pushBack( m_physicsViewersContext );
// Add viewers to the demo display.
// Uncomment these to use them.
// m_debugViewerNames.pushBack( hkpBroadphaseViewer::getName() );
//m_debugViewerNames.pushBack( hkpConstraintViewer::getName() );
// m_debugViewerNames.pushBack( hkpActiveContactPointViewer::getName() );
// m_debugViewerNames.pushBack( hkpInactiveContactPointViewer::getName() );
// m_debugViewerNames.pushBack( hkpRigidBodyCentreOfMassViewer::getName() );
// m_debugViewerNames.pushBack( hkpRigidBodyInertiaViewer::getName() );
// m_debugViewerNames.pushBack( hkpSimulationIslandViewer::getName() );
// m_debugViewerNames.pushBack( hkpVehicleViewer::getName() );
// m_debugViewerNames.pushBack( hkStatisticsProcess::getName() );
// m_debugViewerNames.pushBack( hkpSweptTransformDisplayViewer::getName() );
// m_debugViewerNames.pushBack( hkpToiContactPointViewer::getName() );
// A viewer to look at the collision radius of convex objects.
// m_debugViewerNames.pushBack( hkpConvexRadiusViewer::getName() );
// These are the three "default" viewers which display shapes,
// phantoms and debug lines.
m_debugViewerNames.pushBack( hkpShapeDisplayViewer::getName() );
m_debugViewerNames.pushBack( hkpPhantomDisplayViewer::getName() );
m_debugViewerNames.pushBack( hkDebugDisplayProcess::getName() );
// register all our classes we know about with the vdb for tweaking
if (m_vdbClassReg)
{
m_vdbClassReg->registerList(hkBuiltinTypeRegistry::StaticLinkedTypeInfos, hkBuiltinTypeRegistry::StaticLinkedClasses);
}
}
示例7: getTimerStreamInfo
void hkDefaultDemo::getTimerStreamInfo( hkArray<hkTimerData>& threadStreams, hkArray<hkTimerData>& spuStreams, int maxThreads )
{
hkTimerData info;
info.m_streamBegin = hkMonitorStream::getInstance().getStart();
info.m_streamEnd = hkMonitorStream::getInstance().getEnd();
threadStreams.pushBack(info);
#if defined HK_PLATFORM_PS3_PPU
if ( m_jobThreadPool != HK_NULL )
{
m_jobThreadPool->appendTimerData( spuStreams );
}
#else
if ( m_jobThreadPool != HK_NULL )
{
m_jobThreadPool->appendTimerData( threadStreams );
}
#endif
}
示例8: createSingleBoardOrBeam
void DestructibleBridgeUtil::createSingleBoardOrBeam(const hkpConvexShape* shape, const hkVector4& position, hkArray<hkpConvexShape*>& shapeArray)
{
hkpConvexTranslateShape* translatedShape = new hkpConvexTranslateShape(shape, position);
shapeArray.pushBack(translatedShape);
}
示例9: createShapes
void WorldLinearCastMultithreadedDemo::createShapes(hkArray<hkpShape*>& shapesOut)
{
const hkReal s = 1.25f;
// Create Sphere body
{
hkpConvexShape* shape = new hkpSphereShape(s);
shapesOut.pushBack(shape );
}
// Create Capsule body
{
hkVector4 a(-s * .5f, 0.f, 0.f);
hkVector4 b( s * .5f, 0.f, 0.f);
hkpCapsuleShape* shape = new hkpCapsuleShape(a, b, s);
shapesOut.pushBack(shape );
}
// Create Box body
{
hkVector4 halfExtents; halfExtents.setAll3( s );
hkpBoxShape* shape = new hkpBoxShape(halfExtents, 0 );
shapesOut.pushBack(shape );
}
// Create ConvexVertices body
{
int numVertices = 12;
// 3 for x,y,z (size of float)
int stride = 3 * sizeof(float);
const hkReal t = s * 0.7f;
const hkReal o = 0.0f;
float vertices[] = { // 4 vertices
-s, o, -s,
-s, o, s,
s, o, -s,
s, o, s,
o, s, -t,
o, s, t,
t, s, o,
-t, s, o,
o, -s, -t,
o, -s, t,
t, -s, o,
-t, -s, o,
};
hkpConvexVerticesShape* shape;
hkArray<hkVector4> planeEquations;
hkGeometry geom;
{
hkStridedVertices stridedVerts;
{
stridedVerts.m_numVertices = numVertices;
stridedVerts.m_striding = stride;
stridedVerts.m_vertices = vertices;
}
hkGeometryUtility::createConvexGeometry( stridedVerts, geom, planeEquations );
{
stridedVerts.m_numVertices = geom.m_vertices.getSize();
stridedVerts.m_striding = sizeof(hkVector4);
stridedVerts.m_vertices = &(geom.m_vertices[0](0));
}
shape = new hkpConvexVerticesShape(stridedVerts, planeEquations);
}
shapesOut.pushBack( shape );
}
}
示例10: ensureDimensionIntegrity
bool hkvTextureTransformationSettings::ensureDimensionIntegrity(hkArray<hkvAssetLogMessage>& out_messages)
{
if (m_sourceWidth == 0 || m_sourceHeight == 0)
{
out_messages.pushBack(hkvAssetLogMessage(HKV_MESSAGE_CATEGORY_ASSET_TRANSFORMATION, HKV_MESSAGE_SEVERITY_ERROR, "Size of source texture is invalid; cannot continue!"));
return false;
}
// Perform sanity checks
if (m_validationNeedsPowerOfTwo && m_validationNeedsMultipleOf > 1)
{
if (hkvMath::isPowerOf2(m_validationNeedsMultipleOf))
{
// Both Power-of-Two and Multiple-of restrictions are given. However, multiple-of is a power of two,
// so we can drop the multiple-of constraint as long as we limit the minimum size.
m_validationMinSize = hkvMath::Max(m_validationMinSize, m_validationNeedsMultipleOf);
}
else
{
VASSERT_MSG(false, "Both Power-of-Two and Multiple-of restrictions are specified, but Multiple-of is not a power of two. Ignoring Multiple-of.");
}
m_validationNeedsMultipleOf = 1;
}
if (m_validationNeedsPowerOfTwo)
{
if (m_validationMinSize > 0 && !hkvMath::isPowerOf2(m_validationMinSize))
{
VASSERT_MSG(false, "According to set restrictions, system minimum size needs to be Power-of-Two. Adjusting.");
m_validationMinSize = hkvMath::powerOf2_ceil(m_validationMinSize);
}
if (m_userMinSize > 0)
{
m_userMinSize = adjustToNearestPowerOfTwo(m_userMinSize);
}
if (m_validationMaxSize > 0 && !hkvMath::isPowerOf2(m_validationMaxSize))
{
VASSERT_MSG(false, "According to set restrictions, system maximum size needs to be Power-of-Two. Adjusting.");
m_validationMaxSize = hkvMath::powerOf2_floor(m_validationMaxSize);
}
if (m_userMaxSize > 0)
{
m_userMaxSize = adjustToNearestPowerOfTwo(m_userMaxSize);
}
}
if (m_validationNeedsMultipleOf > 1)
{
if ((m_validationMinSize % m_validationNeedsMultipleOf) != 0)
{
VASSERT_MSG(false, "According to set restrictions, system minimum size needs to be Multiple-of. Adjusting.");
m_validationMinSize = ((m_validationMinSize + m_validationNeedsMultipleOf - 1) / m_validationNeedsMultipleOf) * m_validationNeedsMultipleOf;
}
m_userMinSize = ((m_userMinSize + m_validationNeedsMultipleOf - 1) / m_validationNeedsMultipleOf) * m_validationNeedsMultipleOf;
if (m_validationMaxSize % m_validationNeedsMultipleOf != 0)
{
VASSERT_MSG(false, "According to set restrictions, system maximum size needs to be Multiple-of. Adjusting.");
m_validationMaxSize = (m_validationMaxSize / m_validationNeedsMultipleOf) * m_validationNeedsMultipleOf;
}
m_userMaxSize = (m_userMaxSize / m_validationNeedsMultipleOf) * m_validationNeedsMultipleOf;
}
if ((m_validationMinSize > 0) && (m_validationMaxSize > 0) && (m_validationMaxSize < m_validationMinSize))
{
VASSERT_MSG(false, "System maximum size less than system minimum size; adjusting.");
m_validationMinSize = m_validationMaxSize;
}
if ((m_userMinSize > 0) && (m_userMaxSize > 0) && (m_userMaxSize < m_userMinSize))
{
m_userMinSize = m_userMaxSize;
}
if ((m_validationMinSize > 0) && (m_userMinSize > 0) && (m_userMinSize < m_validationMinSize))
{
m_userMinSize = m_validationMinSize;
}
if ((m_validationMaxSize > 0) && (m_userMaxSize > 0) && (m_userMaxSize > m_validationMaxSize))
{
m_userMaxSize = m_validationMaxSize;
}
return true;
}
示例11: breakOffSubPart
hkResult BreakOffPartsDemo::breakOffSubPart( const ContactImpulseLimitBreachedEvent& event, hkArray<hkpShapeKey>& keysBrokenOffOut, hkpPhysicsSystem& systemOut )
{
const BreakOffPartsVariant& variant = g_variants[m_variantId];
//
// Remove the broken pieces from the car or landscape
//
hkpRigidBody* breakingBody = event.m_breakingBody;
for (int p = 0; p < event.m_points.getSize(); p++)
{
const ContactImpulseLimitBreachedEvent::PointInfo& pointInfo = event.m_points[p];
hkpShapeKey brokenPieceKey = pointInfo.m_brokenShapeKey;
const hkpShape* newShape = HK_NULL;
{
hkpShape* shape = const_cast<hkpShape*>(breakingBody->getCollidable()->getShape());
switch (shape->m_type )
{
case HK_SHAPE_LIST:
{
hkpListShape* list = static_cast<hkpListShape*>(shape);
newShape = list->m_childInfo[brokenPieceKey].m_shape;
hkpBreakOffPartsUtil::removeKeysFromListShape( breakingBody, &brokenPieceKey, 1 );
removeSubShapeFromDisplay( event.m_breakingBody, list, brokenPieceKey );
keysBrokenOffOut.pushBack( brokenPieceKey );
break;
}
case HK_SHAPE_MOPP:
{
hkpMoppBvTreeShape* moppTree = static_cast<hkpMoppBvTreeShape*>(shape);
hkpShapeCollection* collection = const_cast<hkpShapeCollection*>(moppTree->getShapeCollection());
HK_ASSERT2(0xad875a22, collection->getType() == HK_SHAPE_LIST, "The container must be a list shape..");
hkpListShape* list = static_cast<hkpListShape*>(collection);
newShape = list->m_childInfo[brokenPieceKey].m_shape;
hkpBreakOffPartsUtil::removeKeysFromListShape( breakingBody, &brokenPieceKey, 1 );
removeSubShapeFromDisplay( event.m_breakingBody, list, brokenPieceKey );
keysBrokenOffOut.pushBack( brokenPieceKey );
break;
}
default:
HK_ASSERT2( 0xf03df569, 0, "This shape is not implemented yet" );
return HK_FAILURE;
}
}
//
// Create the new broken off piece
//
hkpRigidBodyCinfo rigidBodyCinfo;
{
rigidBodyCinfo.m_shape = newShape;
rigidBodyCinfo.m_position = breakingBody->getPosition();
rigidBodyCinfo.m_rotation = breakingBody->getRotation();
rigidBodyCinfo.m_linearVelocity = breakingBody->getLinearVelocity();
rigidBodyCinfo.m_angularVelocity = breakingBody->getAngularVelocity();
rigidBodyCinfo.m_mass = 10.0f;
rigidBodyCinfo.m_qualityType = (variant.m_type == BREAK_OFF_PARTS_DEMO_TOI) ? HK_COLLIDABLE_QUALITY_MOVING : HK_COLLIDABLE_QUALITY_DEBRIS;
hkpInertiaTensorComputer::setShapeVolumeMassProperties( newShape, rigidBodyCinfo.m_mass, rigidBodyCinfo );
}
hkReferencedObject::lockAll();
hkpRigidBody* newBody = new hkpRigidBody( rigidBodyCinfo );
systemOut.addRigidBody( newBody );
newBody->removeReference();
hkReferencedObject::unlockAll();
// if the original unbroken body was fixed, the colliding impulse is lost, simply apply the impulse to the new piece
if ( breakingBody->isFixedOrKeyframed() )
{
hkReal maxImpulse = pointInfo.m_properties->m_maxImpulse;
hkVector4 impulse; impulse.setMul4( -maxImpulse, pointInfo.m_contactPoint->getNormal() );
newBody->applyPointImpulse( impulse, pointInfo.m_contactPoint->getPosition() );
}
}
return HK_SUCCESS;
}
示例12: buildBrickWall
void BrickWallBuilder::buildBrickWall(const BrickwallBuilderDescriptor& bwDescriptor, hkArray<hkpRigidBody*>& bricksOut, hkArray<hkpConstraintInstance*>& constraintsOut )
{
hkVector4 halfExtents( bwDescriptor.m_brickShape->getHalfExtents() );
// move start point depending on wall size
hkVector4 posX( hkVector4::getZero() );
posX(0) = -bwDescriptor.m_width * halfExtents(0);
posX(0) += halfExtents(0);
posX(1) = -halfExtents(1);
// reserve space for all bricks and constraints
bricksOut.reserve(bwDescriptor.m_height * bwDescriptor.m_width * 2);
constraintsOut.reserve( (2 * bwDescriptor.m_height - 1) * (2 * bwDescriptor.m_width - 1) + bwDescriptor.m_width - 1);
hkReal thresholdDelta = (bwDescriptor.m_strength > bwDescriptor.m_lowerThreshold)? (bwDescriptor.m_strength - bwDescriptor.m_lowerThreshold) /(bwDescriptor.m_height*2-1) : 0.0f;
// set brick properties, used for all the bricks
hkpRigidBodyCinfo boxInfo;
computeBrickInfo(bwDescriptor.m_brickShape, bwDescriptor.m_brickMass, boxInfo);
// QUI
int colOffset=bwDescriptor.m_height;
for(int x=0;x<bwDescriptor.m_width;x++) // along the ground, left to right
{
hkVector4 pos(posX);
// breaking threshold for this row
hkReal rowThreshold = bwDescriptor.m_strength;
for(int y=0; y<bwDescriptor.m_height; y++) // bottom to top
{
pos(1) += (halfExtents(1) + bwDescriptor.m_brickShape->getRadius()) * 2.0f;
// build rigid body for brick
int brickIndOne;
{
brickIndOne=bricksOut.getSize();
boxInfo.m_position.setRotatedDir( bwDescriptor.m_transform.getRotation() /*bwDescriptor.m_orientation*/,pos);
boxInfo.m_position.add4( bwDescriptor.m_transform.getTranslation() /*bwDescriptor.m_position*/);
boxInfo.m_rotation.set( bwDescriptor.m_transform.getRotation() ); //bwDescriptor.m_orientation;
bricksOut.pushBack(new hkpRigidBody(boxInfo));
}
// At each step 2 constraints are built:
hkBool constraintsAdded[] = {false, false};
// 1 - A constraint to the ground OR a constraint to the brick below the one just built
if( y == 0 ) {
// attach the first row to the ground (if requested)
if(bwDescriptor.m_attachToGround)
constraintsOut.pushBack(buildBreakableConstraintInstance(bricksOut[brickIndOne], bwDescriptor.m_theGround, rowThreshold*1000));
} else {
// create a breakable constraint from the brick and the one below
constraintsOut.pushBack(buildBreakableConstraintInstance(bricksOut[brickIndOne], bricksOut[brickIndOne - 1], rowThreshold));
constraintsAdded[0]=true;
}
// 2 - a constraint to the brick to the left
if( x > 0 ) // check if there is a previous column
{
// create a constraint from the new brick and the corresponding brick from the previous column
// the first row is made of unbreakable constraints
if(y==0 && bwDescriptor.m_attachToGround)
constraintsOut.pushBack(buildConstraintInstance(bricksOut[brickIndOne], bricksOut[brickIndOne - colOffset]));
else
constraintsOut.pushBack(buildBreakableConstraintInstance(bricksOut[brickIndOne], bricksOut[brickIndOne - colOffset], rowThreshold));
constraintsAdded[1]=true;
}
if(bwDescriptor.m_setCollisionFilter)
{
// Set filter info
bool b = constraintsAdded[0];
bool l = constraintsAdded[1];
hkUint32 filterInfo = BrickFilter::calcFilterInfo(y, x, bwDescriptor.m_wallID, l, b);
bricksOut[brickIndOne]->setCollisionFilterInfo(filterInfo);
}
rowThreshold -= thresholdDelta;
} // end of for(..y..)
// advance to next col
posX(0) += bwDescriptor.m_gapWidth + halfExtents(0)*2.0f;
} // end of for(..x..)
}