Пример #1
0
	void graphics_context::clear(const colour& aColour) const
	{
		if (origin() == point{} && extents() == iSurface.extents())
			iNativeGraphicsContext->clear(aColour);
		else
			fill_rect(rect{origin(), extents()}, aColour);
	}
Пример #2
0
	const vector4& opengl_window::logical_coordinates() const
	{
		switch (iLogicalCoordinateSystem)
		{
		case neogfx::logical_coordinate_system::Specified:
			return iLogicalCoordinates;
		case neogfx::logical_coordinate_system::AutomaticGui:
			return iLogicalCoordinates = vector4{ 0.0, extents().cy, extents().cx, 0.0 };
		case neogfx::logical_coordinate_system::AutomaticGame:
			return iLogicalCoordinates = vector4{ 0.0, 0.0, extents().cx, extents().cy };
		}
		return iLogicalCoordinates;
	}
Пример #3
0
AABB AABB::convertToMinMaxPts()
{
	//@TODO: 2 continue here.
	
	//Take center, and go back negative half extents.
	CVector3 minPt = mCenter - extents();
	CVector3 maxPt = mCenter + extents();

	CVector3 vec = maxPt;

	setCenter(minPt); //center acts as the miniumum CVector3 in the MinMax representation.
	setExtents(maxPt); //	

	return AABB();
}
Пример #4
0
// Raycast from the bottom (Y is up) to make sure that raycasting against the scaled mopp works
void MoppInstancingDemo::checkRayCasts(const hkpMoppBvTreeShape* mopp, const hkTransform& t)
{
	hkAabb aabb; mopp->getAabb(hkTransform::getIdentity(), 1.0f, aabb);
	hkVector4 extents; extents.setSub4(aabb.m_max, aabb.m_min);

	const int numX=10, numZ = 10;
	const hkReal deltaX = extents(0) / hkReal(numX-1);
	const hkReal deltaZ = extents(2) / hkReal(numZ-1);

	for (int x=0; x<numX; x++)
	{
		for (int z=0; z<numZ; z++)
		{
			hkpShapeRayCastInput input;
			hkpShapeRayCastOutput output;
			input.m_from(0) = aabb.m_min(0) + hkReal(x)*deltaX;
			input.m_from(1) = aabb.m_min(1)                   ;
			input.m_from(2) = aabb.m_min(2) + hkReal(z)*deltaZ;
				
			input.m_to = input.m_from;
			input.m_to(1) = aabb.m_max(1);
			input.m_rayShapeCollectionFilter = HK_NULL;

			mopp->castRay(input, output);

			hkVector4 worldFrom, worldTo;
			worldFrom.setTransformedPos(t, input.m_from);
			worldTo.setTransformedPos(t, input.m_to);

			if (output.hasHit())
			{
				hkVector4 hitpoint; hitpoint.setInterpolate4(worldFrom, worldTo, output.m_hitFraction);
				HK_DISPLAY_LINE(worldFrom, hitpoint, hkColor::GREEN);
			}

			// Check that the naive raycast gives the same results
			hkpShapeRayCastOutput testOutput;
			mopp->getShapeCollection()->castRay(input, testOutput);

			HK_ASSERT(0x793171a3, hkMath::equal(testOutput.m_hitFraction, output.m_hitFraction) );
			if ( !hkMath::equal(testOutput.m_hitFraction, 1.0f) )
			{
				HK_ASSERT(0x793171a3, testOutput.m_normal.equals3(output.m_normal) );
			}
		}
	}

}
Пример #5
0
LLViewerPartGroup::LLViewerPartGroup(const LLVector3 &center_agent, const F32 box_side, bool hud)
 : mHud(hud)
{
	mVOPartGroupp = NULL;
	mUniformParticles = TRUE;

	mRegionp = LLWorld::getInstance()->getRegionFromPosAgent(center_agent);
	llassert_always(center_agent.isFinite());
	
	if (!mRegionp)
	{
		//llwarns << "No region at position, using agent region!" << llendl;
		mRegionp = gAgent.getRegion();
	}
	mCenterAgent = center_agent;
	mBoxRadius = F_SQRT3*box_side*0.5f;

	if (mHud)
	{
		mVOPartGroupp = (LLVOPartGroup *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_HUD_PART_GROUP, getRegion());
	}
	else
	{
	mVOPartGroupp = (LLVOPartGroup *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_PART_GROUP, getRegion());
	}
	mVOPartGroupp->setViewerPartGroup(this);
	mVOPartGroupp->setPositionAgent(getCenterAgent());
	
	mBoxSide = box_side;

	F32 scale = box_side * 0.5f;

	mVOPartGroupp->setScale(LLVector3(scale,scale,scale));
	
	//gPipeline.addObject(mVOPartGroupp);
	gPipeline.createObject(mVOPartGroupp);

	LLSpatialGroup* group = mVOPartGroupp->mDrawable->getSpatialGroup();

	if (group != NULL)
	{
		LLVector3 center(group->mOctreeNode->getCenter().getF32ptr());
		LLVector3 size(group->mOctreeNode->getSize().getF32ptr());
		size += LLVector3(0.01f, 0.01f, 0.01f);
		mMinObjPos = center - size;
		mMaxObjPos = center + size;
	}
	else 
	{
		// Not sure what else to set the obj bounds to when the drawable has no spatial group.
		LLVector3 extents(mBoxRadius, mBoxRadius, mBoxRadius);
		mMinObjPos = center_agent - extents;
		mMaxObjPos = center_agent + extents;
	}

	mSkippedTime = 0.f;

	static U32 id_seed = 0;
	mID = ++id_seed;
}
Пример #6
0
//----------------------------------------------------------------------------//
Rectf ScrolledContainer::getChildExtentsArea(void) const
{
    Rectf extents(0, 0, 0, 0);

    const size_t childCount = getChildCount();
    if (childCount == 0)
        return extents;

    for (size_t i = 0; i < childCount; ++i)
    {
        const Window* const wnd = getChildAtIdx(i);
        const Rectf area(
            CoordConverter::asAbsolute(wnd->getPosition(), d_pixelSize),
            wnd->getPixelSize());

        if (area.d_min.d_x < extents.d_min.d_x)
            extents.d_min.d_x = area.d_min.d_x;

        if (area.d_min.d_y < extents.d_min.d_y)
            extents.d_min.d_y = area.d_min.d_y;

        if (area.d_max.d_x > extents.d_max.d_x)
            extents.d_max.d_x = area.d_max.d_x;

        if (area.d_max.d_y > extents.d_max.d_y)
            extents.d_max.d_y = area.d_max.d_y;
    }

    return extents;
}
Пример #7
0
pair<int, int> TraceTreeItemOwner::v_extents() const
{
	bool has_children = false;

	pair<int, int> extents(INT_MAX, INT_MIN);
	for (const shared_ptr<TraceTreeItem>& t : trace_tree_child_items()) {
		assert(t);
		if (!t->enabled())
			continue;

		has_children = true;

		const int child_offset = t->layout_v_offset();
		const pair<int, int> child_extents = t->v_extents();
		extents.first = min(child_extents.first + child_offset,
			extents.first);
		extents.second = max(child_extents.second + child_offset,
			extents.second);
	}

	if (!has_children)
		extents = make_pair(0, 0);

	return extents;
}
Пример #8
0
void SelectClip::onMouseRelease( QMouseEvent* e )
{
    if( e->button() != Qt::LeftButton || !m_rectangle ) { return; }
    bool append = e->modifiers() == Qt::ControlModifier;
    bool erase = e->modifiers() == Qt::ShiftModifier;
    if( !append && !erase )
    {
        for( std::size_t i = 0; i < m_viewer.datasets().size(); ++i ) { m_viewer.dataset( i ).selection().clear(); }
    }
    snark::math::closed_interval< double, 3 > extents( m_center - m_radius );
    extents = extents.hull( m_center + m_radius );
    for( std::size_t i = 0; i < m_viewer.datasets().size(); ++i )
    {
        if( !erase && !m_viewer.dataset( i ).visible() ) { continue; }
        Dataset::Points m = m_viewer.dataset( i ).points().find( extents.min(), extents.max() );
        if( erase ) { m_viewer.dataset( i ).selection().erase( m ); }
        else { m_viewer.dataset( i ).selection().insert( m ); }
        std::cerr << "label-points: " << m.size() << " point(s) from " << m_viewer.dataset( i ).filename() << ( erase ? " removed from selection" : append ? " added to selection" : " selected" ) << std::endl;
        if( m_viewer.verbose() )
        {
            for( Dataset::Points::ConstEnumerator en = m.begin(); !en.end(); ++en )
            {
                std::cerr << en.key().x() << "," << en.key().y() << "," << en.key().z() << "," << en.value().id << std::endl;
            }
        }
    }
    m_rectangle = boost::optional< QRect >();
    m_viewer.update();
}
//----------------------------------------------------------------------------//
Rectf ScrolledContainer::getChildExtentsArea(void) const
{
    Rectf extents(0, 0, 0, 0);

    const size_t childCount = getChildCount();
    if (childCount == 0)
        return extents;

    for (size_t i = 0; i < childCount; ++i)
    {
        const Window* const wnd = getChildAtIdx(i);
        Rectf area(
            CoordConverter::asAbsolute(wnd->getPosition(), d_pixelSize),
            wnd->getPixelSize());

        if (wnd->getHorizontalAlignment() == HA_CENTRE)
            area.setPosition(area.getPosition() - Vector2<float>(area.getWidth() * 0.5f - d_pixelSize.d_width * 0.5f, 0.0f));
        if (wnd->getVerticalAlignment() == VA_CENTRE)
            area.setPosition(area.getPosition() - Vector2<float>(0.0f, area.getHeight() * 0.5f - d_pixelSize.d_height * 0.5f));

        if (area.d_min.d_x < extents.d_min.d_x)
            extents.d_min.d_x = area.d_min.d_x;

        if (area.d_min.d_y < extents.d_min.d_y)
            extents.d_min.d_y = area.d_min.d_y;

        if (area.d_max.d_x > extents.d_max.d_x)
            extents.d_max.d_x = area.d_max.d_x;

        if (area.d_max.d_y > extents.d_max.d_y)
            extents.d_max.d_y = area.d_max.d_y;
    }

    return extents;
}
Пример #10
0
void		Ext4Extents::read_extents(ext4_extents_header * header,
					  uint8_t * block)
{
  uint64_t	b_size;

  if (!header)
    return ;
  if (header->magic != 0xF30A)
    return ;
  for (int i = 0; i < header->entries; ++i)
    {
      ext4_extent * extent
	= (ext4_extent *)(block + i * sizeof(ext4_extent));
      std::pair<uint16_t, uint64_t> p = extents(extent);
      b_size = p.first * ((uint64_t)__block_size);
      if (b_size > __size)
	b_size = __size;
      else
	__size -= b_size;
      if (__mapping)
	__mapping->push(__offset, b_size, __node,
			p.second * ((uint64_t)__block_size)
			+ __inode->SB()->offset() - __BOOT_CODE_SIZE);
      else
	__extents_list.push_back(p);      
      __offset += (p.first * ((uint64_t)__block_size));
    }
}
Пример #11
0
 void callbacks_t::resize_cb(int32 w, int32 h)
 {
   width = w;
   height = h;
   
   GLUI_Master.get_viewport_area(&tx, &ty, &tw, &th);
   glViewport(tx, ty, tw, th);
   
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   
   //! Notice the type casting 
   //! Read about explicit/implicit type casting in C++
   float32 ratio = static_cast<float32>(tw) / static_cast<float32>(th);
   
   b2Vec2 extents(ratio * 25.0f, 25.0f);
   extents *= view_zoom;
   
   b2Vec2 lower = settings.view_center - extents;
   b2Vec2 upper = settings.view_center + extents;
 
   //! L/R/B/T extents of the view frustum
   //! Find where this function is defined
   gluOrtho2D(lower.x, upper.x, lower.y, upper.y);
 }
