Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Performance Tuning / Re: Java Generics "Compiler" on: 2009-11-02 12:31:04
Yes, this was my first idea, too. Partial specialization could be archived via annotations or maybe even by using concrete types like:
class Triangle2<Real extends Number> {
  public boolean isInCircumCircle(Vector2<Float>) {
    // Numerical stability aware calculation

  public boolean isInCircumCircle(Vector2<Integer>) {
    // Simple calculation


I also considered using bytecode manipulation tools, but that would be almost impossible due to type erasure.
If using this approach there still is the problem that you can't use the normal operators. Thus I might end up using a generator which would know that Triangle2f is supposed to be Triangle2<Float> and would generate Triangle2i. The problem here: Triangle2f will contain isInCircumCircle(Vector2f) and isInCircumCircle(Vector2i), thus I need to create Vector2i first... anyway, i guess i'll finish the float implementation first and maybe I'm even better off using some simple regex and copy/replace.
If I write a tool I'll let you know, just wanted to know if someone had done some stuff like this before.
2  Game Development / Performance Tuning / Re: Java Generics "Compiler" on: 2009-11-01 13:52:52
Ok, I just wanted to do some micro-benchmarking to see what the compiler/run time optimizer might be able to archive.
Again I'm quite disappointed. A friend told me I would be able to use the normal operators (+, -, *, /) if my generic parameter was constrained to Number, but this is not the case. So for serious calculations the code would become totally unreadable.
When I first did some java stuff I was quite euphoric about the ease of the language, but these are serious limitations: You're either unmaintainable and probably slow or inflexible.
For now I will stick to
Just write the class using int. If you want to specialise it with different primitive, you're just going to have to bite the bullet and do it manually.
Thanks again!
3  Game Development / Performance Tuning / Re: Java Generics "Compiler" on: 2009-10-27 13:18:40
Thanks, that looks interesting, especially the tool idea sound what I want.
But I think I didn't express me clearly enough, when I spoke about Vector I meant the mathematical Vectors that have dot product and so on. E.g. I'd like to replace Java3d's Vector3f with an Vector3<float> and get the exact same results (on a bytecode level) but it'll be more flexible, because I could use it in this manner:

class NavMesh<REAL extends Number> {
    Vector3<REAL> someInternalValue;

    public void addPoint(Vector3<REAL> point);

And then some tool would process the whole source code and give me:

class NavMeshf {
    Vector3f someInternalValue;

    public void addPoint(Vector3f point);

class NavMeshd {
    Vector3d someInternalValue;

    public void addPoint(Vector3d point);

class NavMeshi {
    Vector3i someInternalValue;

    public void addPoint(Vector3i point);

And replace all occurrences of NavMesh<float> with NavMeshf and so on...
4  Game Development / Performance Tuning / Re: Java Generics "Compiler" on: 2009-10-26 23:16:09
Thanks a lot so far!
In the grand scheme of things it's rarely a performance hit.

I read something different, I think in "effective java", but I'll give it a try and if it doesn't work... well find and replace will probably Grin

BTW didn't know the "Java interns Integer objects from -127 to 127"... but if I understood it right it just means, that all Integer instances with a value of e.g. 110 are the same reference (and that is true for any other number in this range)

Anyways, as said I'll give it a try!
5  Game Development / Performance Tuning / Re: Quadtree for moving objects on: 2009-10-26 14:59:17
Hi, I was playing around a bit with this matter the other day and I found "kinetic data structures" to be very interesting for something like this. I'm short on time right now, but as a brief explanation: For each entry calculate the distance to the border of the quadtree node it's in. Then from the distance and the (maximal) movement speed calculate when the next update might be possible. Simulate on and just check the time if there's any need to update. If no update is required you're done, otherwise you just need to update a few entities (usually).
I have tried to implement it and it seems to work so far, but I neither have any benchmarks nor any real tests I made about stability etc. ...I just liked the idea Grin
What do you think about this approach?

6  Game Development / Performance Tuning / Java Generics "Compiler" on: 2009-10-26 14:42:57
Hi Folks, my first post here, so greetings and thanks for all the great topics I already looked at Grin
I'm searching quite a while now for something that I would call a generics compiler.
The Problem: I wrote a NavMesh class that calculates an approximation to the minimal convex polygons between obstacle polygons. It's working quite fine, but sometimes I get floating-point related errors that lead to completely wrong meshes. To solve this I could use additional math to prevent this, but according to the site I found the formulas on it will add about 30% overhead and since I will need to update the mesh in-game I'm considering to change to integer arithmetic completely.
Now due to the IMO poor implementation of Java generics, I didn't use them to abstract the base datatype because that would lead to a lot of autoboxing and unnecessary references. So what I imagine is something like this:
You have a class Vector<BaseType extends Number> in Now I want some tool that can produce a VectorI / VectorF class that would create the same class, with the same methods and so on just replace the BaseType by int/float (not Integer/Float). Another approach would be some sort of bytecode manipulation tool, that is able to completely replace all Vector<Float> with VectorF, but I think I would prefer the first approach since I would be able to do something like "manual partial specialization".
Anyway, as I said I couldn't find something like that.

Thanks for any advice!

PS: As you might have guessed I used to do most stuff with C++, so if my idea is just not a good "java-aproach", please let me know Grin
Pages: [1]
Jesse (10 views)
2015-07-29 04:35:27

Riven (33 views)
2015-07-27 16:38:00

Riven (16 views)
2015-07-27 15:35:20

Riven (20 views)
2015-07-27 12:26:13

Riven (10 views)
2015-07-27 12:23:39

BurntPizza (28 views)
2015-07-25 00:14:37

BurntPizza (39 views)
2015-07-24 22:06:39

BurntPizza (22 views)
2015-07-24 06:06:53

NoxInc (25 views)
2015-07-22 22:16:53

NoxInc (17 views)
2015-07-22 22:13:39
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!