Welcome, Guest. Please login or register.
Did you miss your activation email?
September 08, 2010, 02:21:24 am
advanced search




Pages: [1]
  Print  
Author Topic: [commited] QuadMesh: warning about not implemented methods  (Read 419 times)
ttrocha
Project Advocate
Sr. Member
*
Offline Offline

Posts: 773


Es gibt nur eine Fortuna....


View Profile WWW
« on: February 08, 2010, 09:05:33 pm »

As collision-detection-algorithms are not implemented for QuadMesh (caution: QuadMesh!=Quad) we need something like a warning! Actually I think that mostly people using HottBJ-Exporter might find this problem. I quite often forget to convert the mesh to triangles and then wonder why the collision is not working. I have for me decided to throw an exception to notify me about this. Might be bit drastic, but as logger-output is very fast overseen it seems to me the best way. Here a patch that is more a suggestion or a first approach. What is the rest of the community thinking how to handle not implemented methods (there might be more of such cases??).

Code:
Index: src/com/jme/scene/QuadMesh.java
===================================================================
--- src/com/jme/scene/QuadMesh.java (revision 4792)
+++ src/com/jme/scene/QuadMesh.java (working copy)
@@ -381,13 +381,13 @@
     @Override
     public void findCollisions(
             Spatial scene, CollisionResults results, int requiredOnBits) {
-        ; // unsupported
+        throw new RuntimeException("FIND COLLISIONS NOT IMPLEMENTS FOR QUADMESH! ("+toString()+")");
     }
 
     @Override
     public boolean hasCollision(
             Spatial scene, boolean checkTriangles, int requiredOnBits) {
-        return false;
+        throw new RuntimeException("hasCollision NOT IMPLEMENTS FOR QUADMESH!");
     }
 }
 

PS: hehe! ok the text could be changed Cheesy
« Last Edit: February 09, 2010, 09:43:51 pm by ttrocha » Logged

___________________________________________________

dev-blog: http://thomas.trocha.com
This is the Internet: http://www.youtube.com/watch?v=6sydrIIpclk
___________________________________________________
sbook
Moderator
Sr. Member
*
Offline Offline

Posts: 948


Perpetually stating the obvious..


View Profile WWW
« Reply #1 on: February 08, 2010, 10:15:08 pm »

I think this is a good idea but the message should probably be more direct like "Not available for QuadMesh, please use triangles".  I'm not totally sure about a RuntimeException though, that does seem a bit extreme, as you note.

Might be bit drastic, but as logger-output is very fast overseen it seems to me the best way.

A bit off topic, but its interesting you bring this up as I was just thinking the same thing when searching through a zillion lines of "INFO: Node Created".  What do you think of using verbosity levels?
Logged

Every living city is in beta
ttrocha
Project Advocate
Sr. Member
*
Offline Offline

Posts: 773


Es gibt nur eine Fortuna....


View Profile WWW
« Reply #2 on: February 08, 2010, 10:24:30 pm »

Well,..thinking about the problem again, I don't think a runtime-exception is too drastic as actually you want to use a functionality that does not exists. And that should not just passed with an error-logentry. Especially collision-detection which might have so many different other error-sources....

The good thing with runtime-exceptions is that you don't have to mark your method with "throws ...." and therefore don't have to catch it if you don't want to.

Logged

___________________________________________________

dev-blog: http://thomas.trocha.com
This is the Internet: http://www.youtube.com/watch?v=6sydrIIpclk
___________________________________________________
sbook
Moderator
Sr. Member
*
Offline Offline

Posts: 948


Perpetually stating the obvious..


View Profile WWW
« Reply #3 on: February 08, 2010, 10:32:32 pm »

Well,..thinking about the problem again, I don't think a runtime-exception is too drastic as actually you want to use a functionality that does not exists. And that should not just passed with an error-logentry. Especially collision-detection which might have so many different other error-sources....

The good thing with runtime-exceptions is that you don't have to mark your method with "throws ...." and therefore don't have to catch it if you don't want to.

Point well taken, excuse my lack of vision  afro
Logged

Every living city is in beta
Tags:
Pages: [1]
  Print  
 
Jump to: