Jump to content
  • Advertisement
Sign in to follow this  
LifeArtist

OpenGL Best way of handling points and collisions?

This topic is 1008 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey,

 

currently I'am trying to rebuild CurveFever with opengl and python.

 

What I already have:

curveerror.png

 

I'am using a geometry shader to recalculate my lines_adjacency lines into triangle strips.

I am calculating the linethickness and the miter of the edges inside the geometry shader.

 

Problem Nr. 1 This gives me that issue, you can see in the Image. But to fix this, I think I have to know the last recalculated points.

 

Problem Nr. 2 To solve Problem Nr. 1 I thought about to calculate the points on the cpu, because I have to use them for the collission detection anyway. 

 

So my question is should I make a list, then doing my calculations and append those new points to my list and then upload the entire list to the gpu for rendering?

 

Or should fix somehow Problem Nr.1 so I will get a smooth line and then a list adding points with calclulation etc. and just use them for collision detection. But then I have 2 sepperate calculations: GPU and CPU.

Edited by LifeArtist

Share this post


Link to post
Share on other sites
Advertisement

if the rotated quad has the same size for all 'points' you should just render it (with proper rotation and translation) for each point, so you dont need to update vertex buffer, more over, about that cpu solution one way linked list is what you need,

 

i don't understand why you are making that draw on geometry shader.

 

 

one way of using geometry shader is to draw triangle strips, and store each quad last 2 points  in a uniform or texture so you can access it in shader to create continous geometry, but it wont work for collision (since i don't know how you do it but it think you are searching for a point in a list of boxes) the geometry you produce on cpu wont be identical

 

so i think the best way is to go for cpu solution, and calc geometry on cpu for further collision test.

Edited by WiredCat

Share this post


Link to post
Share on other sites

I thought over my implementation and I came finnaly to a better solution without a geometry shader :)

 

My circle have a direction vector. I hope this graphic is understandable:

v3vj4wx5.png

 

So now I'am calculating on the CPU. And just uploading 2 points for one plot to the predefined fixed size buffer.

 

But there is now one problem. I have a LineRenderer class which basically communicats with opengl. And a Line class, which represents a Line in the scene. But where should I have to put my calculated Points aka addPoint(Line class) method. The addPoint(LineRenderer class) method should be inside LineRenderer because I am communicate with opengl in there: using 

gl.glBufferSubData(gl.GL_ARRAY_BUFFER, point._data.nbytes*self._pointCount, point._data.nbytes, point._data)

for uploading the new calculated points.

7mj3bokp.png

 

 

But I dont want to call addPoint(LineRenderer class) outside of Line class. Thats why I calculate the 2 points inside addPoint(Line class) and then add those to points with addPoint(LineRenderer) to the LineRenderer.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!