| 423 | }; |
| 424 | |
| 425 | void PairBench::stepSimulation(float deltaTime) |
| 426 | { |
| 427 | //color all objects blue |
| 428 | |
| 429 | GLInstanceRendererInternalData* internalData = m_guiHelper->getRenderInterface()->getInternalData(); |
| 430 | |
| 431 | if (internalData == 0) |
| 432 | return; |
| 433 | |
| 434 | //bool animate=true; |
| 435 | int numObjects = 0; |
| 436 | { |
| 437 | B3_PROFILE("Num Objects"); |
| 438 | numObjects = internalData->m_totalNumInstances; |
| 439 | } |
| 440 | b3Vector4* positions = 0; |
| 441 | if (numObjects) |
| 442 | { |
| 443 | B3_PROFILE("Sync"); |
| 444 | GLuint vbo = internalData->m_vbo; |
| 445 | |
| 446 | int arraySizeInBytes = numObjects * (3) * sizeof(b3Vector4); |
| 447 | |
| 448 | glBindBuffer(GL_ARRAY_BUFFER, vbo); |
| 449 | // cl_bool blocking= CL_TRUE; |
| 450 | char* hostPtr = 0; |
| 451 | { |
| 452 | B3_PROFILE("glMapBufferRange"); |
| 453 | hostPtr = (char*)glMapBufferRange(GL_ARRAY_BUFFER, internalData->m_maxShapeCapacityInBytes, arraySizeInBytes, GL_MAP_WRITE_BIT | GL_MAP_READ_BIT); //GL_READ_WRITE);//GL_WRITE_ONLY |
| 454 | } |
| 455 | GLint err = glGetError(); |
| 456 | assert(err == GL_NO_ERROR); |
| 457 | positions = (b3Vector4*)hostPtr; |
| 458 | |
| 459 | if (m_data->m_instancePosOrnColor && m_data->m_instancePosOrnColor->size() != 3 * numObjects) |
| 460 | { |
| 461 | delete m_data->m_instancePosOrnColor; |
| 462 | m_data->m_instancePosOrnColor = 0; |
| 463 | } |
| 464 | if (!m_data->m_instancePosOrnColor) |
| 465 | { |
| 466 | m_data->m_instancePosOrnColor = new b3OpenCLArray<b3Vector4>(m_clData->m_clContext, m_clData->m_clQueue); |
| 467 | m_data->m_instancePosOrnColor->resize(3 * numObjects); |
| 468 | m_data->m_instancePosOrnColor->copyFromHostPointer(positions, 3 * numObjects, 0); |
| 469 | m_data->m_bodyTimes = new b3OpenCLArray<float>(m_clData->m_clContext, m_clData->m_clQueue); |
| 470 | m_data->m_bodyTimes->resize(numObjects); |
| 471 | b3AlignedObjectArray<float> tmp; |
| 472 | tmp.resize(numObjects); |
| 473 | for (int i = 0; i < numObjects; i++) |
| 474 | { |
| 475 | tmp[i] = float(i) * (1024.f / numObjects); |
| 476 | } |
| 477 | m_data->m_bodyTimes->copyFromHost(tmp); |
| 478 | } |
| 479 | |
| 480 | if (!gPairBenchFileName) |
| 481 | { |
| 482 | if (1) |
nothing calls this directly
no test coverage detected