Hello,
Do you guys think we could incorporate a vector math library as part of LOVE? I know the LOVE community prides itself on a DIY, "don't force me into a particular way of doing things" kind of spirit, but everyone does the same things with vectors: add, subtract, dot product, normalize, etc. Even though it's the same functionality, everyone implements it with a slightly different interface, making it difficult to interop with different libraries. You end up writing a lot of code that translates between variations of vector interfaces.
Another future benefit could be that performance sensitive vector operations could potentially be implemented in C/C++ behind the scenes, without the end user devs having to worry about bundling native code.
Maybe initially we could bundle hump.vector_light as love.vector? Or if not bundle a particular implementation, create a type signature that anyone can implement so libraries can assume a standard interface, if not implementation.
Standardize on a vector math library?
Standardize on a vector math library?
----------------------------------------
Sluicer Games
Sluicer Games
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Standardize on a vector math library?
I wouldn't use it though, and I would recommend CPML more than hump.vector too. And I don't understand why you can't go and use hump in your code. I don't see any need on vector classes. Maybe we could add some vector math to [wiki]love.math[/wiki] but I would be more interested in transformation matrices and a way to used with [wiki]love.graphics[/wiki]
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Standardize on a vector math library?
If LOVE included a vector library then people would probably assume its other APIs should accept vectors, but...
viewtopic.php?f=3&t=81457&start=50#p193807
If good solutions are proposed for those problems though, then I'd be all ears.
viewtopic.php?f=3&t=81457&start=50#p193807
Having the vector code be in C++ would also (for the most part) either be as efficient or slower than having it in Lua, since love uses LuaJIT.slime wrote:The main problem with LÖVE's APIs using vector objects is that in Lua, vector objects tend to create a lot of garbage if used heavily. So having them required for using LÖVE functions prevents optimal performance. Some engines go to extreme lengths to try to work around that: https://www.youtube.com/watch?v=wTjyM7d7_YA#t=23m6sspill wrote:it would be really cool if LÖVE used 2d vectors instead of x/y coordinates everywhere.
I don't want to make vector-specific function variants either, as that would make the API a lot messier.
If good solutions are proposed for those problems though, then I'd be all ears.
Last edited by slime on Mon Aug 29, 2016 2:32 am, edited 1 time in total.
Re: Standardize on a vector math library?
Ah ok, looks like you guys have discussed this in depth. (Couldn't find it from searching, should I start a FAQ wiki page for questions like these?)
The garbage generation is a good point. I'll think about it for a bit.
The garbage generation is a good point. I'll think about it for a bit.
----------------------------------------
Sluicer Games
Sluicer Games
Re: Standardize on a vector math library?
You could write vector library to use pools internally, you know. No garbage.
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Standardize on a vector math library?
In actuality, that was also discussed a few times, at length, as wellclofresh wrote:(Couldn't find it from searching, should I start a FAQ wiki page for questions like these?)
I planned to do something like that, but alas, i hadn't had time for it yet, nor did i think out a neat format for it.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Standardize on a vector math library?
You pretty much have to choose between arithmetic operator overloads or no-garbage vectors (e.g. CPML has no-garbage APIs, and then the arithmetic operators which do generate garbage).raidho36 wrote:You could write vector library to use pools internally, you know. No garbage.
I did experiment with the gc metamethod and a pool of FFI vectors, but it ended up being slower than just plain FFI structs of doubles (which still generates garbage).
Re: Standardize on a vector math library?
Started it: https://love2d.org/wiki/FAQzorg wrote:In actuality, that was also discussed a few times, at length, as wellclofresh wrote:(Couldn't find it from searching, should I start a FAQ wiki page for questions like these?)
I planned to do something like that, but alas, i hadn't had time for it yet, nor did i think out a neat format for it.
It's not linked from anywhere though.
----------------------------------------
Sluicer Games
Sluicer Games
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Standardize on a vector math library?
I started its discussion page, see there for what i had, and am still, planning on. As for linkage, it would be nice to have a link, but the version history page lacks one as well, so idkclofresh wrote:Started it: https://love2d.org/wiki/FAQ
It's not linked from anywhere though.
/OFF-TOPIC
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Standardize on a vector math library?
Just to be clear, this is about in-engine implementation, not a LUA library?slime wrote: You pretty much have to choose between arithmetic operator overloads or no-garbage vectors (e.g. CPML has no-garbage APIs, and then the arithmetic operators which do generate garbage).
I did experiment with the gc metamethod and a pool of FFI vectors, but it ended up being slower than just plain FFI structs of doubles (which still generates garbage).
Who is online
Users browsing this forum: Ahrefs [Bot] and 1 guest