Commit Graph

34 Commits

Author SHA1 Message Date
vrld ece4ff6472 Make love.math a singleton. Remove code duplication. Add love.math.triangulate.
love::math::Math is now a singleton, so other modules can use it via
love::math::Math::instance.


Removed duplicate implementations of various rng helper functions.
ParticleSystem now uses love::math::Math's RNG.


New function: love.math.triangulate(vertices)

Accepts a table or list of x/y coordinate pairs and returns a table of tables.
The inner tables are the triangles the polygon is composed of.

Works on all *simple* polygons, i.e. a closed chain of vertices that does not
intersect itself. Attempting to triangulate non-simple polygons is undefined
behavior - in the best case it throws an error, in the worst case it returns
an invalid triangulation.

Polygons must be ordered in *clockwise order* with respect to the love
coordinate system. Attempting to triangulate a ccw polygon will throw an
error.

Examples:

  triangles = love.math.triangulate(0,0, 1,1, 2,0, 2,2, 0,2)
  triangles == {
      {1,1, 2,0, 2,2},
      {1,1, 2,2, 0,2},
      {1,1, 0,2, 0,0},
  }

  triangles = love.math.triangulate({0,0, 1,1, 2,0, 2,2, 0,2})
  -- same as above

  triangles = love.math.triangulate(0,2, 2,2, 2,0, 1,1, 0,0)
  -- error - polygons is in counterclockwise order

  triangles = love.math.triangulate(0,0, 1,3, 2,0, 2,2, 0,2)
  -- undefined behavior - polygon intersects itself (because of edge 1,3)
2013-03-13 20:48:39 +01:00
Alex Szpakowski 4704c4e19e Cleaned up some ParticleSystem and Quad code 2013-03-11 17:56:55 -03:00
Alex Szpakowski 318f335c7c ParticleSystem:setQuads can now accept a table argument, cleaned up the ParticleSystem quad code
--HG--
branch : particlesystem-quads
2013-03-11 01:44:43 -03:00
Alex Szpakowski d30809ebff Added ParticleSystem:setQuads(q1, q2, ...), quads are chosen based on current particle lifetime in a similar style to ParticleSystem:setColors
--HG--
branch : particlesystem-quads
2013-03-10 03:40:25 -03:00
Alex Szpakowski 1945b7975d Cleaned up exception handling code when creating new fonts, spritebatches, and shaders 2013-02-14 21:49:11 -04:00
Alex Szpakowski 96161c66f6 Updated copyright text for the new year 2013-02-05 05:32:49 -04:00
Alexander Szpakowski 8fdd6cbbb2 Merged in from main repository (originally from love-mipmap fork) 2013-01-12 18:07:14 -05:00
Alexander Szpakowski eb98e8cc48 Removed unnecessary tabs in empty lines, fixed texture filtering when the minification and mipmap filter are the same 2013-01-07 06:56:59 -04:00
Alexander Szpakowski 6560019829 opengl graphics module files now always include OpenGL.h rather than GLee.h 2013-01-01 17:54:14 -04:00
rude 54498ce378 Apply slime73's ParticleSystem patch. 2012-11-18 11:02:30 +01:00
vrld 4ec7609d37 Fix issue #437: Area-based particle spawn.
New particles are spawned around the particle emitter position according to a
configurabe distribution.

New functionality:

particlesystem:setAreaSpread(distributon, x, y)
distribution, x, y = particlesystem:getAreaSpread()

Where `distribution' is one of "none", "uniform", "normal".
`x' and `y' take different meaning based on the distribution:

  * none:    no area spread - particles spawned at emitter position.
  * uniform: particle spawned at px,py in the rectangle around emitter
             position ex,ey, i.e.:
             ex - x < px < ex + x, ey - y < py < ey + y,
  * normal:  particle position drawn from a normal/gaussian distribution
             with mean ex,ey and standard deviation x,y, i.e.:
             px \in N(ex, x²), py \in N(ey, y²).
