Exemplo n.º 1
0
void Model::UpdateNode(Node * node, Node * parentnode)
{
	if (parentnode) node->combined_transform = parentnode->combined_transform * node->transform;
	else node->combined_transform = node->transform;
	unsigned int i;
	for (i = 0; i<node->children.size(); i++)
		UpdateNode(&node->children[i], node);
}
CNodeMCompose::CNodeMCompose( CNodeView *p ) : BaseClass( "MCompose", p )
{
	GenerateJacks_Output( 1 );

	iTargetMatrix = HLSLVAR_MATRIX3X3;
	bColumns = false;
	UpdateNode();
}
Exemplo n.º 3
0
void Scene::UpdateNode(float dt, GameObject* cNode)
{
	cNode->OnUpdateObject(dt);  

	for (auto child : cNode->GetChildren()) {
		UpdateNode(dt, child);
	}
}
Exemplo n.º 4
0
void Hierarchy::CompleteRefresh()
{
	m_Tree->Clear();

	UpdateNode( m_Tree, m_pCanvas );

	m_Tree->ExpandAll();
}
Exemplo n.º 5
0
void CNodeCustom::RestoreFromKeyValues_Specific( KeyValues *pKV )
{
	RestoreInternal( pKV );

	if ( !IsUsingInlineCode() )
		UpdateFromFile();

	UpdateNode();
}
Exemplo n.º 6
0
void CNeighboursTableModel::UpdateAll()
{
	
	//qDebug() << "UpdateAll";

	if( Network.m_pSection.tryLock() )
    {
		// first check if we need to remove some nodes

		for( int i = 0; i < m_lNodes.size(); i++ )
		{
			bool bFound = false;

			for( int j = 0; j < Network.m_lNodes.size(); j++ )
			{
				if( Network.m_lNodes.at(j) == m_lNodes.at(i).pNode )
				{
					bFound = true;
				}
			}

			if( !bFound )
			{
				// not found in network - remove it
				OnRemoveNode(m_lNodes.at(i).pNode);
			}
		}

		// now add missing nodes or update existing

		for( int i = 0; i < Network.m_lNodes.size(); i++ )
		{
			bool bFound = false;

			for( int j = 0; j < m_lNodes.size(); j++ )
			{
				if( Network.m_lNodes.at(i) == m_lNodes.at(j).pNode )
				{
					UpdateNode(m_lNodes.at(j).pNode, false);
					bFound = true;
					break;
				}
			}

			if( !bFound )
			{
				AddNode(Network.m_lNodes.at(i), false);
			}
		}

		Network.m_pSection.unlock();

		QModelIndex idx1 = index(0, 0, QModelIndex());
		QModelIndex idx2 = index(m_lNodes.size() - 1, 10, QModelIndex());
		emit dataChanged(idx1, idx2);
    }
}
Exemplo n.º 7
0
//----------------------------------------------------------------------------------------------
void UpdateManager::Update(float DeltaTime)
{
	TNodeMap<CObjectAbstract, IUpdateInterface> *pNode = m_List.m_pFirstElement;

	while (pNode)
	{
		UpdateNode(pNode, DeltaTime);
		pNode = pNode->m_pNodeNextPlain;
	}
}
Exemplo n.º 8
0
CNodeFinal::CNodeFinal( CNodeView *p ) : BaseClass( "Final output", p )
{
	GenerateJacks_Output( 1 );
	LockJackOutput_Flags( 0, HLSLVAR_FLOAT4, "Color" );

	i_tonemaptype = 1;
	b_writedepth = true;

	UpdateNode();
}
CNodeCallback::CNodeCallback( CNodeView *p ) : BaseClass( "Callback", p )
{
	m_flMinSizeX = NODEDEFSIZE_SMALL;
	m_flMinSizeY = NODEDEFSIZE_SMALL;
	m_flMinSizePREVIEW_X = NODEDEFSIZE_SMALL;

	szCallbackName = NULL;
	iNumComponents = 1;

	UpdateNode();
}
CNodeLightscale::CNodeLightscale( CNodeView *p ) : BaseClass( "Lightscale", p )
{
    m_flMinSizeX = NODEDEFSIZE_SMALL;
    m_flMinSizeY = NODEDEFSIZE_SMALL;
    m_flMinSizePREVIEW_X = NODEDEFSIZE_SMALL;

    GenerateJacks_Output( 1 );
    LockJackOutput_Flags( 0, HLSLVAR_FLOAT1, "" );
    m_iLightScale = LSCALE_LINEAR;
    UpdateNode();
}
Exemplo n.º 11
0
HTREEITEM XmlTreeView::AddNode(HTREEITEM hParent, const XML::NodePtr& pNode)
{
	// Add it to the tree view.
	HTREEITEM hItem = InsertItem(hParent, TVI_LAST, TXT(""));

	AddItemNodeMapping(hItem, pNode);

	UpdateNode(hItem, pNode);

	return hItem;
}
CNodeConstant::CNodeConstant( CNodeView *p ) : BaseClass( "Constant", p )
{
	m_flMinSizeX = NODEDEFSIZE_SMALL;
	m_flMinSizeY = NODEDEFSIZE_SMALL;
	m_flMinSizePREVIEW_X = NODEDEFSIZE_SMALL;

	m_iChannelInfo.SetDefaultChannels();
	m_iChannelInfo.bAllowChars = false;
	m_szConstantString[0] = '\0';

	UpdateNode();
}
CNodeRandom::CNodeRandom( CNodeView *p ) : BaseClass( "Random", p )
{
	m_flMinSizeX = NODEDEFSIZE_SMALL;
	m_flMinSizeY = NODEDEFSIZE_SMALL;
	m_flMinSizePREVIEW_X = NODEDEFSIZE_SMALL;

	GenerateJacks_Output( 1 );
	m_iNumComponents = 3;
	m_flValue_Min = 0;
	m_flValue_Max = 1;
	UpdateNode();
}
Exemplo n.º 14
0
void CNeighboursTableModel::UpdateNeighbourData(CG2Node* pNode)
{
	//qDebug() << "UpdateNeighboursData";

	if( !Network.m_pSection.tryLock() )
		return;	// forget it

	if( NodeExists(pNode) )
		UpdateNode(pNode);

	Network.m_pSection.unlock();
}
Exemplo n.º 15
0
// traverses all nodes, updates translation, rotation, scale, color, physics...
//------------------------------------------------------------------------------
void npUpdateEngine (void* dataRef)
{
	int i = 0;

	pData data = (pData) dataRef;

	pNPnode node = NULL;
	// update camera after all other nodes so target is current
	node = data->map.node[kNPnodeRootCamera];

	if (node->childCount)
		UpdateNodeChild(node, dataRef);							// recursive function

	UpdateNode (node, dataRef);

	// update menu items and grid											//zz debug
	for (i = 1 + kNPnodeRootCamera; i < kNPnodeRootPin; i++)				//zzhp 
	{
		node = data->map.node[i];

		if (node->childCount)
			UpdateNodeChild(node, dataRef);							// recursive function

		UpdateNode (node, dataRef);
	}

	//updates pin nodes, if not loading from file
	if( !data->io.file.loading )
	for (i = kNPnodeRootPin; i < data->map.nodeRootCount; i++)	// kNPnodeRootPin; i++) //zzhp 
	{
		node = data->map.node[i];

		if (node->childCount)
			UpdateNodeChild(node, dataRef);							// recursive function

		UpdateNode (node, dataRef);
	}

	data->ctrl.user[0]->tool->triggerHi.x = false; //zz select
}
Exemplo n.º 16
0
ptr_t PM_3_UPDATE(data_t *myHeap, data_t *Master2SysAlloc, int *fixedStack, int *secondStack, int stackPtr_avl, ptr_t root, int log2_tree_size){

	if(TestCase == USE_SEQUENTIAL_KEYS){
		int m = log2_tree_size - 1;
		int iter = 1 << m;
		int i;
		for(i = 0; i < iter; i++){
			int oldKey = RandGen(log2_tree_size+2);
			int newKey = RandGen(log2_tree_size+3);
			root = UpdateNode(myHeap, Master2SysAlloc, fixedStack, secondStack, stackPtr_avl, root, oldKey, newKey);
		}
	}else{
		int IterationRange = 1 << (log2_tree_size - 1);
		int i;
		for(i = 0; i < IterationRange; i++){
			int oldKey = RandGen(log2_tree_size - 1);
			int newKey = RandGen(log2_tree_size);
			root = UpdateNode(myHeap, Master2SysAlloc, fixedStack, secondStack, stackPtr_avl, root, oldKey, newKey);
		}
	}
	return root+1;
}
Exemplo n.º 17
0
//----------------------------------------------------------------------------------------------
void UpdateNode(TNodeMap<CObjectAbstract, IUpdateInterface>* pNode, float DeltaTime)
{
	const_cast<IUpdateInterface*>(pNode->m_pValue)->Update(DeltaTime);
	if (pNode->m_NumChilds > 0)
	{
		TNodeMap<CObjectAbstract, IUpdateInterface>* ChildNode = pNode->m_pNodeNext;
		for (size_t Index = 0; Index < pNode->m_NumChilds; ++Index)
		{
			UpdateNode(ChildNode, DeltaTime);
			ChildNode = ChildNode->m_pNodeNextPlain;
		}
	}
}
Exemplo n.º 18
0
CNodeCustom::CNodeCustom( CNodeView *p ) : BaseClass( "Custom code", p )
{
	m_szFunctionName[0] = 0;
	m_szFilePath[0] = 0;

	m_pCode_Global = NULL;
	m_pCode_Function = NULL;

	m_bInline = true;
	m_iEnvFlags = 0;

	UpdateNode();
}
Exemplo n.º 19
0
void MeshX::Update()
{
	UpdateNode(root, NULL);

	
	for (DWORD i = 0; i < skinInfo->GetNumBones(); ++i)
	{
		FrameEx * node = allocMeshHierarchy.GetNode(skinInfo->GetBoneName(i));
		boneMatrices[i] = *skinInfo->GetBoneOffsetMatrix(i) * node->toRoot;

		D3DXMatrixTranspose(&boneMatrices[i], &boneMatrices[i]);
		memcpy(&boneMatrices3x4[i], &boneMatrices[i], sizeof(HQMatrix3x4));
	}
}
/*Build Lazy Neighborhood Graph*/
void LazyNeighborGraph::BuildingGraph(std::vector<SLNG_Node> SGN){
	/*Add Node to SLNG*/

// 	std::cout << "SGN result\n";
// 	for(int i = 0 ; i < SGN.size() ; i++)
// 		std::cout << "ID = " << SGN[i].SignClipInd << " cost = " << SGN[i].cost << "\n";
// 	std::cout << "----------------------------------------------------------\n";

	if(topIndex == 0)
		initialGraph();

	if(topIndex < M)
	{		
		//add column node to graph
		NeighborGraph.push_back(SGN);

		//find max cost value for the penalty cost as inserting the edge
		float maxCost = -1;
		for(int i =0 ; i < SGN.size() ; i++)
		{
			if(maxCost < SGN[i].cost)
				maxCost = SGN[i].cost;
			// 			std::cout << "SGN["<< i  << "] cost = " << SGN[i].cost << std::endl;
			// 			system("pause");
		}
		//std::cout << "max = " << maxCost << std::endl;
		penaltyCost[topIndex] = 2*maxCost;
		//std::cout << "------------------------------------\n";

		Insert_tEdge(topIndex);
		if(topIndex>=1)
			Insert_t1Edge(topIndex-1,topIndex);
		if(topIndex>=2)
			Insert_t2Edge(topIndex-2,topIndex);

		topIndex++;
	}
	else
	{
		
		GetMinCostPath();
		
		if(!IsFull)
			IsFull = true;
		
		UpdateNode(SGN);
	}
}
Exemplo n.º 21
0
void CNodeCallback::RestoreFromKeyValues_Specific( KeyValues *pKV )
{
	const char *cbname = pKV->GetString( "sz_callbackname" );

	if ( Q_strlen( cbname ) )
	{
		delete [] szCallbackName;
		szCallbackName = new char [ Q_strlen( cbname ) + 1 ];
		Q_strcpy( szCallbackName, cbname );
	}

	iNumComponents = pKV->GetInt( "i_numc", iNumComponents );

	UpdateNode();
	OnUpdateHierachy( NULL, NULL );
}
Exemplo n.º 22
0
/**********************************************************************
 * Rebuild the playlist
 **********************************************************************/
