Ejemplo n.º 1
0
void ViewportView::drawBackground(QPainter* painter, const QRectF& rect)
{
    QGraphicsView::drawBackground(painter, rect);

    painter->beginNativePainting();
    if (!gl_initialized)
    {
        initializeOpenGLFunctions();
        gl_initialized = true;
    }
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Get bounds from all child images
    float zmin = INFINITY;
    float zmax = -INFINITY;
    auto m = getMatrix();
    emit(getDepth(m, &zmin, &zmax));

    // Paint all images
    emit(paintImage(m, zmin, zmax));

    painter->endNativePainting();
}
Ejemplo n.º 2
0
GameObj* GOBox::shoot()
{
	if (getIsWeapon())
	{
		Weapon* w = getWeapon();

		if (getIsRangedWeapon()){
			
			if (((RangedWeapon *)w)->readyToShoot())
			{
				double rbDepth = getDepth() / 2 + ((RangedWeapon *)w)->getPDepth()/1.5 + 0.6f;
				btTransform* rbTrans = &getRigidBody()->getWorldTransform();
				btVector3 boxRot = rbTrans->getBasis()[2];
				boxRot.normalize();
				btVector3 correctedDisplacement = boxRot * -rbDepth; // /2
				double x = rbTrans->getOrigin().getX();// + 0.5 - w->getPWidth();
				double y = rbTrans->getOrigin().getY();
				double z = rbTrans->getOrigin().getZ() + correctedDisplacement.getZ();

				GameObj* proj = new Projectile(x, y, z, rbTrans->getRotation().getX(), rbTrans->getRotation().getY(), rbTrans->getRotation().getZ(), rbTrans->getRotation().getW(),
					((RangedWeapon *)w)->getPMass(), ((RangedWeapon *)w)->getPWidth(), ((RangedWeapon *)w)->getPHeight(), ((RangedWeapon *)w)->getPDepth());
				proj->setDamage(w->getDamage());
				//std::cout << "shoot: " << ((RangedWeapon *)w)->getPBlockType() << std::endl;
				proj->setBlockType(((RangedWeapon *)w)->getPBlockType());
				((RangedWeapon *)w)->setLastShot();
				((Projectile*)proj)->initForce = ((RangedWeapon *)w)->getPInitForce();


				return proj;
			}

		}

	}
	return nullptr;
}
bool CollisionManager::ball_vs_wall(Ball *object1, Walls *object2)
{
	// set radians
	float radians;
	radians = -(object2->getOrientation()) * (float)RADIANS;

	// calculate the distance between circle and the wall
	math::Vector2D distance;
	distance = object2->getCentrePoints() - object1->getPosition();

	float distanceX = (distance.getX() * cosf(radians)) + (distance.getY() * -sinf(radians));
	float distanceY = (distance.getX() * sinf(radians)) + (distance.getY() * cosf(radians));

	distance.setX(distanceX);
	distance.setY(distanceY);

	// set the clamps
	math::Vector2D clamps = object2->getHalfExtents();

	if (distance.getX() >= 0)
	{
		clamps.setX(std::min(distance.getX(), object2->getHalfExtents().getX()));
	}
	if (distance.getX() < 0)
	{
		clamps.setX(std::max(distance.getX(), -object2->getHalfExtents().getX()));
	}
	if (distance.getY() >= 0)
	{
		clamps.setY(std::min(distance.getY(), object2->getHalfExtents().getY()));
	}
	if (distance.getY() < 0)
	{
		clamps.setY(std::max(distance.getY(), -object2->getHalfExtents().getY()));
	}

	// total distance and magnitude
	distance = distance - clamps;

	float totalDistance;
	totalDistance = distance.magnitude();
	totalDistance = totalDistance - object1->getRadius();

	if (totalDistance < 0)
	{
		float magnitude = distance.magnitude();
		if (magnitude == 0)
		{
			magnitude = 0.01f;
		}

		setDepth(totalDistance);
		setSlop(0.01f);
		setPercentCorrection(0.2f);
		setElasticity(1.f);

		float normalX = ((distance.getX() / magnitude) * cosf(radians)) + ((distance.getY() / magnitude) * sinf(radians));
		float normalY = ((distance.getX() / magnitude) * (-sinf(radians))) + ((distance.getY() / magnitude) * cosf(radians));
		m_normal.setX(normalX);
		m_normal.setY(normalY);

		// impulse resolution
		math::Vector2D relativeVel;
		relativeVel = object1->getVelocity() - object2->getVelocity();

		float relativeVelocity;
		relativeVelocity = relativeVel.dotProduct(m_normal);
		if (relativeVelocity < 0)
		{
			collision = false;
			return false;
		}

		float e = std::min(object1->getElasticity(), object2->getElasticity());
		float j = ((-(1.0f + e) * relativeVelocity) / object1->getInverseMass());
		object1->setVelocity(object1->getVelocity() + (m_normal * (j * object1->getInverseMass())));
		//object2->setVelocity(object2->getVelocity() - ((m_normal * j) * object2->getInverseMass()));


		if (object1->getMass() == 0)
		{
			object1->m_inverseMass = 0;
		}
		else
		{
			object1->getInverseMass();
		}

		// position correction
		math::Vector2D posCorrection;
		posCorrection = m_normal * (std::max((getDepth() - getSlop()), 0.0f) / (object1->getInverseMass() + object2->getInverseMass()) * getPercentCorrection());
		object1->setPosition(object1->getPosition() + posCorrection);

		collision = true;
		return true;
	}
	else
	{
		collision = false;
		return false;
	}
}
Ejemplo n.º 4
0
 IloNum evaluate() const {
    return -getDepth();
 }
Ejemplo n.º 5
0
	/** 
	 * Set width of the valarray.
	 * 
	 * The depth of the ring buffer remains constant.
	 *
	 * @param _width Width of valarrays in number of elements.  If
	 * the specified width is less than the minimum width, this
	 * function does nothing.
	 */	
	void setWidth(unsigned int _width)
	{
	    setSize(_width, getDepth());
	}
