Exemplo n.º 1
0
static void lh7a40xuart_console_write (struct console* co,
				       const char* s,
				       unsigned int count)
{
	struct uart_port* port = &lh7a40x_ports[co->index].port;
	unsigned int con = UR (port, UART_R_CON);
	unsigned int inten = UR (port, UART_R_INTEN);


	UR (port, UART_R_INTEN) = 0;		/* Disable all interrupts */
	BIT_SET (port, UART_R_CON, UARTEN | SIRDIS); /* Enable UART */

	for (; count-- > 0; ++s) {
		while (UR (port, UART_R_STATUS) & nTxRdy)
			;
		UR (port, UART_R_DATA) = *s;
		if (*s == '\n') {
			while ((UR (port, UART_R_STATUS) & TxBusy))
				;
			UR (port, UART_R_DATA) = '\r';
		}
	}

				/* Wait until all characters are sent */
	while (UR (port, UART_R_STATUS) & TxBusy)
		;

				/* Restore control and interrupt mask */
	UR (port, UART_R_CON) = con;
	UR (port, UART_R_INTEN) = inten;
}
Exemplo n.º 2
0
static irqreturn_t lh7a40xuart_int (int irq, void* dev_id,
				    struct pt_regs* regs)
{
	struct uart_port* port = dev_id;
	unsigned int cLoopLimit = ISR_LOOP_LIMIT;
	unsigned int isr = UR (port, UART_R_ISR);


	do {
		if (isr & (RxInt | RxTimeoutInt))
#ifdef SUPPORT_SYSRQ
			lh7a40xuart_rx_chars(port, regs);
#else
			lh7a40xuart_rx_chars(port);
#endif
		if (isr & ModemInt)
			lh7a40xuart_modem_status (port);
		if (isr & TxInt)
			lh7a40xuart_tx_chars (port);

		if (--cLoopLimit == 0)
			break;

		isr = UR (port, UART_R_ISR);
	} while (isr & (RxInt | TxInt | RxTimeoutInt));

