Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Using sf::ConvexShape without Graphics module  (Read 1662 times)

0 Members and 1 Guest are viewing this topic.

Kai

  • Guest
Using sf::ConvexShape without Graphics module
« on: February 22, 2012, 03:28:17 pm »
I am running SFML on both the client and server of my game. The client and server are two separate projects that share a statically linked library for common code. The common code only uses System and Network; I avoid compiling Graphics and Audio on the server.

I would really like to use the sf::Rect and sf::ConvexShape classes in my shared collision detection code. Is there any way to use those implementations without linking the entire Graphics module?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Using sf::ConvexShape without Graphics module
« Reply #1 on: February 22, 2012, 03:37:27 pm »
sf::Rect is very simple, you can copy and paste it in your project. sf::ConvexShape is more complex and has dependencies on other classes of the graphics module, since it's a drawable entity. But why do you need it for collision detection? It only provides functions for drawing, nothing for collision/computations.
Laurent Gomila - SFML developer

Kai

  • Guest
Using sf::ConvexShape without Graphics module
« Reply #2 on: February 22, 2012, 03:49:30 pm »
My physics will support collisions of convex polygons, so I just need a data structure to represent that. I would rather use the one already in SFML. I'd only be using the functions related to points and bounds and be ignoring the ones that manage visual state such as outline and texture.

If this seems unlikely to work, I'll just create my own ConvexShape data structure that can be rendered on the client by converting to a sf::ConvexShape.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Using sf::ConvexShape without Graphics module
« Reply #3 on: February 22, 2012, 03:57:04 pm »
Quote
I'll just create my own ConvexShape data structure that can be rendered on the client by converting to a sf::ConvexShape.

That would be a much better solution in my opinion. What you want to reuse from sf::ConvexShape is only 10 lines of code, it will take you no more than 5 minutes to rewrite it.
Laurent Gomila - SFML developer

Kai

  • Guest
Using sf::ConvexShape without Graphics module
« Reply #4 on: February 22, 2012, 03:59:39 pm »
Sounds good. Thanks for your amazingly fast responses!

 

anything