Ejemplo n.º 6
0
Archivo: clause.cpp Proyecto: ombt/ombt
// rename variables in clause
int
Clause::renameVariables()
{
	Clause newcl;
	Map<String, String> nvs;

	// rename variables in positive clause
	BinaryTree_AVL_Iterator_InOrder<Literal> pclIter(positiveClause);
	for ( ; !pclIter.done(); pclIter++)
	{
		Literal literal(pclIter());
		if (literal.renameVariables(nvs) != OK)
		{
			ERROR("renameVariables failed.", errno);
			return(NOTOK);
		}
		if (newcl.insert(literal) != OK)
		{
			ERROR("insert failed.", errno);
			return(NOTOK);
		}
	}

	// rename variables in negative clause
	BinaryTree_AVL_Iterator_InOrder<Literal> nclIter(negativeClause);
	for ( ; !nclIter.done(); nclIter++)
	{
		Literal literal(nclIter());
		if (literal.renameVariables(nvs) != OK)
		{
			ERROR("renameVariables failed.", errno);
			return(NOTOK);
		}
		if (newcl.insert(literal) != OK)
		{
			ERROR("insert failed.", errno);
			return(NOTOK);
		}
	}

	// rename variables in answers clause
	ListIterator<Literal> ansIter(answers);
	for ( ; !ansIter.done(); ansIter++)
	{
		Literal literal(ansIter());
		if (literal.renameVariables(nvs) != OK)
		{
			ERROR("renameVariables failed.", errno);
			return(NOTOK);
		}
		if (newcl.insertAnswer(literal) != OK)
		{
			ERROR("insert failed.", errno);
			return(NOTOK);
		}
	}

#if 0
	// update table of renamed variables
	if (updateVariableNames(nvs) != OK)
		return(NOTOK);
#endif

	// overwrite existing clauses
	newcl.setDepth(getDepth());
	newcl.setNumber(getNumber());
	newcl.setConclusion(getConclusion());
	newcl.setQuery(getQuery());
	newcl.setSOS(getSOS());
	*this = newcl;

	// all done
	return(OK);
}
Ejemplo n.º 7
0
//--------------------------------------------------------------
void ofBoxPrimitive::setDepth( float a_depth ) {
    size.z = a_depth;
    set( getWidth(), getHeight(), getDepth() );
}
Ejemplo n.º 8
0
bool
FBOvgGlue::init(int argc, char **argv[])
{
    // GNASH_REPORT_FUNCTION;

#if 0
    bool egl = false;
    bool rawfb = false;
    bool dfb = false;
    bool x11 = false;
    // Probe to see what display devices we have that could be used.
    boost::shared_array<renderer::GnashDevice::dtype_t> devs = probeDevices();
    if (devs) {
        int i = 0;
        while (devs[i] != renderer::GnashDevice::NODEV) {
            switch (devs[i++]) {
              case renderer::GnashDevice::EGL:
                  log_debug(_("Probing found an EGL display device"));
                  egl = true;
                  break;
              case renderer::GnashDevice::RAWFB:
                  log_debug(_("Probing found a raw Framebuffer display device"));
                  rawfb = true;
                  break;
              case renderer::GnashDevice::X11:
                  log_debug(_("Probing found an X11 display device"));
                  x11 = true;
                  break;
              case renderer::GnashDevice::DIRECTFB:
                  log_debug(_("Probing found a DirectFB display device"));
                  dfb = true;
                  break;
              case renderer::GnashDevice::NODEV:
              default:
                  log_error(_("No display devices found by probing!"));
                  break;
            }
        }

    }
    
    // Now that we know what exists, we have to decide which one to
    // use, as OpenVG can work with anything. We can only have one
    // display device operating at a time.
    if (egl) {
        setDevice(renderer::GnashDevice::EGL);
    } else {
        // OpenVG requires EGL, so if we don't have it, Gnash won't run
        log_error("OpenVG needs EGL to work!");
        return false;
    }
#endif

    _device.reset(new renderer::EGLDevice(argc, *argv));

    // Initialize the display device
    // EGL still reqires us to open the framebuffer
    _device->bindClient(renderer::GnashDevice::OPENVG);
    
    _display.initDevice(0, 0);

    _width = getWidth();
    _height = getHeight();

    // Some linux distros like ltib have more information available
    // about the framebuffer
    int fd = ::open("/sys/class/graphics/fb0/stride", O_RDONLY);
    char number[10];
    if (::read(fd, &number, 10)) {
        _stride = strtol(number, NULL, 0);
    } else {
        if (getDepth() == 32) {
            _stride = _width * 4;
        } else {
            _stride = _width * 2;
        }
    }
    close(fd);
    
    // You must pass in the file descriptor to the opened
    // framebuffer when creating a window. Under X11, this is
    // actually the XID of the created window.
    return _device->attachWindow(_display.getHandle());
}
Ejemplo n.º 9
0
 /**
  * @brief Member function <b>popLineMask</b> removes the top line mask only if
  * it is not the last one of the current depth.
  *
  * @return      a <b>LineMaskStack</b> reference to the depth stack.
  */
 LineMaskStack &popLineMask() {
   if (size() > 1 && getNextDepth() == getDepth())
     pop_back();
   return *this;
 }
Ejemplo n.º 10
0
 vector<vector<string>> printTree(TreeNode* root) {
     int d = getDepth(root), N = (1 << d) - 1;
     vector<vector<string>> ans(d, vector<string>(N));
     dfs(root, 0, N, 0, ans);
     return ans;
 }
Ejemplo n.º 11
0
/*
 * resize
 */
