void GameMapRandomizer::RandomizeTerrain( GameMapSectionManagerInterface *manager, int width, int height, int section_width, int section_height) { manager_ = manager; width_ = width; height_ = height; section_width_ = section_width; section_height_ = section_height; // 1. Lay down grass foundation BuildFoundation(); // 2. Add a random amount of dirt everywhere GenerateDirt(); // 4. Add some objects AddObjects(); // 5. Add water GenerateWater(); // 6. Add spawnpoint AddSpawnpoint(); // 7. Add dirt roads GenerateRoads(); // 8. Add dirt around water AddWaterDirt(); // 9. Fix corners for water and dirt // DONE }
void wiSPTree::initialize(const vector<Cullable*>& objects, const XMFLOAT3& newMin, const XMFLOAT3& newMax){ XMFLOAT3 min = newMin; XMFLOAT3 max = newMax; for(Cullable* object : objects){ XMFLOAT3 gMin = object->bounds.getMin(); XMFLOAT3 gMax = object->bounds.getMax(); min=wiMath::Min(gMin,min); max=wiMath::Max(gMax,max); } this->root = new wiSPTree::Node(NULL,AABB(min,max)); AddObjects(this->root,objects); }
void frmGrantWizard::AddObjects(pgCollection *collection) { bool traverseKids = (!collection->IsCollection() || collection->GetMetaType() == PGM_SCHEMA); if (!traverseKids) { pgaFactory *factory=collection->GetFactory(); if (!factory->IsCollectionFor(tableFactory) && !factory->IsCollectionFor(functionFactory) && !factory->IsCollectionFor(triggerFunctionFactory) && !factory->IsCollectionFor(procedureFactory) && !factory->IsCollectionFor(viewFactory) && !factory->IsCollectionFor(extTableFactory) && !factory->IsCollectionFor(sequenceFactory)) return; } ctlTree *browser = mainForm->GetBrowser(); wxTreeItemIdValue foldercookie, cookie; wxTreeItemId folderitem, item; folderitem = browser->GetFirstChild(browser->GetRootItem(), foldercookie); while (folderitem) { if (browser->ItemHasChildren(folderitem)) { item = browser->GetFirstChild(folderitem, cookie); while (item) { pgObject *obj = browser->GetObject(item); if (obj) { if (traverseKids) AddObjects((pgCollection*)obj); else { if (obj->CanEdit()) { objectArray.Add(obj); chkList->Append((wxString)wxGetTranslation(obj->GetTypeName()) + wxT(" ") + obj->GetFullIdentifier()); } } } item = browser->GetNextChild(folderitem, cookie); } } folderitem = browser->GetNextChild(browser->GetRootItem(), foldercookie); } }
wiSPTree* wiSPTree::updateTree(Node* node){ if(this && node) { vector<Cullable*> bad(0); for(Cullable* object : node->objects){ #ifdef SP_TREE_BOX_CONTAIN if( node->box.intersects(object->bounds)!=AABB::INSIDE ) #else if( !node->box.intersects(object->translation) ) #endif bad.push_back(object); } if(!bad.empty()){ for(Cullable* object : bad){ node->objects.remove(object); } if(node->parent){ AddObjects(node->parent,bad); } else{ CulledList culledItems; getVisible(node,node->box,culledItems); for(Cullable* item : culledItems){ bad.push_back(item); } wiSPTree* tree; if(childCount==8) tree = new Octree(); else tree = new QuadTree(); AABB nbb = node->box*1.5; tree->initialize(bad,nbb.getMin(),nbb.getMax()); return tree; } } if(!node->children.empty()){ for (unsigned int i = 0; i<node->children.size(); ++i) updateTree(node->children[i]); } } return NULL; }
void frmGrantWizard::Go() { chkList->SetFocus(); wxString privList = wxT("INSERT,SELECT,UPDATE,DELETE,TRUNCATE,REFERENCES,TRIGGER"); const char *privChar = "arwdDxt"; switch (object->GetMetaType()) { case PGM_DATABASE: case PGM_SCHEMA: privList.Append(wxT(",EXECUTE,USAGE")); privChar = "arwdDxtXU"; break; case PGM_FUNCTION: privList = wxT("EXECUTE"); privChar = "X"; break; case PGM_SEQUENCE: privList = wxT("SELECT,UPDATE,USAGE"); privChar = "rwU"; break; case GP_EXTTABLE: privList = wxT("SELECT"); privChar = "r"; default: break; } securityPage = new ctlSecurityPanel(nbNotebook, privList, privChar, mainForm->GetImageList()); securityPage->SetConnection(object->GetConnection()); this->Connect(EVT_SECURITYPANEL_CHANGE, wxCommandEventHandler(frmGrantWizard::OnChange)); sqlPane = new ctlSQLBox(nbNotebook, CTL_PROPSQL, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY | wxTE_RICH2); nbNotebook->AddPage(sqlPane, wxT("SQL")); txtMessages = new wxTextCtrl(nbNotebook, CTL_MSG, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY | wxHSCROLL); nbNotebook->AddPage(txtMessages, _("Messages")); AddObjects((pgCollection *)object); if (securityPage->cbGroups) { pgSet *set = object->GetConnection()->ExecuteSet(wxT("SELECT groname FROM pg_group ORDER BY groname")); if (set) { while (!set->Eof()) { securityPage->cbGroups->Append(wxT("group ") + set->GetVal(0)); set->MoveNext(); } delete set; } if (settings->GetShowUsersForPrivileges()) { set = object->GetConnection()->ExecuteSet(wxT("SELECT usename FROM pg_user ORDER BY usename")); if (set) { securityPage->stGroup->SetLabel(_("Group/User")); while (!set->Eof()) { securityPage->cbGroups->Append(set->GetVal(0)); set->MoveNext(); } delete set; Layout(); } } } Layout(); Show(true); // Work around a wierd display bug in wx2.7 this->Refresh(); }
void wiSPTree::AddObjects(Node* node, const vector<Cullable*>& newObjects){ for(Cullable* object : newObjects){ /*bool default_mesh = false; bool water_mesh = false; bool transparent_mesh = false; if(object->mesh->renderable) for(Material* mat : object->mesh->materials){ if(!mat->water && !mat->isSky && !mat->transparent) default_mesh=true; if(mat->water && !mat->isSky) water_mesh=true; if(!mat->water && !mat->isSky && mat->transparent) transparent_mesh=true; }*/ node->objects.push_back(object); } if(newObjects.size()>SP_TREE_OBJECT_PER_NODE && node->depth<SP_TREE_MAX_DEPTH){ node->count=childCount; node->children.reserve(node->count); XMFLOAT3 min = node->box.getMin(); XMFLOAT3 max = node->box.getMax(); AABB* boxes = new AABB[node->count]; if(node->count==8){ boxes[0] = AABB(XMFLOAT3(min.x,(min.y+max.y)*0.5f,(min.z+max.z)*0.5f),XMFLOAT3((min.x+max.x)*0.5f,max.y,max.z)); boxes[1] = AABB(XMFLOAT3((min.x+max.x)*0.5f,(min.y+max.y)*0.5f,(min.z+max.z)*0.5f),max); boxes[2] = AABB(XMFLOAT3(min.x,(min.y+max.y)*0.5f,min.z),XMFLOAT3((min.x+max.x)*0.5f,max.y,(min.z+max.z)*0.5f)); boxes[3] = AABB(XMFLOAT3((min.x+max.x)*0.5f,(min.y+max.y)*0.5f,min.z),XMFLOAT3(max.x,max.y,(min.z+max.z)*0.5f)); boxes[4] = AABB(XMFLOAT3(min.x,min.y,(min.z+max.z)*0.5f),XMFLOAT3((min.x+max.x)*0.5f,(min.y+max.y)*0.5f,max.z)); boxes[5] = AABB(XMFLOAT3((min.x+max.x)*0.5f,min.y,(min.z+max.z)*0.5f),XMFLOAT3(max.x,(min.y+max.y)*0.5f,max.z)); boxes[6] = AABB(min,XMFLOAT3((min.x+max.x)*0.5f,(min.y+max.y)*0.5f,(min.z+max.z)*0.5f)); boxes[7] = AABB(XMFLOAT3((min.x+max.x)*0.5f,min.y,min.z),XMFLOAT3(max.x,(min.y+max.y)*0.5f,(min.z+max.z)*0.5f)); } else{ boxes[0] = AABB(XMFLOAT3(min.x,min.y,(min.z+max.z)*0.5f),XMFLOAT3((min.x+max.x)*0.5f,max.y,max.z)); boxes[1] = AABB(XMFLOAT3((min.x+max.x)*0.5f,min.y,(min.z+max.z)*0.5f),max); boxes[2] = AABB(min,XMFLOAT3((min.x+max.x)*0.5f,max.y,(min.z+max.z)*0.5f)); boxes[3] = AABB(XMFLOAT3((min.x+max.x)*0.5f,min.y,min.z),XMFLOAT3(max.x,max.y,(min.z+max.z)*0.5f)); } for(int i=0;i<node->count;++i){ //children[i] = new Node(this,boxes[i],depth+1); vector<Cullable*> o(0); o.reserve(newObjects.size()); for(Cullable* object : newObjects) #ifdef SP_TREE_BOX_CONTAIN if( boxes[i].intersects(object->bounds)==AABB::INSIDE ) #else if( (*boxes[i]).intersects(object->translation) ) #endif { o.push_back(object); node->objects.remove(object); } if(!o.empty()){ node->children.push_back( new Node(node,boxes[i],node->depth+1) ); AddObjects(node->children.back(),o); } } delete[] boxes; } }