Result<Eldritch2::UniquePointer<AssetView>>	SkeletalColliderView::CreateView( Allocator& allocator, PxPhysics& physics, const AssetLibrary& library, const Utf8Char* const name, Range<const char*> rawBytes ) {
		Verifier	verifier( reinterpret_cast<const uint8_t*>( rawBytes.Begin() ), rawBytes.GetSize() );

		if( !FlatBuffers::SkeletalCollisionAssetBufferHasIdentifier( rawBytes.Begin() ) || !FlatBuffers::VerifySkeletalCollisionAssetBuffer( verifier ) ) {
			library.GetLog()( MessageSeverity::Error, "Skeletal collider asset '{}' is malformed!"  ET_UTF8_NEWLINE_LITERAL, name );
			return Error::InvalidParameter;
		}

		const FlatBuffers::SkeletalCollisionAsset&	asset( *FlatBuffers::GetSkeletalCollisionAsset( rawBytes.Begin() ) );
	
		Result<Eldritch2::UniquePointer<SkeletalColliderView::RigidShape[]>>	createRigidShapesResult( CreateRigidShapes( allocator, physics, *asset.RigidBodies() ) );
		if( !createRigidShapesResult ) {
			library.GetLog()( MessageSeverity::Error, "Rigid shape data for skeletal collider asset '{}' is malformed!"  ET_UTF8_NEWLINE_LITERAL, name );
			return createRigidShapesResult.GetErrorCode();
		}

		Result<Eldritch2::UniquePointer<SkeletalColliderView::ClothShape[]>>	createClothShapesResult( CreateClothShapes( allocator, physics, *asset.ClothBodies() ) );
		if( !createClothShapesResult ) {
			library.GetLog()( MessageSeverity::Error, "Cloth data for skeletal collider asset '{}' is malformed!"  ET_UTF8_NEWLINE_LITERAL, name );
			return createClothShapesResult.GetErrorCode();
		}

		auto resultView( MakeUnique<SkeletalColliderView>( allocator, name, eastl::move( *createRigidShapesResult ), eastl::move( *createClothShapesResult ) ) );
		if( !resultView ) {
			return Error::OutOfMemory;
		}

		return eastl::move( resultView );
	}
	void MemoryMappedFile::PrefetchRange( Range<const char*> memoryRange ) const {
#	if( WIN8_MEMORY_MAPPED_FILE_AVAILABLE )
		WIN32_MEMORY_RANGE_ENTRY	ranges[] = { { const_cast<char*>( memoryRange.first ), memoryRange.GetSize() } };

		PrefetchVirtualMemory( GetCurrentProcess(), _countof( ranges ), ranges, 0 );
#	else
		for( auto temp( memoryRange.Begin() ); temp < memoryRange.End(); temp += PrefetchStride ) {
		//	TODO: Is it possible to use prefetch instructions to avoid polluting the processor caches?
			register int readTarget = *reinterpret_cast<const int*>(temp);
		}
#	endif
	}
Esempio n. 3
0
bool
ChunkSet::HasSubrange(const Range& aSubrange) const
{
    for (const Range& range : mRanges) {
        if (range.Contains(aSubrange)) {
            return true;
        } else if (!(aSubrange.Begin() > range.End() ||
                     range.Begin() > aSubrange.End())) {
            // In this case, aSubrange overlaps this range but is not a subrange.
            // because the ChunkSet implementation ensures that there are no
            // overlapping ranges, this means that aSubrange cannot be a subrange of
            // any of the following ranges
            return false;
        }
    }

    return false;
}