Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (546)
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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
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:

1  
2  
3  
4  
5  
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:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
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?

Greetings,
Mene
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 Vector.java. 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!
Greetings,
Mene

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]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (20 views)
2014-08-19 09:29:53

Tekkerue (21 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (55 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (27 views)
2014-08-08 02:01:56

Norakomi (35 views)
2014-08-06 19:49:38

BurntPizza (64 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!