	return IRQ_HANDLED;
}
Exemplo n.º 3
0
static void __init lh7a40xuart_console_get_options (struct uart_port* port,
						    int* baud,
						    int* parity,
						    int* bits)
{
	if (UR (port, UART_R_CON) & UARTEN) {
		unsigned int fcon = UR (port, UART_R_FCON);
		unsigned int quot = UR (port, UART_R_BRCON) + 1;

		switch (fcon & (PEN | EPS)) {
		default:        *parity = 'n'; break;
		case PEN:       *parity = 'o'; break;
		case PEN | EPS: *parity = 'e'; break;
		}

		switch (fcon & WLEN) {
		default:
		case WLEN_8: *bits = 8; break;
		case WLEN_7: *bits = 7; break;
		case WLEN_6: *bits = 6; break;
		case WLEN_5: *bits = 5; break;
		}

		*baud = port->uartclk/(16*quot);
	}
}
Exemplo n.º 4
0
void
test_size_range (size_t n)
{
  const size_t max = __SIZE_MAX__;

  sink (f_size_1 (n));

  sink (f_size_1 (UR (0, 1)));
  sink (f_size_1 (UR (0, max - 1)));
  sink (f_size_1 (UR (1, max - 1)));
  sink (f_size_1 (UR (1, max)));

  sink (f_size_1 (UAR (1, 1)));
  /* Since the only valid argument in the anti-range below is zero
     a warning is expected even though -Walloc-zero is not specified.  */
  sink (f_size_1 (UAR (1, 1234)));   /* { dg-warning "argument 1 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size " } */
  /* The only valid argument in this range is 1.  */
  sink (f_size_1 (UAR (2, max / 2)));

  sink (f_size_2 (n, n));
  sink (f_size_2 (n, 1234));
  sink (f_size_2 (1234, n));

  sink (f_size_2 (UR (0, 1), 1234));
  sink (f_size_2 (UR (0, 1), 1235));   /* { dg-warning "argument 2 value .1235. exceeds maximum object size 1234" } */

  sink (f_size_2 (UR (1235, 1236), n));  /* { dg-warning "argument 1 range \\\[1235, 1236\\\] exceeds maximum object size 1234" } */

  sink (f_size_2 (UR (1235, 1236), UR (max / 2, max)));  /* { dg-warning "argument 1 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size " } */
/* { dg-warning "argument 2 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size " "argument 2" { target *-*-* } .-1 } */

}
Exemplo n.º 5
0
lh7a40xuart_rx_chars (struct uart_port* port)
#endif
{
	struct tty_struct* tty = port->info->tty;
	int cbRxMax = 256;	/* (Gross) limit on receive */
	unsigned int data, flag;/* Received data and status */

	while (!(UR (port, UART_R_STATUS) & nRxRdy) && --cbRxMax) {
		if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
			if (tty->low_latency)
				tty_flip_buffer_push(tty);
			/*
			 * If this failed then we will throw away the
			 * bytes but must do so to clear interrupts
			 */
		}

		data = UR (port, UART_R_DATA);
		flag = TTY_NORMAL;
		++port->icount.rx;

		if (unlikely(data & RxError)) {	/* Quick check, short-circuit */
			if (data & RxBreak) {
				data &= ~(RxFramingError | RxParityError);
				++port->icount.brk;
				if (uart_handle_break (port))
					continue;
			}
			else if (data & RxParityError)
				++port->icount.parity;
			else if (data & RxFramingError)
				++port->icount.frame;
			if (data & RxOverrunError)
				++port->icount.overrun;

				/* Mask by termios, leave Rx'd byte */
			data &= port->read_status_mask | 0xff;

			if (data & RxBreak)
				flag = TTY_BREAK;
			else if (data & RxParityError)
				flag = TTY_PARITY;
			else if (data & RxFramingError)
				flag = TTY_FRAME;
		}

		if (uart_handle_sysrq_char (port, (unsigned char) data, regs))
			continue;

		uart_insert_char(port, data, RxOverrunError, data, flag);
	}
	tty_flip_buffer_push (tty);
	return;
}
Exemplo n.º 6
0
void GEMENI_charsent() {
	unsigned long r = s->log[s->lc];
	if (UCA0IFG & UCTXIFG) {
		s->nch++;
		switch (s->nch) {
			case 1:
				UCA0TXBUF = SL(r) << 5 |TL(r)<<4|KL(r)<<3|PL(r)<<2|WL(r)<<1|HL(r);
			break;
			case 2:
				UCA0TXBUF = RL(r)<<6 | AL(r)<<5 | OL(r)<<4 | STAR(r)<<3;
			break;
			case 3:
				UCA0TXBUF = ER(r)<<3 | UR(r)<<2 | FR(r)<<1 | RR(r);
			break;
			case 4:
				UCA0TXBUF = PR(r)<<6 | BR(r)<<5 | LR(r)<<4 | GR(r)<<3 | TR(r)<<2 | SR(r)<<1 | DRS(r);
			break;
			case 5:
				UCA0TXBUF = POUND(r)<<1 | ZRS(r);
			break;
			default:
				s->lc++;
				if (s->lc != s->nc-1) {

  					s->nch = 0;
  					UCA0TXBUF = 1 << 7; // first packet, no fn or '#'
				} else {
					s->flags &= ~CSEND;
				}

		}
	}
}
Exemplo n.º 7
0
void Compare::execute()
{
	if (data.type == 10) R();
	else if (data.type == 73) A();
	else if (data.type == 11)  UR();
	else if (data.type == 74) UA();
}
Exemplo n.º 8
0
TEST(UniqueRankerTest, test_delete_disposal)
{
    PointerPlayersUniqueRanking UR(5);

    ASSERT_TRUE(UR.insert(new Player("Umpa lumpa A", .1)));
    ASSERT_TRUE(UR.insert(new Player("Umpa lumpa B", .3)));
    ASSERT_TRUE(UR.insert(new Player("Umpa lumpa C", .3)));
    ASSERT_FALSE(UR.insert(new Player("Umpa lumpa B", .2)));
    ASSERT_TRUE(UR.insert(new Player("Umpa lumpa D", .5)));
    ASSERT_TRUE(UR.insert(new Player("Umpa lumpa E", .6)));
    ASSERT_TRUE(UR.insert(new Player("Umpa lumpa B", .5)));
    ASSERT_TRUE(UR.insert(new Player("Umpa lumpa F", .8)));

    PointerPlayersUniqueRankingIterator it(UR);
    ASSERT_TRUE((isSorted<float, PointerPlayersUniqueRankingIterator>(it)));

    ASSERT_EQ("Umpa lumpa F", UR.top()->name);
    ASSERT_EQ("Umpa lumpa C", UR.bottom()->name);

    Player* p = new Player("Umpa lumpa E", .6);
    UR.remove(p);
    delete p;
    PointerPlayersUniqueRankingIterator it2(UR);
    ASSERT_TRUE((isSorted<float, PointerPlayersUniqueRankingIterator>(it2)));
}
Exemplo n.º 9
0
void
serialputc(int c)
{
	ulong *p;

	if(c == 0)
		return;
	p = (ulong*)PHYSUART;
	while((UR(p,Lsr) & Thre) == 0){
		/* skip */
	}
	UR(p,Thr) = c;
	if(c == '\n')
		while((UR(p,Lsr) & Temt) == 0){	/* let fifo drain */
			/* skip */
		}
}
Exemplo n.º 10
0
static void lh7a40xuart_rx_chars (struct uart_port* port)
{
	struct tty_struct* tty = port->info->tty;
	int cbRxMax = 256;	/* (Gross) limit on receive */
	unsigned int data;	/* Received data and status */
	unsigned int flag;

	while (!(UR (port, UART_R_STATUS) & nRxRdy) && --cbRxMax) {
		data = UR (port, UART_R_DATA);
		flag = TTY_NORMAL;
		++port->icount.rx;

		if (unlikely(data & RxError)) {
			if (data & RxBreak) {
				data &= ~(RxFramingError | RxParityError);
				++port->icount.brk;
				if (uart_handle_break (port))
					continue;
			}
			else if (data & RxParityError)
				++port->icount.parity;
			else if (data & RxFramingError)
				++port->icount.frame;
			if (data & RxOverrunError)
				++port->icount.overrun;

				/* Mask by termios, leave Rx'd byte */
			data &= port->read_status_mask | 0xff;

			if (data & RxBreak)
				flag = TTY_BREAK;
			else if (data & RxParityError)
				flag = TTY_PARITY;
			else if (data & RxFramingError)
				flag = TTY_FRAME;
		}

		if (uart_handle_sysrq_char (port, (unsigned char) data))
			continue;

		uart_insert_char(port, data, RxOverrunError, data, flag);
	}
	tty_flip_buffer_push (tty);
	return;
}
Exemplo n.º 11
0
TEST(RankerTest, test_delete_disposal)
{
    PointerRanking UR(2);

    Randomizer<int> r(0, 1000, 0);
    for (unsigned int i = 0; i < 10000; ++i)
    {
        UR.insert(new int(r.get()));
    }
}
Exemplo n.º 12
0
void
test_uint_range (unsigned n)
{
  const unsigned max = UINT_MAX;

  sink (f_uint_1 (n));
  sink (f_uint_1 (UR (0, 1)));
  sink (f_uint_1 (UR (0, 1233)));
  sink (f_uint_1 (UR (0, 1234)));
  sink (f_uint_1 (UR (0, 1235)));
  sink (f_uint_1 (UR (1, 1235)));
  sink (f_uint_1 (UR (1234, 1235)));
  sink (f_uint_1 (UR (1235, 1236)));   /* { dg-warning "argument 1 range \\\[\[0-9\]+u?, \[0-9\]+u?\\\] exceeds maximum object size 1234" } */
  sink (f_uint_1 (UR (1, max - 1)));
  sink (f_uint_1 (UR (1, max)));
}
Exemplo n.º 13
0
void overFace::getRightState(void)
{
  // Note: fptOffset must be set by Solver during overset setup
  for (int i=0; i<nFptsL; i++) {
    for (int k=0; k<nFields; k++) {
      UR(i,k) = OComm->U_in(fptOffset+i,k);

      if (params->oversetMethod == 1)
        Fn(i,k) = OComm->U_in(fptOffset+i,nFields+k);
    }
  }
}
Exemplo n.º 14
0
void test_mempcpy_bounds (char *d, const char *s, size_t n)
{
#undef FUNC
#define FUNC mempcpy

  /* Verify that invalid offsets into an array of known size are
     detected.  */

  T (char, 1, a + SR (DIFF_MIN, -1), s, n);     /* { dg-warning "offset \\\[-\[0-9\]+, -1] is out of the bounds"  "mempcpy" } */
T (char, 1, a + SR (-2, -1), s, n);     /* { dg-warning "offset \\\[-2, -1] is out of the bounds"  "mempcpy" } */
  T (char, 1, a + SR (-2, 0), s, n);

  T (char, 1, a + UR (0, 1), s, n);
  T (char, 1, a + UR (0, 2), s, n);
  T (char, 1, a + UR (1, 2), s, n);
  T (char, 1, a + UR (2, 3), s, n);       /* { dg-warning "offset \\\[2, 3] is out of the bounds \\\[0, 1] of object "  "mempcpy" } */
  T (char, 1, a + UR (2, DIFF_MAX), s, n);  /* { dg-warning "offset \\\[2, \[0-9\]+] is out of the bounds \\\[0, 1] of object"  "mempcpy" } */

  /* Offsets in excess of DIFF_MAX are treated as negative even if
     they appear as large positive in the source.  It would be nice
     if they retained their type but unfortunately that's not how
     it works so be prepared for both in case it ever gets fixed.  */
  T (char, 1, a + UR (3, SIZE_MAX), s, n);   /* { dg-warning "offset \\\[3, -?\[0-9\]+] is out of the bounds \\\[0, 1] of object "  "mempcpy" } */

  /* Verify that invalid offsets into an array of unknown size are
     detected.  */
  extern char arr[];
  T (char, 1, arr + SR (DIFF_MIN,         0), s, n);
  T (char, 1, arr + SR (DIFF_MIN,        -1), s, n);   /* { dg-warning "offset \\\[-\[0-9\]+, -1] is out of the bounds of object"  "mempcpy" } */
  T (char, 1, arr + SR (DIFF_MIN,         1), s, n);
  T (char, 1, arr + SR (DIFF_MIN, DIFF_MAX), s, n);
  T (char, 1, arr + SR (       -2,        -1), s, n);   /* { dg-warning "offset \\\[-2, -1] is out of the bounds of object"  "mempcpy" } */
  T (char, 1, arr + SR (       -1,         0), s, n);
  T (char, 1, arr + SR (       -1,         1), s, n);
  T (char, 1, arr + SR (       -1, DIFF_MAX), s, n);
  T (char, 1, arr + SR (        0,         1), s, n);
  T (char, 1, arr + SR (        0, DIFF_MAX), s, n);
  T (char, 1, arr + SR (        1,         2), s, n);
  T (char, 1, arr + SR (        1, DIFF_MAX), s, n);

  /* Verify that all offsets via a pointer to an uknown object are
     accepted.  */

  /* Negative indices between [DIFF_MIN, DIFF_MAX] are valid since
     the pointer to which the offset is applied can be at a positive
     offset from the beginning of an object.  */
  T (char, 1, d + SR (DIFF_MIN,         0), s, n);
  T (char, 1, d + SR (DIFF_MIN,        -1), s, n);
  T (char, 1, d + SR (DIFF_MIN,         1), s, n);
  T (char, 1, d + SR (DIFF_MIN, DIFF_MAX), s, n);
  T (char, 1, d + SR (       -2,        -1), s, n);
  T (char, 1, d + SR (       -1,         0), s, n);
  T (char, 1, d + SR (       -1,         1), s, n);
  T (char, 1, d + SR (       -1, DIFF_MAX), s, n);
  T (char, 1, d + SR (        0,         1), s, n);
  T (char, 1, d + SR (        0, DIFF_MAX), s, n);
  T (char, 1, d + SR (        1,         2), s, n);
  T (char, 1, d + SR (        1, DIFF_MAX), s, n);
}
Exemplo n.º 15
0
static unsigned int lh7a40xuart_get_mctrl (struct uart_port* port)
{
	unsigned int result = 0;
	unsigned int status = UR (port, UART_R_STATUS);

	if (status & DCD)
		result |= TIOCM_CAR;
	if (status & DSR)
		result |= TIOCM_DSR;
	if (status & CTS)
		result |= TIOCM_CTS;

	return result;
}
Exemplo n.º 16
0
static void lh7a40xuart_tx_chars (struct uart_port* port)
{
	struct circ_buf* xmit = &port->info->xmit;
	int cbTxMax = port->fifosize;

	if (port->x_char) {
		UR (port, UART_R_DATA) = port->x_char;
		++port->icount.tx;
		port->x_char = 0;
		return;
	}
	if (uart_circ_empty (xmit) || uart_tx_stopped (port)) {
		lh7a40xuart_stop_tx (port, 0);
		return;
	}

	/* Unlike the AMBA UART, the lh7a40x UART does not guarantee
	   that at least half of the FIFO is empty.  Instead, we check
	   status for every character.  Using the AMBA method causes
	   the transmitter to drop characters. */

	do {
		UR (port, UART_R_DATA) = xmit->buf[xmit->tail];
		xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
		++port->icount.tx;
		if (uart_circ_empty(xmit))
			break;
	} while (!(UR (port, UART_R_STATUS) & nTxRdy)
		 && cbTxMax--);

	if (uart_circ_chars_pending (xmit) < WAKEUP_CHARS)
		uart_write_wakeup (port);

	if (uart_circ_empty (xmit))
		lh7a40xuart_stop_tx (port, 0);
}
Exemplo n.º 17
0
/*
 *  for iprint, just write it
 */