Пример #12
0
//----------------------------------------------------------------------------//
Rect ScrolledContainer::getChildExtentsArea(void) const
{
    Rect extents(0, 0, 0, 0);

    const size_t childCount = getChildCount();
    if (childCount == 0)
        return extents;

    for (size_t i = 0; i < childCount; ++i)
    {
        const Window* const wnd = getChildAtIdx(i);
        const Rect area(wnd->getArea().asAbsolute(d_pixelSize));

        if (area.d_left < extents.d_left)
            extents.d_left = area.d_left;

        if (area.d_top < extents.d_top)
            extents.d_top = area.d_top;

        if (area.d_right > extents.d_right)
            extents.d_right = area.d_right;

        if (area.d_bottom > extents.d_bottom)
            extents.d_bottom = area.d_bottom;
    }

    return extents;
}
Пример #13
0
 void callbacks_t::resize_cb(int32 w, int32 h)
 {
   width = w;
   height = h;
   
   GLUI_Master.get_viewport_area(&tx, &ty, &tw, &th);
   glViewport(tx, ty, tw, th);
   
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   
   //! Notice the type casting 
   //! Typecasting is making a variable of one type, such as an int, act like another type, a char, for one single operation.
   float32 ratio = static_cast<float32>(tw) / static_cast<float32>(th);
   
   b2Vec2 extents(ratio * 25.0f, 25.0f);
   extents *= view_zoom;
   
   b2Vec2 lower = settings.view_center - extents;
   b2Vec2 upper = settings.view_center + extents;
 
   //! L/R/B/T extents of the view frustum
   //! gluOrtho2D() sets the units of the screen coordinate system
   gluOrtho2D(lower.x, upper.x, lower.y, upper.y);
 }
