예제 #1
0
	PModelResource CModel::getObjectResource(_In_ nfUint32 nIndex)
	{
		nfUint32 nCount = getObjectCount();
		if (nIndex >= nCount)
			throw CNMRException(NMR_ERROR_INVALIDINDEX);

		return m_ObjectLookup[nIndex];
	}
예제 #2
0
      void GroupImpl::updateOutputBuffer( size_t workGroupSize )
      {
        size_t const numberOfObjects = getObjectCount();
        size_t const numberOfWorkingGroups = (numberOfObjects + workGroupSize - 1) / workGroupSize;
        size_t const numberOfResults = numberOfWorkingGroups * workGroupSize;

        GLsizei newBufferOutputSize = static_cast<GLsizei>(numberOfResults / 8);

        if ( m_outputBufferSize != newBufferOutputSize )
        {
          m_outputBufferSize = newBufferOutputSize;

          if ( ! m_outputBuffer )
          {
            m_outputBuffer = dp::gl::Buffer::create(dp::gl::Buffer::CORE, GL_STATIC_DRAW, GL_SHADER_STORAGE_BUFFER);
          }

          m_outputBuffer->setSize(m_outputBufferSize);
        }
      }
예제 #3
0
      void GroupImpl::updateInputBuffer( size_t workgroupSize )
      {
        dp::util::ProfileEntry p("cull::updateInputBuffer");

        if ( m_inputChanged )
        {
          if ( ! m_inputBuffer )
          {
            m_inputBuffer = dp::gl::Buffer::create(dp::gl::Buffer::CORE, GL_STATIC_DRAW, GL_SHADER_STORAGE_BUFFER);
          }

          size_t const numberOfObjects = getObjectCount();
          size_t const numberOfWorkingGroups = (numberOfObjects + workgroupSize - 1) / workgroupSize;
          m_inputBuffer->setSize(numberOfWorkingGroups * workgroupSize * sizeof(ShaderObject));
          dp::gl::MappedBuffer<ShaderObject> inputs(m_inputBuffer, GL_MAP_WRITE_BIT);
          DP_ASSERT( inputs );

          // generate list of objects to cull from shader
          for ( size_t index = 0;index < numberOfObjects; ++index )
          {
            const ObjectBitSetSharedPtr& objectImpl = getObject( index );
            ShaderObject &object = inputs[index];
            object.matrix = static_cast<uint32_t>(objectImpl->getTransformIndex());
            object.lowerLeft = objectImpl->getLowerLeft();
            object.extent = objectImpl->getExtent();
          }

          // initialize unused objects in workgroup
          for ( size_t index = numberOfObjects; index < numberOfWorkingGroups * workgroupSize; ++index )
          {
            ShaderObject &object = inputs[index];
            object.matrix = 0;
            object.extent = dp::math::Vec4f(0.0, 0.0f, 0.0f, 0.0f);
            object.lowerLeft = dp::math::Vec4f( 0.0f, 0.0f, 0.0f, 0.0f);
          }

          m_inputChanged = false;
        }
      }
예제 #4
0
SWObject::~SWObject()
{
	__this::destroy();
    --getObjectCount();
    SWLog( "SWObject deleted, remains: %d", getObjectCount() );
}
예제 #5
0
SWObject::SWObject()
{
    ++getObjectCount();
}
	/// Get the probability of the object at \c objectIdx
	double getObjectProbability(const size_t& objectIdx) {
		double objectCount = static_cast<double>(getObjectCount(objectIdx));
		double totalCount = static_cast<double>(getTotalCount());

		return (objectCount / totalCount);
	}