void
serialputs(char *data, int len)
{
	ulong *p;

	p = (ulong*)PHYSUART;
	while(--len >= 0){
		if(*data == '\n')
			serialputc('\r');
		serialputc(*data++);
	}
	while((UR(p,Lsr) & Temt) == 0){	/* let fifo drain */
		/* skip */
	}
}
Exemplo n.º 18
0
void World::RenderGroup(SceneGroup *i, mat4 t) 
{
	int ii, time = 0;
	// sphere vars
	double r;
	MaterialInfo m;
	
	// light vars
	LightInfo l;
	
	// camera vars
	CameraInfo f;
	   
	// if this is a terminal node
	if (i->getChildCount() == 0) {
		
		// if this node is a sphere
		if (i->computeSphere(r,m,time)) {
			_spheres.push_back(Sphere(vec4(0,0,0,1), r, m, t));
		} else if (i->computeLight(l)) {
			
			if (l.type == LIGHT_POINT) {
				_lights[l.type].push_back(Light(vec3(t*vec4(0,0,0,1),VW),0, l));
			}else if (l.type == LIGHT_DIRECTIONAL){
				_lights[l.type].push_back(Light(0,vec3(t*vec4(0,0,-1,0),VW), l));
			}else if (l.type == LIGHT_AMBIENT)
				_ambientLight = l.color;
				
		} else if (i->computeCamera(f)) {
			vec4 eye(0.0, 0.0, 0.0, 1.0);
		    vec4 LL(f.sides[FRUS_LEFT], f.sides[FRUS_BOTTOM], -1*f.sides[FRUS_NEAR], 1.0);
		    vec4 UL(f.sides[FRUS_LEFT], f.sides[FRUS_TOP], -1*f.sides[FRUS_NEAR], 1.0);
		    vec4 LR(f.sides[FRUS_RIGHT], f.sides[FRUS_BOTTOM], -1*f.sides[FRUS_NEAR], 1.0);
		    vec4 UR(f.sides[FRUS_RIGHT], f.sides[FRUS_TOP], -1*f.sides[FRUS_NEAR], 1.0);

		    _view = Viewport(eye, LL, UL, LR, UR, IMAGE_WIDTH, IMAGE_HEIGHT);
		}
		
	} else {
		
		// expand and traverse this node
		for(ii=0; ii<i->getChildCount();ii++) 
			RenderInstance(i->getChild(ii), t);
		
	}
	
}
Exemplo n.º 19
0
//////////////////////////////////////////////////////////////////////////
//
// BOUNDING BOX COMPUTATION
//
/////////////////////////////////////////////////////////////////////////
void ComputeBoundingBoxesAndPhysicsConstants(vector<GameObject*>& objects){
	for(unsigned int o = 0; o<objects.size(); o++){
		MyMesh* meshptr= objects[o]->GetMesh();
		if(meshptr == NULL) continue;
		float minX = FLT_MAX;
		float minY = FLT_MAX;
		float minZ = FLT_MAX;
		float maxX = -FLT_MAX;
		float maxY = -FLT_MAX;
		float maxZ = -FLT_MAX;
		for(MyMesh::VertexIter vi = meshptr->vertices_begin(); vi != meshptr->vertices_end(); ++vi){
			Vec3f pt = meshptr->point(vi.handle());
			objects[o]->meshBox.push_back(pt);
			minX = min(minX, pt[0]);
			maxX = max(maxX, pt[0]);
			minY = min(minY, pt[1]);
			maxY = max(maxY, pt[1]);
			minZ = min(minZ, pt[2]);
			maxZ = max(maxZ, pt[2]);
		}
		Vec3f UR(maxX, maxY, maxZ);
		Vec3f BL(minX, minY, minZ);
		objects[o]->boundingBox.push_back(UR);
		objects[o]->boundingBox.push_back(Vec3f(UR[0], UR[1], BL[2]));
		objects[o]->boundingBox.push_back(Vec3f(BL[0], UR[1], BL[2]));
		objects[o]->boundingBox.push_back(Vec3f(BL[0], UR[1], UR[2]));
		objects[o]->boundingBox.push_back(Vec3f(BL[0], BL[1], UR[2]));
		objects[o]->boundingBox.push_back(Vec3f(UR[0], BL[1], UR[2]));
		objects[o]->boundingBox.push_back(Vec3f(UR[0], BL[1], BL[2]));
		objects[o]->boundingBox.push_back(BL);

		//	ConstructBoxEdges(meshes[m].BoxEdges, UR, BL);
		float TotalArea = 0;
		for(MyMesh::VertexIter vit = meshptr->vertices_begin(); vit != meshptr->vertices_end(); ++vit){
			float numberVertices  = 0;
			objects[o]->CenterOfMass+= meshptr->point(vit.handle())/meshptr->n_vertices();
		}
		float MomentOfInertia = 0;
		/*	for(MyMesh::VertexIter it = meshes[m].mesh.vertices_begin(); it!= meshes[m].mesh.vertices_end(); ++it){
		MomentOfInertia += ((Vec3f(meshes[m].mesh.point(it.handle())) - meshes[m].CenterOfMass) * (Vec3f(meshes[m].mesh.point(it.handle())) - meshes[m].CenterOfMass)).sqrnorm();
		}
		MomentOfInertia *= meshes[m].mass;
		meshes[m].momentOfInertia = MomentOfInertia;*/
	}
}
  void QuasiNewton<dcomplex>::setupRestart(){
    this->allocGuess();
    ComplexCMMap UR(this->URMem,this->N_,this->nGuess_);
    (*this->guessR_) = UR;
    if(this->symmetrizedTrial_){
      ComplexCMMap UL(this->ULMem,this->N_,this->nGuess_);
      (*this->guessL_) = UL;
    } 
    // Zero out scratch space
    std::memset(this->SCR,0.0,this->LenScr*sizeof(dcomplex));

    // Ensure that the the new guess vectors are orthonormal
    this->Orth(*this->guessR_);
    if(this->symmetrizedTrial_) this->Orth(*this->guessL_);  

    /** DO NOT RESET doRestart_ here! next iteration needs to know that we
        restarted **/
  } // setupRestart
