Example #1
0
//--------------------------------------------------------------------------------------------------
/// Returns the number of triangles in this primitive group
//--------------------------------------------------------------------------------------------------
size_t PrimitiveSet::triangleCount() const
{
    if (m_primitiveType != PT_TRIANGLES)
    {
        return 0;
    }

    CVF_ASSERT(indexCount()%3 == 0);

    return indexCount()/3;
}
Example #2
0
bool Table::equals(const voltdb::Table *other) const {
    if (!(columnCount() == other->columnCount())) return false;
    if (!(indexCount() == other->indexCount())) return false;
    if (!(activeTupleCount() == other->activeTupleCount())) return false;
    if (!(databaseId() == other->databaseId())) return false;
    if (!(tableId() == other->tableId())) return false;
    if (!(name() == other->name())) return false;
    if (!(tableType() == other->tableType())) return false;

    std::vector<voltdb::TableIndex*> indexes = allIndexes();
    std::vector<voltdb::TableIndex*> otherIndexes = other->allIndexes();
    if (!(indexes.size() == indexes.size())) return false;
    for (std::size_t ii = 0; ii < indexes.size(); ii++) {
        if (!(indexes[ii]->equals(otherIndexes[ii]))) return false;
    }

    const voltdb::TupleSchema *otherSchema = other->schema();
    if ((!m_schema->equals(otherSchema))) return false;

    voltdb::TableIterator firstTI(this);
    voltdb::TableIterator secondTI(other);
    voltdb::TableTuple firstTuple(m_schema);
    voltdb::TableTuple secondTuple(otherSchema);
    while(firstTI.next(firstTuple)) {
        if (!(secondTI.next(secondTuple))) return false;
        if (!(firstTuple.equals(secondTuple))) return false;
    }
    return true;
}
Example #3
0
IndexNode IndexPage::newIndex(const char* key, int pageId, size_t cursor)
{
	syncFlag = false;
	size_t size = IndexNode::getSize(key);

	// Create from free space
	if (freeSpace() >= size)
	{
		IndexNode rec(*this, indexStartPos + indexSpace());
		rec.init(key, pageId, cursor);

		setIndexCount(indexCount() + 1);
		setIndexSpace(indexSpace() + size);
		setFreeSpace(freeSpace() - size);

		return rec;
	}

	// Check free node list
	try
	{
		IndexNode rec = freeList->findIndex(size);
		freeList->shrinkIndex(rec, size);

		// Init record
		rec.init(key, pageId, cursor);
		return rec;
	}
	catch (ReachLastIndex)
	{
		error("No space for new record");
		return IndexNode(*this, 0);		// Aviod Warning
	}
}
Example #4
0
void RawEntity::init2(std::vector<float>& vertices, std::vector<unsigned int>& indices)
{
	glGenVertexArrays(1, &m_vaoID);
	glBindVertexArray(m_vaoID);

	unsigned int EBO;
	glGenBuffers(1, &EBO);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount() * sizeof(unsigned int), &indices[0], GL_STATIC_DRAW);

	unsigned int VBO;
	glGenBuffers(1, &VBO);
	glBindBuffer(GL_ARRAY_BUFFER, VBO);
	glBufferData(GL_ARRAY_BUFFER, vertexCount() * sizeof(float), &vertices[0], GL_STATIC_DRAW);

	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)0);
	glEnableVertexAttribArray(0);

	glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(3 * sizeof(float)));
	glEnableVertexAttribArray(1);

	glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(5 * sizeof(float)));
	glEnableVertexAttribArray(2);

	glBindVertexArray(0);

	m_vboList.push_back(VBO);
	m_vboList.push_back(EBO);
}
Example #5
0
void BoundingBox::draw()
{  
  // bind the buffers
  bufferVBO().bind();
  bufferIBO().bind();

  // enable the shader attributes (our buffers)  
  shader()->enableAttributeArray(vertexLocation());
  shader()->enableAttributeArray(colorLocation());

  // set our buffers into shader
  shader()->setAttributeBuffer(vertexLocation(), GL_FLOAT, 0, 3, sizeof(Vertex));
  shader()->setAttributeBuffer(colorLocation(),  GL_FLOAT, 12, 4, sizeof(Vertex));

  
  // draw primitives
  glDrawElements(GL_LINES, indexCount(), GL_UNSIGNED_SHORT, 0);

  
  // disable the shader attributes (our buffers)
  shader()->disableAttributeArray(vertexLocation());
  shader()->disableAttributeArray(colorLocation());

  // release the buffers
  bufferVBO().release();
  bufferIBO().release();
}
Example #6
0
void IndexPage::delIndex(size_t cursor)
{
	IndexNode rec = getIndex(cursor);
	if (!rec.isDeleted())
		setIndexCount(indexCount() - 1);
	rec.initDel(rec.getSize());
	freeList->addIndex(rec);
}
Example #7
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
uint PrimitiveSetIndexedUInt::maxIndex() const
{
    if (indexCount() > 0)
    {
        return m_maxIndex;
    }
    else
    {
        return UNDEFINED_UINT;
    }
}
Example #8
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
size_t PrimitiveSet::faceCount() const
{
    switch (m_primitiveType)
    {
        case PT_POINTS:         return indexCount();
        case PT_LINES:          return indexCount()/2;
        case PT_LINE_LOOP:      return indexCount();
        case PT_LINE_STRIP:     return indexCount() - 1;
        case PT_TRIANGLES:      return triangleCount();
        case PT_TRIANGLE_STRIP: return indexCount() - 2;
        case PT_TRIANGLE_FAN:   return indexCount() - 2;
        default:                CVF_FAIL_MSG("Unhandled primitive type");
    }

    return 0;
}