Esempio n. 1
0
	void EStrMapEditCtrlImp::InsertRoleTexNode(float idx, const char* tex)
	{
		string workDir;
		string strCPlus = tex;
		if( CPathSetImp::GetInst()->GetResFileName(workDir,strCPlus) )
			InsertNewNode(idx, strCPlus.c_str());	
	}
void USoundCueGraphNode_Base::AutowireNewNode(UEdGraphPin* FromPin)
{
	if (FromPin != NULL)
	{
		const USoundCueGraphSchema* Schema = CastChecked<USoundCueGraphSchema>(GetSchema());

		TSet<UEdGraphNode*> NodeList;

		// auto-connect from dragged pin to first compatible pin on the new node
		for (int32 i=0; i<Pins.Num(); i++)
		{
			UEdGraphPin* Pin = Pins[i];
			check(Pin);
			FPinConnectionResponse Response = Schema->CanCreateConnection(FromPin, Pin);
			if (ECanCreateConnectionResponse::CONNECT_RESPONSE_MAKE == Response.Response)
			{
				if (Schema->TryCreateConnection(FromPin, Pin))
				{
					NodeList.Add(FromPin->GetOwningNode());
					NodeList.Add(this);
				}
				break;
			}
			else if(ECanCreateConnectionResponse::CONNECT_RESPONSE_BREAK_OTHERS_A == Response.Response)
			{
				InsertNewNode(FromPin, Pin, NodeList);
				break;
			}
		}

		// Send all nodes that received a new pin connection a notification
		for (auto It = NodeList.CreateConstIterator(); It; ++It)
		{
			UEdGraphNode* Node = (*It);
			Node->NodeConnectionListChanged();
		}
	}
}
void ModifyListProc(DOUBLE_LINK_TYPE * pFirst)
{
    DOUBLE_LINK_TYPE * pList = pFirst;
    short newNumber;

    printf("ModifyListProc: Display contents of doubly linked list:\n");
    while (pList != NULL) {
         printf("pList @0x%p = %d, Next = 0x%p\n",
                pList, pList->sNumber, pList->pNext);
         pList = pList->pNext;
    }

    printf("ModifyListProc: Add one node for every node in tree\n");
    for (pList = pFirst; pList != NULL; pList = pList->pNext) {
        newNumber = pList->sNumber + 1;
        pList = InsertNewNode(newNumber, pList);
    }

    printf("ModifyListProc: Display modified contents of doubly linked list:\n");
    for (pList = pFirst; pList != NULL; pList = pList->pNext) {
        printf("pList @0x%p = %d, Next = 0x%p\n",
               pList, pList->sNumber, pList->pNext);
    }
}
Esempio n. 4
0
void MakeMaxiTriang( NodeList hull )

/*\
 *  Make maxi triangle to include all points
\*/

