예제 #1
0
void BlockSession::extendBlock(BlockNode* blockNode)
{
	if(this->inlineObjects_.size() > 0){
		this->newInline();
	}
	//ここまでで、インライン要素が一切挿入されていないことが保証される
	geom::Box const size = blockNode->areaInBlock().box() + blockNode->margin().totalSpace();
	if(size.width() > this->calcBlockLimit()){
		this->newBlockLine();
	}
	if(this->dir_ == BlockNode::Direction::Unspecified){
		this->dir_ = blockNode->direction();
	}
	switch (this->dir_) {
	case BlockNode::Direction::None:
		this->newBlockLine();
		blockNode->areaInBlock(geom::Area(0, this->consumedHeight_, limitSize_.width(), size.height()));
		this->consumedHeight_ += size.height();
		break;
	case BlockNode::Direction::Right:
		if(blockNode->direction() != BlockNode::Direction::Right){
			this->newBlockLine();
			this->dir_ = blockNode->direction();
		}
		blockNode->areaInBlock(geom::Area(this->blockPosX_, this->consumedHeight_, size.width(), size.height()));
		this->blockConsumedHeight_ = std::max(this->blockConsumedHeight_, size.height());
		this->blockPosX_ += size.width();
		break;
	case BlockNode::Direction::Left:
		if(blockNode->direction() != BlockNode::Direction::Left){
			this->newBlockLine();
			this->dir_ = blockNode->direction();
		}
		blockNode->areaInBlock(geom::Area(limitSize_.width() - this->blockPosX_ - size.width(), this->consumedHeight_, size.width(), size.height()));
		this->blockConsumedHeight_ = std::max(this->blockConsumedHeight_, size.height());
		this->blockPosX_ += size.width();
		break;
	default:
		CINAMO_EXCEPTION(Exception, "[BUG] Unknown direction: %d", this->dir_);
	}
}
예제 #2
0
파일: box_assist.cpp 프로젝트: bo-wu/mobb
bool point_inside_box(const Eigen::Vector3d &point, const Geom::Box &box)
{
    auto p2b = point - box.Center;
    bool result = true;
    for(int i=0; i < 3; ++i)
    {
        float dist = fabs( p2b.dot(box.Axis[i]) );
        if(dist > box.Extent(i))
        {
            result = false;
            break;
        }
    }
    return result;
}
예제 #3
0
파일: Canvas.cpp 프로젝트: kaiinui/Chisa
void Canvas::resize2d(geom::Box const& box)
{
	this->width_ = box.width();
	this->height_ = box.height();
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	this->ortho(0, box.width(), box.height(), 0, -100, 100);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glViewport(0, 0, box.width(), box.height());
	glScissor(0,0,box.width(),box.height());
#ifdef DEBUG
	const GLenum err = glGetError();
	if(err != GL_NO_ERROR){
		CINAMO_EXCEPTION(Exception, "[BUG] Failed to exec resize2d: 0x%08x", err);
	}
#endif
}