// Calculate the V8 version string. void Version::GetString(Vector<char> str) { const char* candidate = IsCandidate() ? " (candidate)" : ""; if (GetPatch() > 0) { OS::SNPrintF(str, "%d.%d.%d.%d%s", GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate); } else { OS::SNPrintF(str, "%d.%d.%d%s", GetMajor(), GetMinor(), GetBuild(), candidate); } }
// Calculate the SONAME for the V8 shared library. void Version::GetSONAME(Vector<char> str) { if (soname_ == NULL || *soname_ == '\0') { // Generate generic SONAME if no specific SONAME is defined. const char* candidate = IsCandidate() ? "-candidate" : ""; if (GetPatch() > 0) { OS::SNPrintF(str, "libv8-%d.%d.%d.%d%s.so", GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate); } else { OS::SNPrintF(str, "libv8-%d.%d.%d%s.so", GetMajor(), GetMinor(), GetBuild(), candidate); } } else { // Use specific SONAME. OS::SNPrintF(str, "%s", soname_); } }
void EC_Terrain::Destroy() { assert(GetFramework()); if (!GetFramework()) return; boost::shared_ptr<OgreRenderer::Renderer> renderer = GetFramework()->GetServiceManager()->GetService<OgreRenderer::Renderer>().lock(); if (!renderer) // Oops! Inconvenient dtor order - can't delete our own stuff since we can't get an instance to the owner. return; Ogre::SceneManager *sceneMgr = renderer->GetSceneManager(); if (!sceneMgr) // Oops! Same as above. return; for(int y = 0; y < cNumPatchesPerEdge; ++y) for(int x = 0; x < cNumPatchesPerEdge; ++x) { Ogre::SceneNode *node = GetPatch(x, y).node; if (!node) continue; sceneMgr->getRootSceneNode()->removeChild(node); // sceneMgr->destroyManualObject(dynamic_cast<Ogre::ManualObject*>(node->getAttachedObject(0))); node->detachAllObjects(); sceneMgr->destroySceneNode(node); } }
void CTerrain::MakeDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1, int dirtyFlags) { // Finds the inclusive limits of the patches that include the specified range of tiles ssize_t pi0 = clamp( i0 /PATCH_SIZE, (ssize_t)0, m_MapSizePatches-1); ssize_t pi1 = clamp((i1-1)/PATCH_SIZE, (ssize_t)0, m_MapSizePatches-1); ssize_t pj0 = clamp( j0 /PATCH_SIZE, (ssize_t)0, m_MapSizePatches-1); ssize_t pj1 = clamp((j1-1)/PATCH_SIZE, (ssize_t)0, m_MapSizePatches-1); for (ssize_t j = pj0; j <= pj1; j++) { for (ssize_t i = pi0; i <= pi1; i++) { CPatch* patch = GetPatch(i, j); // can't fail (i,j were clamped) if (dirtyFlags & RENDERDATA_UPDATE_VERTICES) patch->CalcBounds(); patch->SetDirty(dirtyFlags); } } if (m_Heightmap) { m_HeightMipmap.Update(m_Heightmap, clamp(i0, (ssize_t)0, m_MapSize-1), clamp(j0, (ssize_t)0, m_MapSize-1), clamp(i1, (ssize_t)1, m_MapSize), clamp(j1, (ssize_t)1, m_MapSize) ); } }
void CPatchPageDlg::UpdateEngine(UINT CtrlID) { theApp.GetMain()->NotifyEdit(CtrlID, UCODE_BASE_PATCH, CUndoable::UE_COALESCE); CBasePatch patch; gEngine.GetBasePatch(patch); GetPatch(patch); gEngine.SetBasePatch(patch); }
bool cePatchMeshGL20::CreatePatches(iDevice *device, unsigned numP, unsigned numQ, bool wrapP, bool wrapQ) { unsigned testP = _numP - 1; unsigned testQ = _numQ - 1; // check whether the number of vertices is at least dividable by the number // of patches we want if (testP % numP) return false; if (testQ % numQ) return false; unsigned numPerPatchP = testP / numP; unsigned numPerPatchQ = testQ / numQ; // check if the number of vertices per patch is of power of two if (!is_power_of_two(numPerPatchP)) return false; if (!is_power_of_two(numPerPatchQ)) return false; _wrapP = wrapP; _wrapQ = wrapQ; _numPatchP = numP; _numPatchQ = numQ; _patches.clear (); for (unsigned q=0; q<numQ; q++) { unsigned offsetQ = q * numPerPatchQ * _numP; for (unsigned p=0; p<numP; p++) { unsigned offset = offsetQ + (p * numPerPatchP); Patch* patch = CreatePatch(device, offset, numPerPatchP+1, numPerPatchQ+1); _patches.push_back (patch); } } for (int q=0; q<numQ; q++) { for (int p=0; p<numP; p++) { Patch* patch = GetPatch(p, q); patch->neighbours[PN_NegP] = GetPatch(p-1, q , wrapP, wrapQ); patch->neighbours[PN_NegQ] = GetPatch(p , q-1, wrapP, wrapQ); patch->neighbours[PN_PosP] = GetPatch(p+1, q , wrapP, wrapQ); patch->neighbours[PN_PosQ] = GetPatch(p , q+1, wrapP, wrapQ); } } _dirty = true; return true; }
/////////////////////////////////////////////////////////////////////////////// // GetTile: return the tile at (i,j) in tile space, or null if the tile is out // of bounds CMiniPatch* CTerrain::GetTile(ssize_t i, ssize_t j) const { // see comment above if( (size_t)i >= (size_t)(m_MapSize-1) || (size_t)j >= (size_t)(m_MapSize-1) ) return 0; CPatch* patch=GetPatch(i/PATCH_SIZE, j/PATCH_SIZE); // can't fail (due to above check) return &patch->m_MiniPatches[j%PATCH_SIZE][i%PATCH_SIZE]; }
cePatchMeshGL20::Patch* cePatchMeshGL20::GetPatch(int p, int q, bool wrapP, bool wrapQ) { if (p < 0 && wrapP) p = _numPatchP - 1; if (p >= _numPatchP && wrapP) p = 0; if (q < 0 && wrapQ) q = _numPatchQ - 1; if (q >= _numPatchQ && wrapQ) q = 0; return GetPatch(p, q); }
/////////////////////////////////////////////////////////////////////////////// // InitialisePatches: initialise patch data void CTerrain::InitialisePatches() { for (ssize_t j = 0; j < m_MapSizePatches; j++) { for (ssize_t i = 0; i < m_MapSizePatches; i++) { CPatch* patch = GetPatch(i, j); // can't fail patch->Initialize(this, i, j); } } }
float EC_Terrain::GetPoint(int x, int y) const { if (x < 0) x = 0; if (y < 0) y = 0; if (x >= cNumPatchesPerEdge * 16) x = cNumPatchesPerEdge * 16 - 1; if (y >= cNumPatchesPerEdge * 16) y = cNumPatchesPerEdge * 16 - 1; return GetPatch(x / cPatchSize, y / cPatchSize).heightData[(y % cPatchSize) * cPatchSize + (x % cPatchSize)]; }
void CTerrain::MakeDirty(int dirtyFlags) { for (ssize_t j = 0; j < m_MapSizePatches; j++) { for (ssize_t i = 0; i < m_MapSizePatches; i++) { CPatch* patch = GetPatch(i, j); // can't fail if (dirtyFlags & RENDERDATA_UPDATE_VERTICES) patch->CalcBounds(); patch->SetDirty(dirtyFlags); } } if (m_Heightmap) m_HeightMipmap.Update(m_Heightmap); }
/////////////////////////////////////////////////////////////////////////////// // SetHeightMap: set up a new heightmap from 16-bit source data; // assumes heightmap matches current terrain size void CTerrain::SetHeightMap(u16* heightmap) { // keep a copy of the given heightmap memcpy(m_Heightmap, heightmap, m_MapSize*m_MapSize*sizeof(u16)); // recalculate patch bounds, invalidate vertices for (ssize_t j = 0; j < m_MapSizePatches; j++) { for (ssize_t i = 0; i < m_MapSizePatches; i++) { CPatch* patch = GetPatch(i, j); // can't fail patch->InvalidateBounds(); patch->SetDirty(RENDERDATA_UPDATE_VERTICES); } } // update mipmap m_HeightMipmap.Update(m_Heightmap); }
/* void Print(int x,int y,char h,char v,char string[]); void ScreenAufbau(void); void DisplayPatch(void); void GetPatch(void); void Choose64(void); void PatchData(void); void PatchSuchen(); */ void Patches(void) { long L,l,n,ll; /* int i,k,pepe,k2,k3,Arg; */ int i,pepe,k2,k3; unsigned char Taste; Texes=1; Print(18,10,5,15," ����������������������������������������Ŀ "); Print(18,11,5,15," � Reading Texture Resources... � "); Print(18,12,5,15," ������������������������������������������ "); Print(27,22,0,15," "); for (i=0;i<PNames;i++) PName[i].UsedInTex=999; l=Entry->RStart; fseek(f,l,0); _read(fileno(f),&n,4); TEntries=(int)n; for (L=0;L<n;L++) { i=(int)L; _read(fileno(f),&ll,4); TEntry[i].TStart=ll+l; } for (i=0;i<TEntries;i++) { fseek(f,TEntry[i].TStart,0); _read(fileno(f),&TEntry[i].TName,8); TEntry[i].TName[8]=0; _read(fileno(f),Puffer,12); _read(fileno(f),&pepe,2); _read(fileno(f),Puffer,4); for (k2=0;k2<pepe;k2++) { _read(fileno(f),&k3,2); _read(fileno(f),Puffer,8); PName[k3].UsedInTex=i; } } ScreenAufbau(); DisplayPatch(); for(;;) { Taste=getch(); if (Taste==27) break; if (Taste==73) { TPos-=21; if (TPos<0) { TPos=0; TCPos=2; } DisplayPatch(); Taste=0; } if (Taste==81) { TPos+=21; if (TPos>n-22) { TPos=(int)n-22; TCPos=23; } DisplayPatch(); Taste=0; } if (Taste==72 && TCPos==2 && TPos>0) { TPos--; DisplayPatch(); Taste=0; } if (Taste==80 && TCPos==23) { TPos++; if (TPos>n-22) TPos=(int)n-22; DisplayPatch(); Taste=0; } if (Taste==72 && TCPos==2 && TPos==0) Taste=0; if (Taste==80) { TCPos++; DisplayPatch(); Taste=0; } if (Taste==72) { TCPos--; DisplayPatch(); Taste=0; } if (Taste==79) { TPos=(int)n-22; TCPos=23; DisplayPatch(); } if (Taste==71) { TPos=0; TCPos=2; DisplayPatch(); } if (Taste==13) GetPatch(); if (Taste==60) Choose64(); if (Taste==59) PatchData(); if ( ((Taste>94 && Taste<123) || (Taste>32 && Taste<58)) && SPos<8) { SuchStr[SPos]=Taste; SuchStr[SPos+1]=0; Print(27,22,0,15," "); Print(27,22,0,15,SuchStr); SPos++; if (SPos>0) PatchSuchen(); } if (Taste==8 && SPos>0) { SPos--; SuchStr[SPos]=0; Print(27,22,0,15," "); Print(27,22,0,15,SuchStr); if (SPos>0) PatchSuchen(); } } SuchStr[0]=0; SPos=0; Texes=0; ScreenAufbau(); Display(); }
bool RoadStrip::ReadFrom( std::istream & openfile, bool reverse, std::ostream & error_output) { assert(openfile); int num = 0; openfile >> num; patches.clear(); patches.reserve(num); // Add all road patches to this strip. int badcount = 0; for (int i = 0; i < num; ++i) { Bezier * prevbezier = 0; if (!patches.empty()) prevbezier = &patches.back().GetPatch(); patches.push_back(RoadPatch()); patches.back().GetPatch().ReadFromYZX(openfile); if (prevbezier) prevbezier->Attach(patches.back().GetPatch()); if (patches.back().GetPatch().CheckForProblems()) { badcount++; patches.pop_back(); } } if (badcount > 0) error_output << "Rejected " << badcount << " bezier patch(es) from roadstrip due to errors" << std::endl; // Reverse patches. if (reverse) { std::reverse(patches.begin(), patches.end()); for (auto & patch : patches) { patch.GetPatch().Reverse(); } } // Close the roadstrip if it ends near where it starts. closed = (patches.size() > 2) && ((patches.back().GetPatch().GetFL() - patches.front().GetPatch().GetBL()).Magnitude() < 0.1) && ((patches.back().GetPatch().GetFR() - patches.front().GetPatch().GetBR()).Magnitude() < 0.1); // Connect patches. for (auto p = patches.begin(); p != patches.end() - 1; ++p) { auto n = p + 1; p->GetPatch().Attach(n->GetPatch()); } if (closed) { patches.back().GetPatch().Attach(patches.front().GetPatch()); } GenerateSpacePartitioning(); return true; }