void Volume::resize(void) {
    int w = 0;
    int h = 0;
    int d = 0;
    int start_width = 0;
    int start_height = 0;
    int start_depth = 0;
    if (!isPowerOfTwo(getWidth())) {
        w = nextPowerOfTwo(getWidth());
        start_width = (w - getWidth()) / 2;
    }
    if (!isPowerOfTwo(getHeight())) {
        h = nextPowerOfTwo(getHeight());
        start_height = (h - getHeight()) / 2;
    }
    if (!isPowerOfTwo(getDepth())) {
        d = nextPowerOfTwo(getDepth());
        start_depth = (d - getDepth()) / 2;
    }
    if ((w != 0) || (h != 0) || (d != 0)) {
        if (w == 0) {
            w = getWidth();
        }
        if (h == 0) {
            h = getHeight();
        }
        if (d == 0) {
            d = getDepth();
        }
        int _size[3];
        _size[0] = w;
        _size[1] = h;
        _size[2] = d;
        int _borderSize = 0;
        int _numberOfVoxels = (_size[0] + 2 * _borderSize) * (_size[1] + 2 * _borderSize) * (_size[2] + 2 * _borderSize);
        unsigned char* _voxelsBase = new unsigned char[_numberOfVoxels];
        for (int k = 0; k < getDepth(); k++) {
            for (int j = 0; j < getHeight(); j++) {
                for (int i = 0; i < getWidth(); i++) {
                    _voxelsBase[((start_depth + k) * (w * h)) + ((start_height + j) * w) + (start_width + i)] = voxels[(k
                            * (getWidth() * getHeight())) + (j * getWidth()) + i];
                }
            }
        }
        Point _origin = Point::origin;
        Size _extent;
        Point _center;
        for (int i = 0; i < 3; ++i) {
            _extent[i] = Scalar(_size[i]) * scale[i];
            _center[i] = _origin[i] + _extent[i] * Scalar(0.5);
        }
        unsigned char* _voxels = _voxelsBase + borderSize;
        int _increments[3];
        _increments[2] = 1;
        for (int i = 2; i > 0; --i) {
            _increments[i - 1] = _increments[i] * (_size[i] + 2 * _borderSize);
            _voxels += _borderSize * _increments[i - 1];
        }
        setNumberOfVoxels(_numberOfVoxels);
        setSize(_size);
        setOrigin(_origin);
        setExtent(_extent);
        setCenter(_center);
        delete byteVoxelsBase;
        setByteVoxelsBase(_voxelsBase);
        setBorderSize(_borderSize);
        setIncrements(_increments);
        setVoxels(_voxels);
    }
} // end resize()
Ejemplo n.º 12
0
/**
 * Called by libevent when there is data to read.
 */
