gep::ICollisionFilter* gep::HavokPhysicsFactory::createCollisionFilter_Simple() { auto pHkFilter = new HavokCollisionFilter_Simple(); auto pFilterWrapper = GEP_NEW(m_pAllocator, HavokCollisionFilterWrapper)(pHkFilter); pHkFilter->removeReference(); return pFilterWrapper; }
void NodeCore::kill(NodeCore &ref) { StLock<Mutex> _(*this); assert(hasReference(ref)); ref.kill(); removeReference(ref); }
void do_stop (CompletionCounter) { m_journal.debug << "Stopped"; m_stopped = true; m_work.clear (); m_resolver.cancel (); removeReference (); }
void Reader::removeToken() { secdebug("reader", "%p (%s) removing token %p", this, name().c_str(), mToken); assert(mToken); mToken->remove(); removeReference(*mToken); mToken = NULL; }
void BaseTagHDF5::references(const std::vector<DataArray> &refs_new) { while (referenceCount() > 0) { removeReference(getReference(0)->id()); } for (const auto &ref : refs_new) { addReference(ref.id()); } }
//------------------------------------------------------------------------- // Resolver void do_stop (CompletionCounter) { assert (m_stop_called == true); if (m_stopped.exchange (true) == false) { m_work.clear (); m_resolver.cancel (); removeReference (); } }
/* \brief Assignement operator. * * Does a shallow copy of the data in the provided Array and updates * the reference counter as appropriate. * * \param rhs * The Array to copy. * * \return * A reference to the modified current array. */ CS225::Array& CS225::Array::operator=(const Array &rhs) { if (this != &rhs) { removeReference(); data = rhs.data; reference_counter = rhs.reference_counter; size = rhs.size; pElementFactory = rhs.pElementFactory; ++(*reference_counter); } return(*this); }
void CWorld::AddSystemObject(UINT32 id, const std::string& prefix, NiNode* skeleton, const char* path) { auto locker = m_lock.SmartLock(); auto system = LoadPhysicsFile(path); if(!system) { LogWarning("Invalid havok serialize file : %s", path); return; } LogInfo("Physics system loaded : %s", path); CSystemObject::RenameBodies(skeleton, system, prefix); auto obj = std::shared_ptr<CSystemObject>(new CSystemObject); if(obj && obj->BindPhysicsInfo(system, skeleton)) m_systems.insert(std::make_pair(id, obj)); system->removeReference(); }
void ListShapeSetter::on_listWidget_doubleClicked(const QModelIndex &index) { DialogShapeSetter dialog(this); auto shape = children[index.row()]; if(!dialog.setShape(shape)) { QString text = ui->listWidget->item(index.row())->text(); text += " is not support by the editor\n"; text += "if continue, the shape will be replaced and cannot roll back.\n"; text += "continue?"; if(QMessageBox::warning(this, "Warning", text, QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes) == QMessageBox::No) return; } dialog.show(); if(dialog.exec()) { shape->removeReference(); children[index.row()] = dialog.shape; dialog.shape->addReference(); auto shapeClass = getHavokClass(dialog.shape); ui->listWidget->item(index.row())->setText(shapeClass->getName()); } }
void BaseTagHDF5::references(const std::vector<DataArray> &refs_new) { // extract vectors of names from vectors of new & old references std::vector<std::string> names_new(refs_new.size()); transform(refs_new.begin(), refs_new.end(), names_new.begin(), util::toName<DataArray>); //FIXME: issue 473 std::vector<DataArray> refs_old(static_cast<size_t>(referenceCount())); for (size_t i = 0; i < refs_old.size(); i++) refs_old[i] = getReference(i); std::vector<std::string> names_old(refs_old.size()); transform(refs_old.begin(), refs_old.end(), names_old.begin(), util::toName<DataArray>); // sort them std::sort(names_new.begin(), names_new.end()); std::sort(names_new.begin(), names_new.end()); // get names only in names_new (add), names only in names_old (remove) & ignore rest std::vector<std::string> names_add; std::vector<std::string> names_rem; std::set_difference(names_new.begin(), names_new.end(), names_old.begin(), names_old.end(), std::inserter(names_add, names_add.begin())); std::set_difference(names_old.begin(), names_old.end(), names_new.begin(), names_new.end(), std::inserter(names_rem, names_rem.begin())); // check if all new references exist & add sources auto blck = dynamic_pointer_cast<BlockHDF5>(block()); for (auto name : names_add) { if (!blck->hasDataArray(name)) throw std::runtime_error("One or more data arrays do not exist in this block!"); addReference(blck->getDataArray(name)->id()); } // remove references for (auto name : names_rem) { if (!blck->hasDataArray(name)) removeReference(blck->getDataArray(name)->id()); } }
/* \brief Destructor. * * Ensures that the reference counter is consistent. * * If there are no other references to the data, the data is deallocated. */ CS225::Array::~Array(void) { removeReference(); }
bool TextureReference::load(std::string aFilename, int aUnit, bool aUseUnit) { addReference(); if(m_Texture != 0) { //Texture already here return false; } std::string textureName = aFilename; aFilename = FilePath::getInstance()->convertPathForTextures(aFilename); unsigned char * data; int width(0),height(0); data = SOIL_load_image(aFilename.c_str(),&width,&height,0,SOIL_LOAD_RGBA); //unsigned int error = lodepng_decode32_file(&data,&width,&height,aFilename.c_str()); if(data == 0) { SOIL_free_image_data(data); removeReference(); //failure to load texture remove reference return false; } unsigned int textureHandle = 0; glGenTextures(1, &textureHandle); if(aUseUnit == true) { glActiveTexture(GL_TEXTURE0 + aUnit); } glBindTexture(GL_TEXTURE_2D,textureHandle); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); SOIL_free_image_data(data); //GL_CLAMP - Does not repeat, just stretches lines //GL_REPEAT - repeats.. checker board pattern glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //GL_CLAMP / GL_CLAMP_TO_EDGE / GL_REPEAT / GL_MIRRORED_REPEAT glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //GL_CLAMP / GL_CLAMP_TO_EDGE GL_REPEAT / GL_MIRRORED_REPEAT //GL_LINEAR - Smooth //GL_NEAREST - 8 Bit graphics glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //GL_NEAREST / GL_LINEAR glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //GL_NEAREST / GL_LINEAR //the min filter is used whenever a surface is rendered with smaller dimensions that its corresponding texture //the mag filter is used whenever the surface is bigger than the texture being applied //Unbind glBindTexture(GL_TEXTURE_2D,0); m_Texture = new Texture(); m_Texture->m_Filename = aFilename; m_Texture->m_TextureName = textureName; m_Texture->m_ID = textureHandle; m_Texture->m_FileWidth = width; m_Texture->m_FileHeight = height; m_Texture->m_SourceX = 0; m_Texture->m_SourceY = 0; m_Texture->m_SourceWidth = m_Texture->m_FileWidth; m_Texture->m_SourceHeight = m_Texture->m_FileHeight; m_Texture->m_MinU = 0.0f;//m_Texture->m_SourceX / width; m_Texture->m_MaxU = 1.0f;//m_Texture->m_SourceY / width; m_Texture->m_MinV = 0.0f;//m_Texture->m_SourceWidth / height; m_Texture->m_MaxV = 1.0f;//m_Texture->m_SourceHeight / height; return true; }
hkpConstraintData* Generic::getConstraint() { auto data = new hkpGenericConstraintData; hkpConstraintConstructionKit kit; kit.begin(data); { hkVector4 pivotA, pivotB; ui->pivotA->getVector(pivotA); ui->pivotB->getVector(pivotB); kit.setPivotA(pivotA); kit.setPivotB(pivotB); hkRotation linearBasis; ui->linearBasisB->getRotation(linearBasis); kit.setLinearDofB(linearBasis.getColumn(0), 0); kit.setLinearDofB(linearBasis.getColumn(1), 1); kit.setLinearDofB(linearBasis.getColumn(2), 2); hkVector4 linMin, linMax; ui->linearMin->getVector(linMin); ui->linearMax->getVector(linMax); for(int i=0; i<3; ++i) { if(linMin(i)==linMax(i) && !linMin(i)) kit.constrainLinearDof(i); else if(linMin(i)<=linMax(i)) kit.setLinearLimit(i, linMin(i), linMax(i)); } auto lMotorX = ui->linearMotorX->getMotor(); auto lMotorY = ui->linearMotorY->getMotor(); auto lMotorZ = ui->linearMotorZ->getMotor(); if(lMotorX) kit.setLinearMotor(0, lMotorX); if(lMotorY) kit.setLinearMotor(1, lMotorY); if(lMotorZ) kit.setLinearMotor(2, lMotorZ); if(lMotorX) lMotorX->removeReference(); if(lMotorY) lMotorY->removeReference(); if(lMotorZ) lMotorZ->removeReference(); hkRotation basisA, basisB; ui->angularBasisA->getRotation(basisA); ui->angularBasisB->getRotation(basisB); kit.setAngularBasisA(basisA); kit.setAngularBasisB(basisB); hkVector4 angMin, angMax; ui->angularMin->getVector(angMin); ui->angularMax->getVector(angMax); for(int i=0; i<3; ++i) { if(angMin(i)==angMax(i) && !angMin(i)) kit.constrainToAngularDof(i); else if(angMin(i)<=angMax(i)) kit.setAngularLimit(i, angMin(i), angMax(i)); } auto aMotorX = ui->angularMotorX->getMotor(); auto aMotorY = ui->angularMotorY->getMotor(); auto aMotorZ = ui->angularMotorZ->getMotor(); if(aMotorX) kit.setAngularMotor(0, aMotorX); if(aMotorY) kit.setAngularMotor(1, aMotorY); if(aMotorZ) kit.setAngularMotor(2, aMotorZ); if(aMotorX) aMotorX->removeReference(); if(aMotorY) aMotorY->removeReference(); if(aMotorZ) aMotorZ->removeReference(); hkVector4 linFri, angFri; ui->linearFriction->getVector(linFri); ui->angularFriction->getVector(angFri); for(int i=0; i<3; ++i) if(linFri(i)) kit.setLinearFriction(i, linFri(i)); for(int i=0; i<3; ++i) if(angFri(i)) kit.setAngularFriction(i, angFri(i)); } kit.end(); return data; }