* Natives are now extracted to user.home based on hash of classpath and last modified of jMonkeyEngine3.jar
* Fixed crash in BloomFilter when screen size is 1x1 git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8471 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
afbf8ad69d
commit
97145d7d4d
@ -111,8 +111,8 @@ public class BloomFilter extends Filter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
|
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
|
||||||
screenWidth = (int) (w / downSamplingFactor);
|
screenWidth = (int) Math.max(1, (w / downSamplingFactor));
|
||||||
screenHeight = (int) (h / downSamplingFactor);
|
screenHeight = (int) Math.max(1, (h / downSamplingFactor));
|
||||||
// System.out.println(screenWidth + " " + screenHeight);
|
// System.out.println(screenWidth + " " + screenHeight);
|
||||||
if (glowMode != GlowMode.Scene) {
|
if (glowMode != GlowMode.Scene) {
|
||||||
preGlowPass = new Pass();
|
preGlowPass = new Pass();
|
||||||
|
@ -37,6 +37,7 @@ import com.jme3.asset.AssetManager;
|
|||||||
import com.jme3.asset.AssetNotFoundException;
|
import com.jme3.asset.AssetNotFoundException;
|
||||||
import com.jme3.asset.DesktopAssetManager;
|
import com.jme3.asset.DesktopAssetManager;
|
||||||
import com.jme3.audio.AudioRenderer;
|
import com.jme3.audio.AudioRenderer;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -51,6 +52,33 @@ public class JmeSystem {
|
|||||||
private static final Logger logger = Logger.getLogger(JmeSystem.class.getName());
|
private static final Logger logger = Logger.getLogger(JmeSystem.class.getName());
|
||||||
private static boolean initialized = false;
|
private static boolean initialized = false;
|
||||||
private static boolean lowPermissions = false;
|
private static boolean lowPermissions = false;
|
||||||
|
private static File storageFolder = null;
|
||||||
|
|
||||||
|
public static synchronized File getStorageFolder(){
|
||||||
|
if (lowPermissions){
|
||||||
|
throw new UnsupportedOperationException("File system access restricted");
|
||||||
|
}
|
||||||
|
if (storageFolder == null){
|
||||||
|
// Initialize storage folder
|
||||||
|
storageFolder = new File(System.getProperty("user.home"), ".jme3");
|
||||||
|
if (!storageFolder.exists()){
|
||||||
|
storageFolder.mkdir();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return storageFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getFullName() {
|
||||||
|
return JmeVersion.FULL_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InputStream getResourceAsStream(String name) {
|
||||||
|
return JmeSystem.class.getResourceAsStream(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static URL getResource(String name) {
|
||||||
|
return JmeSystem.class.getResource(name);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean trackDirectMemory() {
|
public static boolean trackDirectMemory() {
|
||||||
return false;
|
return false;
|
||||||
@ -77,7 +105,6 @@ public class JmeSystem {
|
|||||||
throw new IllegalStateException("Cannot run from EDT");
|
throw new IllegalStateException("Cannot run from EDT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final AppSettings settings = new AppSettings(false);
|
final AppSettings settings = new AppSettings(false);
|
||||||
settings.copyFrom(sourceSettings);
|
settings.copyFrom(sourceSettings);
|
||||||
String iconPath = sourceSettings.getSettingsDialogImage();
|
String iconPath = sourceSettings.getSettingsDialogImage();
|
||||||
@ -317,7 +344,6 @@ public class JmeSystem {
|
|||||||
}
|
}
|
||||||
logger.log(Level.INFO, "Running on {0}", getFullName());
|
logger.log(Level.INFO, "Running on {0}", getFullName());
|
||||||
|
|
||||||
|
|
||||||
if (!lowPermissions) {
|
if (!lowPermissions) {
|
||||||
try {
|
try {
|
||||||
Natives.extractNativeLibs(getPlatform(), settings);
|
Natives.extractNativeLibs(getPlatform(), settings);
|
||||||
@ -326,16 +352,4 @@ public class JmeSystem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFullName() {
|
|
||||||
return "jMonkeyEngine 3.0.0 Beta";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static InputStream getResourceAsStream(String name) {
|
|
||||||
return JmeSystem.class.getResourceAsStream(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static URL getResource(String name) {
|
|
||||||
return JmeSystem.class.getResource(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -51,10 +51,50 @@ public class Natives {
|
|||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(Natives.class.getName());
|
private static final Logger logger = Logger.getLogger(Natives.class.getName());
|
||||||
private static final byte[] buf = new byte[1024];
|
private static final byte[] buf = new byte[1024];
|
||||||
private static File workingDir = new File("").getAbsoluteFile();
|
private static File extractionDirOverride = null;
|
||||||
|
private static File extractionDir = null;
|
||||||
|
|
||||||
public static void setExtractionDir(String name) {
|
public static void setExtractionDir(String name) {
|
||||||
workingDir = new File(name).getAbsoluteFile();
|
extractionDirOverride = new File(name).getAbsoluteFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File getExtractionDir(){
|
||||||
|
if (extractionDirOverride != null){
|
||||||
|
return extractionDirOverride;
|
||||||
|
}
|
||||||
|
if (extractionDir == null){
|
||||||
|
extractionDir = new File(JmeSystem.getStorageFolder(),
|
||||||
|
"natives_" + Integer.toHexString(computeNativesHash()) );
|
||||||
|
if (!extractionDir.exists()){
|
||||||
|
extractionDir.mkdir();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return extractionDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int computeNativesHash(){
|
||||||
|
try {
|
||||||
|
String classpath = System.getProperty("java.class.path");
|
||||||
|
URL url = Natives.class.getResource("");
|
||||||
|
if (url != null) {
|
||||||
|
StringBuilder sb = new StringBuilder(url.toString());
|
||||||
|
if (sb.indexOf("jar:") == 0) {
|
||||||
|
sb.delete(0, 4);
|
||||||
|
sb.delete(sb.indexOf("!"), sb.length());
|
||||||
|
sb.delete(sb.lastIndexOf("/") + 1, sb.length());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
url = new URL(sb.toString());
|
||||||
|
} catch (MalformedURLException ex) {
|
||||||
|
throw new UnsupportedOperationException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
URLConnection conn = url.openConnection();
|
||||||
|
int hash = classpath.hashCode() ^ (int)conn.getLastModified();
|
||||||
|
return hash;
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new UnsupportedOperationException(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void extractNativeLib(String sysName, String name) throws IOException {
|
protected static void extractNativeLib(String sysName, String name) throws IOException {
|
||||||
@ -81,7 +121,7 @@ public class Natives {
|
|||||||
|
|
||||||
URLConnection conn = url.openConnection();
|
URLConnection conn = url.openConnection();
|
||||||
InputStream in = conn.getInputStream();
|
InputStream in = conn.getInputStream();
|
||||||
File targetFile = new File(workingDir, fullname);
|
File targetFile = new File(getExtractionDir(), fullname);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (targetFile.exists()){
|
if (targetFile.exists()){
|
||||||
@ -123,24 +163,6 @@ public class Natives {
|
|||||||
logger.log(Level.FINE, "Copied {0} to {1}", new Object[]{fullname, targetFile});
|
logger.log(Level.FINE, "Copied {0} to {1}", new Object[]{fullname, targetFile});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getExtractionDir() {
|
|
||||||
URL temp = Natives.class.getResource("");
|
|
||||||
if (temp != null) {
|
|
||||||
StringBuilder sb = new StringBuilder(temp.toString());
|
|
||||||
if (sb.indexOf("jar:") == 0) {
|
|
||||||
sb.delete(0, 4);
|
|
||||||
sb.delete(sb.indexOf("!"), sb.length());
|
|
||||||
sb.delete(sb.lastIndexOf("/") + 1, sb.length());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return new URL(sb.toString()).toString();
|
|
||||||
} catch (MalformedURLException ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean isUsingNativeBullet(){
|
protected static boolean isUsingNativeBullet(){
|
||||||
try {
|
try {
|
||||||
Class clazz = Class.forName("com.jme3.bullet.util.NativeMeshUtil");
|
Class clazz = Class.forName("com.jme3.bullet.util.NativeMeshUtil");
|
||||||
@ -171,14 +193,11 @@ public class Natives {
|
|||||||
needJInput = settings.useJoysticks();
|
needJInput = settings.useJoysticks();
|
||||||
|
|
||||||
if (needLWJGL) {
|
if (needLWJGL) {
|
||||||
logger.log(Level.INFO, "Extraction Directory #1: {0}", getExtractionDir());
|
logger.log(Level.INFO, "Extraction Directory: {0}", getExtractionDir().toString());
|
||||||
logger.log(Level.INFO, "Extraction Directory #2: {0}", workingDir.toString());
|
|
||||||
logger.log(Level.INFO, "Extraction Directory #3: {0}", System.getProperty("user.dir"));
|
|
||||||
// LWJGL supports this feature where
|
// LWJGL supports this feature where
|
||||||
// it can load libraries from this path.
|
// it can load libraries from this path.
|
||||||
// This is a fallback method in case the OS doesn't load
|
System.setProperty("org.lwjgl.librarypath", getExtractionDir().toString());
|
||||||
// native libraries from the working directory (e.g Linux).
|
|
||||||
System.setProperty("org.lwjgl.librarypath", workingDir.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user