void buffered_on_read(struct bufferevent *bev, void *arg) {
	client_t *client = (client_t *)arg;
	char *line;
	size_t n;
	/* If we have input data, the number of bytes we have is contained in
	 * bev->input->off. Copy the data from the input buffer to the output
	 * buffer in 4096-byte chunks. There is a one-liner to do the whole thing
	 * in one shot, but the purpose of this server is to show actual real-world
	 * reading and writing of the input and output buffers, so we won't take
	 * that shortcut here. */
	struct evbuffer *input =  bufferevent_get_input(bev);
	line = evbuffer_readln(input, &n, EVBUFFER_EOL_CRLF);
	char cmd[256], protocol[256], path[MAX_PATH_SIZE];
	httpHeader_t httpHeader;
	httpHeader.command = UNKNOWN_C;
	httpHeader.status = OK;
	if (n != 0) {
		int scaned = sscanf(line, "%s %s %s\n", cmd, path, protocol);
		if (scaned == 3) {
			if (!strcmp(cmd, "GET")) {
				httpHeader.command = GET;
			}
			else if (!strcmp(cmd, "HEAD")) {
				httpHeader.command = HEAD;
			}
			else { 
				httpHeader.command = UNKNOWN_C;
			}
		/*	if (strcmp(protocol, "HTTP/1.1")) {
				printf("BAD PROTOCOL%s\n", protocol);
				httpHeader.status = BAD_REQUEST;
			}*/
			if (path[0] != '/') {
				printf("BAD INPUtT\n");
				httpHeader.status = BAD_REQUEST;
			}
			urlDecode(path);
			httpHeader.type = getContentType(path);
			if (getDepth(path) == -1) {
				printf("BAD DEPTH\n");
				httpHeader.status = BAD_REQUEST;
			}
		}
		else {
			printf("Bad scanned\n");
			httpHeader.status = BAD_REQUEST;
		}
	}
	else {
		printf("OOO BAD N\n");
		httpHeader.status = BAD_REQUEST;
	}
	switch (httpHeader.status) {
		case BAD_REQUEST:
			printf("Bad request\n");
			break;
		case OK:
			printf("OK\n");
			break;
		case NOT_FOUND:
			printf("NOt found\n");
			break;
	}
	switch (httpHeader.command) {
		case UNKNOWN_C:
			printf("UNKNOWS\n");
			break;
		case GET:
			printf("GET\n");
			break;
		case HEAD:
			printf("HEAD\n");
			break;
	}
	printf("%s\n", path);
	free(line);
	if (httpHeader.status != BAD_REQUEST) {
		char fullPath[2048] = {'\0'};
		strcpy(fullPath, ROOT_PATH);
		strcat(fullPath, path);
		int fd = open(fullPath, O_RDONLY);
		if (fd < 0) {
			httpHeader.status = NOT_FOUND;
			printf("Can't open %s", fullPath);
		}
		client->openFd = -1;
		struct stat st;
		httpHeader.length = lseek(fd, 0, SEEK_END);
		if (httpHeader.length == -1 || lseek(fd, 0, SEEK_SET) == -1) {
			httpHeader.status = BAD_REQUEST;
			printf("Cant seek\n");
		}
		addHeader(&httpHeader, client->output_buffer);
		if (fstat(fd, &st) < 0) {
			perror("fstat");
		}
		if (fd != -1 && httpHeader.status == OK && httpHeader.command == GET) {
			evbuffer_set_flags(client->output_buffer, EVBUFFER_FLAG_DRAINS_TO_FD);
			if(evbuffer_add_file(client->output_buffer, fd, 0, httpHeader.length) != 0) {
				perror("add file");
			}
		}
	//	printf("%d\n", fd);
	}

	//evbuffer_add(client->output_buffer, "AAA", 3);
	/*
	while ((line = evbuffer_readln(input, &n, EVBUFFER_EOL_CRLF))) {
		evbuffer_add(client->output_buffer, line, n);
		evbuffer_add(client->output_buffer, "\n", 1);
		free(line);
	}*/
	//evbuffer_add_printf(client->output_buffer, "HTTP/1.1 200 OK\r\rContent-Type: text/html\r\nDate: Sun, 14 Sep 2014 08:39:53 GMT\r\nContent-Length: 5\r\n\r\n OKK\r\n");
	//  while (evbuffer_get_length(input) > 0) {
	/* Remove a chunk of data from the input buffer, copying it into our
	 * local array (data). */
	//    nbytes = evbuffer_remove(input, data, 4096); 
	/* Add the chunk of data from our local array (data) to the client's
	 * output buffer. */
	//  evbuffer_add(client->output_buffer, data, nbytes);

	//}

	/* Send the results to the client.  This actually only queues the results
	 * for sending. Sending will occur asynchronously, handled by libevent. */
	if (bufferevent_write_buffer(bev, client->output_buffer) == -1) {
		errorOut("Error sending data to client on fd %d\n", client->fd);
	}

	//bufferevent_setcb(bev, NULL, buffered_on_write, NULL, NULL);
	//bufferevent_enable(bev, EV_WRITE);
}
Ejemplo n.º 13
0
int Hex::travelPenalty() const
{
	return BTech::travelPenalty[getTerrain()] + getDepth();
}
Ejemplo n.º 14
0
		static bool load(std::shared_ptr<CookingTask> cookingTask)
		{
			if (!cookingTask->dataSet->loadSkeleton)
				return true;
			auto tid = Singleton<AGE::AE::ConvertorStatusManager>::getInstance()->PushTask("SkeletonLoader : loading " + cookingTask->dataSet->filePath.getShortFileName());

			auto boneOrigin = cookingTask->assimpScene->mRootNode;
			bool hasSkeleton = false;
			for (unsigned int meshIndex = 0; meshIndex < cookingTask->assimpScene->mNumMeshes; ++meshIndex)
			{
				if (cookingTask->assimpScene->mMeshes[0]->HasBones())
					hasSkeleton = true;
			}
			if (!hasSkeleton)
			{
				Singleton<AGE::AE::ConvertorStatusManager>::getInstance()->PopTask(tid);
				std::cerr << "Skeleton loader : mesh do not have skeleton." << std::endl;
				return true;
			}

			cookingTask->skeleton = std::make_shared<Skeleton>();
			Skeleton *skeleton = cookingTask->skeleton.get();
			std::uint32_t minDepth = std::uint32_t(-1);
			skeleton->firstBone = 0;
			skeleton->name = cookingTask->dataSet->filePath.getShortFileName();

			for (unsigned int meshIndex = 0; meshIndex < cookingTask->assimpScene->mNumMeshes; ++meshIndex)
			{
				aiMesh *mesh = cookingTask->assimpScene->mMeshes[meshIndex];

				for (unsigned int i = 0; i < mesh->mNumBones; ++i)
				{
					std::string boneName = mesh->mBones[i]->mName.data;
					if (skeleton->bonesReferences.find(boneName) != std::end(skeleton->bonesReferences))
						continue;
					auto index = skeleton->bones.size();
					skeleton->bones.push_back(AGE::Bone());
					skeleton->bones.back().index = static_cast<uint32_t>(index);
					skeleton->bones.back().name = boneName;
					skeleton->bones.back().offset = AssimpLoader::aiMat4ToGlm(mesh->mBones[i]->mOffsetMatrix);
					skeleton->bonesReferences.insert(std::make_pair(boneName, static_cast<uint32_t>(index)));

					auto boneNode = cookingTask->assimpScene->mRootNode->FindNode(boneName.c_str());
					if (!boneNode)
						continue;
					skeleton->bones.back().transformation = AssimpLoader::aiMat4ToGlm(boneNode->mTransformation);
					std::uint32_t depth = getDepth(boneNode);
					if (depth < minDepth)
					{
						minDepth = depth;
						skeleton->firstBone = static_cast<uint32_t>(index);
						boneOrigin = cookingTask->assimpScene->mRootNode->FindNode(boneName.c_str());
					}
				}
			}

			boneOrigin = cookingTask->assimpScene->mRootNode->FindNode(skeleton->bones[skeleton->firstBone].name.c_str());

			if (boneOrigin->mParent)
			{
				boneOrigin = boneOrigin->mParent;
			}
			skeleton->inverseGlobal = glm::inverse(AssimpLoader::aiMat4ToGlm(boneOrigin->mTransformation));
			
			loadSkeletonFromAssimp(skeleton, cookingTask->assimpScene->mRootNode, minDepth);

			//we fill bone hierarchy
			for (unsigned int i = 0; i < skeleton->bones.size(); ++i)
			{
				aiNode *bonenode = cookingTask->assimpScene->mRootNode->FindNode(aiString(skeleton->bones[i].name));
				if (!bonenode)
					continue;

				//we set bone transformation
				skeleton->bones[i].transformation = AssimpLoader::aiMat4ToGlm(bonenode->mTransformation);

				// we set parent
				if (bonenode->mParent != nullptr && skeleton->bonesReferences.find(bonenode->mParent->mName.data) == std::end(skeleton->bonesReferences))
				{
					auto parent = bonenode->mParent;
					while (parent && skeleton->bonesReferences.find(parent->mName.data) == std::end(skeleton->bonesReferences))
					{
						skeleton->bones[i].offset = glm::inverse(AssimpLoader::aiMat4ToGlm(parent->mTransformation)) * skeleton->bones[i].offset;
						skeleton->bones[i].transformation = AssimpLoader::aiMat4ToGlm(parent->mTransformation) * skeleton->bones[i].transformation;
						parent = parent->mParent;
					}
					if (parent)
					{
						skeleton->bones[i].parent = skeleton->bonesReferences.find(parent->mName.data)->second;
					}
				}
				else if (bonenode->mParent)
				{
					skeleton->bones[i].parent = skeleton->bonesReferences.find(bonenode->mParent->mName.data)->second;
				}

				//we set children
				for (unsigned int c = 0; c < bonenode->mNumChildren; ++c)
				{
					auto f = skeleton->bonesReferences.find(bonenode->mChildren[c]->mName.data);
					if (f == std::end(skeleton->bonesReferences))
						continue;
					skeleton->bones[i].children.push_back(f->second);
				}
			}
			if (skeleton->bones.size() == 0)
			{
				std::cerr << "Skeleton loader : assets does not contain any skeleton." << std::endl;
				cookingTask->skeleton = nullptr;
				Singleton<AGE::AE::ConvertorStatusManager>::getInstance()->PopTask(tid);
				return false;
			}
			Singleton<AGE::AE::ConvertorStatusManager>::getInstance()->PopTask(tid);
			return true;
		}
Ejemplo n.º 15
0
/**
 * Draw the text on screen
 */
