void CCAttrMap::TransformForBrush(TransformBase& Trans) { CCRuntimeClass *pType; void *pVal; for( iterator Pos = GetStartPosition(); Pos != GetEndPosition(); ) { GetNextAssoc(Pos,pType,pVal); if (pVal != NULL) { NodeAttribute* pNodeAttr = (NodeAttribute *)pVal; // check that we are not about to set line width to zero if( pNodeAttr->IsALineWidthAttr() && Trans.TransLines != FALSE ) { double Test = Trans.GetScalar().MakeDouble() * (double)((AttrLineWidth*)pNodeAttr)->Value.LineWidth; // TRACEUSER( "Diccon", _T("Scale line width by %f\n"), Test); if (Test <= 1.0) { // TRACEUSER( "Diccon", _T("Setting line width scaling OFF\n")); Trans.TransLines = FALSE; } } if (pNodeAttr->NeedsToRenderAtEachBrushStroke()) pNodeAttr->Transform(Trans); } } }
void CCAttrMap::TransformBrushFills(TransformBase& Trans) { CCRuntimeClass *pType; void *pVal; for( iterator Pos = GetStartPosition(); Pos != GetEndPosition(); ) { GetNextAssoc(Pos,pType,pVal); if (pVal != NULL) { NodeAttribute* pNodeAttr = (NodeAttribute *)pVal; // check that we are not about to set line width to zero if( pNodeAttr->IsALineWidthAttr() && Trans.TransLines != FALSE ) { INT32 Test = labs( INT32(Trans.GetScalar().MakeDouble() * ((AttrLineWidth*)pNodeAttr)->Value.LineWidth) ); if (Test <= 10) Trans.TransLines = FALSE; } if (!pNodeAttr->NeedsToRenderAtEachBrushStroke()) pNodeAttr->Transform(Trans); } } }
void CCAttrMap::ApplyAttributesToNode(NodeRenderableInk * pInk) { iterator pos = GetStartPosition(); while( pos != GetEndPosition() ) { CCRuntimeClass *pKey; void *pVal; GetNextAssoc(pos, pKey, pVal); NodeAttribute * pAttr = (NodeAttribute *)pVal; // copy the attribute if( pAttr->CanBeAppliedToObject() ) { NodeAttribute * pAttrCopy = NULL; pAttr->NodeCopy((Node **)(&pAttrCopy)); pAttrCopy->AttachNode(pInk, LASTCHILD); // nb now that GLAs have an independent flag to indicate when // they are copied from the default, it is safe to fix linkages // this ensures that GLA defaults get copied when BlendRefs are // made from complex nodes, and that they are found when MakeAppliedAttributes // calls FindAppliedAttributes on the unattached subtree // TODO?? // What about just copying compound node's Parent pointers to // pseudo attach the tree, rather than copying applied attrs to unattached tree // Just need to watch when deleting that it doesn't do anything to the // parents pointers - which it shouldn't surely? pAttrCopy->LinkToGeometry(pInk); } } }
CCAttrMap* CCAttrMap::Copy() { CCAttrMap *pNewAttrMap = new CCAttrMap( GetCount() ); if( pNewAttrMap != NULL ) { // iterating all (key, value) pairs for( iterator Pos = GetStartPosition(); Pos != GetEndPosition(); ) { CCRuntimeClass *pType; void *pVal; GetNextAssoc( Pos, pType, pVal ); // Get the attribute value of this attribute NodeAttribute* pAttr = (NodeAttribute*)pVal; // Copy the attribute NodeAttribute* pNewAttr = (NodeAttribute*) (pAttr->SimpleCopy()); // Stick the new attr into the new attr map if (pNewAttr != NULL) pNewAttrMap->SetAt(pNewAttr->GetAttributeType(),pNewAttr); } } pNewAttrMap->attrMapCreator = attrMapCreator; return pNewAttrMap; }
position_transition GetPositionTransition(unit &u, float t) { auto hi = lower_bound(u.path.begin(), u.path.end(), t, position_finder); if (hi == u.path.end() || hi == u.path.begin()) return GetEndPosition(u); auto lo = hi - 1; position_transition pt = { lo->x, lo->y, hi->x, hi->y }; pt.lerp = (t - lo->t) / (hi->t - lo->t); return pt; }
llvm::Value *Sorter::GetNumberOfStoredTuples(CodeGen &codegen, llvm::Value *sorter_ptr) const { // TODO: util::Sorter has a function to handle this ... llvm::Value *start_pos = GetStartPosition(codegen, sorter_ptr); llvm::Value *end_pos = GetEndPosition(codegen, sorter_ptr); llvm::Value *tuple_size = codegen->CreateZExt(GetTupleSize(codegen), codegen.Int64Type()); llvm::Value *diff_bytes = codegen->CreatePtrDiff(end_pos, start_pos); llvm::Value *num_tuples = codegen->CreateUDiv(diff_bytes, tuple_size); return codegen->CreateTruncOrBitCast(num_tuples, codegen.Int32Type()); }
void CCAttrMap::Transform(TransformBase& Trans) { CCRuntimeClass *pType; void *pVal; for( iterator Pos = GetStartPosition(); Pos != GetEndPosition(); ) { GetNextAssoc(Pos,pType,pVal); if (pVal != NULL) { NodeAttribute* pNodeAttr = (NodeAttribute *)pVal; pNodeAttr->Transform(Trans); } } }
bool PathGenerator::CalculatePath(float destX, float destY, float destZ, bool forceDest) { float x, y, z; _sourceUnit->GetPosition(x, y, z); if (!Trinity::IsValidMapCoord(destX, destY, destZ) || !Trinity::IsValidMapCoord(x, y, z)) return false; Vector3 oldDest = GetEndPosition(); Vector3 dest(destX, destY, destZ); SetEndPosition(dest); Vector3 start(x, y, z); SetStartPosition(start); _forceDestination = forceDest; sLog->outDebug(LOG_FILTER_MAPS, "++ PathGenerator::CalculatePath() for %u \n", _sourceUnit->GetGUIDLow()); // make sure navMesh works - we can run on map w/o mmap // check if the start and end point have a .mmtile loaded (can we pass via not loaded tile on the way?) if (!_navMesh || !_navMeshQuery || _sourceUnit->HasUnitState(UNIT_STATE_IGNORE_PATHFINDING) || !HaveTile(start) || !HaveTile(dest)) { BuildShortcut(); _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH); return true; } UpdateFilter(); // check if destination moved - if not we can optimize something here // we are following old, precalculated path? float dist = _sourceUnit->GetObjectSize(); if (oldDest != Vector3::zero() && InRange(oldDest, dest, dist, dist) && _pathPoints.size() > 2) { // our target is not moving - we just coming closer // we are moving on precalculated path - enjoy the ride sLog->outDebug(LOG_FILTER_MAPS, "++ PathGenerator::CalculatePath:: precalculated path\n"); _pathPoints.erase(_pathPoints.begin()); return false; } else { // target moved, so we need to update the poly path BuildPolyPath(start, dest); return true; } }
bool CSeqMap_CI::x_Prev(void) { if ( !x_TopPrev() ) return x_Pop(); for ( ;; ) { TSeqPos search_end = m_SearchEnd; TSeqPos level_end = GetEndPosition(); TSeqPos end_offset = search_end < level_end? level_end - search_end: 0; if ( !x_Push(m_Selector.m_Length-end_offset-1) ) { break; } } return true; }
/******************************************************************************************** > void CCAttrMap::BuildListOfAttributes(List * pList) Author: David_McClarnon (Xara Group Ltd) <*****@*****.**> Created: 30/4/99 Inputs: The list to use Outputs: - Returns: - Purpose: Builds a list of NodeListItems of all the attributes in this attribute map Notes: Includes all attributes - even those which can't be applied to objects Use CanBeAppliedToObject to test SeeAlso: - ********************************************************************************************/ void CCAttrMap::BuildListOfAttributes(List * pList) { iterator pos = GetStartPosition(); NodeListItem *pItem = NULL; while( pos != GetEndPosition() ) { CCRuntimeClass *pKey; void *pVal; GetNextAssoc( pos, pKey, pVal ); pItem = new NodeListItem((NodeAttribute *)pVal); pList->AddTail(pItem); } }
/******************************************************************************************** > BOOL CCAttrMap::IsSeeThrough() Author: Karim_MacDonald (Xara Group Ltd) <*****@*****.**> Created: 19/02/2001 Returns: TRUE if at least one of our attrs IsSeeThrough(), FALSE otherwise. Purpose: Test each of the attributes in this map for see-through-ness. This is not the same as transparency - what it means is: if I draw something in white, then draw its outline as retrieved from PathBecomeA in black over the top, will I still be able to see white bits? IsSeeThrough() therefore depends partly on the implementation of PathBecomeA. Examples: Transparency is always see-through unless it is a zero transparency. Line width is not see through - PathBecomeA can cope with this attr. Fill colour is not see-through unless it is COLOUR_NONE. Brush attrs are normally see-through, as PathBecomeA ignores them. See Also: NodeRenderableInk::IsSeeThrough() ********************************************************************************************/ BOOL CCAttrMap::IsSeeThrough() { CCRuntimeClass *pKey; void *pVal; BOOL bIsSeeThrough = FALSE; for ( iterator pos = GetStartPosition(); pos != GetEndPosition() && !bIsSeeThrough; ) { GetNextAssoc(pos, pKey, pVal); NodeAttribute* pAttr = (NodeAttribute*)pVal; bIsSeeThrough = pAttr->IsSeeThrough(FALSE); } return bIsSeeThrough; }
void CCAttrMap::DeleteAttributes() { CCRuntimeClass *pType; void *pVal; // iterating all (key, value) pairs for( iterator Pos = GetStartPosition(); Pos != GetEndPosition(); ) { // Get attr at position Pos GetNextAssoc( Pos, pType, pVal ); if (pVal != NULL) { RemoveKey(pType); // Must cast to NodeAttribute before deleting, otherwise wrong destructor gets called delete (NodeAttribute*)pVal; } } }
void GraphCoordinateList::RemoveAll() { if(!m_ListCoordinates.empty()) { GraphCoordinateListPosition i = GetBeginPosition(); GraphCoordinateListPosition ei = GetEndPosition(); while(i != ei) { size_t* elt_ptr = *i; if(elt_ptr) delete [] elt_ptr; NextPosition(i); } } m_ListCoordinates.clear(); }
bool PathGenerator::CalculatePath(float destX, float destY, float destZ, bool /*forceDest*/) { float x, y, z; _sourceUnit->GetPosition(x, y, z); if (!Trinity::IsValidMapCoord(destX, destY, destZ) || !Trinity::IsValidMapCoord(x, y, z)) return false; G3D::Vector3 dest(destX, destY, destZ); SetEndPosition(dest); SetActualEndPosition(GetEndPosition()); G3D::Vector3 start(x, y, z); SetStartPosition(start); TC_LOG_DEBUG("maps", "++ PathGenerator::CalculatePath() for %u\n", _sourceUnit->GetGUIDLow()); BuildShortcut(); _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH); return true; }
/******************************************************************************************** > void CCAttrMap::Render(RenderRegion * pRegion, BOOL RenderOffscreenAttributes = TRUE) Author: David_McClarnon (Xara Group Ltd) <*****@*****.**> Created: 30/4/99 Inputs: pRegion render-region to render into. RenderOffscreenAttributes whether or not to render offscreen attributes, eg feathers. Outputs: - Returns: - Purpose: Renders the attribute map into the given render region Notes: Karim 15/11/2000 Modified so that I can render an attribute map *without* rendering any offscreen attributes contained therein. SeeAlso: - ********************************************************************************************/ void CCAttrMap::Render(RenderRegion * pRegion, BOOL RenderOffscreenAttributes) { // OK, we have found the full quota of attributes. Now render them all. iterator pos = GetStartPosition(); while( pos != GetEndPosition() ) { CCRuntimeClass *pKey; void *pVal; GetNextAssoc( pos, pKey, pVal ); NodeAttribute* pAttr = (NodeAttribute*)pVal; if ( pAttr->CanBeAppliedToObject() && pAttr->RenderSubtree(pRegion)==SUBTREE_ROOTONLY ) { // render all attributes, unless we've been specifically asked // not to render offscreen attributes. if (RenderOffscreenAttributes || !pAttr->IsAnOffscreenAttribute()) pAttr->Render(pRegion); } } }
/*! \brief Method to help reading a Master element and all subsequent children quickly \todo add an option to discard even unknown elements \todo handle when a mandatory element is not found */ void EbmlMaster::Read(EbmlStream & inDataStream, const EbmlSemanticContext & sContext, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt, ScopeMode ReadFully) { if (ReadFully != SCOPE_NO_DATA) { EbmlElement * ElementLevelA; // remove all existing elements, including the mandatory ones... size_t Index; for (Index=0; Index<ElementList.size(); Index++) { if (!(*ElementList[Index]).IsLocked()) { delete ElementList[Index]; } } ElementList.clear(); uint64 MaxSizeToRead; if (IsFiniteSize()) MaxSizeToRead = GetSize(); else MaxSizeToRead = 0x7FFFFFFF; // read blocks and discard the ones we don't care about if (MaxSizeToRead > 0) { inDataStream.I_O().setFilePointer(GetSizePosition() + GetSizeLength(), seek_beginning); ElementLevelA = inDataStream.FindNextElement(sContext, UpperEltFound, MaxSizeToRead, AllowDummyElt); while (ElementLevelA != NULL && UpperEltFound <= 0 && MaxSizeToRead > 0) { if (IsFiniteSize()) MaxSizeToRead = GetEndPosition() - ElementLevelA->GetEndPosition(); // even if it's the default value if (!AllowDummyElt && ElementLevelA->IsDummy()) { ElementLevelA->SkipData(inDataStream, sContext); delete ElementLevelA; // forget this unknown element } else { // more logical to do it afterward ElementList.push_back(ElementLevelA); ElementLevelA->Read(inDataStream, EBML_CONTEXT(ElementLevelA), UpperEltFound, FoundElt, AllowDummyElt, ReadFully); // just in case ElementLevelA->SkipData(inDataStream, EBML_CONTEXT(ElementLevelA)); } if (UpperEltFound > 0) { UpperEltFound--; if (UpperEltFound > 0 || MaxSizeToRead <= 0) goto processCrc; ElementLevelA = FoundElt; continue; } if (UpperEltFound < 0) { UpperEltFound++; if (UpperEltFound < 0) goto processCrc; } if (MaxSizeToRead <= 0) goto processCrc;// this level is finished ElementLevelA = inDataStream.FindNextElement(sContext, UpperEltFound, MaxSizeToRead, AllowDummyElt); } if (UpperEltFound > 0) { FoundElt = ElementLevelA; } } processCrc: EBML_MASTER_ITERATOR Itr, CrcItr; for (Itr = ElementList.begin(); Itr != ElementList.end();) { if ((EbmlId)(*(*Itr)) == EBML_ID(EbmlCrc32)) { bChecksumUsed = true; // remove the element Checksum = *(static_cast<EbmlCrc32*>(*Itr)); CrcItr = Itr; break; } ++Itr; } if (bChecksumUsed) { delete *CrcItr; Remove(CrcItr); } SetValueIsSet(); } }
void PathGenerator::BuildPointPath(const float *startPoint, const float *endPoint) { float pathPoints[MAX_POINT_PATH_LENGTH*VERTEX_SIZE]; uint32 pointCount = 0; dtStatus dtResult = DT_FAILURE; if (_useStraightPath) { dtResult = _navMeshQuery->findStraightPath( startPoint, // start position endPoint, // end position _pathPolyRefs, // current path _polyLength, // lenth of current path pathPoints, // [out] path corner points NULL, // [out] flags NULL, // [out] shortened path (int*)&pointCount, _pointPathLimit); // maximum number of points/polygons to use } else { dtResult = FindSmoothPath( startPoint, // start position endPoint, // end position _pathPolyRefs, // current path _polyLength, // length of current path pathPoints, // [out] path corner points (int*)&pointCount, _pointPathLimit); // maximum number of points } if (pointCount < 2 || dtResult != DT_SUCCESS) { // only happens if pass bad data to findStraightPath or navmesh is broken // single point paths can be generated here // TODO : check the exact cases sLog->outDebug(LOG_FILTER_MAPS, "++ PathGenerator::BuildPointPath FAILED! path sized %d returned\n", pointCount); BuildShortcut(); _type = PATHFIND_NOPATH; return; } else if (pointCount == _pointPathLimit) { sLog->outDebug(LOG_FILTER_MAPS, "++ PathGenerator::BuildPointPath FAILED! path sized %d returned, lower than limit set to %d\n", pointCount, _pointPathLimit); BuildShortcut(); _type = PATHFIND_SHORT; return; } _pathPoints.resize(pointCount); for (uint32 i = 0; i < pointCount; ++i) _pathPoints[i] = Vector3(pathPoints[i*VERTEX_SIZE+2], pathPoints[i*VERTEX_SIZE], pathPoints[i*VERTEX_SIZE+1]); NormalizePath(); // first point is always our current location - we need the next one SetActualEndPosition(_pathPoints[pointCount-1]); // force the given destination, if needed if (_forceDestination && (!(_type & PATHFIND_NORMAL) || !InRange(GetEndPosition(), GetActualEndPosition(), 1.0f, 1.0f))) { // we may want to keep partial subpath if (Dist3DSqr(GetActualEndPosition(), GetEndPosition()) < 0.3f * Dist3DSqr(GetStartPosition(), GetEndPosition())) { SetActualEndPosition(GetEndPosition()); _pathPoints[_pathPoints.size()-1] = GetEndPosition(); } else { SetActualEndPosition(GetEndPosition()); BuildShortcut(); } _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH); } //Custom Point for Bugged Zone (By saqi) float startEndDist = Dist3DSqr(GetStartPosition(), GetEndPosition()); //Blade edge arena (mapid) if (_sourceUnit->GetMapId() == 562) { //Your Position & Target Position if (startEndDist < 2500.0f && endPoint[2] <= 6230.803223f && startPoint[2] >= 6230.803223f && endPoint[1] >= 11.000000 && startPoint[1] >= 11.000000f && endPoint[0] >= 247.547917f && endPoint[0] <= 252.298940f) // southeast pillar { // Path X,y,z _pathPoints.resize(4); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(6234.506836f, 256.696106f, 11.400018f); _pathPoints[2] = Vector3(6231.472656f, 252.849335f, 11.400018f); _pathPoints[3] = GetEndPosition(); } else if (startEndDist < 2500.0f && endPoint[2] >= 6246.201660f && startPoint[2] <= 6246.201660f && endPoint[1] >= 11.000000f && startPoint[1] >= 11.000000f && endPoint[0] >= 217.677917f && endPoint[0] <= 276.888794f) // northwest pillar { // Path X,y,z _pathPoints.resize(4); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(6242.146484f, 267.531030f, 11.400000f); _pathPoints[2] = Vector3(6246.985352f, 271.076599f, 11.400000f); _pathPoints[3] = GetEndPosition(); } if (startEndDist < 2500.0f && startPoint[2] <= 6230.803223f && endPoint[2] >= 6230.803223f && endPoint[1] >= 11.000000 && startPoint[1] >= 11.000000f && startPoint[0] >= 247.547917f && startPoint[0] <= 252.298940f) // southeast pillar { // Path X,y,z _pathPoints.resize(4); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(6231.472656f, 252.849335f, 11.400018f); _pathPoints[2] = Vector3(6234.506836f, 256.696106f, 11.400018f); _pathPoints[3] = GetEndPosition(); } else if (startEndDist < 4000.0f && startPoint[2] >= 6246.201660f && endPoint[2] <= 6246.201660f && endPoint[1] >= 11.000000f && startPoint[1] >= 11.000000f && startPoint[0] >= 217.677917f && startPoint[0] <= 276.888794f) // northwest pillar { // Path X,y,z _pathPoints.resize(4); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(6246.985352f, 271.076599f, 11.400000f); _pathPoints[2] = Vector3(6242.146484f, 267.531030f, 11.400000f); _pathPoints[3] = GetEndPosition(); } } //Dalaran Sewer if (_sourceUnit->GetMapId() == 617) { if (startPoint[2] >= 1330.033223f && startPoint[1] >= 9.000000f) // Canal 1# { // Path X,y,z _pathPoints.resize(5); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(1332.749268f, 816.274780f, 8.355900f); _pathPoints[2] = Vector3(1325.749268f, 816.602539f, 5.4000000f); _pathPoints[3] = Vector3(1328.749268f, 816.602539f, 3.4000000f); _pathPoints[4] = GetEndPosition(); } else if (startPoint[2] <= 1253.904785f && startPoint[1] >= 9.000000f) // Canal 2# { // Path X,y,z _pathPoints.resize(5); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(1252.425395f, 764.971680f, 8.000000f); _pathPoints[3] = Vector3(1255.425395f, 764.971680f, 5.3559000f); _pathPoints[3] = Vector3(1257.425395f, 764.971680f, 3.3559000f); _pathPoints[4] = GetEndPosition(); } } //Eye of The Storm if (_sourceUnit->GetMapId() == 566) { if (startPoint[2] <= 1850.003223f && startPoint[1] >= 1237.000000f && startPoint[0] >= 1501.420000f && startPoint[0] <= 1579.960000f) // StartZone Horde { // Path X,y,z _pathPoints.resize(5); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(1847.004468f, 1540.660539f, 1243.400000f); _pathPoints[2] = Vector3(1842.883268f, 1527.123839f, 1238.410000f); _pathPoints[3] = Vector3(1839.593268f, 1519.479539f, 1229.428000f); _pathPoints[4] = GetEndPosition(); } if (startPoint[2] >= 2484.003223f && startPoint[1] >= 1240.000000f && startPoint[0] >= 1567.420000f && startPoint[0] <= 1626.960000f) // StartZone Alliance { // Path X,y,z _pathPoints.resize(5); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(2485.154468f, 1596.583439f, 1244.898315f); _pathPoints[2] = Vector3(2482.733268f, 1608.305649f, 1238.092000f); _pathPoints[3] = Vector3(2488.073268f, 1623.749539f, 1227.788000f); _pathPoints[4] = GetEndPosition(); } } //Custom Point for Bugged Zone sLog->outDebug(LOG_FILTER_MAPS, "++ PathGenerator::BuildPointPath path type %d size %d poly-size %d\n", _type, pointCount, _polyLength); }
void PathGenerator::BuildPointPath(const float *startPoint, const float *endPoint) { float pathPoints[MAX_POINT_PATH_LENGTH*VERTEX_SIZE]; uint32 pointCount = 0; dtStatus dtResult = DT_FAILURE; if (_straightLine) { // if the path is a straight line then start and end position are enough dtResult = DT_SUCCESS; pointCount = 2; memcpy(&pathPoints[0], startPoint, sizeof(float)* 3); memcpy(&pathPoints[3], endPoint, sizeof(float)* 3); } else if (_useStraightPath) { dtResult = _navMeshQuery->findStraightPath( startPoint, // start position endPoint, // end position _pathPolyRefs, // current path _polyLength, // lenth of current path pathPoints, // [out] path corner points NULL, // [out] flags NULL, // [out] shortened path (int*)&pointCount, _pointPathLimit); // maximum number of points/polygons to use } else { dtResult = FindSmoothPath( startPoint, // start position endPoint, // end position _pathPolyRefs, // current path _polyLength, // length of current path pathPoints, // [out] path corner points (int*)&pointCount, _pointPathLimit); // maximum number of points } if (pointCount < 2 || dtStatusFailed(dtResult)) { // only happens if pass bad data to findStraightPath or navmesh is broken // single point paths can be generated here /// @todo check the exact cases TC_LOG_DEBUG("maps", "++ PathGenerator::BuildPointPath FAILED! path sized %d returned\n", pointCount); BuildShortcut(); _type = PATHFIND_NOPATH; return; } else if (pointCount == _pointPathLimit) { TC_LOG_DEBUG("maps", "++ PathGenerator::BuildPointPath FAILED! path sized %d returned, lower than limit set to %d\n", pointCount, _pointPathLimit); BuildShortcut(); _type = PATHFIND_SHORT; return; } _pathPoints.resize(pointCount); for (uint32 i = 0; i < pointCount; ++i) _pathPoints[i] = G3D::Vector3(pathPoints[i*VERTEX_SIZE+2], pathPoints[i*VERTEX_SIZE], pathPoints[i*VERTEX_SIZE+1]); NormalizePath(); // first point is always our current location - we need the next one SetActualEndPosition(_pathPoints[pointCount-1]); // force the given destination, if needed if (_forceDestination && (!(_type & PATHFIND_NORMAL) || !InRange(GetEndPosition(), GetActualEndPosition(), 1.0f, 1.0f))) { // we may want to keep partial subpath if (Dist3DSqr(GetActualEndPosition(), GetEndPosition()) < 0.3f * Dist3DSqr(GetStartPosition(), GetEndPosition())) { SetActualEndPosition(GetEndPosition()); _pathPoints[_pathPoints.size()-1] = GetEndPosition(); } else { SetActualEndPosition(GetEndPosition()); BuildShortcut(); } _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH); } TC_LOG_DEBUG("maps", "++ PathGenerator::BuildPointPath path type %d size %d poly-size %d\n", _type, pointCount, _polyLength); }
void CCBManager::Update() { //チョコボールを生成していく。 const float deltaTime = 1.0f / 60.0f; m_timer += deltaTime; if (m_interval < m_timer){ int createCount = 0; while ( m_numCreate < CHOCO_NUM ){ if (createCount == 10){ break; } float rate = 100.0f / (rand() % 100 + 1); rate /= 50.0f; if (rand() % 2){ rate *= -1.0f; } D3DXVECTOR3 pos(GetStartPosition()); pos.x += rate; pos.z += fabsf(rate); pos.y += rate; D3DXVECTOR3 Epos(GetEndPosition()); Epos.x += rate; Epos.z += fabsf(rate); Epos.y += rate; m_Choco[m_numCreate].Initialize(pos, Epos); //if (m_IsFirst){ // D3DXMESHCONTAINER_DERIVED* pMeshContainer = static_cast<D3DXMESHCONTAINER_DERIVED*>(m_Choco[m_numCreate].GetImage()->pModel->GetFrameRoot()->pMeshContainer); // LPDIRECT3DVERTEXBUFFER9 buffer; // pMeshContainer->MeshData.pMesh->GetVertexBuffer(&buffer)/*->GetBufferPointer()*/; // VOID* pVertices; // buffer->Lock(0, sizeof(buffer), (void**)&pVertices, 0); // D3DVERTEXBUFFER_DESC desc; // buffer->GetDesc(&desc); // int stride = D3DXGetFVFVertexSize(desc.FVF); // char* p = (char*)pVertices; // int offset = -1; // D3DVERTEXELEMENT9 pDecl[MAX_FVF_DECL_SIZE]; // memset(pDecl, -1, sizeof(pDecl)); // pMeshContainer->MeshData.pMesh->GetDeclaration(pDecl); // for (int idx = 0; idx < MAX_FVF_DECL_SIZE; idx++){ // if (pDecl[idx].Stream == 255){ // //終わり // break; // } // if (pDecl[idx].Usage == D3DDECLUSAGE_BINORMAL){ // offset = pDecl[idx].Offset; // } // } // for (int vertNo = 0; vertNo < pMeshContainer->MeshData.pMesh->GetNumVertices(); vertNo++){ // D3DXVECTOR3* pBinomal = (D3DXVECTOR3*)&p[offset]; // pBinomal->x = // p += stride; // } // // // //buffer // //m_pVertexBuffer-> // //memcpy(pVertices, buffer, sizeof(buffer)); // //pVertices // buffer->Unlock(); // (*graphicsDevice()).CreateVertexBuffer(sizeof(buffer), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &m_pVertexBuffer, nullptr); // m_IsFirst = false; //} SINSTANCE(CShadowRender)->Entry(&m_Choco[m_numCreate]); createCount++; m_numCreate++; } } for (int i = 0; i < m_numCreate; i++) { m_Choco[i].Update(); } }