コード例 #1
0
ファイル: image_cache.cpp プロジェクト: apextw/Ramen
void image_cache_impl::insert( const adobe::md5_t::digest_t& key, image_buffer_t& img)
{
    if( items_.find( key) != items_.end())
    {
	// check to see if the area this image buffer represents
	// is already included in the cache
	std::pair<map_iterator, map_iterator> range = items_.equal_range( key);
	for( map_iterator it( range.first); it != range.second; ++it)
	{
	    if( isInside( it->second.bounds(), img.bounds()))
	    {
		// in this case, just move the buffer to the front
		// of the use list
		touch( it);
		return;
	    }
	}
    }

    // insert the image buffer in the cache
    img.set_cached( true);
    map_iterator result( items_.insert( map_type::value_type( key, img)));
    use_list_.push_front( result);

    // remove image buffers included inside this one
    std::pair<map_iterator, map_iterator> range = items_.equal_range( key);
    for( map_iterator it( range.first); it != range.second; )
    {
	if( it != result)
	{
	    if( isInside( img.bounds(), it->second.bounds()))
	    {
		use_list_.remove( it);
		items_.erase( it++);
	    }
	    else
		++it;
	}
	else
	    ++it;
    }
}
コード例 #2
0
ファイル: PolygonIterator.cpp プロジェクト: DHaylock/grid_map
PolygonIterator& PolygonIterator::operator ++()
{
  ++(*internalIterator_);
  if (internalIterator_->isPastEnd()) return *this;

  for ( ; !internalIterator_->isPastEnd(); ++(*internalIterator_)) {
    if (isInside()) break;
  }

  return *this;
}
コード例 #3
0
ファイル: igs_shiny.tc.c プロジェクト: 4og/guacamole
bool frustum_cull()
{
	//Frustum Culling in Clip Space

	vec4 cs_v1 = projection_matrix * view_matrix * model_matrix * vec4(vPosition[0], 1.0);
	vec4 cs_v2 = projection_matrix * view_matrix * model_matrix * vec4(vPosition[1], 1.0);
	vec4 cs_v3 = projection_matrix * view_matrix * model_matrix * vec4(vPosition[2], 1.0);
	vec4 cs_v4 = projection_matrix * view_matrix * model_matrix * vec4(vPosition[3], 1.0);

	cs_v1 = cs_v1 / cs_v1.w;
	cs_v2 = cs_v2 / cs_v2.w;
	cs_v3 = cs_v3 / cs_v3.w;
	cs_v4 = cs_v4 / cs_v4.w;

	if ( isInside(cs_v1) || isInside(cs_v2) || isInside(cs_v3) || isInside(cs_v4) ) {
		return true;
	}

	return false;
}
コード例 #4
0
const std::string& getStringFontForHeight(bool&changed) {
  static std::string whichfont=vs_config->getVariable("graphics","font","helvetica12");
  static std::string whichdockedfont=vs_config->getVariable("graphics","basefont","helvetica12");
  bool inside=isInside();
  static bool lastinside=inside;
  if (lastinside!=inside) {
    changed=true;
    lastinside=inside;
  }else changed=false;
  return inside?whichdockedfont:whichfont;
}
コード例 #5
0
String
String::getSubString( uint32 first ) const
{
	if (isInside( first ))
	{
		return String( m_Content+first );
	}
	else
	{
		return String( m_Content );
	}
}
コード例 #6
0
ファイル: game.c プロジェクト: grupp7kth/Battlecave
void createAndSendUDPPackets() {
    SDL_Rect viewport;
	viewport.w = SCREEN_WIDTH;
	viewport.h = SCREEN_HEIGHT;

	int i, player, secondary, counter,UDPpacketLength;
	Uint32 tmp;

	packetId++;
	for (i=0; i<4; i++) {
		gameData[i] = packetId >> i*8;
	}
	for (player=0; player<MAX_CLIENTS; player++) {
		tmp=0;
		tmp = (int)ships[player].xPos | (int)ships[player].yPos << 12 | (int)(ships[player].angle/6) << 24;
		tmp = tmp | ships[player].alive <<30 | clients[player].active << 31;
		printf("tmp:%u\n",tmp);
		for (i=0; i<4; i++) {
			gameData[4+player*4+i] = tmp >> i*8;
		}
	}
	printf("__________________________\n");
	for (player=0; player<MAX_CLIENTS; player++) {
		if (!clients[player].active) continue;
		if (ships[player].xPos < SCREEN_WIDTH/2)
			viewport.x=0;
		else if (ships[player].xPos > STAGE_WIDTH-SCREEN_WIDTH/2)
			viewport.x=STAGE_WIDTH-SCREEN_WIDTH;
		else viewport.x=ships[player].xPos-SCREEN_WIDTH/2;
		if (ships[player].yPos < SCREEN_HEIGHT/2)
			viewport.y=0;
		else if (ships[player].yPos > STAGE_HEIGHT-SCREEN_HEIGHT/2)
			viewport.y=STAGE_HEIGHT-SCREEN_HEIGHT;
		else viewport.y=ships[player].yPos-SCREEN_HEIGHT/2;

		for (secondary=0, counter=0; secondary<MAX_BULLETS; secondary++) {
			if (bullets[secondary].active && isInside((int)bullets[secondary].xPos, (int)bullets[secondary].yPos, &viewport)) {
				tmp=0;
				tmp = (int)(bullets[secondary].xPos-viewport.x) | (int)(bullets[secondary].yPos-viewport.y) << 11 | (int)(bullets[secondary].type) << 21;
				for (i=0; i<3; i++) {
					gameData[36+counter*3+i] = tmp >> i*8;
				}
				counter++;
			}
		}
		UDPpacketLength = 36+counter*3;
		gameData[UDPpacketLength++]=0xFF;
		packetOut->data = gameData;
		packetOut->len = UDPpacketLength;
		packetOut->address.host=clients[player].ip;
		packetOut->address.port=clients[player].recvPort;
		SDLNet_UDP_Send(udpSendSock,-1,packetOut);
	}
コード例 #7
0
ファイル: Plane.cpp プロジェクト: notrabttam/Raytracer
//Function to compute the paramter t at the point of intersection.
float Plane::intersect(Vector pos, Vector dir)
{
	Vector n = normal(pos);
	Vector vdif = a-pos;
	float vdotn = dir.dot(n);
	if(fabs(vdotn) < 1.e-4) return -1;
    float t = vdif.dot(n)/vdotn;
	if(fabs(t) < 0.0001) return -1;
	Vector q = pos + dir*t;
	if(isInside(q)) return t;
    else return -1;
}
コード例 #8
0
ファイル: ToggleButton.cpp プロジェクト: lucaszardo/SCV
void ToggleButton::processMouse(const scv::MouseEvent &evt) {
   static Kernel *kernel = Kernel::getInstance();

   Component::processMouse(evt);

   if (!_receivingCallbacks) return;

   if (isInside(evt.getPosition())) {
      if (evt.getState() == MouseEvent::UP && isFocused())
         setState(!getState());
   }
}
コード例 #9
0
IntersectType clipPoly3D(const Points3D& points,
	const Imath::Plane3<typename points_adaptor<Points3D>::scalar>& plane,
	std::list<ClippedPoly<typename points_adaptor<Points3D>::scalar> >& result,
	detail::ClippingContext<typename points_adaptor<Points3D>::scalar>* ctxt)
{
	typedef points_adaptor<Points3D> 			Adaptor;
	typedef typename Adaptor::scalar			T;
	typedef Imath::Vec2<T> 						vec2_type;
	typedef Imath::Vec3<T> 						vec3_type;
	typedef typename Adaptor::const_elem_ref	vec3_const_ref;
	typedef ClippedPoly<T>						polyclip_type;
	Adaptor a(points);

	vec3_type polyNorm;
	calc_normal(points, polyNorm);
	vec3_const_ref p0 = a[0];

	// project poly and cutting plane into 2D
	std::vector<vec2_type> points2D;
	Line2<T> plane2D;

	{
		Imath::Line3<T> planesInt;
		Imath::Plane3<T> polyPlane(p0, polyNorm);
		if(intersect(plane, polyPlane, planesInt))
		{
			Projection_2D<T> proj(polyNorm, &plane.normal);
			proj.project(planesInt, plane2D);
			proj.project(points, points2D);
		}
		else
		{
			// poly and cutting plane are parallel, so poly is either all out or all in
			if((ctxt)? ctxt->isPointInside(a.index(0)) : isInside(plane, p0))
			{
				result.push_back(polyclip_type());
				result.back().makeInside(points);
				return INTERSECT_INSIDE;
			}
			else
				return INTERSECT_OUTSIDE;
		}
	}

	// do the clip in 2D.
	if(a.is_indexed())
	{
		points_replacer<Points3D, std::vector<vec2_type> > points2D_(points, points2D, false);
		return clipPoly2D(points2D_, plane2D, result, ctxt);
	}
	else
		return clipPoly2D(points2D, plane2D, result, ctxt);
}
コード例 #10
0
ファイル: simbox.cpp プロジェクト: CRAVA/crava
bool Simbox::IsPointBetweenVisibleSurfaces(double x, double y, double z) const{
  const NRLib::Surface<double> * top_surf  = &GetTopErodedSurface();
  const NRLib::Surface<double> * base_surf = &GetBaseErodedSurface();
  bool b = false;
  if(isInside(x, y)){
    double z_top  = top_surf->GetZ(x,y);
    double z_base = base_surf->GetZ(x,y);
    if (z_top <= z && z_base > z)
      b = true;
  }
  return b;
}
コード例 #11
0
ファイル: gridUtility.cpp プロジェクト: manteapi/utility
void Grid2dUtility::get5Neighbors(std::vector<int>& neighbors, const Vec2i& p) const
{
    neighbors.clear();
    if(!isInside(p))
        return;

    Vec2i neighbor;

    neighbor = p;
    if(isInside(neighbor))
        neighbors.push_back(cellId(neighbor));

    neighbor = p + Vec2i(1,0);
    if(isInside(neighbor))
        neighbors.push_back(cellId(neighbor));

    neighbor = p + Vec2i(-1,0);
    if(isInside(neighbor))
        neighbors.push_back(cellId(neighbor));

    neighbor = p + Vec2i(0,1);
    if(isInside(neighbor))
        neighbors.push_back(cellId(neighbor));

    neighbor = p + Vec2i(0,-1);
    if(isInside(neighbor))
        neighbors.push_back(cellId(neighbor));
}
コード例 #12
0
ファイル: NewButton.cpp プロジェクト: KeckCAVES/Vrui
bool NewButton::findRecipient(Event& event)
	{
	/* Ignore events if the button is disabled: */
	if(!isEnabled())
		return false;
	
	/* Check ourselves: */
	Event::WidgetPoint wp=event.calcWidgetPoint(this);
	if(isInside(wp.getPoint()))
		return event.setTargetWidget(this,wp);
	else
		return false;
	}
コード例 #13
0
ファイル: Maze.cpp プロジェクト: omochi/MazeMouse
void Maze::setWall(const Point &p,Direction d,bool exists){
	switch(d){
		case DirectionLeft:
		case DirectionTop:
			if(isInside(p)){
				cellAt(p)=cellAt(p).cellBySetWall(d,exists);
			}
			break;
		case DirectionRight:
		case DirectionBottom:
			return setWall(p.neighbor(d),DirectionReverse(d),exists);
	}
}
コード例 #14
0
ファイル: virtual_input.cpp プロジェクト: Ced2911/native
void TouchButton::update(InputState &input_state)
{
	bool down = false;
	for (int i = 0; i < MAX_POINTERS; i++) {
		if (input_state.pointer_down[i] && isInside(input_state.pointer_x[i], input_state.pointer_y[i]))
			down = true;
	}

	if (down)
		input_state.pad_buttons |= button_;

	isDown_ = (input_state.pad_buttons & button_) != 0;
}
コード例 #15
0
void EyedropperStatusDisplay::pointerMove( float inX, float inY ) {
    if( isInside( inX, inY ) ) {
        mHover = true;
        setToolTip( translate( "eyedropperTip" ) );
        }
    else {
        if( mHover ) {
            // just hovered out
            setToolTip( NULL );
            }
        mHover = false;
        }
    }
コード例 #16
0
ファイル: tool.cpp プロジェクト: JRevel/src
void Tool::update(const PlayerController &event)
{
    updateTool(event);
    if(event.pressed(SELECT) && isInside(event.mousePos()))
    {
        if(m_selected)
            m_player = (m_player+1)%m_players.size();
        else
        {
            select();
        }
    }
}
コード例 #17
0
ファイル: Maze.cpp プロジェクト: omochi/MazeMouse
//こういうの気持ち良い
bool Maze::existsWall(const Point &p,Direction d) const{
	switch(d){
		case DirectionLeft:
		case DirectionTop:
			if(isInside(p)){
				return constCellAt(p).existsWall(d);
			}
			return true;		
			break;
		case DirectionRight:
		case DirectionBottom:
			return existsWall(p.neighbor(d),DirectionReverse(d));
	}
}
コード例 #18
0
ファイル: gui.cpp プロジェクト: kucerad/natu-renderer
bool GUICheckBox::mouseClickEvent(int x, int y)
{
	if (isInside(x, y))
	{
		m_bActive = !m_bActive;
				
		if (m_pCallBackFunc)
		{
			m_pCallBackFunc(m_bActive);
		}
		return true;
	}
	return false;
}
コード例 #19
0
ファイル: map.cpp プロジェクト: zaboing/DoungenGenerator
	void Map::update() {
		for (int i = 0; i < width; i++) {
			for (int j = 0; j < height; j++) {
				tileMap[i][j] = std::shared_ptr<Region>(nullptr);
			}
		}
		for (auto region : regions) {
			for (auto tile : region->tiles) {
				if (isInside(tile)) {
					tileMap[tile.x][tile.y] = region;
				}
			}
		}
	}
コード例 #20
0
ファイル: TacticalZone.cpp プロジェクト: AlohaWu/M.A.R.S.
void TacticalZone::update() {
    shipCount_ = 0;
    if (homeSide_ == 0) {
        std::vector<Player*> const& players = teams::getTeamL()->members();
        for (std::vector<Player*>::const_iterator it = players.begin(); it != players.end(); ++it)
            if (isInside(*(*it)->ship()))
                ++shipCount_;
        shipCount_ /= players.size();
    }
    else {
        std::vector<Player*> const& players = teams::getTeamR()->members();
        for (std::vector<Player*>::const_iterator it = players.begin(); it != players.end(); ++it)
            if (isInside(*(*it)->ship()))
                ++shipCount_;
        shipCount_ /= players.size();
    }


    if (shipCount_ != 0  && radius_ * radius_ / zones::totalTacticalArea(homeSide_) < shipCount_)
        covered_ = true;
    else
        covered_ = false;
}
コード例 #21
0
ファイル: p1.cpp プロジェクト: jasonfsmitty/psu_projects
/*------------------------------------------------------------*/
MyObject* findFirst( int x, int y )
{
    MyObject* t;
    MyObject* f;
    t = head;
    f = NULL;

    while( t != NULL ) {
        if( isInside(t, x, y ) )
            f=t;
        t = t->next;
    }
    return f;
}
コード例 #22
0
ファイル: gridUtility.cpp プロジェクト: manteapi/utility
void Grid2dUtility::get9Neighbors(std::vector<int>& neighbors, const Vec2i& p, const int radius)
{
    neighbors.clear();
    if(!isInside(p))
        return;

        for(int j = std::max(p[1]-radius,0); j<= std::min(p[1]+radius,dimension[1]-1); ++j )
        {
            for(int i = std::max(p[0]-radius,0); i<= std::min(p[0]+radius,dimension[0]-1); ++i )
            {
                neighbors.push_back(cellId(i,j));
            }
        }
}
コード例 #23
0
ファイル: PolygonIterator.cpp プロジェクト: DHaylock/grid_map
PolygonIterator::PolygonIterator(const grid_map::GridMap& gridMap, const grid_map::Polygon& polygon)
    : polygon_(polygon)
{
  mapLength_ = gridMap.getLength();
  mapPosition_ = gridMap.getPosition();
  resolution_ = gridMap.getResolution();
  bufferSize_ = gridMap.getSize();
  bufferStartIndex_ = gridMap.getStartIndex();
  Index submapStartIndex;
  Size submapBufferSize;
  findSubmapParameters(polygon, submapStartIndex, submapBufferSize);
  internalIterator_ = std::shared_ptr<SubmapIterator>(new SubmapIterator(gridMap, submapStartIndex, submapBufferSize));
  if(!isInside()) ++(*this);
}
コード例 #24
0
void ofxDraggableNode::mousePressed(ofMouseEventArgs & args) {
	if (isInside(ofPoint(args.x, args.y)) && args.button == GLFW_MOUSE_BUTTON_RIGHT) {
		draggingNode = !draggingNode;
		if (draggingNode) {
			cam->disableMouseInput();

			ofPoint screenCenter = cam->worldToScreen(this->getGlobalPosition());
			gui->setPosition(screenCenter.x, screenCenter.y);
		}
		else
			cam->enableMouseInput();
	}

}
コード例 #25
0
ファイル: LastPatch.cpp プロジェクト: Art-n-MathS/DASOS
//-----------------------------------------------------------------------------
void LastPatch::createMap()
{
   for(unsigned int x=0; x<m_noOfPixelsX; ++x)
   {
      for(unsigned int y=0; y<m_noOfPixelsY; ++y)
      {
         int zz = 0, z;
         for(z=m_noOfPixelsZ-1; z>=0; --z)
         {
             if(isInside(x,y,z))
             {
                break;
             }
         }
         if(z<=0)
         {
            m_mapValues[getIndex(x,y)] = -0.0f;
         }
         else
         {
            for(; z>=0; z--)
            {
               if (isInside(x,y,z))
               {
                  zz++;
               }
               else
               {
                  break;
               }
            }
            m_mapValues[getIndex(x,y)] = zz *m_object->getVoxelLen();
         }
      }
   }
}
コード例 #26
0
ファイル: virtual_input.cpp プロジェクト: Adolfoi/native
void TouchButton::update(InputState &input_state)
{
	bool oldIsDown = isDown_;
	isDown_ = false;
	for (int i = 0; i < MAX_POINTERS; i++) {
		if (input_state.pointer_down[i] && isInside(input_state.pointer_x[i], input_state.pointer_y[i]))
			isDown_ = true;
	}

	if (isDown_) {
		input_state.pad_buttons |= button_;
	} else if (oldIsDown && !isDown_) {
		input_state.pad_buttons &= ~button_;
	}
}
コード例 #27
0
ファイル: Popup.cpp プロジェクト: VisualIdeation/Vrui
bool Popup::findRecipient(Event& event)
	{
	/* Distribute the question to the child widget: */
	if(child==0||!child->findRecipient(event))
		{
		/* Check ourselves: */
		Event::WidgetPoint wp=event.calcWidgetPoint(this);
		if(isInside(wp.getPoint()))
			return event.setTargetWidget(this,wp);
		else
			return false;
		}
	else
		return true;
	}
コード例 #28
0
bool Planner::InCollision(Point p)
{
	int collision = 0;
	std::cout<<ob.size()<<std::endl;
	for(int i = 0 ; i<ob.size(); i++)
	{
		std::cout<<(ob.at(i)).p[0].x<<(ob.at(i)).p[0].y<<(ob.at(i)).p[1].x<<(ob.at(i)).p[1].y<<(ob.at(i)).p[2].x<<(ob.at(i)).p[2].y<<(ob.at(i)).p[3].x<<(ob.at(i)).p[3].y;
		std::cout<<"Collision Check\n";
		if(isInside(ob.at(i),4,p)) {collision++;}
	}
	if(collision!=0){
	std::cout<<"In Collision\n";
	return true;
	}
	else return false;
}
コード例 #29
0
ファイル: polygon.cpp プロジェクト: axelerator/adgr
bool PolygonRect::shadow(const Vector3D& e, const Vector3D& w, geovalue length) {
  geovalue denominator = normal * w;

  geovalue numerator = (normal * e) + d;
  geovalue s = numerator / -denominator;

  if (s <= 0.0) return false;

  Vector3D direction = w * s;

  if (direction.length() < length) {
    return isInside(direction + e);
  }

  return false;
}
コード例 #30
0
ファイル: multiplelabel.cpp プロジェクト: q4a/scourge
bool MultipleLabel::handleEvent( Window* parent, SDL_Event* event, int x, int y ) {
	inside = isInside( x, y );
	// handle it
	switch ( event->type ) {
	case SDL_MOUSEMOTION:
		break;
	case SDL_MOUSEBUTTONUP:
		if ( ( event->button.button == SDL_BUTTON_LEFT ) && inside ) {
			setNextText(); return inside;
		}
	case SDL_MOUSEBUTTONDOWN:
		break;
	default:
		break;
	}
	return false;
}