diff --git a/src/main/java/com/sonicether/soundphysics/Config.java b/src/main/java/com/sonicether/soundphysics/Config.java index acbfacf6..5a880d34 100644 --- a/src/main/java/com/sonicether/soundphysics/Config.java +++ b/src/main/java/com/sonicether/soundphysics/Config.java @@ -43,16 +43,9 @@ public class Config { public static float sandReflectivity; public static float snowReflectivity; - // misc - public static boolean debugLogging = false; - public static boolean occlusionLogging = false; - public static boolean environmentLogging = false; - public static boolean performanceLogging = false; - private static final String categoryGeneral = "General"; private static final String categoryPerformance = "Performance"; private static final String categoryMaterialProperties = "Material properties"; - private static final String categoryMisc = "Misc"; static { instance = new Config(); @@ -83,7 +76,6 @@ public List getConfigElements() { list.add(new ConfigElement(this.forgeConfig.getCategory(Config.categoryGeneral))); list.add(new ConfigElement(this.forgeConfig.getCategory(Config.categoryPerformance))); list.add(new ConfigElement(this.forgeConfig.getCategory(Config.categoryMaterialProperties))); - list.add(new ConfigElement(this.forgeConfig.getCategory(Config.categoryMisc))); return list; } @@ -140,15 +132,6 @@ private void syncConfig() { snowReflectivity = this.forgeConfig.getFloat("Snow Reflectivity", categoryMaterialProperties, 0.2f, 0.0f, 1.0f, "Sound reflectivity for snow blocks."); - // misc - debugLogging = this.forgeConfig.getBoolean("Debug Logging", categoryMisc, false, "General debug logging"); - occlusionLogging = this.forgeConfig.getBoolean("Occlusion Logging", categoryMisc, false, - "Occlusion tracing information logging"); - environmentLogging = this.forgeConfig.getBoolean("Environment Logging", categoryMisc, false, - "Environment evaluation information logging"); - performanceLogging = this.forgeConfig.getBoolean("Performance Logging", categoryMisc, false, - "Performance information logging"); - if (this.forgeConfig.hasChanged()) { this.forgeConfig.save(); SoundPhysics.applyConfigChanges(); diff --git a/src/main/java/com/sonicether/soundphysics/CoreModInjector.java b/src/main/java/com/sonicether/soundphysics/CoreModInjector.java index bf3ae720..76153951 100644 --- a/src/main/java/com/sonicether/soundphysics/CoreModInjector.java +++ b/src/main/java/com/sonicether/soundphysics/CoreModInjector.java @@ -151,27 +151,19 @@ private byte[] patchMethodInClass(String className, final byte[] bytes, final St final String targetInvocationMethodName, final String targetInvocationMethodSignature, final InsnList instructionsToInject, final boolean insertBefore, final int nodesToDeleteBefore, final int nodesToDeleteAfter, final boolean deleteTargetNode, final int targetNodeOffset) { - log("//// Patching Class: " + className); - // Setup ASM class manipulation stuff final ClassNode classNode = new ClassNode(); final ClassReader classReader = new ClassReader(bytes); classReader.accept(classNode, 0); - - // Now we loop over all of the methods declared inside the class until - // we get to the target method name final Iterator methodIterator = classNode.methods.iterator(); + while (methodIterator.hasNext()) { final MethodNode m = methodIterator.next(); - log("@" + m.name + " " + m.desc); - // Check if this is the method name and the signature matches if (m.name.equals(targetMethod) && m.desc.equals(targetMethodSignature)) { - log("Inside target method: " + targetMethod); AbstractInsnNode targetNode = null; - // Loop over the instruction set final ListIterator nodeIterator = m.instructions.iterator(); while (nodeIterator.hasNext()) { AbstractInsnNode currentNode = nodeIterator.next(); @@ -184,8 +176,6 @@ private byte[] patchMethodInClass(String className, final byte[] bytes, final St if (method.name.equals(targetInvocationMethodName)) { if (method.desc.equals(targetInvocationMethodSignature) || targetInvocationMethodSignature == null) { - log("Found target method invocation for injection: " - + targetInvocationMethodName); targetNode = currentNode; // Due to collisions, do not put break // statements here! @@ -195,7 +185,6 @@ private byte[] patchMethodInClass(String className, final byte[] bytes, final St } } else { if (currentNode.getType() == targetNodeType) { - log("Found target node for injection: " + targetNodeOpcode); targetNode = currentNode; // Due to collisions, do not put break // statements here! @@ -224,13 +213,11 @@ private byte[] patchMethodInClass(String className, final byte[] bytes, final St // If we've found the target, inject the instructions! for (int i = 0; i < nodesToDeleteBefore; i++) { final AbstractInsnNode previousNode = targetNode.getPrevious(); - log("Removing Node " + previousNode.getOpcode()); m.instructions.remove(previousNode); } for (int i = 0; i < nodesToDeleteAfter; i++) { final AbstractInsnNode nextNode = targetNode.getNext(); - log("Removing Node " + nextNode.getOpcode()); m.instructions.remove(nextNode); } @@ -248,17 +235,9 @@ private byte[] patchMethodInClass(String className, final byte[] bytes, final St } } - log("//// Class finished: " + className); - final ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); classNode.accept(writer); return writer.toByteArray(); } - private void log(final String message) { - if (Config.debugLogging) { - SoundPhysics.log(message); - } - } - } diff --git a/src/main/java/com/sonicether/soundphysics/SoundPhysics.java b/src/main/java/com/sonicether/soundphysics/SoundPhysics.java index fca3bf58..a92deade 100644 --- a/src/main/java/com/sonicether/soundphysics/SoundPhysics.java +++ b/src/main/java/com/sonicether/soundphysics/SoundPhysics.java @@ -73,7 +73,6 @@ public void init(final FMLInitializationEvent event) { * CALLED BY ASM INJECTED CODE! */ public static void init() { - log("Initializing Sound Physics..."); setupEFX(); mc = Minecraft.getMinecraft(); } @@ -175,25 +174,7 @@ public static void setLastSoundName(final String name) { * CALLED BY ASM INJECTED CODE! */ public static void onPlaySound(final float posX, final float posY, final float posZ, final int sourceID) { - if (Config.debugLogging) { - logGeneral("onPlaySound, Source ID: " + sourceID + " " + posX + ", " + posY + ", " + posZ - + " Sound category: " + lastSoundCategory.toString() + " Sound name: " + lastSoundName); - } - - long startTime = 0; - long endTime = 0; - - if (Config.performanceLogging) { - startTime = System.nanoTime(); - } - evaluateEnvironment(sourceID, posX, posY, posZ); - - if (Config.performanceLogging) { - endTime = System.nanoTime(); - log("Total calculation time for sound " + lastSoundName + ": " - + (double) (endTime - startTime) / (double) 1000000 + " milliseconds"); - } } /** @@ -319,12 +300,6 @@ private static void evaluateEnvironment(final int sourceID, final float posX, fi final Vec3d soundPos = offsetSoundByName(posX, posY, posZ, playerPos, lastSoundName, lastSoundCategory); final Vec3d normalToPlayer = playerPos.subtract(soundPos).normalize(); - if (Config.debugLogging) { - logGeneral("Player pos: " + playerPos.x + ", " + playerPos.y + ", " + playerPos.z + " Sound Pos: " - + soundPos.x + ", " + soundPos.y + ", " + soundPos.z + " To player vector: " - + normalToPlayer.x + ", " + normalToPlayer.y + ", " + normalToPlayer.z); - } - Vec3d rayOrigin = soundPos; float occlusionAccumulation = 0.0f; @@ -345,28 +320,15 @@ private static void evaluateEnvironment(final int sourceID, final float posX, fi blockOcclusion *= 0.15f; } - if (Config.occlusionLogging) { - logOcclusion(blockHit.getUnlocalizedName() + " " + rayHit.hitVec.x + ", " + rayHit.hitVec.y + ", " - + rayHit.hitVec.z); - } - occlusionAccumulation += blockOcclusion; rayOrigin = new Vec3d(rayHit.hitVec.x + normalToPlayer.x * 0.1, rayHit.hitVec.y + normalToPlayer.y * 0.1, rayHit.hitVec.z + normalToPlayer.z * 0.1); - - if (Config.occlusionLogging) { - logOcclusion("New trace position: " + rayOrigin.x + ", " + rayOrigin.y + ", " + rayOrigin.z); - } } directCutoff = (float) Math.exp(-occlusionAccumulation * absorptionCoeff); float directGain = (float) Math.pow(directCutoff, 0.1); - if (Config.occlusionLogging) { - logOcclusion("direct cutoff: " + directCutoff + " direct gain:" + directGain); - } - // Calculate reverb parameters for this sound float sendGain0 = 0.0f; float sendGain1 = 0.0f; @@ -534,12 +496,6 @@ private static void evaluateEnvironment(final int sourceID, final float posX, fi directGain = (float) Math.pow(directCutoff, 0.1); - if (Config.environmentLogging) { - logEnvironment("Bounce reflectivity 0: " + bounceReflectivityRatio[0] + " bounce reflectivity 1: " - + bounceReflectivityRatio[1] + " bounce reflectivity 2: " + bounceReflectivityRatio[2] - + " bounce reflectivity 3: " + bounceReflectivityRatio[3]); - } - sendGain1 *= bounceReflectivityRatio[1]; sendGain2 *= (float) Math.pow(bounceReflectivityRatio[2], 3.0); sendGain3 *= (float) Math.pow(bounceReflectivityRatio[3], 4.0); @@ -554,11 +510,6 @@ private static void evaluateEnvironment(final int sourceID, final float posX, fi sendGain2 *= (float) Math.pow(sendCutoff2, 0.1); sendGain3 *= (float) Math.pow(sendCutoff3, 0.1); - if (Config.environmentLogging) { - logEnvironment("Final environment settings: " + sendGain0 + ", " + sendGain1 + ", " + sendGain2 - + ", " + sendGain3); - } - if (mc.player.isInWater()) { sendCutoff0 *= 0.4f; sendCutoff1 *= 0.4f; @@ -644,18 +595,6 @@ public static void log(final String message) { System.out.println(logPrefix.concat(" : ").concat(message)); } - public static void logOcclusion(final String message) { - System.out.println(logPrefix.concat(" [OCCLUSION] : ").concat(message)); - } - - public static void logEnvironment(final String message) { - System.out.println(logPrefix.concat(" [ENVIRONMENT] : ").concat(message)); - } - - public static void logGeneral(final String message) { - System.out.println(logPrefix.concat(": ").concat(message)); - } - public static void logError(final String errorMessage) { System.out.println(logPrefix.concat(" [ERROR]: ").concat(errorMessage)); }