Пример #14
0
	void DeferredIBLProbeMat::bind(const GBufferTextures& gBufferInput, const SPtr<GpuParamBlockBuffer>& perCamera, 
		const SceneInfo& sceneInfo, const ReflProbeData& probeData, const SPtr<GpuParamBlockBuffer>& reflProbeParams)
	{
		mGBufferParams.bind(gBufferInput);

		mParams->setParamBlockBuffer("PerCamera", perCamera);
		mParams->setParamBlockBuffer("ReflProbeParams", reflProbeParams);

		gPerProbeParamDef.gPosition.set(mParamBuffer, probeData.position);

		if(probeData.type == 1)
			gPerProbeParamDef.gExtents.set(mParamBuffer, probeData.boxExtents);
		else
		{
			Vector3 extents(probeData.radius, probeData.radius, probeData.radius);
			gPerProbeParamDef.gExtents.set(mParamBuffer, extents);
		}

		gPerProbeParamDef.gTransitionDistance.set(mParamBuffer, probeData.transitionDistance);
		gPerProbeParamDef.gInvBoxTransform.set(mParamBuffer, probeData.invBoxTransform);
		gPerProbeParamDef.gCubemapIdx.set(mParamBuffer, probeData.cubemapIdx);
		gPerProbeParamDef.gType.set(mParamBuffer, probeData.type);

		mIBLParams.reflectionProbeCubemapsTexParam.set(sceneInfo.reflProbeCubemapsTex);

		RendererMaterial::bind();
	}