void GuiText::draw(CVideo *pVideo)
{
	if(!text)
		return;

	if(!isVisible())
		return;

    color[3] = getAlpha();
    blurGlowColor[3] = blurAlpha * getAlpha();
	int newSize = size * getScale();

	if(newSize != currentSize)
	{
		currentSize = newSize;

		if(text)
			textWidth = font->getWidth(text, currentSize);
	}

	if(maxWidth > 0 && maxWidth <= textWidth)
	{
		if(wrapMode == DOTTED) // text dotted
		{
			if(textDyn.size() == 0)
				makeDottedText();

			if(textDynWidth.size() != textDyn.size())
            {
                textDynWidth.resize(textDyn.size());

                for(u32 i = 0; i < textDynWidth.size(); i++)
                    textDynWidth[i] = font->getWidth(textDyn[i], currentSize);
            }

			if(textDyn.size() > 0)
				font->drawText(pVideo, getCenterX(), getCenterY(), getDepth(), textDyn[textDyn.size()-1], currentSize, color, alignment, textDynWidth[textDyn.size()-1], defaultBlur, blurGlowIntensity, blurGlowColor);
		}

		else if(wrapMode == SCROLL_HORIZONTAL)
		{
			scrollText(pVideo->getFrameCount());

			if(textDyn.size() > 0)
				font->drawText(pVideo, getCenterX(), getCenterY(), getDepth(), textDyn[textDyn.size()-1], currentSize, color, alignment, maxWidth, defaultBlur, blurGlowIntensity, blurGlowColor);
		}
		else if(wrapMode == WRAP)
		{
			int lineheight = currentSize + 6;
			int yoffset = 0;
			int voffset = 0;

			if(textDyn.size() == 0)
				wrapText();

			if(textDynWidth.size() != textDyn.size())
            {
                textDynWidth.resize(textDyn.size());

                for(u32 i = 0; i < textDynWidth.size(); i++)
                    textDynWidth[i] = font->getWidth(textDyn[i], currentSize);
            }

			if(alignment & ALIGN_MIDDLE)
				voffset = (lineheight * (textDyn.size()-1)) >> 1;

			for(u32 i = 0; i < textDyn.size(); i++)
			{
				font->drawText(pVideo, getCenterX(), getCenterY() + voffset + yoffset, getDepth(), textDyn[i], currentSize, color, alignment, textDynWidth[i], defaultBlur, blurGlowIntensity, blurGlowColor);
                yoffset -= lineheight;
			}
		}
	}
Ejemplo n.º 16
0
void
DLVertex :: Print ( std::ostream& o ) const
{
	o << "[d(" << getDepth(true) << "/" << getDepth(false)
	  << "),s(" << getSize(true) << "/" << getSize(false)
	  << "),b(" << getBranch(true) << "/" << getBranch(false)
	  << "),g(" << getGener(true) << "/" << getGener(false)
	  << "),f(" << getFreq(true) << "/" << getFreq(false) << ")] ";
	o << getTagName();

	switch ( Type() )
	{
	case dtAnd:		// nothing to do (except for printing operands)
	case dtSplitConcept:
		break;

	case dtTop:		// nothing to do
	case dtNN:
		return;

	case dtDataExpr:
		o << ' ' << *static_cast<const TDataEntry*>(getConcept())->getFacet();
		return;

	case dtDataValue:	// named entry -- just like concept names
	case dtDataType:

	case dtPConcept:
	case dtNConcept:
	case dtPSingleton:
	case dtNSingleton:
		o << '(' << getConcept()->getName() << ") " << (isNNameTag(Type()) ? "=" : "[=") << ' ' << getC();
		return;

	case dtLE:
		o << ' ' << getNumberLE() << ' ' << getRole()->getName() << ' ' << getC();
		return;

	case dtForall:
		o << ' ' << getRole()->getName() << '{' << getState() << '}' << ' ' << getC();
		return;

	case dtIrr:
		o << ' ' << getRole()->getName();
		return;

	case dtProj:
		o << ' ' << getRole()->getName() << ", " << getC() << " => " << getProjRole()->getName();
		return;

	case dtChoose:
		o << ' ' << getC();
		return;

	default:
		std::cerr << "Error printing vertex of type " << getTagName() << "(" << Type() << ")";
		fpp_unreachable();
	}

	// print operands of the concept constructor
	for ( const_iterator q = begin(); q != end(); ++q )
		o << ' ' << *q;
}
int main()
{
    int i,j,V,E;

    printf("Enter no. of vertices and edges : ");
    scanf("%d%d",&V,&E);

    //int from[20];
    //int to[20];

    int a,b;


    for(i=1;i<=E;i++)
    {
        scanf("%d%d",&a,&b);//alphabetical, directed/undirected edges
        adj[a][b]=1;
        adj[b][a]=1;
    }

    /*for(i=1;i<=V;i++)
    {
        for(j=1;j<=V;j++)
        {
            printf("%d ",adj[i][j]);
        }
        printf("\n");
    }*/
    printf("\n");

    visited[1]=1;
    getDepth(1,V);

    int max=0,maxV;

    printf("\nIntermediate Depth:\n");
    for(i=1;i<=V;i++)
    {
        //printf("%d %d\n",i,depth[i]);
        if(depth[i]>max)
        {
            max=depth[i];
            maxV=i;
        }
        depth[i]=0;
        visited[i]=0;
    }

    printf("MaxV = %d\n",maxV);
    visited[maxV]=1;
    getDepth(maxV,V);


    printf("\nFinal depth: \n");
    max=0;
    for(i=1;i<=V;i++)
    {
        //printf("%d %d\n",i,depth[i]);
        if(depth[i]>max)
        {
            max=depth[i];
        }
    }
    printf("%d",max+1);


    return 0;
}
Ejemplo n.º 18
0
 /**
  * @brief Member function <b>resetDepth</b> resets the stack so that the depth of the top entry
  * on the stack exceeds the depth of the entry prior to the top entry on the stack.
  *
  * @return      a <b>LineMaskStack</b> reference to the depth stack.
  */
 LineMaskStack &resetDepth() {
   while (size() > 1 && getNextDepth() == getDepth())
     pop_back();
   return *this;
 }
Ejemplo n.º 19
0
//--------------------------------------------------------------
void ofBoxPrimitive::setHeight( float a_height ) {
    size.y = a_height;
    set( getWidth(), getHeight(), getDepth() );
}
Ejemplo n.º 20
0
bool CBTriangle::operator<(const CBTriangle &b) const
{
	//std::cout << Vertex << "   *" << std::endl;
	return getDepth() < b.getDepth();
}
Ejemplo n.º 21
0
//--------------------------------------------------------------
void ofBoxPrimitive::setResolution( int resWidth, int resHeight, int resDepth ) {
    resolution.set( resWidth, resHeight, resDepth );
    set( getWidth(), getHeight(), getDepth() );
}
Ejemplo n.º 22
0
 MusicNode *createNode(const QString &title) 
 {
     return new MusicNode(title, m_paths[getDepth()]);
 }
Ejemplo n.º 23
0
	void GLTextureBuffer::download(const PixelData &data)
	{
		if (data.getWidth() != getWidth() || data.getHeight() != getHeight() || data.getDepth() != getDepth())
		{
			LOGERR("Only download of entire buffer is supported by OpenGL.");
			return;
		}

		glBindTexture(mTarget, mTextureID);
		BS_CHECK_GL_ERROR();

		if(PixelUtil::isCompressed(data.getFormat()))
		{
			// Block-compressed data cannot be smaller than 4x4, and must be a multiple of 4
			const UINT32 actualWidth = Math::divideAndRoundUp(std::max(mWidth, 4U), 4U) * 4U;
			const UINT32 actualHeight = Math::divideAndRoundUp(std::max(mHeight, 4U), 4U) * 4U;

			const UINT32 expectedRowPitch = actualWidth;
			const UINT32 expectedSlicePitch = actualWidth * actualHeight;

			const bool isConsecutive = data.getRowPitch() == expectedRowPitch && data.getSlicePitch() == expectedSlicePitch;
			if (data.getFormat() != mFormat || !isConsecutive)
			{
				LOGERR("Compressed images must be consecutive, in the source format");
				return;
			}

			// Data must be consecutive and at beginning of buffer as PixelStorei not allowed
			// for compressed formate
			glGetCompressedTexImage(mFaceTarget, mLevel, data.getData());
			BS_CHECK_GL_ERROR();
		} 
		else
		{
			if (data.getWidth() != data.getRowPitch())
			{
				glPixelStorei(GL_PACK_ROW_LENGTH, data.getRowPitch());
				BS_CHECK_GL_ERROR();
			}

			if (data.getHeight()*data.getWidth() != data.getSlicePitch())
			{
				glPixelStorei(GL_PACK_IMAGE_HEIGHT, (data.getSlicePitch() / data.getWidth()));
				BS_CHECK_GL_ERROR();
			}

			if (data.getLeft() > 0 || data.getTop() > 0 || data.getFront() > 0)
			{
				glPixelStorei(
					GL_PACK_SKIP_PIXELS, 
					data.getLeft() + data.getRowPitch() * data.getTop() + data.getSlicePitch() * data.getFront());
				BS_CHECK_GL_ERROR();
			}

			if ((data.getWidth()*PixelUtil::getNumElemBytes(data.getFormat())) & 3)
			{
				glPixelStorei(GL_PACK_ALIGNMENT, 1);
				BS_CHECK_GL_ERROR();
			}

			// We can only get the entire texture
			glGetTexImage(mFaceTarget, mLevel, GLPixelUtil::getGLOriginFormat(data.getFormat()), 
				GLPixelUtil::getGLOriginDataType(data.getFormat()), data.getData());
			BS_CHECK_GL_ERROR();

			// Restore defaults
			glPixelStorei(GL_PACK_ROW_LENGTH, 0);
			BS_CHECK_GL_ERROR();

			glPixelStorei(GL_PACK_IMAGE_HEIGHT, 0);
			BS_CHECK_GL_ERROR();

			glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
			BS_CHECK_GL_ERROR();

			glPixelStorei(GL_PACK_ALIGNMENT, 4);
			BS_CHECK_GL_ERROR();
		}

		BS_INC_RENDER_STAT_CAT(ResRead, RenderStatObject_Texture);
	}
Ejemplo n.º 24
0
 bool isLeafDone(Metadata *meta) 
 {
     return getDepth() + 1 >= getPathsForMeta(meta)->size();
 }
void SpecificWorker::getImage(ColorSeq& color, DepthSeq& depth, PointSeq& points, RoboCompJointMotor::MotorStateMap &hState, RoboCompDifferentialRobot::TBaseState& bState)
{
	getDepth(depth,hState,bState);
	getRGB(color,hState,bState);
	getXYZ(points,hState,bState);
}
Ejemplo n.º 26
0
 QString getField(Metadata *meta) 
 {
     return getPathsForMeta(meta)->operator[](getDepth());
 }
bool CollisionManager::ball_vs_bumper(Ball *object1, Bumper *object2)
{
	// distance to circle
	math::Vector2D distance;
	distance = object2->getPosition() - object1->getPosition();

	// length of distance
	float distanceLength;
	distanceLength = distance.magnitude();

	if (distanceLength < (object1->getRadius() + object2->getRadius()))
	{
		float length;
		length = distance.magnitude();
		if (length == 0)
		{
			length = 0.01f;
		}

		// collidable attributes
		setDepth(distanceLength - (object1->getRadius() + object2->getRadius()));
		setSlop(0.03f);
		setPercentCorrection(0.7f);
		setElasticity(1.f);
		m_normal = math::Vector2D((distance.getX() / length), (distance.getY() / length));

		// position correction
		math::Vector2D positionCorrection;
		float temp = (std::max(getDepth() - getSlop(), 0.0f));
		temp = temp / (object1->getInverseMass() + object2->getInverseMass());
		temp = getPercentCorrection() * temp;

		positionCorrection = m_normal * temp;

		object1->setPosition(object1->getPosition() + (positionCorrection * object1->getInverseMass()));
		object2->setPosition(object2->getPosition() + (positionCorrection * object2->getInverseMass()));

		// calculate the relative velocity
		math::Vector2D relativeVel;
		relativeVel = object1->getVelocity() - object2->getVelocity();
		float relativeNorm;
		relativeNorm = relativeVel.dotProduct(m_normal);

		// impulse resolution
		float j;
		j = -(1.0f + getElasticity());
		j = j * relativeNorm;
		j = j / (object1->getInverseMass() + object2->getInverseMass());

		// update impulse velocity
		object1->setVelocity(object1->getVelocity() + ((m_normal * j) * object1->getInverseMass()));
		object2->setVelocity(object2->getVelocity() - ((m_normal * j) * object2->getInverseMass()));

		collision = true;
		return true;
	}
	else
	{
		collision = false;
		return false;
	}
}
Ejemplo n.º 28
0
VkBool32 Example::buildTexture(const vkts::ICommandBuffersSP& cmdBuffer, vkts::IImageSP& stageImage, vkts::IDeviceMemorySP& stageDeviceMemoryImage)
{
	auto imageData = vkts::imageDataLoad(VKTS_TEXTURE_NAME);

	if (!imageData.get())
	{
		vkts::logPrint(VKTS_LOG_ERROR, "Example: Could not load image data: '%s'", VKTS_TEXTURE_NAME);

		return VK_FALSE;
	}

	//

	VkFormatProperties formatProperties;

	vkGetPhysicalDeviceFormatProperties(physicalDevice->getPhysicalDevice(), imageData->getFormat(), &formatProperties);

	VkImageTiling imageTiling = VK_IMAGE_TILING_LINEAR;
	VkMemoryPropertyFlagBits memoryPropertyFlagBits = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
	VkImageLayout initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
	VkAccessFlags accessMask = VK_ACCESS_HOST_WRITE_BIT;

	// Check, how to upload image data.
	if (!(formatProperties.linearTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
	{
		if (!(formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
		{
			vkts::logPrint(VKTS_LOG_ERROR, "Example: Format not supported.");

			return VK_FALSE;
		}

		imageTiling = VK_IMAGE_TILING_OPTIMAL;
		memoryPropertyFlagBits = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
		initialLayout = VK_IMAGE_LAYOUT_GENERAL;
		accessMask = 0;
	}

	//

	if (!createTexture(image, deviceMemoryImage, imageData, imageTiling, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, initialLayout, memoryPropertyFlagBits, accessMask))
	{
		vkts::logPrint(VKTS_LOG_ERROR, "Example: Could not create image.");

		return VK_FALSE;
	}

	//

	VkImageMemoryBarrier imageMemoryBarrier;

	memset(&imageMemoryBarrier, 0, sizeof(VkImageMemoryBarrier));

	imageMemoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;

	imageMemoryBarrier.srcAccessMask = 0;			// Defined later.
	imageMemoryBarrier.dstAccessMask = 0;			// Defined later.
	imageMemoryBarrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;// Defined later.
	imageMemoryBarrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED;// Defined later.
	imageMemoryBarrier.srcQueueFamilyIndex = 0;
	imageMemoryBarrier.dstQueueFamilyIndex = 0;
	imageMemoryBarrier.image = VK_NULL_HANDLE;		// Defined later.
	imageMemoryBarrier.subresourceRange = {	VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};

	//

	imageMemoryBarrier.dstAccessMask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT | VK_ACCESS_SHADER_READ_BIT;
	imageMemoryBarrier.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
	imageMemoryBarrier.image = image->getImage();

	cmdBuffer->cmdPipelineBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);

	//

	// If the image is only accessible by the device ...
	if (memoryPropertyFlagBits == VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
	{
		// ... create texture with host visibility. This texture contains the pixel data.
		if (!createTexture(stageImage, stageDeviceMemoryImage, imageData, VK_IMAGE_TILING_LINEAR, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_IMAGE_LAYOUT_PREINITIALIZED, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, VK_ACCESS_HOST_WRITE_BIT))
		{
			vkts::logPrint(VKTS_LOG_ERROR, "Example: Could not create image.");

			return VK_FALSE;
		}

		// Prepare source image layout for copy.

		imageMemoryBarrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
		imageMemoryBarrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
		imageMemoryBarrier.image = stageImage->getImage();

		cmdBuffer->cmdPipelineBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);

		// Prepare target image layout for copy.

		imageMemoryBarrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
		imageMemoryBarrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
		imageMemoryBarrier.oldLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
		imageMemoryBarrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
		imageMemoryBarrier.image = image->getImage();

		cmdBuffer->cmdPipelineBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);

		// Copy image data by command.

		VkImageCopy imageCopy;

		imageCopy.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};

		imageCopy.srcOffset = {	0, 0, 0};

		imageCopy.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
		imageCopy.dstOffset = {	0, 0, 0};
		imageCopy.extent = { imageData->getWidth(), imageData->getHeight(), imageData->getDepth()};

		vkCmdCopyImage(cmdBuffer->getCommandBuffer(), stageImage->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, image->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &imageCopy);

		// Switch back to original layout.
		imageMemoryBarrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
		imageMemoryBarrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
		imageMemoryBarrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
		imageMemoryBarrier.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;

		cmdBuffer->cmdPipelineBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);
	}

	//

	sampler = vkts::samplerCreate(device->getDevice(), 0, VK_FILTER_NEAREST, VK_FILTER_NEAREST, VK_SAMPLER_MIPMAP_MODE_NEAREST, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, 0.0f, VK_FALSE, 1.0f, VK_FALSE, VK_COMPARE_OP_NEVER, 0.0f, 0.0f, VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE, VK_FALSE);

	if (!sampler.get())
	{
		vkts::logPrint(VKTS_LOG_ERROR, "Example: Could not create sampler.");

		return VK_FALSE;
	}

	imageView = vkts::imageViewCreate(device->getDevice(), 0, image->getImage(), VK_IMAGE_VIEW_TYPE_2D, image->getFormat(), { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A }, { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 });

	if (!imageView.get())
	{
		vkts::logPrint(VKTS_LOG_ERROR, "Example: Could not create image view.");

		return VK_FALSE;
	}

	return VK_TRUE;
}
Ejemplo n.º 29
0
	void GLTextureBuffer::download(const PixelData &data)
	{
		if(data.getWidth() != getWidth() || data.getHeight() != getHeight() || data.getDepth() != getDepth())
			BS_EXCEPT(InvalidParametersException, "only download of entire buffer is supported by GL");

		glBindTexture( mTarget, mTextureID );
		if(PixelUtil::isCompressed(data.getFormat()))
		{
			if(data.getFormat() != mFormat || !data.isConsecutive())
				BS_EXCEPT(InvalidParametersException, 
				"Compressed images must be consecutive, in the source format");

			// Data must be consecutive and at beginning of buffer as PixelStorei not allowed
			// for compressed formate
			glGetCompressedTexImage(mFaceTarget, mLevel, data.getData());
		} 
		else
		{
			if(data.getWidth() != data.getRowPitch())
				glPixelStorei(GL_PACK_ROW_LENGTH, data.getRowPitch());

			if(data.getHeight()*data.getWidth() != data.getSlicePitch())
				glPixelStorei(GL_PACK_IMAGE_HEIGHT, (data.getSlicePitch()/data.getWidth()));

			if(data.getLeft() > 0 || data.getTop() > 0 || data.getFront() > 0)
				glPixelStorei(GL_PACK_SKIP_PIXELS, data.getLeft() + data.getRowPitch() * data.getTop() + data.getSlicePitch() * data.getFront());

			if((data.getWidth()*PixelUtil::getNumElemBytes(data.getFormat())) & 3)
				glPixelStorei(GL_PACK_ALIGNMENT, 1);

			// We can only get the entire texture
			glGetTexImage(mFaceTarget, mLevel, GLPixelUtil::getGLOriginFormat(data.getFormat()), 
				GLPixelUtil::getGLOriginDataType(data.getFormat()), data.getData());

			// Restore defaults
			glPixelStorei(GL_PACK_ROW_LENGTH, 0);
			glPixelStorei(GL_PACK_IMAGE_HEIGHT, 0);
			glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
			glPixelStorei(GL_PACK_ALIGNMENT, 4);
		}

		BS_INC_RENDER_STAT_CAT(ResRead, RenderStatObject_Texture);
	}
Ejemplo n.º 30
0
bool BoundingBox::overlapsWith(const BoundingBox& other)
{
   if(!use || !other.use) return false;

   float wa = getWidth()/2;
   float ha = getHeight()/2;
   float da = getDepth()/2;

   glm::vec3 Ca = getCenter();
   glm::vec3 Az = getFrontNormal();
   glm::vec3 Ay = getUpNormal();
   glm::vec3 Ax = getRightNormal();

   glm::vec3 Cb = other.getCenter();
   glm::vec3 Bz = other.getFrontNormal();
   glm::vec3 By = other.getUpNormal();
   glm::vec3 Bx = other.getRightNormal();
   float wb = other.getWidth()/2;
   float hb = other.getHeight()/2;
   float db = other.getDepth()/2;

   glm::vec3 T = Cb - Ca;

   float lhs = 0, rhs = 0;

   float Rxx = glm::dot(Ax, Bx);
   float Rxy = glm::dot(Ax, By);
   float Rxz = glm::dot(Ax, Bz);

   // Case 1: L = Ax
   lhs = glm::dot(T, Ax);
   rhs = wa + fabs(wb * Rxx) + fabs(hb * Rxy) + fabs(db * Rxz);
   if(lhs > rhs) return false;

   float Ryx = glm::dot(Ay, Bx);
   float Ryy = glm::dot(Ay, By);
   float Ryz = glm::dot(Ay, Bz);

   // Case 2: L = Ay
   lhs = glm::dot(T, Ay);
   rhs = ha + fabs(wb * Ryx) + fabs(hb * Ryy) + fabs(db * Ryz);
   if(lhs > rhs) return false;

   float Rzx = glm::dot(Az, Bx);
   float Rzy = glm::dot(Az, By);
   float Rzz = glm::dot(Az, Bz);

   // Case 3: L = Az
   lhs = glm::dot(T, Az);
   rhs = da + fabs(wb * Rzx) + fabs(hb * Rzy) + fabs(db * Rzz);
   if(lhs > rhs) return false;

   // Case 4: L = Bx
   lhs = glm::dot(T, Bx);
   rhs = fabs(wa * Rxx) + fabs(ha * Ryx) + fabs(da * Rzx) + wb;
   if(lhs > rhs) return false;

   // Case 5: L = By
   lhs = glm::dot(T, By);
   rhs = fabs(wa * Rxy) + fabs(ha * Ryy) + fabs(da * Rzy) + hb;
   if(lhs > rhs) return false;

   // Case 6: L = Bz
   lhs = glm::dot(T, Bz);
   rhs = fabs(wa * Rxz) + fabs(ha * Ryz) + fabs(da * Rzz) + db;
   if(lhs > rhs) return false;

   // Case 7: L = Ax x Bx
   lhs = glm::dot(T, glm::cross(Ax, Bx));
   rhs = fabs(ha * Rzx) + fabs(da * Ryx) + fabs(hb * Rxz) + fabs(db * Rxy);
   if(lhs > rhs) return false;

   // Case 8: L = Ax x By
   lhs = glm::dot(T, glm::cross(Ax, By));
   rhs = fabs(ha * Rzy) + fabs(da * Ryy) + fabs(wb * Rxz) + fabs(db * Rxx);
   if(lhs > rhs) return false;

   // Case 9: L = Ax x Bz
   lhs = glm::dot(T, glm::cross(Ax, Bz));
   rhs = fabs(ha * Rzz) + fabs(da * Ryz) + fabs(wb * Rxy) + fabs(hb * Rxx);
   if(lhs > rhs) return false;

   // Case 10: L = Ay x Bx
   lhs = glm::dot(T, glm::cross(Ay, Bx));
   rhs = fabs(wa * Rzx) + fabs(da * Rxx) + fabs(hb * Ryz) + fabs(db * Ryy);
   if(lhs > rhs) return false;

   // Case 11: L = Ay x By
   lhs = glm::dot(T, glm::cross(Ay, By));
   rhs = fabs(wa * Rzy) + fabs(da * Rxy) + fabs(wb * Ryz) + fabs(db * Ryx);
   if(lhs > rhs) return false;

   // Case 12: L = Ay x Bz
   lhs = glm::dot(T, glm::cross(Ay, Bz));
   rhs = fabs(wa * Rzz) + fabs(da * Rxz) + fabs(wb * Ryy) + fabs(hb * Ryx);
   if(lhs > rhs) return false;

   // Case 13: L = Az x Bx
   lhs = glm::dot(T, glm::cross(Az, Bx));
   rhs = fabs(wa * Ryx) + fabs(ha * Rxx) + fabs(hb * Rzz) + fabs(db * Rzy);
   if(lhs > rhs) return false;

   // Case 14: L = Az x By
   lhs = glm::dot(T, glm::cross(Az, By));
   rhs = fabs(wa * Ryy) + fabs(ha * Rxy) + fabs(wb * Rzz) + fabs(db * Rzx);
   if(lhs > rhs) return false;

   // Case 15: L = Az x Bz
   lhs = glm::dot(T, glm::cross(Az, Bz));
   rhs = fabs(wa * Ryz) + fabs(ha * Rxz) + fabs(wb * Rzy) + fabs(hb * Rzx);
   if(lhs > rhs) return false;

   return true;
}