瀏覽代碼

Merge branch 'master' into PBRisComing

Nehon 9 年之前
父節點
當前提交
4726da1e41

+ 8 - 2
jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java

@@ -46,7 +46,9 @@ import com.jme3.scene.plugins.blender.objects.Properties;
  */
 public class TemporalMesh extends Geometry {
     private static final Logger        LOGGER                    = Logger.getLogger(TemporalMesh.class.getName());
-
+    /** A minimum weight value. */
+    private static final double 	   MINIMUM_BONE_WEIGHT 		 = FastMath.DBL_EPSILON;
+    
     /** The blender context. */
     protected final BlenderContext     blenderContext;
 
@@ -530,7 +532,11 @@ public class TemporalMesh extends Geometry {
                         for (Entry<String, Integer> entry : boneIndexes.entrySet()) {
                             if (vertexGroupsForVertex.containsKey(entry.getKey())) {
                                 float weight = vertexGroupsForVertex.get(entry.getKey());
-                                if (weight > 0) {// no need to use such weights
+                                if (weight > MINIMUM_BONE_WEIGHT) {
+                                	// only values of weight greater than MINIMUM_BONE_WEIGHT are used
+                                	// if all non zero weights were used, and they were samm enough, problems with normalisation would occur
+                                	// because adding a very small value to 1.0 will give 1.0
+                                	// so in order to avoid such errors, which can cause severe animation artifacts we need to use some minimum weight value
                                     boneBuffersForVertex.put(weight, entry.getValue());
                                 }
                             }

+ 2 - 0
jme3-core/src/main/resources/Common/MatDefs/Gui/Gui.frag

@@ -1,3 +1,5 @@
+#import "Common/ShaderLib/GLSLCompat.glsllib"
+
 #ifdef TEXTURE
     uniform sampler2D m_Texture;
     varying vec2 texCoord;

+ 13 - 2
jme3-core/src/main/resources/Common/MatDefs/Gui/Gui.j3md

@@ -7,8 +7,8 @@ MaterialDef Default GUI {
     }
 
     Technique {
-        VertexShader GLSL100:   Common/MatDefs/Gui/Gui.vert
-        FragmentShader GLSL100: Common/MatDefs/Gui/Gui.frag
+        VertexShader GLSL150:   Common/MatDefs/Gui/Gui.vert
+        FragmentShader GLSL150: Common/MatDefs/Gui/Gui.frag
 
         WorldParameters {
             WorldViewProjectionMatrix
@@ -21,6 +21,17 @@ MaterialDef Default GUI {
     }
 
     Technique {
+        VertexShader GLSL100:   Common/MatDefs/Gui/Gui.vert
+        FragmentShader GLSL100: Common/MatDefs/Gui/Gui.frag
+
+        WorldParameters {
+            WorldViewProjectionMatrix
+        }
+
+        Defines {
+            TEXTURE : Texture
+            VERTEX_COLOR : VertexColor
+        }
     }
 
 }

+ 2 - 0
jme3-core/src/main/resources/Common/MatDefs/Gui/Gui.vert

@@ -1,3 +1,5 @@
+#import "Common/ShaderLib/GLSLCompat.glsllib"
+
 uniform mat4 g_WorldViewProjectionMatrix;
 uniform vec4 m_Color;
 

+ 44 - 0
jme3-core/src/main/resources/joystick-mapping.properties

@@ -69,3 +69,47 @@ Microsoft\ PC-joystick\ driver.12=POV +Y
 Microsoft\ PC-joystick\ driver.13=POV +X
 Microsoft\ PC-joystick\ driver.14=POV -Y
 Microsoft\ PC-joystick\ driver.15=POV -X
+
+# Logitech F310 gamepad with dip switch DirectInput
+Logitech\ Dual\ Action.1=2
+Logitech\ Dual\ Action.2=1
+Logitech\ Dual\ Action.3=0
+Logitech\ Dual\ Action.0=3
+
+# Logitech F310 gamepad with dip switch XInput
+Gamepad\ F310\ (Controller).0=2
+Gamepad\ F310\ (Controller).1=1
+Gamepad\ F310\ (Controller).2=3
+Gamepad\ F310\ (Controller).3=0
+
+Gamepad\ F310\ (Controller).6=8
+Gamepad\ F310\ (Controller).7=9
+
+Gamepad\ F310\ (Controller).8=10
+Gamepad\ F310\ (Controller).9=11
+
+Gamepad\ F310\ (Controller).rx=z
+Gamepad\ F310\ (Controller).ry=rz
+
+# requires custom code to support trigger buttons but this
+# keeps it from confusing the .rx mapping.
+Gamepad\ F310\ (Controller).z=trigger
+
+# Alternate version of the XBOX 360 controller
+XBOX\ 360\ For\ Windows\ (Controller).0=2
+XBOX\ 360\ For\ Windows\ (Controller).1=1
+XBOX\ 360\ For\ Windows\ (Controller).2=3
+XBOX\ 360\ For\ Windows\ (Controller).3=0
+
+XBOX\ 360\ For\ Windows\ (Controller).6=8
+XBOX\ 360\ For\ Windows\ (Controller).7=9
+
+XBOX\ 360\ For\ Windows\ (Controller).8=10
+XBOX\ 360\ For\ Windows\ (Controller).9=11
+
+XBOX\ 360\ For\ Windows\ (Controller).rx=z
+XBOX\ 360\ For\ Windows\ (Controller).ry=rz
+
+# requires custom code to support trigger buttons but this
+# keeps it from confusing the .rx mapping.
+XBOX\ 360\ For\ Windows\ (Controller).z=trigger

+ 1 - 1
jme3-desktop/src/main/java/com/jme3/system/NativeLibraryLoader.java

@@ -149,7 +149,7 @@ public final class NativeLibraryLoader {
         registerNativeLibrary("glfw-lwjgl3", Platform.Windows32, "native/windows/glfw32.dll");
         registerNativeLibrary("glfw-lwjgl3", Platform.Windows64, "native/windows/glfw.dll");
         registerNativeLibrary("glfw-lwjgl3", Platform.Linux32, "native/linux/libglfw32.so");
-        registerNativeLibrary("glfw-lwjgl3", Platform.Linux64, "native/linux/libglfw.dll");
+        registerNativeLibrary("glfw-lwjgl3", Platform.Linux64, "native/linux/libglfw.so");
         registerNativeLibrary("glfw-lwjgl3", Platform.MacOSX32, "native/macosx/libglfw.dylib");
         registerNativeLibrary("glfw-lwjgl3", Platform.MacOSX64, "native/macosx/libglfw.dylib");
 

+ 56 - 23
jme3-jogl/src/main/java/com/jme3/input/jogl/NewtMouseInput.java

@@ -50,6 +50,8 @@ import com.jogamp.nativewindow.util.DimensionImmutable;
 import com.jogamp.nativewindow.util.PixelFormat;
 import com.jogamp.nativewindow.util.PixelRectangle;
 import com.jogamp.nativewindow.util.Point;
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.event.WindowEvent;
 
 public class NewtMouseInput  implements MouseInput, MouseListener {
     
@@ -106,40 +108,67 @@ public class NewtMouseInput  implements MouseInput, MouseListener {
 
         component = comp;
         component.addMouseListener(this);
+        component.addWindowListener(new WindowAdapter(){
+
+            @Override
+            public void windowGainedFocus(WindowEvent e) {
+                setCursorVisible(visible);
+            }
+
+            @Override
+            public void windowLostFocus(WindowEvent e) {
+                //without those lines,
+                //on Linux (OpenBox) the mouse is not restored if invisible (eg via Alt-Tab)
+                component.setPointerVisible(true);
+                component.confinePointer(false);
+            }
+            
+        });
     }
 
+    @Override
     public void initialize() {
     }
 
+    @Override
     public void destroy() {
     }
 
+    @Override
     public boolean isInitialized() {
         return true;
     }
 
+    @Override
     public void setInputListener(RawInputListener listener) {
         this.listener = listener;
     }
 
+    @Override
     public long getInputTimeNanos() {
         return System.nanoTime();
     }
 
+    @Override
     public void setCursorVisible(boolean visible) {
-        if (this.visible != visible) {
-            lastKnownLocation.setX(0);
-            lastKnownLocation.setY(0);
-
-            this.visible = visible;
-            component.setPointerVisible(visible);
-            if (!visible) {
-                recenterMouse(component);
-            }
-        }
+        lastKnownLocation.setX(0);
+        lastKnownLocation.setY(0);
+
+        this.visible = visible;
+        component.setPointerVisible(visible);
+        component.confinePointer(!visible);
+        hack_confinePointer();
     }
 
+    private void hack_confinePointer() {
+      if (component.hasFocus() && component.isPointerConfined() && !component.isPointerVisible()) {
+        recenterMouse(component);
+      }
+    }
+    
+    @Override
     public void update() {
+      if (!component.hasFocus()) return;
         if (cursorMoved) {
             int newX = location.getX();
             int newY = location.getY();
@@ -173,15 +202,18 @@ public class NewtMouseInput  implements MouseInput, MouseListener {
         }
     }
 
+    @Override
     public int getButtonCount() {
         return 3;
     }
 
+    @Override
     public void mouseClicked(MouseEvent awtEvt) {
 //        MouseButtonEvent evt = new MouseButtonEvent(getJMEButtonIndex(arg0), false);
 //        listener.onMouseButtonEvent(evt);
     }
 
+    @Override
     public void mousePressed(MouseEvent newtEvt) {
         MouseButtonEvent evt = new MouseButtonEvent(getJMEButtonIndex(newtEvt), true, newtEvt.getX(), newtEvt.getY());
         evt.setTime(newtEvt.getWhen());
@@ -190,7 +222,8 @@ public class NewtMouseInput  implements MouseInput, MouseListener {
         }
     }
 
-    public void mouseReleased(MouseEvent awtEvt) {
+    @Override
+     public void mouseReleased(MouseEvent awtEvt) {
         MouseButtonEvent evt = new MouseButtonEvent(getJMEButtonIndex(awtEvt), false, awtEvt.getX(), awtEvt.getY());
         evt.setTime(awtEvt.getWhen());
         synchronized (eventQueue) {
@@ -198,18 +231,17 @@ public class NewtMouseInput  implements MouseInput, MouseListener {
         }
     }
 
+    @Override
     public void mouseEntered(MouseEvent awtEvt) {
-        if (!visible) {
-            recenterMouse(component);
-        }
+        hack_confinePointer();
     }
 
+    @Override
     public void mouseExited(MouseEvent awtEvt) {
-        if (!visible) {
-            recenterMouse(component);
-        }
+        hack_confinePointer();
     }
 
+    @Override
     public void mouseWheelMoved(MouseEvent awtEvt) {
         //FIXME not sure this is the right way to handle this case
         // [0] should be used when the shift key is down
@@ -218,10 +250,12 @@ public class NewtMouseInput  implements MouseInput, MouseListener {
         cursorMoved = true;
     }
 
+    @Override
     public void mouseDragged(MouseEvent awtEvt) {
         mouseMoved(awtEvt);
     }
 
+    @Override
     public void mouseMoved(MouseEvent awtEvt) {
         if (isRecentering) {
             // MHenze (cylab) Fix Issue 35:
@@ -239,16 +273,14 @@ public class NewtMouseInput  implements MouseInput, MouseListener {
             int dy = awtEvt.getY() - lastKnownLocation.getY();
             location.setX(location.getX() + dx);
             location.setY(location.getY() + dy);
-            if (!visible) {
-                recenterMouse(component);
-            }
+            hack_confinePointer();
             lastKnownLocation.setX(awtEvt.getX());
             lastKnownLocation.setY(awtEvt.getY());
 
             cursorMoved = true;
         }
     }
-
+    
     // MHenze (cylab) Fix Issue 35: A method to generate recenter the mouse to allow the InputSystem to "grab" the mouse
     private void recenterMouse(final GLWindow component) {
         eventsSinceRecenter = 0;
@@ -287,12 +319,13 @@ public class NewtMouseInput  implements MouseInput, MouseListener {
         return index;
     }
 
+    @Override
     public void setNativeCursor(JmeCursor cursor) {
         final ByteBuffer pixels = Buffers.copyIntBufferAsByteBuffer(cursor.getImagesData());
         final DimensionImmutable size = new Dimension(cursor.getWidth(), cursor.getHeight());
         final PixelFormat pixFormat = PixelFormat.RGBA8888;
         final PixelRectangle.GenericPixelRect rec = new PixelRectangle.GenericPixelRect(pixFormat, size, 0, true, pixels);
-        final PointerIcon joglCursor = component.getScreen().getDisplay().createPointerIcon(rec, cursor.getXHotSpot(), cursor.getYHotSpot());
+        final PointerIcon joglCursor = component.getScreen().getDisplay().createPointerIcon(rec, cursor.getXHotSpot(), cursor.getHeight() - cursor.getYHotSpot());
         component.setPointerIcon(joglCursor);
     }
-}
+}