Пример #15
0
static void Resize(int32 w, int32 h)
{
	width = w;
	height = h;

	tx = 0;
	ty = 0;
	tw = width;
	th = height;
	glViewport(tx, ty, tw, th);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	float32 ratio = float32(tw) / float32(th);

	b2Vec2 extents(ratio * 25.0f, 25.0f);
	extents *= viewZoom;

	b2Vec2 lower = settings.viewCenter - extents;
	b2Vec2 upper = settings.viewCenter + extents;

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    glOrthof(lower.x, upper.x, lower.y, upper.y, -1024.0f, 1024.0f);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}
Пример #16
0
// Convert from world coordinates to normalized device coordinates.
// http://www.songho.ca/opengl/gl_projectionmatrix.html
void Camera::BuildProjectionMatrix(float32* m, float32 zBias)
{
	float32 w = float32(m_width);
	float32 h = float32(m_height);
	float32 ratio = w / h;
	b2Vec2 extents(ratio * 25.0f, 25.0f);
	extents *= m_zoom;

	b2Vec2 lower = m_center - extents;
	b2Vec2 upper = m_center + extents;

	m[0] = 2.0f / (upper.x - lower.x);
	m[1] = 0.0f;
	m[2] = 0.0f;
	m[3] = 0.0f;

	m[4] = 0.0f;
	m[5] = 2.0f / (upper.y - lower.y);
	m[6] = 0.0f;
	m[7] = 0.0f;

	m[8] = 0.0f;
	m[9] = 0.0f;
	m[10] = 1.0f;
	m[11] = 0.0f;

	m[12] = -(upper.x + lower.x) / (upper.x - lower.x);
	m[13] = -(upper.y + lower.y) / (upper.y - lower.y);
	m[14] = zBias;
	m[15] = 1.0f;
}
Пример #17
0
void Pane::display( void )
{

    // Draw border:
    FloatBox::display();

    // Fill in gaps:
    int x = staticWin.getxa() + 1, y;
    String str = String().fillnchar(' ', staticWin.getwidth() - 2);

    for ( y = staticWin.getya() + 1; y < staticWin.getyb(); ++y )
    {
        gui->write_text( x, y, str.toChar() );
    }

    // Draw elements:
    if (elements.reset())
    {

        Rectangle extents( staticWin.geta() + Point(1, 1), staticWin.getb() + Point(-1, -1) );

        do
        {

            elements.get()->display( extents );

        }
        while (elements.next());

    }
}
Пример #18
0
bool BotNavTrace( int botClientNum, botTrace_t *trace, const vec3_t start, const vec3_t end )
{
	dtPolyRef startRef;
	dtStatus status;
	rVec extents( 75, 96, 75 );
	rVec spos = qVec( start );
	rVec epos = qVec( end );

	memset( trace, 0, sizeof( *trace ) );

	Bot_t *bot = &agents[ botClientNum ];

	status = bot->nav->query->findNearestPoly( spos, extents, &bot->nav->filter, &startRef, nullptr );
	if ( dtStatusFailed( status ) || startRef == 0 )
	{
		//try larger extents
		extents[ 1 ] += 500;
		status = bot->nav->query->findNearestPoly( spos, extents, &bot->nav->filter, &startRef, nullptr );
		if ( dtStatusFailed( status ) || startRef == 0 )
		{
			return false;
		}
	}

	status = bot->nav->query->raycast( startRef, spos, epos, &bot->nav->filter, &trace->frac, trace->normal, nullptr, nullptr, 0 );
	if ( dtStatusFailed( status ) )
	{
		return false;
	}

	recast2quake( trace->normal );
	return true;
}
Пример #19
0
static void sSimulate()
{
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	float32 ratio = float32(windowWidth) / float32(windowHeight);

	b2Vec2 extents(ratio * 25.0f, 25.0f);
	extents *= viewZoom;

	b2Vec2 lower = settings.viewCenter - extents;
	b2Vec2 upper = settings.viewCenter + extents;

	// L/R/B/T
	gluOrtho2D(lower.x, upper.x, lower.y, upper.y);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	test->Step(&settings);

	test->DrawTitle(entry->name);

	if (testSelection != testIndex)
	{
		testIndex = testSelection;
		delete test;
		entry = g_testEntries + testIndex;
		test = entry->createFcn();
		test->SetWindow(mainWindow);
		viewZoom = 1.0f;
		settings.viewCenter.Set(0.0f, 20.0f);
	}
}
Пример #20
0
bool Collision::CircleToAABB(Circle &a, Box &b, bool &hitFloor,bool &hitSide, bool &hitUnder)
{
	
	Vector2D extents(b.getWidth()/2,b.getHeight()/2);//!< puts the extents of the box into a vector2d.
	Vector2D disti = b.getPosition().subtract(a.getPosition());//!< Finds the distance between the two origins.
	Vector2D clamp = clamp.minMax(disti,extents);//!<Clamp closet point?
	disti = disti.subtract(clamp);//!< Calculates the distance from the box. In the X and Y.
	distance = disti.magnitude() - a.getRadius();//!< Gets the length between the two objects. 
	if(distance > 0)
	{
		return false; //!<Exits if the distance is greater than 0
	}
	//return true;
	normal2 = disti.getUnitVector();//!< Calculates the normal
	//!Used to find out if ive hit top side or under
	if(normal2.getY() > 0.2f)
	{ 
		hitFloor = true;
	}
	else hitFloor = false;
	if(normal2.getY() < -0.5f)
	{ 
		hitUnder = true;
	}
	if(normal2.getX() == -1.f || normal2.getX() == 1.f )
	{ 
		hitSide = true;
	}

	return true;
}
Пример #21
0
int main(int argc, char** argv) {

    // load the extents from the dfxml
    extents_t extents(argv[1]);

    // Print them back out again
    //for (const auto& extent : extents.extents)  {
    //  std::cout << extent << std::endl;
    //}

    // A test list of offsets to look up
    std::vector<uint64_t> offsets = {
        2098176, 2621440, 3146752, 3163136, 3195904,
        3212288, 3687424, 4195328, 8908800, 8913920,
        9044992, 9208832, 9305088, 9306112, 9307136,
        9388032, 9389056, 9418752, 9418751, 0
    };

    // Try to look up each of the offsets:
    for (uint64_t offset : offsets) {
        try {
            std::cerr << extents.find(offset) << " (" << offset << ")" << std::endl;
        } catch (const std::runtime_error& e) {
            std::cerr << "Not in file: " << offset << " : " << e.what() << "\n";
        }
    }

    return 0;
}
XNA::AxisAlignedBox ModelLoader::GetBoundingBox() {
	XNA::AxisAlignedBox aabb;
	XMFLOAT3 center( minX+(maxX-minX) * 0.5f, minY+(maxY-minY) * 0.5f, minZ+(maxZ-minZ)*0.5f );
	XMFLOAT3 extents( (maxX-minX)*0.5f, (maxY-minY)*0.5f, (maxZ-minZ)*0.5f );
	aabb.Center = center;
	aabb.Extents = extents;
	return aabb;
}
Пример #23
0
static PyObject *Py_get_path_collection_extents(PyObject *self, PyObject *args, PyObject *kwds)
{
    agg::trans_affine master_transform;
    PyObject *pathsobj;
    numpy::array_view<const double, 3> transforms;
    numpy::array_view<const double, 2> offsets;
    agg::trans_affine offset_trans;
    extent_limits e;

    if (!PyArg_ParseTuple(args,
                          "O&OO&O&O&:get_path_collection_extents",
                          &convert_trans_affine,
                          &master_transform,
                          &pathsobj,
                          &convert_transforms,
                          &transforms,
                          &convert_points,
                          &offsets,
                          &convert_trans_affine,
                          &offset_trans)) {
        return NULL;
    }

    try
    {
        py::PathGenerator paths(pathsobj);

        CALL_CPP("get_path_collection_extents",
                 (get_path_collection_extents(
                     master_transform, paths, transforms, offsets, offset_trans, e)));
    }
    catch (const py::exception &)
    {
        return NULL;
    }

    npy_intp dims[] = { 2, 2 };
    numpy::array_view<double, 2> extents(dims);
    extents(0, 0) = e.x0;
    extents(0, 1) = e.y0;
    extents(1, 0) = e.x1;
    extents(1, 1) = e.y1;

    return extents.pyobj();
}
Пример #24
0
Файл: life.c Проект: jons/life
/**
 * write cell value v at <x,y> in grid g
 */