{
	int ntotal;
	int i,imin;
	int n1,n2,n3,n4;
	int nx1,nx2,nx3,nx4;
	int nex1,nex2,nex3,nex4;
	int nem1,nem2;
	float xmin,ymin,xmax,ymax;
	float x,y,dx,dy;
	float fact=2.1;	/* factor for construction of exterior elements */
	Node_type *pn;

	ntotal = hull->count;

	for(i=0;i<ntotal;i++) {
	    pn = RetrieveByNodeNumber(HNN,hull->index[i]);
	    if( !IsNtype(pn, N_EXTERNAL ) ) break;
	}
	if( i == ntotal )
		Error("MakeMaxiTriang: No node available");

	pn = RetrieveByNodeNumber(HNN,hull->index[i]);
	xmin = pn->coord.x;
	ymin = pn->coord.y;
	xmax = xmin;
	ymax = ymin;
	imin = i+1;

	for(i=imin;i<ntotal;i++) {
		pn = RetrieveByNodeNumber(HNN,hull->index[i]);
	        if( IsNtype(pn, N_EXTERNAL ) ) continue;
		x = pn->coord.x;
		y = pn->coord.y;
		if( x > xmax ) xmax = x;
		if( y > ymax ) ymax = y;
		if( x < xmin ) xmin = x;
		if( y < ymin ) ymin = y;
	}

	dx = xmax - xmin;
	dy = ymax - ymin;

	xmin -= dx/2.;
	ymin -= dy/2.;
	xmax += dx/2.;
	ymax += dy/2.;

	/* xmin,... are coordinates of maxi rectangle */

	/* make nodes from vertices of maxi rectangle */

	n1=InsertNewNode(N_EXTERNAL,xmin,ymin);
	n2=InsertNewNode(N_EXTERNAL,xmax,ymin);
	n3=InsertNewNode(N_EXTERNAL,xmax,ymax);
	n4=InsertNewNode(N_EXTERNAL,xmin,ymax);

	/* make auxiliary nodes for external triangles */

	nx1=InsertNewNode(N_EXTERNAL,(xmin+xmax)/2.,ymin-fact*dy);
	nx2=InsertNewNode(N_EXTERNAL,xmax+fact*dx,(ymin+ymax)/2.);
	nx3=InsertNewNode(N_EXTERNAL,(xmin+xmax)/2.,ymax+fact*dy);
	nx4=InsertNewNode(N_EXTERNAL,xmin-fact*dx,(ymin+ymax)/2.);

	/* make two maxi triangles */

	nem1 = InsertNewElem( E_INTERNAL, n1, n2, n3
				, NB_UNKNOWN, NB_UNKNOWN, NB_UNKNOWN);
	nem2 = InsertNewElem( E_INTERNAL, n1, n3, n4
				, NB_UNKNOWN, NB_UNKNOWN, NB_UNKNOWN);
	
	/* make four external triangles (auxiliary) */

	nex1 = InsertNewElem( E_EXTERNAL, n1, nx1, n2
				, NB_UNKNOWN, NB_UNKNOWN, NB_UNKNOWN);
	nex2 = InsertNewElem( E_EXTERNAL, n2, nx2, n3
				, NB_UNKNOWN, NB_UNKNOWN, NB_UNKNOWN);
	nex3 = InsertNewElem( E_EXTERNAL, n3, nx3, n4
				, NB_UNKNOWN, NB_UNKNOWN, NB_UNKNOWN);
	nex4 = InsertNewElem( E_EXTERNAL, n4, nx4, n1
				, NB_UNKNOWN, NB_UNKNOWN, NB_UNKNOWN);

	/* update neighbor information */

	UpdateNeiborByNumber(nem1,nex2,nem2,nex1);
	UpdateNeiborByNumber(nem2,nex3,nex4,nem1);
	UpdateNeiborByNumber(nex1,0,nem1,0);
	UpdateNeiborByNumber(nex2,0,nem1,0);
	UpdateNeiborByNumber(nex3,0,nem2,0);
	UpdateNeiborByNumber(nex4,0,nem2,0);
	
	/* insert new elements (except extern) in list */

	InsertListTable(NEL,(void *) RetrieveByElemNumber(HEL,nem1));
	InsertListTable(NEL,(void *) RetrieveByElemNumber(HEL,nem2));
}
Esempio n. 5
0
void UK2Node::AutowireNewNode(UEdGraphPin* FromPin)
{
	const UEdGraphSchema_K2* K2Schema = CastChecked<UEdGraphSchema_K2>(GetSchema());
	
	// Do some auto-connection
	if (FromPin != NULL)
	{
		TSet<UEdGraphNode*> NodeList;

		// sometimes we don't always find an ideal connection, but we want to exhaust 
		// all our options first... this stores a secondary less-ideal pin to connect to, if nothing better was found
		UEdGraphPin* BackupConnection = NULL;
		// If not dragging an exec pin, auto-connect from dragged pin to first compatible pin on the new node
		for (int32 i=0; i<Pins.Num(); i++)
		{
			UEdGraphPin* Pin = Pins[i];
			check(Pin);

			ECanCreateConnectionResponse ConnectResponse = K2Schema->CanCreateConnection(FromPin, Pin).Response;
			if (ConnectResponse == ECanCreateConnectionResponse::CONNECT_RESPONSE_MAKE)
			{
				if (K2Schema->TryCreateConnection(FromPin, Pin))
				{
					NodeList.Add(FromPin->GetOwningNode());
					NodeList.Add(this);
				}

				// null out the backup connection (so we don't attempt to make it 
				// once we exit the loop... we successfully made this connection!)
				BackupConnection = NULL;
				break;
			}
			else if((FromPin->PinType.PinCategory == K2Schema->PC_Exec) && (ConnectResponse == ECanCreateConnectionResponse::CONNECT_RESPONSE_BREAK_OTHERS_A))
			{
				InsertNewNode(FromPin, Pin, NodeList);

				// null out the backup connection (so we don't attempt to make it 
				// once we exit the loop... we successfully made this connection!)
				BackupConnection = NULL;
				break;
			}
			else if ((BackupConnection == NULL) && (ConnectResponse == ECanCreateConnectionResponse::CONNECT_RESPONSE_MAKE_WITH_CONVERSION_NODE))
			{
				// save this off, in-case we don't make any connection at all
				BackupConnection = Pin;
			}
		}

		// if we didn't find an ideal connection, then lets connect this pin to 
		// the BackupConnection (something, like a connection that requires a conversion node, etc.)
		if ((BackupConnection != NULL) && K2Schema->TryCreateConnection(FromPin, BackupConnection))
		{
			NodeList.Add(FromPin->GetOwningNode());
			NodeList.Add(this);
		}

		// If we were not dragging an exec pin, but it was an output pin, try and connect the Then and Execute pins
		if ((FromPin->PinType.PinCategory != K2Schema->PC_Exec  && FromPin->Direction == EGPD_Output))
		{
			UEdGraphNode* FromPinNode = FromPin->GetOwningNode();
			UEdGraphPin* FromThenPin = FromPinNode->FindPin(K2Schema->PN_Then);

			UEdGraphPin* ToExecutePin = FindPin(K2Schema->PN_Execute);

			if ((FromThenPin != NULL) && (FromThenPin->LinkedTo.Num() == 0) && (ToExecutePin != NULL) && K2Schema->ArePinsCompatible(FromThenPin, ToExecutePin, NULL))
			{
				if (K2Schema->TryCreateConnection(FromThenPin, ToExecutePin))
				{
					NodeList.Add(FromPinNode);
					NodeList.Add(this);
				}
			}
		}

		// Send all nodes that received a new pin connection a notification
		for (auto It = NodeList.CreateConstIterator(); It; ++It)
		{
			UEdGraphNode* Node = (*It);
			Node->NodeConnectionListChanged();
		}
	}
}