void PlaylistManager::Rebuild( vlc_bool_t b_root )
{
    playlist_view_t *p_view;

    i_items_to_append = 0;
    i_cached_item_id = -1;

    p_view = playlist_ViewFind( p_playlist, VIEW_CATEGORY );

    treectrl->DeleteAllItems();
    treectrl->AddRoot( wxU(_("root" )), -1, -1,
                       new PlaylistItem( p_view->p_root ) );

    wxTreeItemId root = treectrl->GetRootItem();
    UpdateNode( p_view->p_root, root );
}
Exemplo n.º 23
0
/* get the frame from the existing cache, return NULL if it is missing */
bool LFUCache::GetNode(int frameid, int& result) {
    /* if hit some node*/
    if (LFUHash.find(frameid)!=LFUHash.end()) {
        /* update the cache */
        LFUListNode* listnode = LFUHash[frameid]; /* hit LFU list node */
	UpdateNode(listnode);
	result = listnode->Value;
	return true;
    }

    /* if not hit any node */
    else {
        PutNode(frameid, DB[frameid][VALUE]);
        return false;
    }
}
Exemplo n.º 24
0
void
BClipboardRefsWatcher::MessageReceived(BMessage *message)
{
	if (message->what == B_CLIPBOARD_CHANGED && fRefsInClipboard) {
		if (!(fRefsInClipboard = FSClipboardHasRefs()))
			Clear();
		return;
	} else if (message->what != B_NODE_MONITOR) {
		_inherited::MessageReceived(message);
		return;
	}

	switch (message->FindInt32("opcode")) {	
		case B_ENTRY_MOVED:
		{
			ino_t toDir;
			ino_t fromDir;
			node_ref node;
			const char *name = NULL;
			message->FindInt64("from directory", &fromDir);
			message->FindInt64("to directory", &toDir);
			message->FindInt64("node", &node.node);
			message->FindInt32("device", &node.device);
			message->FindString("name", &name);
			entry_ref ref(node.device, toDir, name);
			UpdateNode(&node, &ref);
			break;
		}			

		case B_DEVICE_UNMOUNTED:
		{
			dev_t device;
			message->FindInt32("device", &device);
			RemoveNodesByDevice(device);
			break;
		}

		case B_ENTRY_REMOVED:
		{
			node_ref node;
			message->FindInt64("node", &node.node);
			message->FindInt32("device", &node.device);
			RemoveNode(&node, true);
			break;
		}
	}
}
void CNodeConstant::RestoreFromKeyValues_Specific( KeyValues *pKV )
{
	char tmp[MAX_PATH];
	Q_snprintf( tmp, sizeof(tmp), "%s", pKV->GetString( "szConstantString" ) );

	m_iChannelInfo.Tokenize( tmp );
	m_iChannelInfo.PrintTargetString( m_szConstantString, MAX_PATH );

	m_flMinSizeY_VS = 0;
	if ( m_iChannelInfo.iActiveChannels >= 2 )
	{
		m_flMinSizeY_VS = 28;
		m_flMinSizeY_VS += 10 * (m_iChannelInfo.iActiveChannels - 2);
	}

	UpdateNode();
}
Exemplo n.º 26
0
// recursively calls this function to traverse entire tree
//------------------------------------------------------------------------------
void UpdateNodeChild (pNPnode node, pData dataRef)
{
	int i = 0;

						//crashes without this when link created, not sure why, zz debug
	if (node->type == kNodeLink)
		return;

	for (i=0; i < node->childCount; i++)
	{
		UpdateNodeChild (node->child[i], dataRef);			// recursively call function

		UpdateNodeData (node->child[i], dataRef);

		UpdateNode(node->child[i], dataRef);
	}
}
Exemplo n.º 27
0
BOOL CTaskXml::Add( CTaskData* pData )
{
	if ( pData == NULL ) return FALSE;

	if ( m_pDoc == NULL
		|| m_pTasksNode == NULL 
		|| m_pDownLoadTasksNode == NULL
		|| m_pUpLoadTasksNode == NULL
		|| m_pCopyTasksNode == NULL)
	{
		return FALSE;
	}

	// 创建新节点
	xml_node<>* pTaskNode = m_pDoc->allocate_node(node_element,"task"); 
	if ( pTaskNode == NULL ) return FALSE;

	if ( !UpdateNode( pTaskNode, pData ) )
		return FALSE;

	// 把节点增加到对应子项下面
	if ( pData->m_sOperatorFlag.CompareNoCase("download") == 0 )
	{
		m_pDownLoadTasksNode->append_node(pTaskNode);
	}
	else if ( pData->m_sOperatorFlag.CompareNoCase("upload") == 0 )
	{
		m_pUpLoadTasksNode->append_node(pTaskNode);
	}
	else if ( pData->m_sOperatorFlag.CompareNoCase("copy") == 0 )
	{
		m_pCopyTasksNode->append_node(pTaskNode);
	}
	m_vTasks.push_back(pData);
	return TRUE;
}
Exemplo n.º 28
0
bool QTPFS::PathSearch::Execute(
	unsigned int searchStateOffset,
	unsigned int searchMagicNumber
) {
	searchState = searchStateOffset; // starts at NODE_STATE_OFFSET
	searchMagic = searchMagicNumber; // starts at numTerrainChanges

	haveFullPath = (srcNode == tgtNode);
	havePartPath = false;

	// early-out
	if (haveFullPath)
		return true;

	const bool srcBlocked = (srcNode->GetMoveCost() == QTPFS_POSITIVE_INFINITY);

	std::vector<INode*>& allNodes = nodeLayer->GetNodes();
	std::vector<INode*> ngbNodes;

	#ifdef QTPFS_TRACE_PATH_SEARCHES
	searchExec = new PathSearchTrace::Execution(gs->frameNum);
	#endif

	switch (searchType) {
		case PATH_SEARCH_ASTAR:    { hCostMult = 1.0f; } break;
		case PATH_SEARCH_DIJKSTRA: { hCostMult = 0.0f; } break;
		default:                   {    assert(false); } break;
	}

	// allow the search to start from an impassable node (because single
	// nodes can represent many terrain squares, some of which can still
	// be passable and allow a unit to move within a node)
	// NOTE: we need to make sure such paths do not have infinite cost!
	if (srcBlocked) {
		srcNode->SetMoveCost(0.0f);
	}

	{
		openNodes.reset();
		openNodes.push(srcNode);

		UpdateNode(srcNode, NULL, 0.0f, (tgtPoint - srcPoint).Length() * hCostMult, srcNode->GetMoveCost());
	}

	while (!openNodes.empty()) {
		Iterate(allNodes, ngbNodes);

		#ifdef QTPFS_TRACE_PATH_SEARCHES
		searchExec->AddIteration(searchIter);
		searchIter.Clear();
		#endif

		haveFullPath = (curNode == tgtNode);
		havePartPath = (minNode != srcNode);

		if (haveFullPath) {
			openNodes.reset();
		}
	}

	if (srcBlocked) {
		srcNode->SetMoveCost(QTPFS_POSITIVE_INFINITY);
	}
		

	#ifdef QTPFS_SUPPORT_PARTIAL_SEARCHES
	// adjust the target-point if we only got a partial result
	// NOTE:
	//   should adjust GMT::goalPos accordingly, otherwise
	//   units will end up spinning in-place over the last
	//   waypoint (since "atGoal" can never become true)
	if (!haveFullPath && havePartPath) {
		tgtNode    = minNode;
		tgtPoint.x = minNode->xmid() * SQUARE_SIZE;
		tgtPoint.z = minNode->zmid() * SQUARE_SIZE;
	}
	#endif

	return (haveFullPath || havePartPath);
}
Exemplo n.º 29
0
void QTPFS::PathSearch::Iterate(
	const std::vector<INode*>& allNodes,
	      std::vector<INode*>& ngbNodes
) {
	curNode = openNodes.top();
	curNode->SetSearchState(searchState | NODE_STATE_CLOSED);
	curNode->SetMagicNumber(searchMagic);

	openNodes.pop();
	openNodes.check_heap_property(0);

	#ifdef QTPFS_TRACE_PATH_SEARCHES
	searchIter.SetPoppedNodeIdx(curNode->zmin() * gs->mapx + curNode->xmin());
	#endif

	if (curNode == tgtNode)
		return;
	if (curNode != srcNode)
		curPoint = curNode->GetNeighborEdgeTransitionPoint(curNode->GetPrevNode(), curPoint);
	if (curNode->GetMoveCost() == QTPFS_POSITIVE_INFINITY)
		return;

	if (curNode->xmid() < searchRect.x1) return;
	if (curNode->zmid() < searchRect.z1) return;
	if (curNode->xmid() > searchRect.x2) return;
	if (curNode->zmid() > searchRect.z2) return;

	#ifdef QTPFS_SUPPORT_PARTIAL_SEARCHES
	// remember the node with lowest h-cost in case the search fails to reach tgtNode
	if (curNode->GetPathCost(NODE_PATH_COST_H) < minNode->GetPathCost(NODE_PATH_COST_H))
		minNode = curNode;
	#endif


	#ifdef QTPFS_WEIGHTED_HEURISTIC_COST
	const float hWeight = math::sqrtf(curNode->GetPathCost(NODE_PATH_COST_M) / (curNode->GetNumPrevNodes() + 1));
	#else
	// the default speedmod on flat terrain (assuming no typemaps) is 1.0
	// this value lies halfway between the minimum and the maximum of the
	// speedmod range (2.0), so a node covering such terrain will receive
	// a *relative* (average) speedmod of 0.5 --> the average move-cost of
	// a "virtual node" containing nxtPoint and tgtPoint is the inverse of
	// 0.5, making our "admissable" heuristic distance-weight 2.0 (1.0/0.5)
	const float hWeight = 2.0f;
	#endif

	#ifdef QTPFS_COPY_NEIGHBOR_NODES
	const unsigned int numNgbs = curNode->GetNeighbors(allNodes, ngbNodes);
	#else
	// cannot assign to <ngbNodes> because that would still make a copy
	const std::vector<INode*>& nxtNodes = curNode->GetNeighbors(allNodes);
	const unsigned int numNgbs = nxtNodes.size();
	#endif

	for (unsigned int i = 0; i < numNgbs; i++) {
		// NOTE:
		//   this uses the actual distance that edges of the final path will cover,
		//   from <curPoint> (initialized to sourcePoint) to the middle of the edge
		//   shared between <curNode> and <nxtNode>
		//   (each individual path-segment is weighted by the average move-cost of
		//   the node it crosses; the heuristic is weighted by the average move-cost
		//   of all nodes encountered along partial path thus far)
		// NOTE:
		//   heading for the MIDDLE of the shared edge is not always the best option
		//   we deal with this sub-optimality later (in SmoothPath if it is enabled)
		// NOTE:
		//   short paths that should have 3 points (2 nodes) can contain 4 (3 nodes);
		//   this happens when a path takes a "detour" through a corner neighbor of
		//   srcNode if the shared corner vertex is closer to the goal position than
		//   the mid-point on the edge between srcNode and tgtNode
		// NOTE:
		//   H needs to be of the same order as G, otherwise the search reduces to
		//   Dijkstra (if G dominates H) or becomes inadmissable (if H dominates G)
		//   in the first case we would explore many more nodes than necessary (CPU
		//   nightmare), while in the second we would get low-quality paths (player
		//   nightmare)
		#ifdef QTPFS_COPY_NEIGHBOR_NODES
		nxtNode = ngbNodes[i];
		#else
		nxtNode = nxtNodes[i];
		#endif

		#ifdef QTPFS_CACHED_EDGE_TRANSITION_POINTS
		nxtPoint = curNode->GetNeighborEdgeTransitionPoint(i);
		#else
		nxtPoint = curNode->GetNeighborEdgeTransitionPoint(nxtNode, curPoint);
		#endif

		if (nxtNode->GetMoveCost() == QTPFS_POSITIVE_INFINITY)
			continue;

		const bool isCurrent = (nxtNode->GetSearchState() >= searchState);
		const bool isClosed = ((nxtNode->GetSearchState() & 1) == NODE_STATE_CLOSED);
		const bool isTarget = (nxtNode == tgtNode);

		// cannot use squared-distances because that will bias paths
		// towards smaller nodes (eg. 1^2 + 1^2 + 1^2 + 1^2 != 4^2)
		const float gDist = (nxtPoint - curPoint).Length();
		const float hDist = (tgtPoint - nxtPoint).Length();

		const float mCost =
			curNode->GetPathCost(NODE_PATH_COST_M) +
			curNode->GetMoveCost() +
			nxtNode->GetMoveCost() * int(isTarget);
		const float gCost =
			curNode->GetPathCost(NODE_PATH_COST_G) +
			curNode->GetMoveCost() * gDist +
			nxtNode->GetMoveCost() * hDist * int(isTarget);
		const float hCost = hWeight * hDist * int(!isTarget);

		if (!isCurrent) {
			UpdateNode(nxtNode, curNode, gCost, hCost, mCost);

			openNodes.push(nxtNode);
			openNodes.check_heap_property(0);

			#ifdef QTPFS_TRACE_PATH_SEARCHES
			searchIter.AddPushedNodeIdx(nxtNode->zmin() * gs->mapx + nxtNode->xmin());
			#endif

			continue;
		}

		if (gCost >= nxtNode->GetPathCost(NODE_PATH_COST_G))
			continue;
		if (isClosed)
			openNodes.push(nxtNode);


		UpdateNode(nxtNode, curNode, gCost, hCost, mCost);

		// restore ordering in case nxtNode was already open
		// (changing the f-cost of an OPEN node messes up the
		// queue's internal consistency; a pushed node remains
		// OPEN until it gets popped)
		openNodes.resort(nxtNode);
		openNodes.check_heap_property(0);
	}
}
Exemplo n.º 30
0
BN* MakeTree(STRING* Leaf,int NLeaf){
	if(!NLeaf) return NULL;
	random_quicksort(Leaf,0,NLeaf-1);
	DEPTH=strlen(Leaf[0]);
	BS* bs = (BS*)malloc(sizeof(BS)*NLeaf);
	int i;
	for(i=0;i!=NLeaf;i++){
		bs[i].curr=CreateNode(Leaf[i]);
		if(i!=NLeaf-1)bs[i].next=&bs[i+1];
		else bs[i].next=NULL;
		if(DEPTH<(int) strlen(Leaf[i])) DEPTH=(int) strlen(Leaf[i]);
	}	
	IS* is=(IS*)malloc(sizeof(IS)*NLeaf);
	for(i=0;i<NLeaf;i++){
		int idx=DEPTH-strlen(Leaf[i]);
		is[i].id=B2D(Leaf[i],(int) strlen(Leaf[i]))<<idx;
		if(i!=NLeaf-1)is[i].next=&is[i+1];
		else is[i].next=NULL;
	}
	
	int stack_size=NLeaf-1;
	IS* iseek;
	BS* bseek;
	/*bseek=bs;
	iseek=is;
	while(bseek){
		printf("tag:%s  id:%d TreeInfo:%s\n",bseek->curr->tag,iseek->id,bseek->curr->TreeInfo);
		bseek=bseek->next;
		iseek=iseek->next;
	}*/
	while(stack_size>0){
		bseek=bs;
		iseek=is;
		int i1,i2;
		BN* nbn;
		int tail_branch=0;
		while(iseek->next){
			i1=(int) ((unsigned) iseek->id)>>1;
			i2=(int) ((unsigned) iseek->next->id)>>1;
			if(i1==i2){
				nbn=MergeNode(bseek->curr,bseek->next->curr);
				iseek->id=(int) ((unsigned) iseek->id)>>1;
				bseek->curr=nbn;
				bseek->next=bseek->next->next;
				iseek->next=iseek->next->next;
				if(bseek->next){
					bseek=bseek->next;
					iseek=iseek->next;
					stack_size--;
				}
				else{
					stack_size--;
					tail_branch=1;
					break;
				}	
			}
			else{
				if((int) strlen(bseek->curr->tag)==DEPTH)UpdateNode(bseek->curr,1);
				else UpdateNode(bseek->curr,0);
				iseek->id=(int) ((unsigned) iseek->id)>>1;
				if(bseek->next){
					bseek=bseek->next;
					iseek=iseek->next;
				}
				else break;
			}
		}