void wcell (grid_t *g, uint32_t x, uint32_t y, uint8_t v)
{
  uint32_t d = g->d;
  if (x >= d || y >= d)
    return;
  g->m[x + d * y] = v;
  if (v)
    extents(g, x, y);
}
Пример #25
0
static LayoutRect computeScrollSnapPortOrAreaRect(const LayoutRect& rect, const LengthBox& insetOrOutsetBox, InsetOrOutset insetOrOutset)
{
    LayoutBoxExtent extents(valueForLength(insetOrOutsetBox.top(), rect.height()), valueForLength(insetOrOutsetBox.right(), rect.width()), valueForLength(insetOrOutsetBox.bottom(), rect.height()), valueForLength(insetOrOutsetBox.left(), rect.width()));
    auto snapPortOrArea(rect);
    if (insetOrOutset == InsetOrOutset::Inset)
        snapPortOrArea.contract(extents);
    else
        snapPortOrArea.expand(extents);
    return snapPortOrArea;
}
Пример #26
0
static void drawGlyphsShadow(GraphicsContext* graphicsContext, const FloatPoint& point, PangoLayoutLine* layoutLine, PangoRegionType renderRegion)
{
    ShadowBlur& shadow = graphicsContext->platformContext()->shadowBlur();

    if (!(graphicsContext->textDrawingMode() & TextModeFill) || shadow.type() == ShadowBlur::NoShadow)
        return;

    FloatPoint totalOffset(point + graphicsContext->state().shadowOffset);

    // Optimize non-blurry shadows, by just drawing text without the ShadowBlur.
    if (!shadow.mustUseShadowBlur(graphicsContext)) {
        cairo_t* context = graphicsContext->platformContext()->cr();
        cairo_save(context);
        cairo_translate(context, totalOffset.x(), totalOffset.y());

        setSourceRGBAFromColor(context, graphicsContext->state().shadowColor);
#if PLATFORM(GTK)
        gdk_cairo_region(context, renderRegion);
#else
        appendRegionToCairoContext(context, renderRegion);
#endif
        cairo_clip(context);
        pango_cairo_show_layout_line(context, layoutLine);

        cairo_restore(context);
        return;
    }

    FloatRect extents(getPangoRegionExtents(renderRegion));
    extents.setLocation(FloatPoint(point.x(), point.y() - extents.height()));
    if (GraphicsContext* shadowContext = shadow.beginShadowLayer(graphicsContext, extents)) {
        cairo_t* cairoShadowContext = shadowContext->platformContext()->cr();
        cairo_translate(cairoShadowContext, point.x(), point.y());
        pango_cairo_show_layout_line(cairoShadowContext, layoutLine);

        // We need the clipping region to be active when we blit the blurred shadow back,
        // because we don't want any bits and pieces of characters out of range to be
        // drawn. Since ShadowBlur expects a consistent transform, we have to undo the
        // translation before calling endShadowLayer as well.
        cairo_t* context = graphicsContext->platformContext()->cr();
        cairo_save(context);
        cairo_translate(context, totalOffset.x(), totalOffset.y());
#if PLATFORM(GTK)
        gdk_cairo_region(context, renderRegion);
#else
        appendRegionToCairoContext(context, renderRegion);
#endif
        cairo_clip(context);
        cairo_translate(context, -totalOffset.x(), -totalOffset.y());

        shadow.endShadowLayer(graphicsContext);
        cairo_restore(context);
    }
}
Пример #27
0
bool Extensions::hasShape(xcb_window_t w) const
{
    if (!isShapeAvailable()) {
        return false;
    }
    ScopedCPointer<xcb_shape_query_extents_reply_t> extents(xcb_shape_query_extents_reply(
        connection(), xcb_shape_query_extents_unchecked(connection(), w), NULL));
    if (extents.isNull()) {
        return false;
    }
    return extents->bounding_shaped > 0;
}
Пример #28
0
//-----------------------------------------------------------------------
void
EBAMRGodunovGeomFactory::
getBasicGeometry(RealVect& a_domainExtent,
                 RealVect& a_origin,
                 RealVect& a_coarsestDx,
                 RealVect& a_finestDx,
                 const Vector<int>& a_refRatios)
{
  // Retrieve command line parameters.
  ParmParse parms;

  // Get the extents of the domain.
  RealVect domainExtents = RealVect::Unit; // Unit square by default.
  if (parms.contains("domain_length")) // Square domain
  {
    parms.get("domain_length", domainExtents[0]);
    for (int idir = 1; idir < SpaceDim; ++idir)
      domainExtents[idir] = domainExtents[0];
  }
  else if (parms.contains("domain_extents"))
  {
    Vector<Real> extents(SpaceDim);
    parms.getarr("domain_extents", extents, 0, SpaceDim);
    for (int idir = 0; idir < SpaceDim; ++idir)
      domainExtents[idir] = extents[idir];
  }

  // Get the number of grid cells again.
  Vector<int> nCell(SpaceDim);
  parms.getarr("n_cell",nCell,0,SpaceDim);

  // Determine the cell spacing at the coarsest grid level.
  for (int idir = 0; idir< SpaceDim; idir++)
    a_coarsestDx[idir] = domainExtents[idir]/nCell[idir];

  // Determine the finest grid spacing.
  a_finestDx = a_coarsestDx;
  for (int ilev = 0; ilev < a_refRatios.size(); ++ilev)
    a_finestDx /= a_refRatios[ilev];

  // If the origin is given, use it. Otherwise assume zero.
  if (parms.contains("origin"))
  {
    Vector<Real> O(SpaceDim);
    parms.getarr("origin", O, 0, SpaceDim);
    for (int idir = 0; idir < SpaceDim; ++idir)
      a_origin[idir] = O[idir];
  }
  else
    a_origin = RealVect::Zero;
}
 // Moved work of identifying matches of an extent from ExtentRestriction to here.
 // This allows the computation for the list of matches for an extent to be 
 // overridden.  ExtentParent, ExtentChild, and ExtentDescendant are among the
 // classes that need to do this, as the parent/child/descedant relationships
 // are not based on extent containment - these relationships may be among
 // arbitrary fields in a document.
 virtual const indri::utility::greedy_vector<indri::index::Extent>& matches( indri::index::Extent &extent ) {
   int begin = extent.begin;
   int end = extent.end;
   const indri::utility::greedy_vector<indri::index::Extent>& exts = extents();
   _matches.clear();
   for( size_t i = 0 ; i < exts.size(); i++ ) {
     if ( begin <= exts[i].begin && end >= exts[i].end ) {
       _matches.push_back( exts[i] );
     } else if ( exts[i].begin > end ) {
       break;
     }
   }
   return _matches;
 }
hkpRigidBody* DestructibleWallsDemo::createGround() 
{
	// build ground box
	hkVector4 extents(50.f, 2.0f, 50.0f);
	hkpConvexShape* groundBoxShape= new hkpBoxShape(extents);
	hkpRigidBodyCinfo groundInfo;
	groundInfo.m_shape = groundBoxShape;
	groundInfo.m_motionType = hkpMotion::MOTION_FIXED;
	groundInfo.m_position = hkVector4(0.0f, -2.0f, 0.0f);
	groundInfo.m_qualityType = HK_COLLIDABLE_QUALITY_FIXED;

	hkpRigidBody* ground = new hkpRigidBody(groundInfo);
	groundBoxShape->removeReference();
	return ground;
}