本文整理汇总了C++中hkArray类的典型用法代码示例。如果您正苦于以下问题:C++ hkArray类的具体用法?C++ hkArray怎么用?C++ hkArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了hkArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: path
const char* HK_CALL hkDemoFileSystem::removeDemoBasePath( const char* pathIn, hkArray<char>& buffer )
{
hkString path( pathIn );
path.makeLowerCase();
// strip everything up to the demo root folder
hkString root("/demos/");
root.makeLowerCase();
const char* str = path.cString();
const char* start = hkString::strStr(str, root.cString());
if ( start != HK_NULL )
{
int pos = static_cast<int>(start - str) + root.getLength();
buffer.setSize( path.getLength() - pos + 1 );
// copy the part of the string that follows the demo prefix
hkString::memCpy( buffer.begin(), pathIn+pos, buffer.getSize()-1 );
buffer[ buffer.getSize()-1 ] = 0; // null terminate
return buffer.begin();
}
else
{
// nothing to do
return pathIn;
}
}
示例2: setSpecificProperty
void hkvTextureAsset::setSpecificProperty(const hkvProperty& prop, const hkArray<hkStringPtr>& path, unsigned int stackIndex, hkvProperty::Purpose purpose)
{
int stackSize = (path.getSize() - stackIndex);
if ((stackSize == 1) && (hkvStringHelper::safeCompare(path.back(), "Texture") == 0))
{
m_imageProperties.setProperty(prop, path, stackIndex + 1, purpose);
if (hkvStringHelper::safeCompare(prop.getName(), "Usage") == 0)
{
if (purpose == hkvProperty::PURPOSE_SERIALIZATION)
{
if (m_usageInstance.setByString(prop.getString()) != HK_SUCCESS)
{
m_usageInstance.setByAvailableElementsId(0);
}
}
else
{
m_usageInstance.setByAvailableElementsId(prop.getEnumValue());
}
}
else if (hkvStringHelper::safeCompare(prop.getName(), "sRGB") == 0)
{
m_sRgb = prop.getBool();
}
}
}
示例3: setSpecificProperty
void hkvTextureAsset::setSpecificProperty(const hkvProperty& prop, const hkArray<hkStringPtr>& path, unsigned int stackIndex, hkvProperty::Purpose purpose)
{
int stackSize = (path.getSize() - stackIndex);
if ((stackSize == 1) && (hkvStringHelper::safeCompare(path.back(), "Texture") == 0))
{
m_imageProperties.setProperty(prop, path, stackIndex + 1, purpose);
// Usage is still present here for backwards compatibility to convert older asset libraries, but has now moved to the texture transform rule instead.
if (hkvStringHelper::safeCompare(prop.getName(), "Usage") == 0)
{
if (purpose == hkvProperty::PURPOSE_SERIALIZATION)
{
if (m_usageInstance.setByString(prop.getString()) != HK_SUCCESS)
{
m_usageInstance.setByAvailableElementsId(0);
}
}
}
else if (hkvStringHelper::safeCompare(prop.getName(), "sRGB") == 0)
{
m_sRgb = prop.getBool();
}
}
}
示例4: builder
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));
}
}
示例5: compareHitArrays
//
// Test function to make sure that the hits from the kd-tree are identical to the ones from the broadphase.
//
static hkBool compareHitArrays(const hkAabb& aabb, const hkPrimitiveId* kdHits, int numKdHits, const hkArray<hkpBroadPhaseHandlePair>& sapHits)
{
hkLocalArray<const hkpCollidable*> sapCollidables(sapHits.getSize());
for (int i=0; i<sapHits.getSize(); i++)
{
const hkpTypedBroadPhaseHandle* tp = static_cast<const hkpTypedBroadPhaseHandle*>( sapHits[i].m_b );
const hkpCollidable* collB = static_cast<hkpCollidable*>(tp->getOwner());
// Make sure no spurious hits from the broadphase
hkAabb colAabb;
hkpRigidBody* rb = hkGetRigidBody(collB);
if (rb)
{
collB->getShape()->getAabb(rb->getTransform(), 0.0f, colAabb);
hkBool aabbOverlap = colAabb.overlaps(aabb);
if (aabbOverlap)
sapCollidables.pushBack(collB);
}
}
// Make sure that the contents of the arrays at the same
// It would be faster to sort and do a string compare, but this is just as easy.
hkBool isOk = true;
for (int i=0; i<numKdHits; i++)
{
const hkpCollidable* kdCollidable = reinterpret_cast<const hkpCollidable*> (kdHits[i]);
int idx = sapCollidables.indexOf(kdCollidable);
if(idx < 0)
{
// There's a hit in the kd-tree's list but not the 3AxisSweep's list
// It's possible that 3AxisSweep skipped something. So get the AABB of the body in the kd-tree list.
hkAabb colAabb;
hkpRigidBody* rb = hkGetRigidBody(kdCollidable);
kdCollidable->getShape()->getAabb(rb->getTransform(), rb->getWorld()->getCollisionInput()->getTolerance(), colAabb);
hkBool aabbOverlap = colAabb.overlaps(aabb);
if (!aabbOverlap)
{
// Something in the list doesn't overlap with the query's aabb
isOk = false;
}
continue;
}
sapCollidables.removeAt(idx);
}
// If we made it this far, they must agree.
return isOk && sapCollidables.isEmpty();
}
示例6: setSpecificProperty
void hkvStaticMeshAsset::setSpecificProperty(const hkvProperty& prop, const hkArray<hkStringPtr>& path, unsigned int stackIndex, hkvProperty::Purpose purpose)
{
int stackSize = (path.getSize() - stackIndex);
if ((stackSize == 1) && (hkvStringHelper::safeCompare(path.back(), "Model") == 0))
{
if (hkvStringHelper::safeCompare(prop.getName(), "LODSwitchDistances") == 0)
{
m_lodDistances = prop.getArray();
}
}
}
示例7: removeDuplicatesFromArray
void HK_CALL SlidingWorldDemo::removeDuplicatesFromArray(hkArray<hkpBroadPhaseHandle*>& objectsEnteringBroadphaseBorder )
{
hkArray<hkpBroadPhaseHandle*> noDups;
noDups.reserve( objectsEnteringBroadphaseBorder.getSize() );
for (int i = 0; i < objectsEnteringBroadphaseBorder.getSize(); i++)
{
if( noDups.indexOf( objectsEnteringBroadphaseBorder[i] ) == -1)
{
noDups.pushBack( objectsEnteringBroadphaseBorder[i] );
}
}
objectsEnteringBroadphaseBorder.swap( noDups );
}
示例8: getVDBViewersByName
void hkDefaultDemo::getVDBViewersByName( const char* name, hkArray<hkProcess*>& processes )
{
if (m_vdb)
{
int tag = hkProcessFactory::getInstance().getProcessId( name );
m_vdb->getCurrentProcesses( processes );
int np = processes.getSize();
for (int pi = np -1; pi >= 0; --pi)
{
if (processes[pi]->getProcessTag() != tag)
processes.removeAt(pi);
}
}
}
示例9: FillTransforms
static void FillTransforms( hkArray<hkQsTransform>& transforms, int boneIdx, int numTracks
, const hkQsTransform& localTransform, PosRotScale prs = prsDefault
, int from=0, int to=-1)
{
int n = transforms.getSize() / numTracks;
if (n == 0)
return;
if (to == -1 || to >= n) to = n-1;
if ((prs & prsDefault) == prsDefault)
{
for (int idx = from; idx <= to; ++idx)
{
hkQsTransform& transform = transforms[idx*numTracks + boneIdx];
transform = localTransform;
}
}
else
{
for (int idx = from; idx <= to; ++idx)
{
hkQsTransform& transform = transforms[idx*numTracks + boneIdx];
if ((prs & prsPos) != 0)
transform.setTranslation(localTransform.getTranslation());
if ((prs & prsRot) != 0)
transform.setRotation(localTransform.getRotation());
if ((prs & prsScale) != 0)
transform.setScale(localTransform.getScale());
}
}
}
示例10: setProperty
void hkvImageFileProperties::setProperty(const hkvProperty& prop, const hkArray<hkStringPtr>& path, hkUint32 stackIndex, hkvProperty::Purpose purpose)
{
int stackSize = (path.getSize() - stackIndex);
if ((stackSize != 0))
return;
if (hkvStringHelper::safeCompare(prop.getName(), "FileFormat") == 0)
{
if (m_imageFormatInstance.setByString(prop.getString()) != HK_SUCCESS)
{
m_imageFormatInstance.setByDefinitionId(HKV_IMAGE_FILE_FORMAT_INVALID);
}
}
else if (hkvStringHelper::safeCompare(prop.getName(), "Width") == 0)
{
m_width = prop.getUint();
}
else if (hkvStringHelper::safeCompare(prop.getName(), "Height") == 0)
{
m_height = prop.getUint();
}
else if (hkvStringHelper::safeCompare(prop.getName(), "HasAlpha") == 0)
{
m_hasAlpha = prop.getBool();
}
}
示例11: 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);
}
示例12: setInternalProperty
void hkvTagfileAsset::setInternalProperty(const hkvProperty& prop, const hkArray<hkStringPtr>& path, unsigned int stackIndex, hkvProperty::Purpose purpose)
{
int stackSize = (path.getSize() - stackIndex);
if ((stackSize >= 1) && (hkvStringHelper::safeCompare(path[stackIndex + 0], "Tagfile") == 0))
{
setTagfileArrayProperty(prop, path, stackIndex, purpose);
}
}
示例13: 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;
}
示例14: setProperty
void hkvTextureTransformationRule::setProperty(const hkvProperty& prop, const hkArray<hkStringPtr>& path, unsigned int iStackIndex, hkvProperty::Purpose purpose)
{
int iStackSize = (path.getSize() - iStackIndex);
if (iStackSize == 0)
{
if (hkvStringHelper::safeCompare(prop.getName(), "Compression") == 0)
{
if (purpose == hkvProperty::PURPOSE_SERIALIZATION)
{
if (m_compressionInstance.setByString(prop.getString()) != HK_SUCCESS)
{
m_compressionInstance.setByAvailableElementsId(0);
}
}
else
{
m_compressionInstance.setByAvailableElementsId(prop.getEnumValue());
}
}
else if (hkvStringHelper::safeCompare(prop.getName(), "Usage") == 0)
{
if (purpose == hkvProperty::PURPOSE_SERIALIZATION)
{
if (m_usageInstance.setByString(prop.getString()) != HK_SUCCESS)
{
m_usageInstance.setByAvailableElementsId(0);
}
}
else
{
m_usageInstance.setByAvailableElementsId(prop.getEnumValue());
}
}
else if (hkvStringHelper::safeCompare(prop.getName(), "RemoveAlphaChannel") == 0)
{
m_removeAlphaChannel = prop.getBool();
}
else if (hkvStringHelper::safeCompare(prop.getName(), "CreateMipMaps") == 0)
{
m_createMipMaps = prop.getBool();
}
else if (hkvStringHelper::safeCompare(prop.getName(), "DownscaleLevel") == 0)
{
m_downscaleLevel = prop.getUint();
}
else if (hkvStringHelper::safeCompare(prop.getName(), "MinimumSize") == 0)
{
m_minSize = prop.getUint();
}
else if (hkvStringHelper::safeCompare(prop.getName(), "MaximumSize") == 0)
{
m_maxSize = prop.getUint();
}
}
}
示例15: SetTransformScaleRange
static void SetTransformScaleRange( hkArray<hkQsTransform>& transforms, int numTracks, int boneIdx
, float ¤tTime, float lastTime, int &frame
, FloatKey &first, FloatKey &last)
{
int n = transforms.getSize()/numTracks;
for ( ; COMPARE(currentTime, lastTime) <= 0 && frame < n; currentTime += FramesIncrement, ++frame)
{
hkQsTransform& transform = transforms[frame*numTracks + boneIdx];
SetTransformScale(transform, first.data);
}
}