Beispiel #1
0
static void
winInsert(rdWin *w, int which, ulong p, char *str)
{
	rdItem *i;
	int l;

	assert(w);
	assert(str);
	l = strlen(str);
	if (which == IsTag) {
		w->taglen += l;
		return;
	}
	if (w->wintype == rdArticle) {
		w->bodylen += l;
		return;
	}
	for (i = w->items; i; i = i->next)
		if (i->p0 <= p && p <= i->p1)
			break;
	if (!i)
		return;
	i->p1 += l;
	for (i = i->next; i; i = i->next) {
		i->p0 += l;
		i->p1 += l;
	}
	updateBody(w, p, (ulong)l, str);
	return;
}
Beispiel #2
0
static void
winDelete(rdWin *w, int which, ulong p0, ulong p1)
{
	rdItem *i;
	ulong l = p1 - p0;

	assert(w);
	assert(p0 <= p1);
	if (which == IsTag) {
		w->taglen -= l;
		return;
	}
	if (w->wintype == rdArticle) {
		w->bodylen -= l;
		return;
	}
	for (i = w->items; i; i = i->next)
		if (i->p0 <= p0 && p1 <= i->p1)
			break;
	if (!i)
		return;
	i->p1 -= l;
	for (i = i->next; i; i = i->next) {
		i->p0 -= l;
		i->p1 -= l;
	}
	updateBody(w, p0, p1, (char *)0);
	return;
}
Beispiel #3
0
//Move left
void Snake::left()
{
	//Allows no 180 degree turn
	if(dir == RIGHT)
		return;
	Cell &header = cells.at(0);
	//Updates body and set new coordinates of header
	updateBody();
	header.setCoords(header.getX()-1, header.getY());
	dir = LEFT;
}
Beispiel #4
0
//Move down
void Snake::down()
{
	//Allows no 180 degree turn
	if(dir == UP)
		return;
	Cell &header = cells.at(0);
	//Updates body and set new coordinates of header
	updateBody();
	header.setCoords(header.getX(), header.getY()+1);
	dir = DOWN;
}
Beispiel #5
0
// Update Data
void Kinect::update()
{
    // Update Color
    updateColor();

    // Update Body
    updateBody();

    // Update Face
    updateFace();

    // Update Recognition
    updateRecognition();
}
Beispiel #6
0
void Player::update(bool aim, int xMouse, int yMouse, const Uint8 *keyState, Food *food)
{
	float xHead = 0;
	float yHead = 0;
	_head.getPos(&xHead, &yHead);
	
	updateBody(xHead, yHead);
	_head.update(aim, xMouse, yMouse, keyState);
	
	int eat = checkFood(food);
	if(eat){
		BodyPart bodyPart(xHead, yHead);
		_bodyParts.push_back(bodyPart);
	}
}
Beispiel #7
0
void KinectPlugin::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {

    if (!_enabled) {
        return;
    }

    updateBody(); // updates _joints

    std::vector<KinectJoint> joints = _joints;

    auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
    userInputMapper->withLock([&, this]() {
        _inputDevice->update(deltaTime, inputCalibrationData, joints, _prevJoints);
    });

    _prevJoints = joints;
}
void CentipedeSegment::update(GLfloat tpf)
{
	if (previous != nullptr && previous->isAlive == GL_FALSE) type = HEAD;

	if (type != HEAD) {
		updateBody(tpf);
		return;
	}

	GLfloat movement = CENTIPEDE_SPEED * tpf;
	switch (direction)
	{
		case LEFT:
			Position.x1 -= movement;
			if (Position.x1 < 0) updateDirection();
			break;
		case RIGHT:
			Position.x1 += movement;
			if (Position.x1 > FIELDSIZE - CENTISEGMENT_WIDTH) updateDirection();
			break;
		case UP:
			Position.y1 -= movement;
			if (getCenter().y < FIELDSIZE - AREA && (GLuint)Position.y1 != (GLuint)AABB.y1) updateDirection();
			break;
		case DOWN:
			Position.y1 += movement;
			if (getCenter().y > 1 && (GLuint)Position.y1 + CENTISEGMENT_HEIGHT != (GLuint)AABB.y2) updateDirection();
		default:
			break;
	}

	Position.x2 = Position.x1 + CENTISEGMENT_WIDTH;
	Position.y2 = Position.y1 + CENTISEGMENT_HEIGHT;

	AABB = Position;
}
void WordUpdateStyles(WordConverter *converter, CSSSheet *styleSheet)
{
    CSSStyle *paraDefault = CSSSheetDefaultStyleForFamily(styleSheet,StyleFamilyParagraph);
    if (CSSGet(CSSStyleRule(paraDefault),"margin-top") == NULL)
        CSSPut(CSSStyleRule(paraDefault),"margin-top","-word-auto");

    if (CSSGet(CSSStyleRule(paraDefault),"margin-bottom") == NULL)
        CSSPut(CSSStyleRule(paraDefault),"margin-bottom","-word-auto");

    if (converter->package->styles == NULL) // FIXME: create this document
        return;;
    DFNode *root = converter->package->styles->root;
    if ((root == NULL) || (root->tag != WORD_STYLES))
        return;;

    DFHashTable *remainingSelectors = DFHashTableNew(NULL,NULL); // Used as a set
    const char **allSelectors = CSSSheetCopySelectors(styleSheet);
    for (int i = 0; allSelectors[i]; i++) {
        const char *selector = allSelectors[i];
        DFHashTableAdd(remainingSelectors,selector,"");
    }
    free(allSelectors);

    WordSheet *sheet = converter->styles;
    DFHashTable *oldConcreteNumIds = WordSheetFindUsedConcreteNumIds(sheet);
    updateNumbering(converter,styleSheet);

    // Update or remove existing styles
    const char **allIdents = WordSheetCopyIdents(sheet);
    for (int i = 0; allIdents[i]; i++) {
        WordStyle *wordStyle = WordSheetStyleForIdent(sheet,allIdents[i]);
        DFNode *element = wordStyle->element;

        if (WordStyleIsProtected(wordStyle)) {
            DFHashTableRemove(remainingSelectors,wordStyle->selector);
            continue;
        }

        if (!DFStringEquals(wordStyle->type,"paragraph") &&
            !DFStringEquals(wordStyle->type,"character") &&
            !DFStringEquals(wordStyle->type,"table"))
            continue;

        CSSStyle *cssStyle = CSSSheetLookupSelector(styleSheet,wordStyle->selector,0,0);
        if (cssStyle == NULL) {
            // Remove style
            WordSheetRemoveStyle(sheet,wordStyle);
            continue;
        }

        // Update style
        WordPutStyle(element,cssStyle,converter);
        updateDefault(cssStyle,element,styleSheet,converter);
        DFHashTableRemove(remainingSelectors,wordStyle->selector);
    }
    free(allIdents);

    // Sort the list of new styles, so that test output is deterministic
    const char **sortedSelectors = DFHashTableCopyKeys(remainingSelectors);
    DFSortStringsCaseInsensitive(sortedSelectors);

    // Add new styles. We do this in two stages - first creating the styles, and then setting their properties.
    // This is because the second stage depends on referenced styles (e.g. based on and next) to be already
    // present.
    for (int selIndex = 0; sortedSelectors[selIndex]; selIndex++) {
        const char *selector = sortedSelectors[selIndex];
        CSSStyle *style = CSSSheetLookupSelector(styleSheet,selector,0,0);
        const char *familyStr = NULL;

        StyleFamily family = WordStyleFamilyForSelector(selector);
        if (family == StyleFamilyParagraph)
            familyStr = "paragraph";
        else if (family == StyleFamilyCharacter)
            familyStr = "character";
        else if (family == StyleFamilyTable)
            familyStr = "table";
        else
            continue;

        char *styleId = WordStyleIdForStyle(style);
        char *name = WordStyleNameForStyle(style);
        if (name == NULL)
            name = xstrdup(styleId);;
        WordStyle *wordStyle = WordSheetAddStyle(sheet,familyStr,styleId,name,selector);
        DFCreateChildElement(wordStyle->element,WORD_QFORMAT);
        free(styleId);
        free(name);
    }

    for (int selIndex = 0; sortedSelectors[selIndex]; selIndex++) {
        const char *selector = sortedSelectors[selIndex];
        StyleFamily family = WordStyleFamilyForSelector(selector);
        if ((family != StyleFamilyParagraph) &&
            (family != StyleFamilyCharacter) &&
            (family != StyleFamilyTable))
            continue;

        CSSStyle *style = CSSSheetLookupSelector(styleSheet,selector,0,0);
        WordStyle *wordStyle = WordSheetStyleForSelector(converter->styles,selector);
        assert(wordStyle != NULL);

        CSSStyleAddDefaultHTMLProperties(style);
        // FIXME: language
        // FIXME: not covered by tests
        if ((style->headingLevel >= 1) && (style->headingLevel <= 6))
            CSSStyleSetNext(style,"p.Normal");

        WordPutStyle(wordStyle->element,style,converter);
        updateDefault(style,wordStyle->element,styleSheet,converter);
    }
    free(sortedSelectors);

    // Update body style (document defaults)
    updateDefaults(converter,styleSheet);

    updateBody(converter,styleSheet);

    DFHashTable *newConcreteNumIds = WordSheetFindUsedConcreteNumIds(sheet);
    const char **oldKeys = DFHashTableCopyKeys(oldConcreteNumIds);
    for (int oldIndex = 0; oldKeys[oldIndex]; oldIndex++) {
        const char *numId = oldKeys[oldIndex];
        if (DFHashTableLookup(newConcreteNumIds,numId) == NULL) {
            WordConcreteNum *concreteNum = WordNumberingConcreteWithId(converter->numbering,numId);
            if (concreteNum != NULL)
                WordNumberingRemoveConcrete(converter->numbering,concreteNum);
        }
    }
    free(oldKeys);
    DFHashTableRelease(remainingSelectors);
    DFHashTableRelease(oldConcreteNumIds);
    DFHashTableRelease(newConcreteNumIds);
}
Beispiel #10
0
//-------------------------------------------------------------------------------------
void EntityComplex::addTime(Real deltaTime)
{
	if(mBodyNode)
	{
		if(mCamera)
			updateBody(deltaTime);

		updateAnimations(deltaTime);
	}

	Ogre::Vector3 currpos;

	if(mCamera)
	{
		currpos = getPosition();
		updateCamera(deltaTime);
	}
	else
	{
		currpos = getLastPosition();
		if(kbe_playerID() != mID)
		{
			Ogre::Vector3 movement = destPos_ - currpos;
			float speed = mMoveSpeed * deltaTime;

			movement.y = 0.f;

			Real mlen = movement.length();

			if(mlen < speed || (mBaseAnimID != ANIM_RUN_BASE && mlen <= 1.0f))
			{
				if (mBaseAnimID == ANIM_RUN_BASE)
				{
					float y = currpos.y;
					currpos = destPos_;
					currpos.y = y;

					setBaseAnimation(ANIM_IDLE_BASE);
					if (mTopAnimID == ANIM_RUN_TOP) 
						setTopAnimation(ANIM_IDLE_TOP);
				}
			}
			else
			{
				movement.normalise();

				// 移动位置
				movement *= speed;
				currpos += movement;
				
				if (mBaseAnimID == ANIM_IDLE_BASE) 
				{
					setBaseAnimation(ANIM_RUN_BASE, true);
					if (mTopAnimID == ANIM_IDLE_TOP) 
					{
						setTopAnimation(ANIM_RUN_TOP, true);
					}
				}
			}
		}
	}

	setPosition(currpos.x, currpos.y, currpos.z);
	KBEntity::addTime(deltaTime);

	if(pWeaponTrailLeft_)
		pWeaponTrailLeft_->onUpdate(deltaTime);

	if(pWeaponTrailRight_)
		pWeaponTrailRight_->onUpdate(deltaTime);
}
Beispiel #11
0
PhysicalBodyConvexHull::PhysicalBodyConvexHull(Vertex* vertices, unsigned int vertexCount, btScalar mass)
: PhysicalBody(mass),
_vertices(vertices), _vertexCount(vertexCount), _verticesvec(0)
{
    updateBody();
}
Beispiel #12
0
int main(void) {
  // Setup window and give pointer
  GLFWwindow* window = windowSetup();

  // Create objects
  render renderMain;
  shared sharedMain;

  // Create access pointers
  render* renderAP = &renderMain;
  shared* sharedAP = &sharedMain;

  setupDefaultScenario(renderAP, sharedAP);

  setupGUI(window, renderAP);

  // Create simulation thread
  std::thread simThread(startup, sharedAP);

  // Main Runtime Loop
  while(!glfwWindowShouldClose(window)) {
    // Clear screen before drawing
    glClear(GL_COLOR_BUFFER_BIT);

    sharedAP->updateControl(renderAP->getControl());

    if(renderAP->getPaused()) {
      updateBody(renderAP); // Update body storage from interface
      // Send update to shared
      sharedAP->updateBodies(renderAP->getBodies());
    } else {
      updateUI(renderAP); // Update interface from body store
      // Get update from shared
      renderAP->updateBodies(sharedAP->getBodies());
    }

    // Wake sim thread
    sharedAP->simWait.notify_all();

    // Render scene
    renderAP->drawScene();

    // Apply camera transform and scale
    applyCamera();

    // Draw GUI
    TwDraw();

    // Display is double buffered to prevent screen tearing
    // Swap display buffers
    glfwSwapBuffers(window);
    // Poll and process events
    glfwPollEvents();
  }

  // Unpause and Exit, direct to shared
  sharedAP->setPaused(0);
  sharedAP->setExit(1);

  // Repeat sim wait notify until exit is acknowleged, directly check shared
  while(sharedAP->getExit()) {
    sharedAP->simWait.notify_all();
  }

  // Program exit
  simThread.join();

  // Terminate Libraries
  glfwDestroyWindow(window);
  glfwTerminate();

  #ifdef EXITNOTE
    std::cerr << "Main Exit" << std::endl;
  #endif

  return 0;
}