void RaceSelectionPreview::setPrototype(const ESM::NPC &proto) { mBase = proto; mBase.mId = "player"; rebuild(); }
//-------------------------------------------------------------- void Page::update() { animateCounter = (ofGetElapsedTimef() * 30.0) + animateOffset * offsetAmount; rotInc = sin(animateCounter * 0.1); // twirl and tilt twirlAngle = rotInc * 5 * twirlAmount; tiltAngle = sin(rotInc * 0.01) * 100 * tiltAmount; // flip around, always in the same direction bool bFlipDecelerating = false; if (flipAmount > 0.05) { float offsetSpeed = animateOffset * .02 * offsetAmount * 0.3; float newSpeed = MIN(0.4, flipAmount); flipSpeed = MAX(flipSpeed, newSpeed + offsetSpeed); } else if (localFlipAngle != 0) { bFlipDecelerating = true; flipSpeed = MAX(flipSpeed * 0.9, 0.1); int currRotations = localFlipAngle / M_TWO_PI; int nextRotations = (localFlipAngle + flipSpeed) / M_TWO_PI; if (currRotations != nextRotations) { localFlipAngle = 0; flipSpeed = 0; } } localFlipAngle += flipSpeed; // flip the global value if it hasn't already been set this frame if (sharedLastFlipFrame < ofGetFrameNum()) { sharedFlipAngle = localFlipAngle; sharedLastFlipFrame = ofGetFrameNum(); flipAngle = sharedFlipAngle; } else if (bFlipDecelerating) { // don't sync if you're decelerating flipAngle = localFlipAngle; } else if (localFlipAngle != 0) { // sync the flips flipAngle = ofLerp(sharedFlipAngle, localFlipAngle, offsetAmount); } else { flipAngle = 0; } // sway back and forth swayInc += swaySpeed; swayAngle = (sin(swayInc) * swayAmount) - M_PI / 2; swayPos.x = cos(swayAngle) * swayRadius; swayPos.y = sin(swayAngle) * swayRadius + swayRadius; swayPos *= swayAmount; if (bendTail) { // bend the bottom of the page vertBendPct = sin(animateCounter * 0.1) * bottomBendAmount; } else if (bendWings) { // bend more topBendPct = sin(animateCounter * 0.1) * topBendAmount; bottomBendPct = sin(animateCounter * 0.1) * bottomBendAmount; } else if (bendFresh) { // funky fresh bending topBendPct = sin(animateCounter * 0.1) * topBendAmount; bottomBendPct = -rotInc * 2 * bottomBendAmount; } ofVec3f posFromCenter(pos.x, 0, pos.z); alignPivot = posFromCenter; if (tornadoAmount > 0) { float tornadoRadius = MIN(pos.y, groundSize); float distFromCenter = posFromCenter.length(); if ((int)distFromCenter < 1) { // move away from the center pos.x += cos(tornadoAngle); pos.z += sin(tornadoAngle); } else { // tornado! ofPoint center(0, pos.y, 0); tornadoOffset = pos.getPerpendicular(center); tornadoOffset.normalize(); tornadoOffset *= (pos.y * 0.1); if (bGoingUp) { // ease up the angle tornadoOffset.y += ofMap(pos.y, startPos.y, startPos.y + 10, tornadoAngle / 10, tornadoAngle, true); if (tornadoRadius >= groundSize) { bGoingUp = false; } } else { // ease down the angle tornadoOffset.y -= ofMap(pos.y, startPos.y + 10, startPos.y, tornadoAngle, tornadoAngle / 10, true); tornadoOffset -= (posFromCenter * 0.01); if (tornadoRadius < startPos.y) { bGoingUp = true; } } tornadoOffset.y *= liftAmount; pos += tornadoOffset * speedAmount; ofVec3f newPosFromCenter(pos.x, 0, pos.z); float newDistFromCenter = newPosFromCenter.length(); float deltaDistFromCenter = newDistFromCenter - distFromCenter; newPosFromCenter.scale(distFromCenter + deltaDistFromCenter * expandAmount); pos.x = newPosFromCenter.x; pos.z = newPosFromCenter.z; } } if (bendTail) { rebuild(vertBendPct); } else if (bendWings || bendFresh) { rebuild(topBendPct, bottomBendPct); } else { rebuild(); } }
NZMQT_INLINE void ZMQMessage::clone(ZMQMessage* msg_) { rebuild(msg_->size()); memcpy(data(), msg_->data(), size()); }
/** @param style is an int representing a given neighbor style */ void CellList::setNeighborStyle(int style) { _neighbor_style = style; _force_rebuild = true; rebuild(); }
uint32 SearchResults::onMessage(uint32 message, uint32 wParam, uint32 lParam) { switch (message) { case WM_ADDFILE: EnterCriticalSection(&lock); while (getCount() < items.length()) addItem(getCount(), true); LeaveCriticalSection(&lock); return 0; case WM_NOTIFY: { NMHDR* pnm = (NMHDR*) lParam; if (pnm->code == LVN_ITEMACTIVATE) { NMITEMACTIVATE* pia = (NMITEMACTIVATE*) pnm; if (pia->iItem >= 0 && pia->iItem < items.length()) { SendMessage(getApp()->getMainWindow(), WM_PUSHVIEW, (uint32) new ReplayViewItem(items[pia->iItem].path), 0); } return 0; } else if (pnm->code == LVN_BEGINDRAG) { Array<String> sel; getSelList(sel); if (sel.length()) { HGLOBAL data = CreateFileDrop(sel); if (data) DoDragDrop(CF_HDROP, data, DROPEFFECT_MOVE | DROPEFFECT_COPY | DROPEFFECT_LINK); } return TRUE; } else if (pnm->code == LVN_COLUMNCLICK) { NMLISTVIEW* lv = (NMLISTVIEW*) lParam; bool colShow[colCount] = {true, cfg.selColumns & COL_SAVED, cfg.selColumns & COL_SIZE, cfg.selColumns & COL_NAME, cfg.selColumns & COL_RATIO, cfg.selColumns & COL_LENGTH, cfg.selColumns & COL_MODE }; int col = lv->iSubItem; for (int i = 0; i < col && col < colCount - 1; i++) if (!colShow[i]) col++; int pos = 0; while (pos < colCount - 1 && cfg.colSort[pos] != col && cfg.colSort[pos] != ~col) pos++; if (pos == 0) cfg.colSort[0] = ~cfg.colSort[0]; else { for (int i = pos; i > 0; i--) cfg.colSort[i] = cfg.colSort[i - 1]; cfg.colSort[0] = col; } rebuild(); } else if (pnm->code == HDN_ENDDRAG) PostMessage(hWnd, WM_POSTHEADERDRAG, 0, 0); else if (pnm->code == HDN_ENDTRACK) { NMHEADER* nhdr = (NMHEADER*) pnm; bool colShow[colCount] = {true, cfg.selColumns & COL_SAVED, cfg.selColumns & COL_SIZE, cfg.selColumns & COL_NAME, cfg.selColumns & COL_RATIO, cfg.selColumns & COL_LENGTH, cfg.selColumns & COL_MODE }; int count = 0; int colUnpos[colCount]; for (int i = 0; i < colCount; i++) if (colShow[i]) colUnpos[count++] = i; if (nhdr->iItem >= 0 && nhdr->iItem < count && nhdr->pitem && nhdr->pitem->mask & HDI_WIDTH) { int col = colUnpos[nhdr->iItem]; cfg.colWidth[col] = nhdr->pitem->cxy; } } else if (pnm->code == LVN_KEYDOWN) { NMLVKEYDOWN* kd = (NMLVKEYDOWN*) lParam; bool controlKey = ((GetAsyncKeyState(VK_CONTROL) & 0x8000) || wParam == VK_CONTROL); if (kd->wVKey == 'C' && controlKey) { Array<String> sel; getSelList(sel); if (sel.length()) { HGLOBAL hDrop = CreateFileDrop(sel); SetClipboard(CF_HDROP, hDrop); } } else if (kd->wVKey == VK_DELETE) { Array<String> sel; getSelList(sel); if (sel.length()) { char* str = FileListToString(sel); SHFILEOPSTRUCT fileop; memset(&fileop, 0, sizeof fileop); fileop.wFunc = FO_DELETE; fileop.pFrom = str; SHFileOperationEx(&fileop); } } return 0; } } break; case WM_POSTHEADERDRAG: { bool colShow[colCount] = {true, cfg.selColumns & COL_SAVED, cfg.selColumns & COL_SIZE, cfg.selColumns & COL_NAME, cfg.selColumns & COL_RATIO, cfg.selColumns & COL_LENGTH, cfg.selColumns & COL_MODE }; int count = 0; int colUnpos[colCount]; for (int i = 0; i < colCount; i++) if (colShow[i]) colUnpos[count++] = i; int colOrder[colCount]; ListView_GetColumnOrderArray(hWnd, count, colOrder); int pos = 0; for (int i = 0; i < colCount; i++) if (colShow[cfg.colOrder[i]]) cfg.colOrder[i] = colUnpos[colOrder[pos++]]; } return 0; } return ListFrame::onMessage(message, wParam, lParam); }
void grid::setYSize( JFLOAT s ) { _ySize = s; rebuild(); }
/** The interaction range determines which cells are neighbors. Normally, the cell size is slightly larger than the interaction range such that each cell has 26 neighbors. However, we can make the cells smaller and loop over more cell neighbors to more closely approximate a spherical interaction range and avoid calculating interactions between non-interacting particles. @param range is the interaction range */ void CellList::setInteractionRange(double range) { _interaction_range = range; rebuild(); }
int main(int argc, char **argv) { int envc; /* environment argument count */ char **envv; /* environment argument list */ FILE *names; /* name file pointer */ int oldnum; /* number in old cross-ref */ char path[PATHLEN + 1]; /* file path */ FILE *oldrefs; /* old cross-reference file */ char *s; int c, i; pid_t pid; /* save the command name for messages */ argv0 = basename(argv[0]); /* get the current directory for build() and line-oriented P command */ if (mygetwd(currentdir) == NULL) { (void) fprintf(stderr, "cscope: warning: cannot get current directory name\n"); (void) strcpy(currentdir, "<unknown>"); } /* initialize any view path; (saves time since currendir is known) */ vpinit(currentdir); dbvpndirs = vpndirs; /* number of directories in database view path */ /* directories (including current) in database view path */ dbvpdirs = vpdirs; /* the first source directory is the current directory */ sourcedir("."); /* read the environment */ editor = mygetenv("EDITOR", EDITOR); editor = mygetenv("VIEWER", editor); /* use viewer if set */ home = getenv("HOME"); shell = mygetenv("SHELL", SHELL); tmpdir = mygetenv("TMPDIR", TMPDIR); /* increment nesting depth */ cscopedepth = atoi(mygetenv("CSCOPEDEPTH", "0")); (void) sprintf(path, "CSCOPEDEPTH=%d", ++cscopedepth); (void) putenv(stralloc(path)); if ((s = getenv("CSCOPEOPTIONS")) != NULL) { /* parse the environment option string */ envc = 1; envv = mymalloc(sizeof (char *)); s = strtok(stralloc(s), OPTSEPS); while (s != NULL) { envv = myrealloc(envv, ++envc * sizeof (char *)); envv[envc - 1] = stralloc(s); s = strtok((char *)NULL, OPTSEPS); } /* set the environment options */ options(envc, envv); } /* set the command line options */ options(argc, argv); /* create the temporary file names */ pid = getpid(); (void) sprintf(temp1, "%s/cscope%d.1", tmpdir, (int)pid); (void) sprintf(temp2, "%s/cscope%d.2", tmpdir, (int)pid); /* if running in the foreground */ if (signal(SIGINT, SIG_IGN) != SIG_IGN) { /* cleanup on the interrupt and quit signals */ (void) signal(SIGINT, myexit); (void) signal(SIGQUIT, myexit); } /* cleanup on the hangup signal */ (void) signal(SIGHUP, myexit); /* if the database path is relative and it can't be created */ if (reffile[0] != '/' && access(".", WRITE) != 0) { /* if the database may not be up-to-date or can't be read */ (void) sprintf(path, "%s/%s", home, reffile); if (isuptodate == NO || access(reffile, READ) != 0) { /* put it in the home directory */ reffile = stralloc(path); (void) sprintf(path, "%s/%s", home, invname); invname = stralloc(path); (void) sprintf(path, "%s/%s", home, invpost); invpost = stralloc(path); (void) fprintf(stderr, "cscope: symbol database will be %s\n", reffile); } } /* if the cross-reference is to be considered up-to-date */ if (isuptodate == YES) { if ((oldrefs = vpfopen(reffile, "r")) == NULL) { cannotopen(reffile); exit(1); } /* * get the crossref file version but skip the current * directory */ if (fscanf(oldrefs, "cscope %d %*s", &fileversion) != 1) { (void) fprintf(stderr, "cscope: cannot read file version from file %s\n", reffile); exit(1); } if (fileversion >= 8) { /* override these command line options */ compress = YES; invertedindex = NO; /* see if there are options in the database */ for (;;) { /* no -q leaves multiple blanks */ while ((c = getc(oldrefs)) == ' ') { ; } if (c != '-') { (void) ungetc(c, oldrefs); break; } switch (c = getc(oldrefs)) { case 'c': /* ASCII characters only */ compress = NO; break; case 'q': /* quick search */ invertedindex = YES; (void) fscanf(oldrefs, "%ld", &totalterms); break; case 'T': /* truncate symbols to 8 characters */ dbtruncated = YES; truncatesyms = YES; break; } } initcompress(); /* seek to the trailer */ if (fscanf(oldrefs, "%ld", &traileroffset) != 1) { (void) fprintf(stderr, "cscope: cannot read trailer offset from " "file %s\n", reffile); exit(1); } if (fseek(oldrefs, traileroffset, 0) != 0) { (void) fprintf(stderr, "cscope: cannot seek to trailer in " "file %s\n", reffile); exit(1); } } /* * read the view path for use in converting relative paths to * full paths * * note: don't overwrite vp[n]dirs because this can cause * the wrong database index files to be found in the viewpath */ if (fileversion >= 13) { if (fscanf(oldrefs, "%d", &dbvpndirs) != 1) { (void) fprintf(stderr, "cscope: cannot read view path size from " "file %s\n", reffile); exit(1); } if (dbvpndirs > 0) { dbvpdirs = mymalloc( dbvpndirs * sizeof (char *)); for (i = 0; i < dbvpndirs; ++i) { if (fscanf(oldrefs, "%s", path) != 1) { (void) fprintf(stderr, "cscope: cannot read view " "path from file %s\n", reffile); exit(1); } dbvpdirs[i] = stralloc(path); } } } /* skip the source and include directory lists */ skiplist(oldrefs); skiplist(oldrefs); /* get the number of source files */ if (fscanf(oldrefs, "%d", &nsrcfiles) != 1) { (void) fprintf(stderr, "cscope: cannot read source file size from " "file %s\n", reffile); exit(1); } /* get the source file list */ srcfiles = mymalloc(nsrcfiles * sizeof (char *)); if (fileversion >= 9) { /* allocate the string space */ if (fscanf(oldrefs, "%d", &oldnum) != 1) { (void) fprintf(stderr, "cscope: cannot read string space size " "from file %s\n", reffile); exit(1); } s = mymalloc(oldnum); (void) getc(oldrefs); /* skip the newline */ /* read the strings */ if (fread(s, oldnum, 1, oldrefs) != 1) { (void) fprintf(stderr, "cscope: cannot read source file names " "from file %s\n", reffile); exit(1); } /* change newlines to nulls */ for (i = 0; i < nsrcfiles; ++i) { srcfiles[i] = s; for (++s; *s != '\n'; ++s) { ; } *s = '\0'; ++s; } /* if there is a file of source file names */ if (namefile != NULL && (names = vpfopen(namefile, "r")) != NULL || (names = vpfopen(NAMEFILE, "r")) != NULL) { /* read any -p option from it */ while (fscanf(names, "%s", path) == 1 && *path == '-') { i = path[1]; s = path + 2; /* for "-Ipath" */ if (*s == '\0') { /* if "-I path" */ (void) fscanf(names, "%s", path); s = path; } switch (i) { case 'p': /* file path components */ /* to display */ if (*s < '0' || *s > '9') { (void) fprintf(stderr, "cscope: -p option " "in file %s: " "missing or " "invalid numeric " "value\n", namefile); } dispcomponents = atoi(s); } } (void) fclose(names); } } else { for (i = 0; i < nsrcfiles; ++i) { if (fscanf(oldrefs, "%s", path) != 1) { (void) fprintf(stderr, "cscope: cannot read source file " "name from file %s\n", reffile); exit(1); } srcfiles[i] = stralloc(path); } } (void) fclose(oldrefs); } else { /* get source directories from the environment */ if ((s = getenv("SOURCEDIRS")) != NULL) { sourcedir(s); } /* make the source file list */ srcfiles = mymalloc(msrcfiles * sizeof (char *)); makefilelist(); if (nsrcfiles == 0) { (void) fprintf(stderr, "cscope: no source files found\n"); printusage(); exit(1); } /* get include directories from the environment */ if ((s = getenv("INCLUDEDIRS")) != NULL) { includedir(s); } /* add /usr/include to the #include directory list */ includedir("/usr/include"); /* initialize the C keyword table */ initsymtab(); /* create the file name(s) used for a new cross-reference */ (void) strcpy(path, reffile); s = basename(path); *s = '\0'; (void) strcat(path, "n"); ++s; (void) strcpy(s, basename(reffile)); newreffile = stralloc(path); (void) strcpy(s, basename(invname)); newinvname = stralloc(path); (void) strcpy(s, basename(invpost)); newinvpost = stralloc(path); /* build the cross-reference */ initcompress(); build(); if (buildonly == YES) { exit(0); } } opendatabase(); /* * removing a database will not release the disk space if a cscope * process has the file open, so a project may want unattended cscope * processes to exit overnight, including their subshells and editors */ if (noacttime) { (void) signal(SIGALRM, timedout); (void) alarm(noacttime); } /* * if using the line oriented user interface so cscope can be a * subprocess to emacs or samuel */ if (linemode == YES) { if (*pattern != '\0') { /* do any optional search */ if (search() == YES) { while ((c = getc(refsfound)) != EOF) { (void) putchar(c); } } } if (onesearch == YES) { myexit(0); } for (;;) { char buf[PATLEN + 2]; if (noacttime) { (void) alarm(noacttime); } (void) printf(">> "); (void) fflush(stdout); if (fgets(buf, sizeof (buf), stdin) == NULL) { myexit(0); } /* remove any trailing newline character */ if (*(s = buf + strlen(buf) - 1) == '\n') { *s = '\0'; } switch (*buf) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': /* samuel only */ field = *buf - '0'; (void) strcpy(pattern, buf + 1); (void) search(); (void) printf("cscope: %d lines\n", totallines); while ((c = getc(refsfound)) != EOF) { (void) putchar(c); } break; case 'c': /* toggle caseless mode */ case ctrl('C'): if (caseless == NO) { caseless = YES; } else { caseless = NO; } egrepcaseless(caseless); break; case 'r': /* rebuild database cscope style */ case ctrl('R'): freefilelist(); makefilelist(); /* FALLTHROUGH */ case 'R': /* rebuild database samuel style */ rebuild(); (void) putchar('\n'); break; case 'C': /* clear file names */ freefilelist(); (void) putchar('\n'); break; case 'F': /* add a file name */ (void) strcpy(path, buf + 1); if (infilelist(path) == NO && vpaccess(path, READ) == 0) { addsrcfile(path); } (void) putchar('\n'); break; case 'P': /* print the path to the files */ if (prependpath != NULL) { (void) puts(prependpath); } else { (void) puts(currentdir); } break; case 'q': /* quit */ case ctrl('D'): case ctrl('Z'): myexit(0); default: (void) fprintf(stderr, "cscope: unknown command '%s'\n", buf); break; } } /* NOTREACHED */ } /* pause before clearing the screen if there have been error messages */ if (errorsfound == YES) { errorsfound = NO; askforreturn(); } (void) signal(SIGINT, SIG_IGN); /* ignore interrupts */ (void) signal(SIGPIPE, SIG_IGN); /* | command can cause pipe signal */ /* initialize the curses display package */ (void) initscr(); /* initialize the screen */ setfield(); /* set the initial cursor position */ entercurses(); (void) keypad(stdscr, TRUE); /* enable the keypad */ dispinit(); /* initialize display parameters */ putmsg(""); /* clear any build progress message */ display(); /* display the version number and input fields */ /* do any optional search */ if (*pattern != '\0') { atfield(); /* move to the input field */ (void) command(ctrl('A')); /* search */ display(); /* update the display */ } else if (reflines != NULL) { /* read any symbol reference lines file */ (void) readrefs(reflines); display(); /* update the display */ } for (;;) { if (noacttime) { (void) alarm(noacttime); } atfield(); /* move to the input field */ /* exit if the quit command is entered */ if ((c = mygetch()) == EOF || c == ctrl('D') || c == ctrl('Z')) { break; } /* execute the commmand, updating the display if necessary */ if (command(c) == YES) { display(); } } /* cleanup and exit */ myexit(0); /* NOTREACHED */ return (0); }
void CSVDoc::GlobalDebugProfileMenu::profileAboutToBeRemoved (const QModelIndex& parent, int start, int end) { rebuild(); }
/** execute the command */ BOOL command(int commandc) { char filename[PATHLEN + 1]; /* file path name */ MOUSE *p; /* mouse data */ int c, i; FILE *file; struct cmd *curritem, *item; /* command history */ char *s; switch (commandc) { case ctrl('C'): /* toggle caseless mode */ if (caseless == NO) { caseless = YES; postmsg2("Caseless mode is now ON"); } else { caseless = NO; postmsg2("Caseless mode is now OFF"); } return(NO); case ctrl('R'): /* rebuild the cross reference */ if (isuptodate == YES) { postmsg("The -d option prevents rebuilding the symbol database"); return(NO); } postmsg("Rebuilding cross-reference..."); rebuild(); postmsg(""); totallines = 0; disprefs = 0; topline = nextline = 1; selecting = 0; break; #if UNIXPC case ESC: /* possible unixpc mouse selection */ #endif case ctrl('X'): /* mouse selection */ if ((p = getmouseaction(DUMMYCHAR)) == NULL) { return(NO); /* unknown control sequence */ } /* if the button number is a scrollbar tag */ if (p->button == '0') { scrollbar(p); break; } /* ignore a sweep */ if (p->x2 >= 0) { return(NO); } /* if this is a line selection */ if (p->y1 < FLDLINE) { /* find the selected line */ /* note: the selection is forced into range */ for (i = disprefs - 1; i > 0; --i) { if (p->y1 >= displine[i]) { break; } } /* display it in the file with the editor */ editref(i); } else { /* this is an input field selection */ field = p->y1 - FLDLINE; /* force it into range */ if (field >= FIELDS) { field = FIELDS - 1; } setfield(); resetcmd(); return(NO); } break; case '\t': /* go to next input field */ if (disprefs) { selecting = !selecting; if (selecting) { move(displine[curdispline], 0); refresh(); } else { atfield(); resetcmd(); } } return(NO); #ifdef KEY_ENTER case KEY_ENTER: #endif case '\r': case '\n': /* go to reference */ if (selecting) { editref(curdispline); return(YES); } /* FALLTHROUGH */ case ctrl('N'): #ifdef KEY_DOWN case KEY_DOWN: #endif #ifdef KEY_RIGHT case KEY_RIGHT: #endif if (selecting) { if ((curdispline + 1) < disprefs) { move(displine[++curdispline], 0); refresh(); } } else { field = (field + 1) % FIELDS; if (field == 2) field = 3; setfield(); atfield(); resetcmd(); } return(NO); case ctrl('P'): /* go to previous input field */ #ifdef KEY_UP case KEY_UP: #endif #ifdef KEY_LEFT case KEY_LEFT: #endif if (selecting) { if (curdispline) { move(displine[--curdispline], 0); refresh(); } } else { field = (field + (FIELDS - 1)) % FIELDS; if (field == 2) field = 1; setfield(); atfield(); resetcmd(); } return(NO); #ifdef KEY_HOME case KEY_HOME: /* go to first input field */ if (selecting) { curdispline = 0; move(REFLINE, 0); refresh(); } else { field = 0; setfield(); atfield(); resetcmd(); } return(NO); #endif #ifdef KEY_LL case KEY_LL: /* go to last input field */ if (selecting) { move(displine[disprefs - 1], 0); refresh(); } else { field = FIELDS - 1; setfield(); atfield(); resetcmd(); } return(NO); #endif /* def(KEY_LL) */ case ' ': /* display next page */ case '+': case ctrl('V'): #ifdef KEY_NPAGE case KEY_NPAGE: #endif /* don't redisplay if there are no lines */ if (totallines == 0) { return(NO); } /* note: seekline() is not used to move to the next * page because display() leaves the file pointer at * the next page to optimize paging forward */ curdispline = 0; break; case ctrl('H'): case '-': /* display previous page */ #ifdef KEY_PPAGE case KEY_PPAGE: #endif /* don't redisplay if there are no lines */ if (totallines == 0) { return(NO); } curdispline = 0; /* if there are only two pages, just go to the other one */ if (totallines <= 2 * mdisprefs) { break; } /* if on first page but not at beginning, go to beginning */ nextline -= mdisprefs; /* already at next page */ if (nextline > 1 && nextline <= mdisprefs) { nextline = 1; } else { nextline -= mdisprefs; if (nextline < 1) { nextline = totallines - mdisprefs + 1; if (nextline < 1) { nextline = 1; } } } seekline(nextline); break; case '>': /* write or append the lines to a file */ if (totallines == 0) { postmsg("There are no lines to write to a file"); } else { /* get the file name */ move(PRLINE, 0); addstr("Write to file: "); s = "w"; if ((c = mygetch()) == '>') { move(PRLINE, 0); addstr(appendprompt); c = '\0'; s = "a"; } if (c != '\r' && mygetline("", newpat, COLS - sizeof(appendprompt), c, NO) > 0 ) { shellpath(filename, sizeof(filename), newpat); if ((file = myfopen(filename, s)) == NULL) { cannotopen(filename); } else { seekline(1); while ((c = getc(refsfound)) != EOF) { putc(c, file); } seekline(topline); fclose(file); } } clearprompt(); } return(NO); /* return to the previous field */ case '<': /* read lines from a file */ move(PRLINE, 0); addstr(readprompt); if (mygetline("", newpat, COLS - sizeof(readprompt), '\0', NO) > 0) { clearprompt(); shellpath(filename, sizeof(filename), newpat); if (readrefs(filename) == NO) { postmsg2("Ignoring an empty file"); return(NO); } return(YES); } clearprompt(); return(NO); case '^': /* pipe the lines through a shell command */ case '|': /* pipe the lines to a shell command */ if (totallines == 0) { postmsg("There are no lines to pipe to a shell command"); return(NO); } /* get the shell command */ move(PRLINE, 0); addstr(pipeprompt); if (mygetline("", newpat, COLS - sizeof(pipeprompt), '\0', NO) == 0) { clearprompt(); return(NO); } /* if the ^ command, redirect output to a temp file */ if (commandc == '^') { strcat(strcat(newpat, " >"), temp2); /* HBB 20020708: somebody might have even * their non-interactive default shells * complain about clobbering * redirections... --> delete before * overwriting */ remove(temp2); } exitcurses(); if ((file = mypopen(newpat, "w")) == NULL) { fprintf(stderr, "\ cscope: cannot open pipe to shell command: %s\n", newpat); } else {
std::shared_ptr<gx::scene> universe_bootstrap( gx::render_context* render_context, d3d11::system_context context, std::shared_ptr<fnd::universe> universe ) { auto scene = std::make_shared<gx::scene>(); auto entities = std::make_shared<gx::entity_world> (); auto dynamic_entities = std::make_shared<fnd::typed_world> (); //add two worlds //1. with entities, created or loaded //2. dynamic entities which change depending on time //3. add a spatial structure for representing these entities universe->add_world(entities); universe->add_world(dynamic_entities); universe->add_world(scene); //room std::ifstream f("giroom.am", std::ios_base::in | std::ios_base::binary); std::future< std::shared_ptr<room_entity> > future_room = std::async( std::launch::async, [&]() { return create_room_entity(context.m_device.get(), render_context->get_shader_database(), f); }); //auto room_entity = create_room_entity(context.m_device.get(), render_context->get_shader_database(), f); //floor auto floor_entity = create_floor_entity( context.m_device.get(), render_context->get_shader_database(), 20, 20, 30 ); //directional light std::vector<directional_light> directional_lights; directional_lights.reserve(8); math::float4 light_position = math::set( 5.0f, 1.0f, 5.0f, 1.0f ); directional_lights.push_back( directional_light( gx::color::white(), math::sub(light_position, math::set(0.0f, 0.0f, 0.0f, 1.0f) ) )); //should be quad auto directional_entity = create_directional_lights_entity( context.m_device.get(), render_context->m_screen_space_render_data.m_screen_space_vertex_buffer, &directional_lights[0], &directional_lights[0] + directional_lights.size() ); //create point light entity and insert it into two worlds (for update and render) auto point_lights = create_point_lights_entity( context.m_device.get() ); auto light_updater = create_light_entity_updater(); dynamic_entities->add_type( 0, light_updater ); point_light light1 ( math::set(0.3f, 0.2f, 0.0f, 0.0f), light_position, 1.0f, 0.5f); point_lights->add_light(light1); auto it = scene->begin(); auto it_end = scene->end(); auto pi_div_two = 1.570796327f; //auto m_1 = math::rotation_x(-pi_div_two); //auto m_2 = math::translation(-1.0f, 0.0f, 0.0f); auto m_4 = math::translation(0.0f, 0.0f, 0.0f); auto root = scene->get_root(); //auto entity_1 = gxu::create_lat_lon_sphere_entity<gx::lambert_shift_invairant_material_factory>( render_context, 1.0f, 20, gx::color::blue() ); auto sphere_1 = gxu::create_lat_lon_sphere_entity<gx::blinn_phong_shift_invairant_material_factory>( render_context->get_device(), render_context->get_shader_database(), 1.0f, 20 , gx::color::green() , math::set(0.05f, 0.05f, 0.05f, gx::encode_specular_power(2 * 25.0f) ) ); auto sphere_2 = gxu::create_lat_lon_sphere_entity<gx::blinn_phong_shift_invairant_material_factory>( render_context->get_device(), render_context->get_shader_database(), 1.0f, 20 , gx::color::green() , math::set(0.05f, 0.05f, 0.05f, gx::encode_specular_power(2 * 50.0f) ) ); auto sphere_3 = gxu::create_lat_lon_sphere_entity<gx::blinn_phong_shift_invairant_material_factory>( render_context->get_device(), render_context->get_shader_database(), 1.0f, 20 , gx::color::green() , math::set(0.05f, 0.05f, 0.05f, gx::encode_specular_power(2 * 75.0f) ) ); auto sphere_4 = gxu::create_lat_lon_sphere_entity<gx::blinn_phong_shift_invairant_material_factory>( render_context->get_device(), render_context->get_shader_database(), 1.0f, 20 , gx::color::green() , math::set(0.05f, 0.05f, 0.05f, gx::encode_specular_power(2 * 100.0f) ) ); auto node_1 = std::make_shared<gx::scene::node> ( m_4, sphere_1.get() ); auto node_2 = std::make_shared<gx::scene::node> ( m_4, point_lights.get() ); auto node_3 = std::make_shared<gx::scene::node> ( m_4, directional_entity.get() ); auto node_4 = std::make_shared<gx::scene::node> ( math::translation(0.0f, -2.0f, 0.0f) , floor_entity.get() ); auto room_entity = future_room.get(); auto node_5 = std::make_shared<gx::scene::node> ( math::translation(0.0f, -2.0f, 0.0f), room_entity.get() ); auto node_6 = std::make_shared<gx::scene::node> ( math::translation(2.0f, 0.0f, 0.0f), sphere_2.get() ); auto node_7 = std::make_shared<gx::scene::node> ( math::translation(4.0f, 0.0f, 0.0f), sphere_3.get() ); auto node_8 = std::make_shared<gx::scene::node> ( math::translation(6.0f, 0.0f, 0.0f), sphere_4.get() ); //1. add to graphic world gx::add_node(root, node_1); gx::add_node(root, node_2); gx::add_node(root, node_3); gx::add_node(root, node_4); gx::add_node(root, node_5); gx::add_node(root, node_6); gx::add_node(root, node_7); gx::add_node(root, node_8); //2. add to entities world entities->add_entity( point_lights); entities->add_entity( directional_entity ); entities->add_entity( floor_entity ); entities->add_entity( room_entity ); entities->add_entity( sphere_1); entities->add_entity( sphere_2); entities->add_entity( sphere_3); entities->add_entity( sphere_4); scene->rebuild(); //3. add lights for updating light_updater->add_item(point_lights); return scene; }
void ZDLInterface::writeConfig(){ rebuild(); emit buildChildren(this); }
void ZDLInterface::sendSignals(){ rebuild(); emit buildParent(this); emit buildChildren(this); }
static double sistematica2(pp3d_rob protein, double scale, int iteraciones, double *initial){ int j,njoints=protein->njoints; int conf_in_col; double inicio,fin, aux, tiempo,averagecol,usual_averagecol,averagecol0; double tinit,tpos,tposzig,trebuild,tprep,tlongdist,tcol,tcolzig,trebuilt_percent0; Robot_structure *rob; p3d_init_random_seed(0); printf ("numero de joints: %d\n", njoints); printf ("proteina %s, iteraciones %d, escala %4.3f\n", protein->name, iteraciones,escala_cont_pos); /*for (i=0;i<njoints;i++){ printf("%s,%2.2f, %2.2f\n ", protein->joints[i]->name,protein->joints[i]->vmin,protein->joints[i]->vmax); } */ charlatan=0; ChronoOn(); ChronoTimes(&inicio, &aux); bio_set_col_mode(NORMAL_BIOCOL_MODE); #ifdef HYDROGEN_BOND bio_init_molecules(0.8); printf("compilado con HYDROGEN_BOND", tpos); #else bio_init_molecules(scale); #endif rob=bcd_robots[0]; ChronoTimes(&fin, &aux); tinit= fin - inicio; printf("inicializacion: %4.4f segundos\n", tinit); /**************** unuseful action; only to "inject fuel to the machine" ***********/ /* for (j=0;j<iteraciones;j++){ random_pos(protein); set_n_collisions_to_zero(); rebuild(rob); preprogr_collisions(rob); sup_collision(rob->superroot, rob->superroot); } restore_conf(initial,njoints); */ /****************** end of unuseful action ******************************** */ /*tpos */ ChronoTimes(&inicio, &aux); for (j=0;j<iteraciones;j++){ random_pos(protein); } ChronoTimes(&fin, &aux); tpos= fin - inicio; printf("pos: %4.4f segundos\n", tpos); restore_conf(initial,njoints); //goto abrevia; /*trbuild */ ChronoTimes(&inicio, &aux); averagecol=0; for (j=0;j<iteraciones;j++){ random_pos(protein); set_n_collisions_to_zero(); rebuild(rob); } ChronoTimes(&fin, &aux); //ChronoOff(); tiempo= fin - inicio; averagecol= averagecol / iteraciones; trebuild= tiempo - tpos; printf("rebuild: %4.4f segundos \n", trebuild); restore_conf(initial,njoints); /* tshordistance */ ChronoTimes(&inicio, &aux); averagecol=0; for (j=0;j<iteraciones;j++){ random_pos(protein); set_n_collisions_to_zero(); rebuild(rob); preprogr_collisions(rob); averagecol+= get_n_collisions(); // printf("numero de colisiones es %d \n", get_n_collisions()); } ChronoTimes(&fin, &aux); tiempo= fin - inicio; averagecol= averagecol / iteraciones; tprep= tiempo - (tpos + trebuild); printf("preprog: %4.4f segundos, %3.2f colisiones\n", tprep, averagecol); restore_conf(initial,njoints); abrevia: /* tlongdistance */ ChronoTimes(&inicio, &aux); conf_in_col=averagecol=0; for (j=0;j<iteraciones;j++){ random_pos(protein); set_n_collisions_to_zero(); rebuild(rob); preprogr_collisions(rob); my_robot_autocollision(rob); if (get_n_collisions()) conf_in_col++; averagecol+= get_n_collisions(); // printf("numero de colisiones es %d \n", get_n_collisions()); } ChronoTimes(&fin, &aux); tiempo= fin - inicio; averagecol= averagecol / iteraciones; tlongdist= tiempo - (tpos + trebuild + tprep); printf("sup: %4.4f segundos, conf. en colision %d, %3.2f colisiones\n", tlongdist,conf_in_col, averagecol); restore_conf(initial,njoints); tcol= tiempo - tpos; usual_averagecol=averagecol; //goto t0; /* tposzig */ ChronoTimes(&inicio, &aux); for (j=0;j<iteraciones;j++){ zigzag_change_pos(protein); } ChronoTimes(&fin, &aux); tposzig= fin - inicio; printf("poszig: %4.4f segundos\n", tposzig); restore_conf(initial,njoints); /* tzig */ ChronoTimes(&inicio, &aux); averagecol=0; for (j=0;j<iteraciones;j++){ zigzag_change_pos(protein); set_n_collisions_to_zero(); rebuild(rob); preprogr_collisions(rob); my_robot_autocollision(rob); averagecol+= get_n_collisions(); } ChronoTimes(&fin, &aux); tiempo= fin - inicio; printf("tiempo total escala pequegna %5.2f\n", tiempo); averagecol= averagecol / iteraciones; tcolzig= tiempo - tposzig; restore_conf(initial,njoints); averagecol0= averagecol; t0: /* t0 */ set_n_collisions_to_zero(); rebuild(rob); preprogr_collisions(rob); my_robot_autocollision(rob); if (get_n_collisions() != averagecol0) printf("\n NO HAY LAS MISMAS COLISIONES!!!\n\n"); printf("colisiones en posicion inicial %d\n", get_n_collisions()); //goto acaba; ChronoTimes(&inicio, &aux); for (j=0;j<iteraciones;j++){ set_n_collisions_to_zero(); //rebuild(rob); preprogr_collisions(rob); my_robot_autocollision(rob); } ChronoTimes(&fin, &aux); tiempo= fin - inicio; printf("tiempo total escala 0: %5.2f\n", tiempo); trebuilt_percent0= (100 *(tcolzig - tiempo ))/ tcolzig; restore_conf(initial,njoints); acaba: //free_robot(rob); printf("bio\n"); printf("%8s %7s %7s %7s %7s %7s %7s %7s %7s %7s\n", "col_conf", "ncol", "tinit", "tpos", "tbuild", "tshort", "tlong", "tcol", "ncol0", "%build0"); printf(" %7d %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.1f %7.2f\n", conf_in_col,usual_averagecol,tinit,tpos,trebuild,tprep,tlongdist,tcol,averagecol0,trebuilt_percent0); /* tiempo surf_distance */ bio_set_col_mode(SURFACE_DISTANCE_BIOCOL_MODE); bio_set_surface_d(0.8); ChronoTimes(&inicio, &aux); conf_in_col=averagecol=0; for (j=0;j<iteraciones;j++){ random_pos(protein); set_n_collisions_to_zero(); rebuild(rob); preprogr_collisions(rob); my_robot_autocollision(rob); if (get_n_collisions()) conf_in_col++; averagecol+= get_n_collisions(); // printf("numero de colisiones es %d \n", get_n_collisions()); } ChronoTimes(&fin, &aux); tiempo= fin - inicio; averagecol= averagecol / iteraciones; printf("SURF_DISTANCE: %4.4f segundos, conf. en colision %d, %3.2f colisiones\n", tiempo - tpos, conf_in_col, averagecol); restore_conf(initial,njoints); /* tiempo minimum_surf_distance */ bio_set_col_mode(MINIMUM_DISTANCE_BIOCOL_MODE); ChronoTimes(&inicio, &aux); conf_in_col=averagecol=0; for (j=0;j<iteraciones;j++){ random_pos(protein); set_n_collisions_to_zero(); set_minimum_Sdistance_to_max(); rebuild(rob); preprogr_collisions(rob); my_robot_autocollision(rob); if (get_n_collisions()) conf_in_col++; averagecol+= get_n_collisions(); // printf("numero de colisiones es %d \n", get_n_collisions()); } ChronoTimes(&fin, &aux); tiempo= fin - inicio; averagecol= averagecol / iteraciones; printf("MINIMUM_DISTANCE: %4.4f segundos, conf. en colision %d, %3.2f colisiones\n", tiempo - tpos, conf_in_col, averagecol); restore_conf(initial,njoints); bio_set_col_mode(NORMAL_BIOCOL_MODE); ChronoOff(); return tpos; }
void grid::setSize( JFLOAT s ) { setXSize( s ); setYSize( s ); rebuild(); }
void CSVDoc::GlobalDebugProfileMenu::profileInserted (const QModelIndex& parent, int start, int end) { rebuild(); }
void grid::setXSize( JFLOAT s ) { _xSize = s; rebuild(); }
void CSVDoc::GlobalDebugProfileMenu::profileChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) { rebuild(); }
void SkScene::rebuild () { if ( !_skeleton ) return; const std::vector<SkJoint*>& joints = _skeleton->joints(); for (size_t i=0; i<joints.size(); i++ ) rebuild ( i ); }
int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, int n_events_, long timeout_) { if (need_rebuild) if (rebuild () == -1) return -1; #if defined ZMQ_POLL_BASED_ON_POLL if (unlikely (poll_size == 0)) { // We'll report an error (timed out) as if the list was non-empty and // no event occured within the specified timeout. Otherwise the caller // needs to check the return value AND the event to avoid using the // nullified event data. errno = ETIMEDOUT; if (timeout_ == 0) return -1; #if defined ZMQ_HAVE_WINDOWS Sleep (timeout_ > 0 ? timeout_ : INFINITE); return -1; #elif defined ZMQ_HAVE_ANDROID usleep (timeout_ * 1000); return -1; #else usleep (timeout_ * 1000); return -1; #endif } zmq::clock_t clock; uint64_t now = 0; uint64_t end = 0; bool first_pass = true; while (true) { // Compute the timeout for the subsequent poll. int timeout; if (first_pass) timeout = 0; else if (timeout_ < 0) timeout = -1; else timeout = end - now; // Wait for events. while (true) { int rc = poll (pollfds, poll_size, timeout); if (rc == -1 && errno == EINTR) { return -1; } errno_assert (rc >= 0); break; } // Receive the signal from pollfd if (use_signaler && pollfds[0].revents & POLLIN) signaler.recv (); // Check for the events. int found = 0; for (items_t::iterator it = items.begin (); it != items.end () && found < n_events_; ++it) { events_[found].socket = NULL; events_[found].fd = 0; events_[found].user_data = NULL; events_[found].events = 0; // The poll item is a 0MQ socket. Retrieve pending events // using the ZMQ_EVENTS socket option. if (it->socket) { size_t events_size = sizeof (uint32_t); uint32_t events; if (it->socket->getsockopt (ZMQ_EVENTS, &events, &events_size) == -1) { return -1; } if (it->events & events) { events_[found].socket = it->socket; events_[found].user_data = it->user_data; events_[found].events = it->events & events; ++found; } } // Else, the poll item is a raw file descriptor, simply convert // the events to zmq_pollitem_t-style format. else { short revents = pollfds [it->pollfd_index].revents; short events = 0; if (revents & POLLIN) events |= ZMQ_POLLIN; if (revents & POLLOUT) events |= ZMQ_POLLOUT; if (revents & POLLPRI) events |= ZMQ_POLLPRI; if (revents & ~(POLLIN | POLLOUT | POLLPRI)) events |= ZMQ_POLLERR; if (events) { events_[found].socket = NULL; events_[found].user_data = it->user_data; events_[found].fd = it->fd; events_[found].events = events; ++found; } } } if (found) { for (int i = found; i < n_events_; ++i) { events_[i].socket = NULL; events_[i].fd = 0; events_[i].user_data = NULL; events_[i].events = 0; } return found; } // If timeout is zero, exit immediately whether there are events or not. if (timeout_ == 0) break; // At this point we are meant to wait for events but there are none. // If timeout is infinite we can just loop until we get some events. if (timeout_ < 0) { if (first_pass) first_pass = false; continue; } // The timeout is finite and there are no events. In the first pass // we get a timestamp of when the polling have begun. (We assume that // first pass have taken negligible time). We also compute the time // when the polling should time out. if (first_pass) { now = clock.now_ms (); end = now + timeout_; if (now == end) break; first_pass = false; continue; } // Find out whether timeout have expired. now = clock.now_ms (); if (now >= end) break; } errno = ETIMEDOUT; return -1; #elif defined ZMQ_POLL_BASED_ON_SELECT if (unlikely (poll_size == 0)) { // We'll report an error (timed out) as if the list was non-empty and // no event occured within the specified timeout. Otherwise the caller // needs to check the return value AND the event to avoid using the // nullified event data. errno = ETIMEDOUT; if (timeout_ == 0) return -1; #if defined ZMQ_HAVE_WINDOWS Sleep (timeout_ > 0 ? timeout_ : INFINITE); return -1; #else usleep (timeout_ * 1000); return -1; #endif } zmq::clock_t clock; uint64_t now = 0; uint64_t end = 0; bool first_pass = true; fd_set inset, outset, errset; while (true) { // Compute the timeout for the subsequent poll. timeval timeout; timeval *ptimeout; if (first_pass) { timeout.tv_sec = 0; timeout.tv_usec = 0; ptimeout = &timeout; } else if (timeout_ < 0) ptimeout = NULL; else { timeout.tv_sec = (long) ((end - now) / 1000); timeout.tv_usec = (long) ((end - now) % 1000 * 1000); ptimeout = &timeout; } // Wait for events. Ignore interrupts if there's infinite timeout. while (true) { memcpy (&inset, &pollset_in, sizeof (fd_set)); memcpy (&outset, &pollset_out, sizeof (fd_set)); memcpy (&errset, &pollset_err, sizeof (fd_set)); #if defined ZMQ_HAVE_WINDOWS int rc = select (0, &inset, &outset, &errset, ptimeout); if (unlikely (rc == SOCKET_ERROR)) { errno = zmq::wsa_error_to_errno (WSAGetLastError ()); wsa_assert (errno == ENOTSOCK); return -1; } #else int rc = select (maxfd + 1, &inset, &outset, &errset, ptimeout); if (unlikely (rc == -1)) { errno_assert (errno == EINTR || errno == EBADF); return -1; } #endif break; } if (use_signaler && FD_ISSET (signaler.get_fd (), &inset)) signaler.recv (); // Check for the events. int found = 0; for (items_t::iterator it = items.begin (); it != items.end () && found < n_events_; ++it) { // The poll item is a 0MQ socket. Retrieve pending events // using the ZMQ_EVENTS socket option. if (it->socket) { size_t events_size = sizeof (uint32_t); uint32_t events; if (it->socket->getsockopt (ZMQ_EVENTS, &events, &events_size) == -1) return -1; if (it->events & events) { events_[found].socket = it->socket; events_[found].user_data = it->user_data; events_[found].events = it->events & events; ++found; } } // Else, the poll item is a raw file descriptor, simply convert // the events to zmq_pollitem_t-style format. else { short events = 0; if (FD_ISSET (it->fd, &inset)) events |= ZMQ_POLLIN; if (FD_ISSET (it->fd, &outset)) events |= ZMQ_POLLOUT; if (FD_ISSET (it->fd, &errset)) events |= ZMQ_POLLERR; if (events) { events_[found].socket = NULL; events_[found].user_data = it->user_data; events_[found].fd = it->fd; events_[found].events = events; ++found; } } } if (found) { // zero-out remaining events for (int i = found; i < n_events_; ++i) { events_[i].socket = NULL; events_[i].fd = 0; events_[i].user_data = NULL; events_[i].events = 0; } return found; } // If timeout is zero, exit immediately whether there are events or not. if (timeout_ == 0) break; // At this point we are meant to wait for events but there are none. // If timeout is infinite we can just loop until we get some events. if (timeout_ < 0) { if (first_pass) first_pass = false; continue; } // The timeout is finite and there are no events. In the first pass // we get a timestamp of when the polling have begun. (We assume that // first pass have taken negligible time). We also compute the time // when the polling should time out. if (first_pass) { now = clock.now_ms (); end = now + timeout_; if (now == end) break; first_pass = false; continue; } // Find out whether timeout have expired. now = clock.now_ms (); if (now >= end) break; } errno = ETIMEDOUT; return -1; #else // Exotic platforms that support neither poll() nor select(). errno = ENOTSUP; return -1; #endif }
/** If the minimum cell size is not set, the default value is the interaction range. @param size is the minimum cell size */ void CellList::setMinimumCellSize(double size) { _min_cell_size = size; rebuild(); }
void StatisticWindow::onUpdatePress() { rebuild(ui->dateEditFrom->date(),ui->dateEditTo->date()); ui->pushButtonExportApplicationsCSV->setEnabled(true); ui->pushButtonExportCategoriesCSV->setEnabled(true); }
void rebuild(std::string const& str) { rebuild(boost::asio::buffer(str)); }
std::shared_ptr<gameplay::Node> Room::createSceneNode(gameplay::Game* game, size_t roomId, const level::Level& level, const std::vector<std::shared_ptr<gameplay::Texture>>& textures, const std::map<loader::TextureLayoutProxy::TextureKey, std::shared_ptr<gameplay::Material>>& materials, const std::map<loader::TextureLayoutProxy::TextureKey, std::shared_ptr<gameplay::Material>>& waterMaterials, const std::vector<std::shared_ptr<gameplay::Model>>& staticMeshes, render::TextureAnimator& animator) { RenderModel renderModel; std::map<TextureLayoutProxy::TextureKey, size_t> texBuffers; std::vector<RenderVertex> vbuf; auto mesh = std::make_shared<gameplay::Mesh>(RenderVertex::getFormat(), vbuf.size(), true); for( const QuadFace& quad : rectangles ) { const TextureLayoutProxy& proxy = level.m_textureProxies.at(quad.proxyId); if( texBuffers.find(proxy.textureKey) == texBuffers.end() ) { texBuffers[proxy.textureKey] = renderModel.m_parts.size(); renderModel.m_parts.emplace_back(); auto it = isWaterRoom() ? waterMaterials.find(proxy.textureKey) : materials.find(proxy.textureKey); Expects(it != (isWaterRoom() ? waterMaterials.end() : materials.end())); renderModel.m_parts.back().material = it->second; } const auto partId = texBuffers[proxy.textureKey]; const auto firstVertex = vbuf.size(); for( int i = 0; i < 4; ++i ) { RenderVertex iv; iv.position = vertices[quad.vertices[i]].position.toRenderSystem(); iv.color = vertices[quad.vertices[i]].color; iv.texcoord0 = proxy.uvCoordinates[i].toGl(); vbuf.push_back(iv); } animator.registerVertex(quad.proxyId, {mesh, partId}, 0, firstVertex + 0); renderModel.m_parts[partId].indices.emplace_back(firstVertex + 0); animator.registerVertex(quad.proxyId, {mesh, partId}, 1, firstVertex + 1); renderModel.m_parts[partId].indices.emplace_back(firstVertex + 1); animator.registerVertex(quad.proxyId, {mesh, partId}, 2, firstVertex + 2); renderModel.m_parts[partId].indices.emplace_back(firstVertex + 2); animator.registerVertex(quad.proxyId, {mesh, partId}, 0, firstVertex + 0); renderModel.m_parts[partId].indices.emplace_back(firstVertex + 0); animator.registerVertex(quad.proxyId, {mesh, partId}, 2, firstVertex + 2); renderModel.m_parts[partId].indices.emplace_back(firstVertex + 2); animator.registerVertex(quad.proxyId, {mesh, partId}, 3, firstVertex + 3); renderModel.m_parts[partId].indices.emplace_back(firstVertex + 3); } for( const Triangle& tri : triangles ) { const TextureLayoutProxy& proxy = level.m_textureProxies.at(tri.proxyId); if( texBuffers.find(proxy.textureKey) == texBuffers.end() ) { texBuffers[proxy.textureKey] = renderModel.m_parts.size(); renderModel.m_parts.emplace_back(); auto it = isWaterRoom() ? waterMaterials.find(proxy.textureKey) : materials.find(proxy.textureKey); Expects(it != (isWaterRoom() ? waterMaterials.end() : materials.end())); renderModel.m_parts.back().material = it->second; } const auto partId = texBuffers[proxy.textureKey]; const auto firstVertex = vbuf.size(); for( int i = 0; i < 3; ++i ) { RenderVertex iv; iv.position = vertices[tri.vertices[i]].position.toRenderSystem(); iv.color = vertices[tri.vertices[i]].color; iv.texcoord0 = proxy.uvCoordinates[i].toGl(); vbuf.push_back(iv); } animator.registerVertex(tri.proxyId, {mesh, partId}, 0, firstVertex + 0); renderModel.m_parts[partId].indices.emplace_back(firstVertex + 0); animator.registerVertex(tri.proxyId, {mesh, partId}, 1, firstVertex + 1); renderModel.m_parts[partId].indices.emplace_back(firstVertex + 1); animator.registerVertex(tri.proxyId, {mesh, partId}, 2, firstVertex + 2); renderModel.m_parts[partId].indices.emplace_back(firstVertex + 2); } mesh->rebuild(reinterpret_cast<float*>(vbuf.data()), vbuf.size()); auto resModel = renderModel.toModel(mesh); node = std::make_shared<gameplay::Node>("Room:" + boost::lexical_cast<std::string>(roomId)); node->setDrawable(resModel); for( Light& light : lights ) { const auto f = std::abs(light.specularIntensity) / 8191.0f; BOOST_ASSERT(f >= 0 && f <= 1); switch( light.getLightType() ) { case LightType::Shadow: BOOST_LOG_TRIVIAL(debug) << "Light: Shadow"; light.node = gameplay::Light::createPoint(light.color.r / 255.0f * f, light.color.g / 255.0f * f, light.color.b / 255.0f * f, light.specularFade); break; case LightType::Null: case LightType::Point: BOOST_LOG_TRIVIAL(debug) << "Light: Null/Point"; light.node = gameplay::Light::createPoint(light.color.r / 255.0f * f, light.color.g / 255.0f * f, light.color.b / 255.0f * f, light.specularFade); break; case LightType::Spotlight: BOOST_LOG_TRIVIAL(debug) << "Light: Spot"; light.node = gameplay::Light::createSpot(light.color.r / 255.0f * f, light.color.g / 255.0f * f, light.color.b / 255.0f * f, light.specularFade, light.r_inner, light.r_outer); break; case LightType::Sun: BOOST_LOG_TRIVIAL(debug) << "Light: Sun"; light.node = gameplay::Light::createDirectional(light.color.r / 255.0f * f, light.color.g / 255.0f * f, light.color.b / 255.0f * f); break; } BOOST_LOG_TRIVIAL(debug) << " - Position: " << light.position.X << "/" << light.position.Y << "/" << light.position.Z; BOOST_LOG_TRIVIAL(debug) << " - Length: " << light.length; BOOST_LOG_TRIVIAL(debug) << " - Color: " << light.color.a / 255.0f << "/" << light.color.r / 255.0f << "/" << light.color.g / 255.0f << "/" << light.color.b / 255.0f; BOOST_LOG_TRIVIAL(debug) << " - Specular Fade: " << light.specularFade; BOOST_LOG_TRIVIAL(debug) << " - Specular Intensity: " << light.specularIntensity; BOOST_LOG_TRIVIAL(debug) << " - Inner: " << light.r_inner; BOOST_LOG_TRIVIAL(debug) << " - Outer: " << light.r_outer; BOOST_LOG_TRIVIAL(debug) << " - Intensity: " << light.intensity; } for( const RoomStaticMesh& sm : this->staticMeshes ) { auto idx = level.findStaticMeshIndexById(sm.meshId); BOOST_ASSERT(idx >= 0); BOOST_ASSERT(static_cast<size_t>(idx) < staticMeshes.size()); auto subNode = std::make_shared<gameplay::Node>(""); subNode->setDrawable(staticMeshes[idx]); subNode->setLocalMatrix(glm::translate(glm::mat4{1.0f}, (sm.position - position).toRenderSystem()) * glm::rotate(glm::mat4{1.0f}, util::auToRad(sm.rotation), glm::vec3{0,-1,0})); node->addChild(subNode); } node->setLocalMatrix(glm::translate(glm::mat4{1.0f}, position.toRenderSystem())); for( const Sprite& sprite : sprites ) { BOOST_ASSERT(sprite.vertex < vertices.size()); BOOST_ASSERT(sprite.texture < level.m_spriteTextures.size()); const SpriteTexture& tex = level.m_spriteTextures[sprite.texture]; auto spriteNode = std::make_shared<gameplay::Sprite>(game, textures[tex.texture], tex.right_side - tex.left_side + 1, tex.bottom_side - tex.top_side + 1, tex.buildSourceRectangle()); spriteNode->setBlendMode(gameplay::Sprite::BLEND_ADDITIVE); auto n = std::make_shared<gameplay::Node>(""); n->setDrawable(spriteNode); n->setLocalMatrix(glm::translate(glm::mat4{1.0f}, (vertices[sprite.vertex].position - core::TRCoordinates{0, tex.bottom_side / 2, 0}).toRenderSystem())); node->addChild(n); } // resultNode->addShadowVolumeSceneNode(); return node; }
// Set comparison function and resort heap void CbcTreeArray::setComparison(CbcCompareBase &compare) { comparison_.test_ = &compare; rebuild() ; }
void GeoManager::init() { geo6.reset(new GeoIP(getDbPath(true))); geo4.reset(new GeoIP(getDbPath(false))); rebuild(); }
static int alsa_run(cubeb * ctx) { int r; int timeout; int i; char dummy; cubeb_stream * stm; enum stream_state state; pthread_mutex_lock(&ctx->mutex); if (ctx->rebuild) { rebuild(ctx); } /* Wake up at least once per second for the watchdog. */ timeout = 1000; for (i = 0; i < CUBEB_STREAM_MAX; ++i) { stm = ctx->streams[i]; if (stm && stm->state == DRAINING) { r = ms_until(&stm->drain_timeout); if (r >= 0 && timeout > r) { timeout = r; } } } pthread_mutex_unlock(&ctx->mutex); r = poll(ctx->fds, ctx->nfds, timeout); pthread_mutex_lock(&ctx->mutex); if (r > 0) { if (ctx->fds[0].revents & POLLIN) { if (read(ctx->control_fd_read, &dummy, 1) < 0) { /* ignore read error */ } if (ctx->shutdown) { pthread_mutex_unlock(&ctx->mutex); return -1; } } for (i = 0; i < CUBEB_STREAM_MAX; ++i) { stm = ctx->streams[i]; if (stm && stm->state == RUNNING && stm->fds && any_revents(stm->fds, stm->nfds)) { alsa_set_stream_state(stm, PROCESSING); pthread_mutex_unlock(&ctx->mutex); state = alsa_refill_stream(stm); pthread_mutex_lock(&ctx->mutex); alsa_set_stream_state(stm, state); } } } else if (r == 0) { for (i = 0; i < CUBEB_STREAM_MAX; ++i) { stm = ctx->streams[i]; if (stm) { if (stm->state == DRAINING && ms_since(&stm->drain_timeout) >= 0) { alsa_set_stream_state(stm, INACTIVE); stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_DRAINED); } else if (stm->state == RUNNING && ms_since(&stm->last_activity) > CUBEB_WATCHDOG_MS) { alsa_set_stream_state(stm, ERROR); stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_ERROR); } } } } pthread_mutex_unlock(&ctx->mutex); return 0; }
void grid::setColour( math::colour4 colour ) { _colour = colour; rebuild(); }
//------------------------------------------------------------------------------ static void #if GLFW_VERSION_MAJOR>=3 keyboard(GLFWwindow *, int key, int scancode, int event, int mods) { #else #define GLFW_KEY_ESCAPE GLFW_KEY_ESC keyboard(int key, int event) { #endif if (event == GLFW_RELEASE) return; if (g_hud.KeyDown(tolower(key))) return; switch (key) { case 'Q': g_running = 0; break; case 'F': fitFrame(); break; case '+': case '=': g_tessLevel++; break; case '-': g_tessLevel = std::max(g_tessLevelMin, g_tessLevel-1); break; case '.': g_moveModels = std::max(g_moveModels*2, 1); break; case ',': g_moveModels = std::max(g_moveModels/2, 0); break; case 'I': g_modelCount = std::max(g_modelCount/2, 1); rebuild(); break; case 'O': g_modelCount = std::min(g_modelCount*2, MAX_MODELS); rebuild(); break; case GLFW_KEY_ESCAPE: g_hud.SetVisible(!g_hud.IsVisible()); break; } } //------------------------------------------------------------------------------ static void callbackDisplayStyle(int b) { if (g_displayStyle == kVaryingColor or b == kVaryingColor or g_displayStyle == kFaceVaryingColor or b == kFaceVaryingColor) { // need to rebuild for varying reconstruct g_displayStyle = b; rebuild(); return; } g_displayStyle = b; } static void callbackKernel(int k) { g_kernel = k; #ifdef OPENSUBDIV_HAS_OPENCL if (g_kernel == kCL and g_clContext == NULL) { if (initCL(&g_clContext, &g_clQueue) == false) { printf("Error in initializing OpenCL\n"); exit(1); } } #endif #ifdef OPENSUBDIV_HAS_CUDA if (g_kernel == kCUDA and g_cudaInitialized == false) { g_cudaInitialized = true; cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() ); } #endif rebuild(); }
void Menger::setRadius(float newRadius) { cubeRadius = newRadius; rebuild(); }