예제 #1
0
void CollisionComponentManager::findCollisions(HitEventQueue& hitQueue) {
	compactArray();

	// TODO: Less brute-force approach.
	// TODO: Support shapes other than aligned boxes
	HitEvent hit;
	for(int ci0 = 0; ci0 < int(nComponents()); ++ci0) {
		CollisionComponent& c0 = _components[ci0];
		if(!c0.entity().isEnabledRec() || !c0.isEnabled()
		|| !c0.shape() || c0.shape()->type() != SHAPE_ALIGNED_BOX)
			continue;
		hit.entities[0] = c0.entity();

		for(int ci1 = ci0 + 1; ci1 < int(nComponents()); ++ci1) {
			CollisionComponent& c1 = _components[ci1];

			if(!c1.entity().isEnabledRec() || !c1.isEnabled()
			|| !c1.shape() || c1.shape()->type() != SHAPE_ALIGNED_BOX
			|| (c0.hitMask() & c1.hitMask())    == 0
			|| (c0.hitMask() & c1.ignoreMask()) != 0
			|| (c1.hitMask() & c0.ignoreMask()) != 0)
				continue;
			hit.entities[1] = c1.entity();

			hit.boxes[0] = c0.worldAlignedBox();
			hit.boxes[1] = c1.worldAlignedBox();

			if(!hit.boxes[0].intersection(hit.boxes[1]).isEmpty())
				hitQueue.push_back(hit);
		}
	}
}
예제 #2
0
void TileLayerComponentManager::render(EntityRef entity, float interp, const OrthographicCamera& camera) {
	compactArray();

	_states.shader = _spriteRenderer->shader().shader;
	_states.buffer = _spriteRenderer->buffer();
	_states.format = _spriteRenderer->format();

	_render(entity, interp, camera);
}
예제 #3
0
void BitmapTextComponentManager::render(EntityRef entity, float interp, const OrthographicCamera& camera) {
	compactArray();

	_states.shader = _spriteRenderer->shader().shader;
	_states.buffer = _spriteRenderer->buffer();
	_states.format = _spriteRenderer->format();
	_states.textureFlags = Texture::BILINEAR_NO_MIPMAP | Texture::CLAMP;
	_states.blendingMode = BLEND_ALPHA;

	_render(entity, interp, camera);
}
예제 #4
0
파일: ejsArray.c 프로젝트: leemit/ejscript
PUBLIC int ejsRemoveItemAtPos(Ejs *ejs, EjsArray *ap, int index, int compact)
{
    int     rc;

    assert(ap);

    if (ap->length <= 0) {
        return MPR_ERR_CANT_FIND;
    }
    rc = deleteArrayProperty(ejs, ap, index);
    if (compact) {
        compactArray(ejs, ap, 0, NULL);
    }
    return rc;
}
예제 #5
0
파일: ejsArray.c 프로젝트: leemit/ejscript
PUBLIC int ejsRemoveItem(Ejs *ejs, EjsArray *ap, EjsAny *item, int compact)
{
    int     i;

    for (i = 0; i < ap->length; i++) {
        if (ap->data[i] == item) {
            deleteArrayProperty(ejs, ap, i);
            if (compact) {
                compactArray(ejs, ap, 0, NULL);
            }
            return i;
        }
    }
    return MPR_ERR_CANT_FIND;
}