2012-09-10 19:58:44 +02:00
Bart van Strien 7793e7f02f CRLF to LF 2012-07-04 14:40:24 +02:00
rude 81c38e22d0 Applied the new style guidelines.
Well, sort of. Lot's more to be done, but this is a start.
2012-06-28 23:52:33 +02:00
Bill Meltsner 86abc9323b Add ParticleSystem:getPosition (issue #368) 2012-02-04 11:31:07 -05:00
Bill Meltsner be55579a22 Happy New Year, have an enormous diff 2012-01-09 02:41:11 -06:00
vrld a855a01f02 Fix two particle system typos (thanks, Boolsheet!) 2011-12-26 21:29:47 +01:00
Bill Meltsner 969c53e592 make love build on OS X again - there's no need to include gl.h directly, GLee.h does that for us in a cross-platform way 2011-12-19 00:28:45 -06:00
Bart van Strien 7c8fff979a Create love.window, abstract SDL out of love.graphics 2011-12-11 16:55:52 +01:00
Bart van Strien 0aae9684b3 Automated formatting fix 2011-11-16 11:32:41 +01:00
rude 9a4b921605 Particles now have fixed origin. (ParticleSystem::SetPosition will only affect
new particles, and existing particles will not gravitate against the new point).

This is another requirement to implement ParticleSystem in GLSL.
2011-07-24 18:47:13 +02:00
rude e1d1ebb2f1 Fix warnings in MSVC 2010. 2011-07-24 18:32:11 +02:00
vrld d420d68048 Add shear transformation and transform object (issue #152).
Add origin parameters to love.graphics.print.

New shear parameters kx,ky for:
- love.graphics.draw,
- love.graphics.drawq,
- love.graphics.print,
- SpriteBatch:add,
- SpriteBatch:addq.

Transform objects apply to:
- love.graphics.draw,
- love.graphics.drawq,
- love.graphics.print.
2011-07-05 14:33:34 +02:00
vrld 2425ea9979 Change particle system to accept an arbitrary number of colors and sizes to inerpolate.
API changes:
- ParticleSystem:setSize(min, max, var) -> ParticleSystem:setSizes(s0, ..., sN)
  !! ParticleSystem:setSize() drops variation parameter !!
- ParticleSystem:setColor([color1], [color2]) -> ParticleSystem:setColor([color1], ..., [colorN])

--HG--
branch : minor
2011-04-06 21:24:09 +02:00
Bill Meltsner fde708160e bringing in the new year by changing every 2010 to 2011 2011-01-15 14:40:27 -06:00
rude ea38442770 Fixed VS project files, and a bug where ParticleSystem::setSprite did not retain the new Image. 2010-05-04 18:06:10 +02:00
Bill Meltsner 80bea88c9f replaced a few hardcoded radian->degree conversions with LOVE_TODEG 2010-04-14 11:10:17 -04:00
rude aa01c984b9 Updated all dates to 2010. 2010-01-31 16:54:47 +01:00
bart@bartbes.ath.cx af01b840a1 Several rad2deg conversions for glRotate 2009-11-30 08:21:48 +01:00
bart@bartbes.ath.cx 692fd9a890 Converted ParticleSystem to radians 2009-11-29 13:40:37 +01:00
bill@Ixion 8d666d0284 user can now manually set the offset for particle rotation 2009-08-30 05:05:27 -05:00
bill@Ixion 98db275e76 particles now rotate around their center 2009-08-30 04:33:54 -05:00
rude a3bff7cde9 Reintegrated ParticleSystem. 2009-08-26 00:14:40 +02:00
rude 84bf839872 Removed classes which should be implemented in Lua (or need of re-implementation). 2009-07-26 23:08:40 +02:00
rude dcb3dfd83d Initial Mercurial commit. 2009-07-26 15:46:49 +02:00