void gkPhysicsController::createShape(void) { GK_ASSERT(!m_shape && m_object); m_shape = _createShape(); }
void gkBlenderSceneConverter::convertGroups(utArray<Blender::Object*> &groups) { gkGroupManager* mgr = gkGroupManager::getSingletonPtr(); // This is a complete list of groups & containing objects. // The gkGameObjectGroup is a containter, the gkGameObjectGroupInstance // is where the object should be added / removed from the scene. // for (Blender::Group* bgrp = (Blender::Group*)m_file->_getInternalFile()->m_group.first; bgrp != 0; // bgrp = (Blender::Group*)bgrp->id.next) gkBlendListIterator iter = m_file->_getInternalFile()->getGroupList(); while (iter.hasMoreElements()) { Blender::Group* bgrp = (Blender::Group*)iter.getNext(); const gkResourceName groupName(GKB_IDNAME(bgrp), m_groupName); if (mgr->exists(groupName)) { // Can most likely assert here continue; } gkGameObjectGroup* group = (gkGameObjectGroup*)mgr->create(groupName); for (Blender::GroupObject* bgobj = (Blender::GroupObject*)bgrp->gobject.first; bgobj; bgobj = bgobj->next) { if (bgobj->ob) { Blender::Object* bobj = bgobj->ob; if (!validObject(bobj)) continue; gkGameObject* gobj = m_gscene->getObject(GKB_IDNAME(bobj)); // add it to the list if (gobj) group->addObject(gobj); } } // Destroy if empty if (group->isEmpty()) mgr->destroy(group); else mgr->attachGroupToScene(m_gscene, group); } // Process user created groups. utArray<Blender::Object*>::Iterator it = groups.iterator(); while (it.hasMoreElements()) { Blender::Object* bobj = it.getNext(); // Should not fail GK_ASSERT((bobj->transflag& OB_DUPLIGROUP && bobj->dup_group != 0)); // Owning group Blender::Group* bgobj = bobj->dup_group; const gkResourceName groupName(GKB_IDNAME(bgobj), m_groupName); if (mgr->exists(groupName)) { gkGameObjectGroup* ggobj = (gkGameObjectGroup*)mgr->getByName(groupName); gkGameObjectInstance* inst = ggobj->createGroupInstance(m_gscene, gkResourceName(GKB_IDNAME(bobj), m_groupName)); if (inst) convertObject(bobj, inst->getRoot()); } } }
gkPhysicsController* gkPhysicsController::castController(btCollisionObject* colObj) { GK_ASSERT(colObj); return static_cast<gkPhysicsController*>(colObj->getUserPointer()); }
gkPhysicsController* gkPhysicsController::castController(void* colObj) { GK_ASSERT(colObj); return castController(static_cast<btCollisionObject*>(colObj)); }
bool gkPhysicsController::sensorCollides(const gkString& prop, const gkString& material, bool onlyActor, bool testAllMaterials, utArray<gkGameObject*>* collisionList) { if (collisionList){ collisionList->clear(); } if (onlyActor && !m_object->getProperties().isActor()) return false; if (!m_localContacts.empty()) { if (!collisionList && prop.empty() && material.empty()) { // there are contacts and we do not care about property, nor empty, nor we need a list of objects (list = NULL) // any filter return true; } UTsize i, s; gkContactInfo::Array::Pointer p; i = 0; s = m_localContacts.size(); p = m_localContacts.ptr(); while (i < s) { GK_ASSERT(p[i].collider); gkGameObject* gobj = p[i].collider->getObject(); if (onlyActor) { if (prop.empty() && material.empty()) return true; if (gobj->getProperties().isActor()) { if (!prop.empty()) { if (gobj->hasVariable(prop)){ if (!collisionList){ return true; } else if (collisionList->find(gobj)==UT_NPOS) collisionList->push_back(gobj); } } else if (!material.empty()) { if (gobj->hasSensorMaterial(material, !testAllMaterials)) { if (!collisionList) { return true; } else if (collisionList->find(gobj)==UT_NPOS){ collisionList->push_back(gobj); } } } } } else { if (prop.empty() && material.empty()) if (!collisionList) { return true; } else if (collisionList->find(gobj)==UT_NPOS) { collisionList->push_back(gobj); } if (!prop.empty()) { if (gobj->hasVariable(prop)) { if (!collisionList) { return true; } else if (collisionList->find(gobj)==UT_NPOS) { collisionList->push_back(gobj); } } } else if (!material.empty()) { if (gobj->hasSensorMaterial(material, !testAllMaterials)){ if (!collisionList) { return true; } else if (collisionList->find(gobj)==UT_NPOS) { collisionList->push_back(gobj); } } } } ++i; } } if (!collisionList) return false; else if (collisionList->empty()) return false; else return true; }
gkPhysicsProperties& gkPhysicsController::getProperties(void) { GK_ASSERT(m_object); return m_props; }
void gkGroupManager::notifyResourceDestroyedImpl(gkResource* res) { gkGameObjectGroup* grp = static_cast<gkGameObjectGroup*>(res); GK_ASSERT(grp); if (grp) grp->destroyGameObjectInstances(); }