Exemplo n.º 21
0
static int lh7a40xuart_startup (struct uart_port* port)
{
	int retval;

	retval = request_irq (port->irq, lh7a40xuart_int, 0,
			      "serial_lh7a40x", port);
	if (retval)
		return retval;

				/* Initial modem control-line settings */
	((struct uart_port_lh7a40x*) port)->statusPrev
		= UR (port, UART_R_STATUS);

	/* There is presently no configuration option to enable IR.
	   Thus, we always disable it. */

	BIT_SET (port, UART_R_CON, UARTEN | SIRDIS);
	BIT_SET (port, UART_R_INTEN, RxTimeoutInt | RxInt);

	return 0;
}
Exemplo n.º 22
0
TEST(UniqueRankerTest, test_pointer)
{
    PlayersRanking UR(5);

    ASSERT_TRUE(UR.insert(Player("Umpa lumpa A", .1)));
    ASSERT_TRUE(UR.insert(Player("Umpa lumpa B", .3)));
    ASSERT_TRUE(UR.insert(Player("Umpa lumpa C", .3)));
    ASSERT_FALSE(UR.insert(Player("Umpa lumpa B", .2)));
    ASSERT_TRUE(UR.insert(Player("Umpa lumpa D", .5)));
    ASSERT_TRUE(UR.insert(Player("Umpa lumpa E", .6)));
    ASSERT_TRUE(UR.insert(Player("Umpa lumpa B", .5)));
    ASSERT_TRUE(UR.insert(Player("Umpa lumpa F", .8)));

    PlayersRankingIterator it(UR);
    ASSERT_TRUE((isSorted<float, PlayersRankingIterator>(it)));

    ASSERT_EQ("Umpa lumpa F", UR.top().name);
    ASSERT_EQ("Umpa lumpa C", UR.bottom().name);

    UR.remove(Player("Umpa lumpa E", .6));
    PlayersRankingIterator it2(UR);
    ASSERT_TRUE((isSorted<float, PlayersRankingIterator>(it2)));
}
Exemplo n.º 23
0
TEST(UniqueRankerLinealTest, test)
{
    PlayersRankingLineal UR(5);

    ASSERT_TRUE(UR.insert(Player("Umpa lumpa A", .1)));
    ASSERT_TRUE(UR.insert(Player("Umpa lumpa B", .3)));
    ASSERT_TRUE(UR.insert(Player("Umpa lumpa C", .3)));
    ASSERT_FALSE(UR.insert(Player("Umpa lumpa B", .2)));
    ASSERT_TRUE(UR.insert(Player("Umpa lumpa D", .5)));
    ASSERT_TRUE(UR.insert(Player("Umpa lumpa E", .6)));
    ASSERT_TRUE(UR.insert(Player("Umpa lumpa B", .5)));
    ASSERT_TRUE(UR.insert(Player("Umpa lumpa F", .8)));

    CAutonomousIterator<PlayersRankingLineal> it(UR);
    ASSERT_TRUE((isSorted<float, PlayersRankingLinealIterator>(it)));

    ASSERT_EQ("Umpa lumpa F", UR.top().name);
    ASSERT_EQ("Umpa lumpa C", UR.bottom().name);

    UR.remove(Player("Umpa lumpa E", .6));
    CAutonomousIterator<PlayersRankingLineal> it2(UR);
    ASSERT_TRUE((isSorted<float, PlayersRankingLinealIterator>(it2)));
}
Exemplo n.º 24
0
static void lh7a40xuart_modem_status (struct uart_port* port)
{
	unsigned int status = UR (port, UART_R_STATUS);
	unsigned int delta
		= status ^ ((struct uart_port_lh7a40x*) port)->statusPrev;

	BIT_SET (port, UART_R_RAWISR, MSEOI); /* Clear modem status intr */

	if (!delta)		/* Only happens if we missed 2 transitions */
		return;

	((struct uart_port_lh7a40x*) port)->statusPrev = status;

	if (delta & DCD)
		uart_handle_dcd_change (port, status & DCD);

	if (delta & DSR)
		++port->icount.dsr;

	if (delta & CTS)
		uart_handle_cts_change (port, status & CTS);

	wake_up_interruptible (&port->info->delta_msr_wait);
}
Exemplo n.º 25
0
static void lh7a40xuart_console_write (struct console* co,
				       const char* s,
				       unsigned int count)
{
	struct uart_port* port = &lh7a40x_ports[co->index].port;
	unsigned int con = UR (port, UART_R_CON);
	unsigned int inten = UR (port, UART_R_INTEN);


	UR (port, UART_R_INTEN) = 0;		/* Disable all interrupts */
	BIT_SET (port, UART_R_CON, UARTEN | SIRDIS); /* Enable UART */

	uart_console_write(port, s, count, lh7a40xuart_console_putchar);

				/* Wait until all characters are sent */
	while (UR (port, UART_R_STATUS) & TxBusy)
		;

				/* Restore control and interrupt mask */
	UR (port, UART_R_CON) = con;
	UR (port, UART_R_INTEN) = inten;
}
void UNavMeshRenderingComponent::GatherData(struct FNavMeshSceneProxyData* CurrentData) const
{
#if WITH_RECAST
	const ARecastNavMesh* NavMesh = Cast<ARecastNavMesh>(GetOwner());

	CurrentData->Reset();
	CurrentData->bEnableDrawing = NavMesh->bEnableDrawing;
	CurrentData->bNeedsNewData = false;

	if (CurrentData && NavMesh && NavMesh->bEnableDrawing)
	{
		FHitProxyId HitProxyId = FHitProxyId();
		CurrentData->bDrawPathCollidingGeometry = NavMesh->bDrawPathCollidingGeometry;

		CurrentData->NavMeshDrawOffset.Z = NavMesh->DrawOffset;
		CurrentData->NavMeshGeometry.bGatherPolyEdges = NavMesh->bDrawPolyEdges;
		CurrentData->NavMeshGeometry.bGatherNavMeshEdges = NavMesh->bDrawNavMeshEdges;

		const FNavDataConfig& NavConfig = NavMesh->GetConfig();
		CurrentData->NavMeshColors[RECAST_DEFAULT_AREA] = NavConfig.Color.DWColor() > 0 ? NavConfig.Color : NavMeshRenderColor_RecastMesh;
		for (uint8 i = 0; i < RECAST_DEFAULT_AREA; ++i)
		{
			CurrentData->NavMeshColors[i] = NavMesh->GetAreaIDColor(i);
		}

		// just a little trick to make sure navmeshes with different sized are not drawn with same offset
		CurrentData->NavMeshDrawOffset.Z += NavMesh->GetConfig().AgentRadius / 10.f;

		NavMesh->BeginBatchQuery();

		if (NavMesh->bDrawOctree)
		{
			const UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(GetWorld());
			const FNavigationOctree* NavOctree = NavSys ? NavSys->GetNavOctree() : NULL;
			if (NavOctree)
			{
				for (FNavigationOctree::TConstIterator<> NodeIt(*NavOctree); NodeIt.HasPendingNodes(); NodeIt.Advance())
				{
					const FNavigationOctree::FNode& CurrentNode = NodeIt.GetCurrentNode();
					const FOctreeNodeContext& CorrentContext = NodeIt.GetCurrentContext();
					CurrentData->OctreeBounds.Add(CorrentContext.Bounds);

					FOREACH_OCTREE_CHILD_NODE(ChildRef)
					{
						if (CurrentNode.HasChild(ChildRef))
						{
							NodeIt.PushChild(ChildRef);
						}
					}
				}
			}
		}

		NavMesh->GetDebugGeometry(CurrentData->NavMeshGeometry);
		const TArray<FVector>& MeshVerts = CurrentData->NavMeshGeometry.MeshVerts;

		// @fixme, this is going to double up on lots of interior lines
		if (NavMesh->bDrawTriangleEdges)
		{
			for (int32 AreaIdx = 0; AreaIdx < RECAST_MAX_AREAS; ++AreaIdx)
			{
				const TArray<int32>& MeshIndices = CurrentData->NavMeshGeometry.AreaIndices[AreaIdx];
				for (int32 Idx=0; Idx<MeshIndices.Num(); Idx += 3)
				{
					CurrentData->ThickLineItems.Add(FNavMeshSceneProxyData::FDebugThickLine(MeshVerts[MeshIndices[Idx + 0]] + CurrentData->NavMeshDrawOffset, MeshVerts[MeshIndices[Idx + 1]] + CurrentData->NavMeshDrawOffset, NavMeshRenderColor_Recast_TriangleEdges, DefaultEdges_LineThickness));
					CurrentData->ThickLineItems.Add(FNavMeshSceneProxyData::FDebugThickLine(MeshVerts[MeshIndices[Idx + 1]] + CurrentData->NavMeshDrawOffset, MeshVerts[MeshIndices[Idx + 2]] + CurrentData->NavMeshDrawOffset, NavMeshRenderColor_Recast_TriangleEdges, DefaultEdges_LineThickness));
					CurrentData->ThickLineItems.Add(FNavMeshSceneProxyData::FDebugThickLine(MeshVerts[MeshIndices[Idx + 2]] + CurrentData->NavMeshDrawOffset, MeshVerts[MeshIndices[Idx + 0]] + CurrentData->NavMeshDrawOffset, NavMeshRenderColor_Recast_TriangleEdges, DefaultEdges_LineThickness));
				}
			}
		}

		// make lines for tile edges
		if (NavMesh->bDrawPolyEdges)
		{
			const TArray<FVector>& TileEdgeVerts = CurrentData->NavMeshGeometry.PolyEdges;
			for (int32 Idx=0; Idx < TileEdgeVerts.Num(); Idx += 2)
			{
				CurrentData->TileEdgeLines.Add( FDebugRenderSceneProxy::FDebugLine(TileEdgeVerts[Idx] + CurrentData->NavMeshDrawOffset, TileEdgeVerts[Idx+1] + CurrentData->NavMeshDrawOffset, NavMeshRenderColor_Recast_TileEdges));
			}
		}

		// make lines for navmesh edges
		if (NavMesh->bDrawNavMeshEdges)
		{
			const FColor EdgesColor = DarkenColor(CurrentData->NavMeshColors[RECAST_DEFAULT_AREA]);
			const TArray<FVector>& NavMeshEdgeVerts = CurrentData->NavMeshGeometry.NavMeshEdges;
			for (int32 Idx=0; Idx < NavMeshEdgeVerts.Num(); Idx += 2)
			{
				CurrentData->NavMeshEdgeLines.Add( FDebugRenderSceneProxy::FDebugLine(NavMeshEdgeVerts[Idx] + CurrentData->NavMeshDrawOffset, NavMeshEdgeVerts[Idx+1] + CurrentData->NavMeshDrawOffset, EdgesColor));
			}
		}

		// offset all navigation-link positions
		if (!NavMesh->bDrawClusters)
		{
			for (int32 OffMeshLineIndex = 0; OffMeshLineIndex < CurrentData->NavMeshGeometry.OffMeshLinks.Num(); ++OffMeshLineIndex)
			{
				FRecastDebugGeometry::FOffMeshLink& Link = CurrentData->NavMeshGeometry.OffMeshLinks[OffMeshLineIndex];
				const bool bLinkValid = (Link.ValidEnds & FRecastDebugGeometry::OMLE_Left) && (Link.ValidEnds & FRecastDebugGeometry::OMLE_Right);

				if (NavMesh->bDrawFailedNavLinks || (NavMesh->bDrawNavLinks && bLinkValid))
				{
					const FVector V0 = Link.Left + CurrentData->NavMeshDrawOffset;
					const FVector V1 = Link.Right + CurrentData->NavMeshDrawOffset;
					const FColor LinkColor = ((Link.Direction && Link.ValidEnds) || (Link.ValidEnds & FRecastDebugGeometry::OMLE_Left)) ? DarkenColor(CurrentData->NavMeshColors[Link.AreaID]) : NavMeshRenderColor_OffMeshConnectionInvalid;

					CacheArc(CurrentData->NavLinkLines, V0, V1, 0.4f, 4, LinkColor, LinkLines_LineThickness);

					const FVector VOffset(0, 0, FVector::Dist(V0, V1) * 1.333f);
					CacheArrowHead(CurrentData->NavLinkLines, V1, V0+VOffset, 30.f, LinkColor, LinkLines_LineThickness);
					if (Link.Direction)
					{
						CacheArrowHead(CurrentData->NavLinkLines, V0, V1+VOffset, 30.f, LinkColor, LinkLines_LineThickness);
					}

					// if the connection as a whole is valid check if there are any of ends is invalid
					if (LinkColor != NavMeshRenderColor_OffMeshConnectionInvalid)
					{
						if (Link.Direction && (Link.ValidEnds & FRecastDebugGeometry::OMLE_Left) == 0)
						{
							// left end invalid - mark it
							DrawWireCylinder(CurrentData->NavLinkLines, V0, FVector(1,0,0), FVector(0,1,0), FVector(0,0,1), NavMeshRenderColor_OffMeshConnectionInvalid, Link.Radius, NavMesh->AgentMaxStepHeight, 16, 0, DefaultEdges_LineThickness);
						}
						if ((Link.ValidEnds & FRecastDebugGeometry::OMLE_Right) == 0)
						{
							DrawWireCylinder(CurrentData->NavLinkLines, V1, FVector(1,0,0), FVector(0,1,0), FVector(0,0,1), NavMeshRenderColor_OffMeshConnectionInvalid, Link.Radius, NavMesh->AgentMaxStepHeight, 16, 0, DefaultEdges_LineThickness);
						}
					}
				}					
			}
		}

		if (NavMesh->bDrawTileLabels || NavMesh->bDrawPolygonLabels || NavMesh->bDrawDefaultPolygonCost || NavMesh->bDrawTileBounds)
		{
			// calculate appropriate points for displaying debug labels
			const int32 TilesCount = NavMesh->GetNavMeshTilesCount();
			CurrentData->DebugLabels.Reserve(TilesCount);

			for (int32 TileIndex = 0; TileIndex < TilesCount; ++TileIndex)
			{
				int32 X, Y, Layer;
				if (NavMesh->GetNavMeshTileXY(TileIndex, X, Y, Layer))
				{
					const FBox TileBoundingBox = NavMesh->GetNavMeshTileBounds(TileIndex);
					FVector TileLabelLocation = TileBoundingBox.GetCenter();
					TileLabelLocation.Z = TileBoundingBox.Max.Z;

					FNavLocation NavLocation(TileLabelLocation);
					if (!NavMesh->ProjectPoint(TileLabelLocation, NavLocation, FVector(NavMesh->TileSizeUU/100, NavMesh->TileSizeUU/100, TileBoundingBox.Max.Z-TileBoundingBox.Min.Z)))
					{
						NavMesh->ProjectPoint(TileLabelLocation, NavLocation, FVector(NavMesh->TileSizeUU/2, NavMesh->TileSizeUU/2, TileBoundingBox.Max.Z-TileBoundingBox.Min.Z));
					}

					if (NavMesh->bDrawTileLabels)
					{
						CurrentData->DebugLabels.Add(FNavMeshSceneProxyData::FDebugText(
							/*Location*/NavLocation.Location + CurrentData->NavMeshDrawOffset
							, /*Text*/FString::Printf(TEXT("(%d,%d:%d)"), X, Y, Layer)
							));
					}

					if (NavMesh->bDrawPolygonLabels || NavMesh->bDrawDefaultPolygonCost)
					{
						TArray<FNavPoly> Polys;
						NavMesh->GetPolysInTile(TileIndex, Polys);

						if (NavMesh->bDrawDefaultPolygonCost)
						{
							float DefaultCosts[RECAST_MAX_AREAS];
							float FixedCosts[RECAST_MAX_AREAS];

							NavMesh->GetDefaultQueryFilter()->GetAllAreaCosts(DefaultCosts, FixedCosts, RECAST_MAX_AREAS);

							for(int k = 0; k < Polys.Num(); ++k)
							{
								uint32 AreaID = NavMesh->GetPolyAreaID(Polys[k].Ref);

								CurrentData->DebugLabels.Add(FNavMeshSceneProxyData::FDebugText(
									/*Location*/Polys[k].Center + CurrentData->NavMeshDrawOffset
									, /*Text*/FString::Printf(TEXT("\\%.3f; %.3f\\"), DefaultCosts[AreaID], FixedCosts[AreaID])
									));
							}
						}
						else
						{
							for(int k = 0; k < Polys.Num(); ++k)
							{
								uint32 NavPolyIndex = 0;
								uint32 NavTileIndex = 0;
								NavMesh->GetPolyTileIndex(Polys[k].Ref, NavPolyIndex, NavTileIndex);

								CurrentData->DebugLabels.Add(FNavMeshSceneProxyData::FDebugText(
									/*Location*/Polys[k].Center + CurrentData->NavMeshDrawOffset
									, /*Text*/FString::Printf(TEXT("[%X:%X]"), NavTileIndex, NavPolyIndex)
									));
							}
						}
					}							

					if (NavMesh->bDrawTileBounds)
					{
						FBox TileBox = NavMesh->GetNavMeshTileBounds(TileIndex);

						float DrawZ = (TileBox.Min.Z + TileBox.Max.Z) * 0.5f;		// @hack average
						FVector LL(TileBox.Min.X, TileBox.Min.Y, DrawZ);
						FVector UR(TileBox.Max.X, TileBox.Max.Y, DrawZ);
						FVector UL(LL.X, UR.Y, DrawZ);
						FVector LR(UR.X, LL.Y, DrawZ);
						CurrentData->ThickLineItems.Add(FNavMeshSceneProxyData::FDebugThickLine(LL, UL, NavMeshRenderColor_TileBounds, DefaultEdges_LineThickness));
						CurrentData->ThickLineItems.Add(FNavMeshSceneProxyData::FDebugThickLine(UL, UR, NavMeshRenderColor_TileBounds, DefaultEdges_LineThickness));
						CurrentData->ThickLineItems.Add(FNavMeshSceneProxyData::FDebugThickLine(UR, LR, NavMeshRenderColor_TileBounds, DefaultEdges_LineThickness));
						CurrentData->ThickLineItems.Add(FNavMeshSceneProxyData::FDebugThickLine(LR, LL, NavMeshRenderColor_TileBounds, DefaultEdges_LineThickness));
					}
				}
			}
		}

		CurrentData->bSkipDistanceCheck = GIsEditor && (GEngine->GetDebugLocalPlayer() == NULL);
		CurrentData->bDrawClusters = NavMesh->bDrawClusters;
		NavMesh->FinishBatchQuery();

		// Draw Mesh
		if (NavMesh->bDrawClusters)
		{
			for (int32 Idx = 0; Idx < CurrentData->NavMeshGeometry.Clusters.Num(); ++Idx)
			{
				const TArray<int32>& MeshIndices = CurrentData->NavMeshGeometry.Clusters[Idx].MeshIndices;

				if (MeshIndices.Num() == 0)
				{
					continue;
				}

				FNavMeshSceneProxyData::FDebugMeshData DebugMeshData;
				DebugMeshData.ClusterColor = GetClusterColor(Idx);
				for (int32 VertIdx=0; VertIdx < MeshVerts.Num(); ++VertIdx)
				{
					AddVertexHelper(DebugMeshData, MeshVerts[VertIdx] + CurrentData->NavMeshDrawOffset, DebugMeshData.ClusterColor);
				}
				for (int32 TriIdx=0; TriIdx < MeshIndices.Num(); TriIdx+=3)
				{
					AddTriangleHelper(DebugMeshData, MeshIndices[TriIdx], MeshIndices[TriIdx+1], MeshIndices[TriIdx+2]);
				}

				CurrentData->MeshBuilders.Add(DebugMeshData);
			}
		}
		else if (NavMesh->bDrawNavMesh)
		{			
			for (int32 AreaType = 0; AreaType < RECAST_MAX_AREAS; ++AreaType)
			{
				const TArray<int32>& MeshIndices = CurrentData->NavMeshGeometry.AreaIndices[AreaType];

				if (MeshIndices.Num() == 0)
				{
					continue;
				}

				FNavMeshSceneProxyData::FDebugMeshData DebugMeshData;
				for (int32 VertIdx=0; VertIdx < MeshVerts.Num(); ++VertIdx)
				{
					AddVertexHelper(DebugMeshData, MeshVerts[VertIdx] + CurrentData->NavMeshDrawOffset, CurrentData->NavMeshColors[AreaType]);
				}
				for (int32 TriIdx=0; TriIdx < MeshIndices.Num(); TriIdx+=3)
				{
					AddTriangleHelper(DebugMeshData, MeshIndices[TriIdx], MeshIndices[TriIdx+1], MeshIndices[TriIdx+2]);
				}

				DebugMeshData.ClusterColor = CurrentData->NavMeshColors[AreaType];
				CurrentData->MeshBuilders.Add(DebugMeshData);
			}
		}

		if (NavMesh->bDrawPathCollidingGeometry)
		{
			// draw all geometry gathered in navoctree
			const FNavigationOctree* NavOctree = NavMesh->GetWorld()->GetNavigationSystem()->GetNavOctree();

			TArray<FVector> PathCollidingGeomVerts;
			TArray <int32> PathCollidingGeomIndices;
			for (FNavigationOctree::TConstIterator<> It(*NavOctree); It.HasPendingNodes(); It.Advance())
			{
				const FNavigationOctree::FNode& Node = It.GetCurrentNode();
				for (FNavigationOctree::ElementConstIt ElementIt(Node.GetElementIt()); ElementIt; ElementIt++)
				{
					const FNavigationOctreeElement& Element = *ElementIt;
					if (Element.ShouldUseGeometry(&NavMesh->NavDataConfig) && Element.Data.CollisionData.Num())
					{
						const FRecastGeometryCache CachedGeometry(Element.Data.CollisionData.GetData());
						AppendGeometry(PathCollidingGeomVerts, PathCollidingGeomIndices, CachedGeometry.Verts, CachedGeometry.Header.NumVerts, CachedGeometry.Indices, CachedGeometry.Header.NumFaces);
					}
				}
				FOREACH_OCTREE_CHILD_NODE(ChildRef)
				{
					if (Node.HasChild(ChildRef))
					{
						It.PushChild(ChildRef);
					}
				}
			}
			CurrentData->PathCollidingGeomIndices = PathCollidingGeomIndices;
			for (const auto& Vertex : PathCollidingGeomVerts)
			{
				CurrentData->PathCollidingGeomVerts.Add(FDynamicMeshVertex(Vertex));
			}

		}

		if (CurrentData->NavMeshGeometry.BuiltMeshIndices.Num() > 0)
		{
			FNavMeshSceneProxyData::FDebugMeshData DebugMeshData;
			for (int32 VertIdx=0; VertIdx < MeshVerts.Num(); ++VertIdx)
			{
				AddVertexHelper(DebugMeshData, MeshVerts[VertIdx] + CurrentData->NavMeshDrawOffset, NavMeshRenderColor_RecastTileBeingRebuilt);
			}
			DebugMeshData.Indices.Append(CurrentData->NavMeshGeometry.BuiltMeshIndices);
			DebugMeshData.ClusterColor = NavMeshRenderColor_RecastTileBeingRebuilt;
			CurrentData->MeshBuilders.Add(DebugMeshData);

			// updates should be requested by FRecastNavMeshGenerator::TickAsyncBuild after tiles were refreshed
		}

		if (NavMesh->bDrawClusters)
		{
			for (int i = 0; i < CurrentData->NavMeshGeometry.ClusterLinks.Num(); i++)
			{
				const FRecastDebugGeometry::FClusterLink& CLink = CurrentData->NavMeshGeometry.ClusterLinks[i];
				const FVector V0 = CLink.FromCluster + CurrentData->NavMeshDrawOffset;
				const FVector V1 = CLink.ToCluster + CurrentData->NavMeshDrawOffset + FVector(0,0,20.0f);

				CacheArc(CurrentData->ClusterLinkLines, V0, V1, 0.4f, 4, FColor::Black, ClusterLinkLines_LineThickness);
				const FVector VOffset(0, 0, FVector::Dist(V0, V1) * 1.333f);
				CacheArrowHead(CurrentData->ClusterLinkLines, V1, V0+VOffset, 30.f, FColor::Black, ClusterLinkLines_LineThickness);
			}
		}

		// cache segment links
		if (NavMesh->bDrawNavLinks)
		{
			for (int32 iArea = 0; iArea < RECAST_MAX_AREAS; iArea++)
			{
				const TArray<int32>& Indices = CurrentData->NavMeshGeometry.OffMeshSegmentAreas[iArea];
				FNavMeshSceneProxyData::FDebugMeshData DebugMeshData;
				int32 VertBase = 0;

				for (int32 i = 0; i < Indices.Num(); i++)
				{
					FRecastDebugGeometry::FOffMeshSegment& SegInfo = CurrentData->NavMeshGeometry.OffMeshSegments[Indices[i]];
					const FVector A0 = SegInfo.LeftStart + CurrentData->NavMeshDrawOffset;
					const FVector A1 = SegInfo.LeftEnd + CurrentData->NavMeshDrawOffset;
					const FVector B0 = SegInfo.RightStart + CurrentData->NavMeshDrawOffset;
					const FVector B1 = SegInfo.RightEnd + CurrentData->NavMeshDrawOffset;
					const FVector Edge0 = B0 - A0;
					const FVector Edge1 = B1 - A1;
					const float Len0 = Edge0.Size();
					const float Len1 = Edge1.Size();
					const FColor SegColor = DarkenColor(CurrentData->NavMeshColors[SegInfo.AreaID]);
					const FColor ColA = (SegInfo.ValidEnds & FRecastDebugGeometry::OMLE_Left) ? FColor::White : FColor::Black;
					const FColor ColB = (SegInfo.ValidEnds & FRecastDebugGeometry::OMLE_Right) ? FColor::White : FColor::Black;

					const int32 NumArcPoints = 8;
					const float ArcPtsScale = 1.0f / NumArcPoints;

					FVector Prev0 = EvalArc(A0, Edge0, Len0*0.25f, 0);
					FVector Prev1 = EvalArc(A1, Edge1, Len1*0.25f, 0);
					AddVertexHelper(DebugMeshData, Prev0, ColA);
					AddVertexHelper(DebugMeshData, Prev1, ColA);
					for (int32 j = 1; j <= NumArcPoints; j++)
					{
						const float u = j * ArcPtsScale;
						FVector Pt0 = EvalArc(A0, Edge0, Len0*0.25f, u);
						FVector Pt1 = EvalArc(A1, Edge1, Len1*0.25f, u);

						AddVertexHelper(DebugMeshData, Pt0, (j == NumArcPoints) ? ColB : FColor::White);
						AddVertexHelper(DebugMeshData, Pt1, (j == NumArcPoints) ? ColB : FColor::White);

						AddTriangleHelper(DebugMeshData, VertBase+0, VertBase+2, VertBase+1);
						AddTriangleHelper(DebugMeshData, VertBase+2, VertBase+3, VertBase+1);
						AddTriangleHelper(DebugMeshData, VertBase+0, VertBase+1, VertBase+2);
						AddTriangleHelper(DebugMeshData, VertBase+2, VertBase+1, VertBase+3);

						VertBase += 2;
						Prev0 = Pt0;
						Prev1 = Pt1;
					}
					VertBase += 2;

					DebugMeshData.ClusterColor = SegColor;
				}

				if (DebugMeshData.Indices.Num())
				{
					CurrentData->MeshBuilders.Add(DebugMeshData);
				}
			}
		}

		CurrentData->NavMeshGeometry.PolyEdges.Empty();
		CurrentData->NavMeshGeometry.NavMeshEdges.Empty();
	}
Exemplo n.º 27
0
void World::loadScene(string filename) {
    // for as4, you can optionally hard-code the scene.  For as5 and as6 it must be loaded from a file.

    if (_FINAL_PROJ) {
        vec4 eye(0.0, 0.0, 0, 1.0);
        vec4 LL(-1.0, -1.0, -3.0, 1.0);
        vec4 UL(-1.0, 1.0, -3.0, 1.0);
        vec4 LR(1.0, -1.0, -3.0, 1.0);
        vec4 UR(1.0, 1.0, -3.0, 1.0);

        _view = Viewport(eye, LL, UL, LR, UR, IMAGE_WIDTH, IMAGE_HEIGHT, 1);

        _lights[LIGHT_DIRECTIONAL].push_back(
            Light(0, vec3(0.5,0.5,-0.5),
                  LightInfo(LIGHT_DIRECTIONAL, vec3(.4, .8, 1.2))));
        _lights[LIGHT_POINT].push_back(
            Light(vec3(0.0,0.0,-14.0), vec3(0.5,0.5,-0.5),
                  LightInfo(LIGHT_POINT, vec3(1.39, 0.2, 0.2))));

        _ambientLight = vec3(.5,.2,.2);
        /*
        _spheres.push_back(Sphere(vec4(-2.5,-1.5,-17.0,1.0), 2.0,
        					MaterialInfo(vec3(.4, .5, .9),
        					.1, .5, .5, 150, 1.0)));
        _spheres.push_back(Sphere(vec4(0.0,4.0,-25.0,1.0), 2.5,
        					MaterialInfo(vec3(.9, .4, .5),
        					.4, .2, .5, 20, 0.0)));
        _spheres.push_back(Sphere(vec4(1.5,-1.5,-10.0,1.0), 1.0,
        					MaterialInfo(vec3(.5, .9, .4),
        					.5, .5, .3, 4, .5)));
        */

        _cubes.push_back(Cube(vec4(-3.5,-3.5,-15.0,1.0), 1.5, MaterialInfo(vec3(.4, .5, .9),
                              .1, .5, .5, 150, 1.0)));

        _cubes.push_back(Cube(vec4(2.0, 1.5, -10,1.0), 1.5, MaterialInfo(vec3(.9, .4, .5),
                              .4, .2, .5, 20, 0.0)));

        _cubes.push_back(Cube(vec4(-3.5,4,-120.0,1.0), 3, MaterialInfo(vec3(.5, .9, .4),
                              .5, .5, .3, 4, .5)));

        _cubes.push_back(Cube(vec4(3.5,-4,-250.0,1.0), 3.5, MaterialInfo(vec3(.5, .9, .4),
                              .5, .5, .3, 4, .5)));

        ksmMod = kspMod = 1.0;
    }

    else if (_ASSIGNMENT >= 5) {
        scene = new Scene(filename);

        loadInstance(scene->getRoot());

        if (_ASSIGNMENT >= 6)
            _bb = new BoundingBox(_spheres, 0);
    }

    if (_ASSIGNMENT <= 4) {
        //vec4 eye(0.0, 0.0, 0, 1.0);
        //vec4 LL(-1.0, -1.0, -3.0, 1.0);
        //vec4 UL(-1.0, 1.0, -3.0, 1.0);
        //vec4 LR(1.0, -1.0, -3.0, 1.0);
        //vec4 UR(1.0, 1.0, -3.0, 1.0);

        //_view = Viewport(eye, LL, UL, LR, UR, IMAGE_WIDTH, IMAGE_HEIGHT);

        //_lights[LIGHT_DIRECTIONAL].push_back(
        //						Light(0, vec3(0.5,0.5,-0.5),
        //						LightInfo(LIGHT_DIRECTIONAL, vec3(.4, .8, 1.2))));
        //_lights[LIGHT_POINT].push_back(
        //						Light(vec3(0.0,0.0,-14.0), vec3(0.5,0.5,-0.5),
        //						LightInfo(LIGHT_POINT, vec3(1.39, 0.2, 0.2))));

        //_ambientLight = vec3(.5,.2,.2);

        //_spheres.push_back(Sphere(vec4(-2.5,-1.5,-17.0,1.0), 2.0,
        //					MaterialInfo(vec3(.4, .5, .9),
        //					.1, .5, .5, 150, 1.0)));
        //_spheres.push_back(Sphere(vec4(0.0,4.0,-25.0,1.0), 2.5,
        //					MaterialInfo(vec3(.9, .4, .5),
        //					.4, .2, .5, 20, 0.0)));
        //_spheres.push_back(Sphere(vec4(1.5,-1.5,-10.0,1.0), 1.0,
        //					MaterialInfo(vec3(.5, .9, .4),
        //					.5, .5, .3, 4, .5)));

        //ksmMod = kspMod = 1.0;
    }
}
Exemplo n.º 28
0
void World::loadInstance(SceneInstance *si) {

    // Compute transform information. Should add a mat4 even if there is no transform.
    mat4 mTransform;
    if (!si->computeTransform(mTransform)) {
        mTransform = identity3D(); // if there is no transform, push an identity matrix.
    }
    if (!transformStack.empty() && transformStack.top() != identity3D()) {
        mat4 mPreviousTransform = transformStack.top();
        mTransform =  mPreviousTransform * mTransform;
    }
    transformStack.push(mTransform);

    SceneGroup *sg = si->getChild();

    // Get camera info, if any.
    CameraInfo camInfo;
    if (sg->computeCamera(camInfo)) {
        vec4 eye(0.0, 0.0, 0.0, 1.0);
        double left = camInfo.sides[FRUS_LEFT];
        double right = camInfo.sides[FRUS_RIGHT];
        double top = camInfo.sides[FRUS_TOP];
        double bottom = camInfo.sides[FRUS_BOTTOM];
        double depth = -1*camInfo.sides[FRUS_NEAR];
        vec4 LL(left, bottom, depth, 1.0);
        vec4 UL(left, top, depth, 1.0);
        vec4 LR(right, bottom, depth, 1.0);
        vec4 UR(right, top, depth, 1.0);
        eye = mTransform * eye;
        LL = mTransform * LL;
        UL = mTransform * UL;
        LR = mTransform * LR;
        UR = mTransform * UR;
        _view = Viewport(eye, LL, UL, LR, UR, IMAGE_WIDTH, IMAGE_HEIGHT, camInfo.perspective);
    }

    // Compute light info, if any.
    LightInfo li;
    if (sg->computeLight(li)) {
        vec3 direction, position;
        switch (li.type) {
        case LIGHT_DIRECTIONAL:
        case LIGHT_POINT:
        case LIGHT_SPOT:
            direction = vec3(-1*mTransform[0][2],-1*mTransform[1][2],-1*mTransform[2][2]);
            position = mTransform * vec3(0.0);
            _lights[li.type].push_back(Light(position, direction, li));
            break;
        case LIGHT_AMBIENT:
            _ambientLight = li.color;
            break;
        }
    }

    // Computes sphere info, if any.
    double radius;
    MaterialInfo matInfo;
    if (sg->computeSphere(radius, matInfo, 0)) {
        _spheres.push_back(Sphere(vec4(0.0), radius, matInfo, mTransform));
    }

    // Recursively parse scene.
    for (int i = 0; i < sg->getChildCount(); i++) {
        loadInstance(sg->getChild(i));
    }

    // Pops the transformation matrix of this SceneGroup. This function should have added this matrix at the beginning.
    transformStack.pop();
}
Exemplo n.º 29
0
void overFace::rusanovFlux(void)
{
  /* Different flux function to utilize interpolated corrected flux, but still
   * apply upwinding */
  if (params->oversetMethod == 1) {
    for (int fpt=0; fpt<nFptsL; fpt++) {
      // Get primitive variables
      double rhoL = UL(fpt,0);     double rhoR = UR(fpt,0);
      double uL = UL(fpt,1)/rhoL;  double uR = UR(fpt,1)/rhoR;
      double vL = UL(fpt,2)/rhoL;  double vR = UR(fpt,2)/rhoR;

      double wL, pL, vnL=0.;
      double wR, pR, vnR=0.;
      double vgn=0.;

      // Calculate pressure
      if (params->nDims==2) {
        pL = (params->gamma-1.0)*(UL(fpt,3)-0.5*rhoL*(uL*uL+vL*vL));
        pR = (params->gamma-1.0)*(UR(fpt,3)-0.5*rhoR*(uR*uR+vR*vR));
      }
      else {
        wL = UL(fpt,3)/rhoL;   wR = UR(fpt,3)/rhoR;
        pL = (params->gamma-1.0)*(UL(fpt,4)-0.5*rhoL*(uL*uL+vL*vL+wL*wL));
        pR = (params->gamma-1.0)*(UR(fpt,4)-0.5*rhoR*(uR*uR+vR*vR+wR*wR));
      }

      // Get normal fluxes, normal velocities
      for (int dim=0; dim<params->nDims; dim++) {
        vnL += normL(fpt,dim)*UL(fpt,dim+1)/rhoL;
        vnR += normL(fpt,dim)*UR(fpt,dim+1)/rhoR;
        if (params->motion)
          vgn += normL(fpt,dim)*Vg(fpt,dim);
      }

      // Get maximum eigenvalue for diffusion coefficient
      double csqL = max(params->gamma*pL/rhoL,0.0);
      double csqR = max(params->gamma*pR/rhoR,0.0);
      double eigL = std::fabs(vnL) + sqrt(csqL);
      double eigR = std::fabs(vnR) + sqrt(csqR);
      double eig  = max(eigL,eigR);

      /* Calculate Rusanov flux using corrected normal flux from donor grid
       * (copied to Fn) */

      // Outflow - use internal state
      if (vnL - vgn > 0) {
        inviscidFlux(UL[fpt],tempFL,params);
        double tempFnL[5] = {0,0,0,0,0};
        for (int k=0; k<nFields; k++)
          for (int dim=0; dim<nDims; dim++)
            tempFnL[k] += tempFL[dim][k]*normL(fpt,dim);

        for (int k=0; k<params->nFields; k++) {
          Fn(fpt,k) = tempFnL[k] - 0.5*eig*(UR(fpt,k)-UL(fpt,k));
        }
      }

      // Inflow - use external state [previously copied into Fn]
      else {
        for (int k=0; k<params->nFields; k++) {
          Fn(fpt,k) = Fn(fpt,k) - 0.5*eig*(UR(fpt,k)-UL(fpt,k));
        }
      }

      // Store wave speed for calculation of allowable dt
      if (params->motion) {
        eigL = std::fabs(vnL-vgn) + sqrt(csqL);
        eigR = std::fabs(vnR-vgn) + sqrt(csqR);
      }
      *waveSp[fpt] = max(eigL,eigR);
    }
  }

  // For other overset methods, just call normal Rusanov flux
  else {
    face::rusanovFlux();
  }
}
Exemplo n.º 30
0
static void lh7a40xuart_set_termios (struct uart_port* port,
				     struct termios* termios,
				     struct termios* old)
{
	unsigned int con;
	unsigned int inten;
	unsigned int fcon;
	unsigned long flags;
	unsigned int baud;
	unsigned int quot;

	baud = uart_get_baud_rate (port, termios, old, 8, port->uartclk/16);
	quot = uart_get_divisor (port, baud); /* -1 performed elsewhere */

	switch (termios->c_cflag & CSIZE) {
	case CS5:
		fcon = WLEN_5;
		break;
	case CS6:
		fcon = WLEN_6;
		break;
	case CS7:
		fcon = WLEN_7;
		break;
	case CS8:
	default:
		fcon = WLEN_8;
		break;
	}
	if (termios->c_cflag & CSTOPB)
		fcon |= STP2;
	if (termios->c_cflag & PARENB) {
		fcon |= PEN;
		if (!(termios->c_cflag & PARODD))
			fcon |= EPS;
	}
	if (port->fifosize > 1)
		fcon |= FEN;

	spin_lock_irqsave (&port->lock, flags);

	uart_update_timeout (port, termios->c_cflag, baud);

	port->read_status_mask = RxOverrunError;
	if (termios->c_iflag & INPCK)
		port->read_status_mask |= RxFramingError | RxParityError;
	if (termios->c_iflag & (BRKINT | PARMRK))
		port->read_status_mask |= RxBreak;

		/* Figure mask for status we ignore */
	port->ignore_status_mask = 0;
	if (termios->c_iflag & IGNPAR)
		port->ignore_status_mask |= RxFramingError | RxParityError;
	if (termios->c_iflag & IGNBRK) {
		port->ignore_status_mask |= RxBreak;
		/* Ignore overrun when ignorning parity */
		/* *** FIXME: is this in the right place? */
		if (termios->c_iflag & IGNPAR)
			port->ignore_status_mask |= RxOverrunError;
	}

		/* Ignore all receive errors when receive disabled */
	if ((termios->c_cflag & CREAD) == 0)
		port->ignore_status_mask |= RxError;

	con   = UR (port, UART_R_CON);
	inten = (UR (port, UART_R_INTEN) & ~ModemInt);

	if (UART_ENABLE_MS (port, termios->c_cflag))
		inten |= ModemInt;

	BIT_CLR (port, UART_R_CON, UARTEN);	/* Disable UART */
	UR (port, UART_R_INTEN) = 0;		/* Disable interrupts */
	UR (port, UART_R_BRCON) = quot - 1;	/* Set baud rate divisor */
	UR (port, UART_R_FCON)  = fcon;		/* Set FIFO and frame ctrl */
	UR (port, UART_R_INTEN) = inten;	/* Enable interrupts */
	UR (port, UART_R_CON)   = con;		/* Restore UART mode */

	spin_unlock_irqrestore(&port->lock, flags);
}