From: Rene S. <sa...@us...> - 2005-01-16 21:22:01
|
Update of /cvsroot/jake2/jake2/src/jake2/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29339/src/jake2/util Modified Files: Tag: RST Lib.java Math3D.java Added Files: Tag: RST Vec3Cache.java Log Message: This has vec3-optimize and the OAK bot. Index: Lib.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/util/Lib.java,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -C2 -d -r1.11 -r1.11.2.1 *** Lib.java 16 Dec 2004 19:46:49 -0000 1.11 --- Lib.java 16 Jan 2005 21:21:11 -0000 1.11.2.1 *************** *** 211,215 **** FS.Read(buffer, len, f); ! return new String(buffer).trim(); } public static String rightFrom(String in, char c) { --- 211,215 ---- FS.Read(buffer, len, f); ! return Lib.CtoJava(buffer); } public static String rightFrom(String in, char c) { *************** *** 267,272 **** } public static String CtoJava(byte[] old, int offset, int maxLenght) { ! int i; for (i = offset; old[i] != 0 && (i - offset) < maxLenght; i++); return new String(old, offset, i - offset); --- 267,277 ---- } + public static String CtoJava(byte[] old) { + return CtoJava(old, 0, old.length); + } + public static String CtoJava(byte[] old, int offset, int maxLenght) { ! if (old.length == 0 || old[0] == 0) return ""; ! int i; for (i = offset; old[i] != 0 && (i - offset) < maxLenght; i++); return new String(old, offset, i - offset); Index: Math3D.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/util/Math3D.java,v retrieving revision 1.7 retrieving revision 1.7.6.1 diff -C2 -d -r1.7 -r1.7.6.1 *** Math3D.java 22 Sep 2004 19:22:13 -0000 1.7 --- Math3D.java 16 Jan 2005 21:21:11 -0000 1.7.6.1 *************** *** 175,184 **** private static float tmpmat[][] = new float[3][3]; private static float zrot[][] = new float[3][3]; ! public static void RotatePointAroundVector(float[] dst, float[] dir, float[] point, float degrees) { ! ! float[] vr = { 0.0f, 0.0f, 0.0f }; ! float[] vup = { 0.0f, 0.0f, 0.0f }; ! float[] vf = { 0.0f, 0.0f, 0.0f }; vf[0] = dir[0]; vf[1] = dir[1]; --- 175,185 ---- private static float tmpmat[][] = new float[3][3]; private static float zrot[][] = new float[3][3]; ! ! // to reduce garbage ! private static final float[] vr = {0, 0, 0}; ! private static final float[] vup = {0, 0, 0}; ! private static final float[] vf = {0, 0, 0}; + public static void RotatePointAroundVector(float[] dst, float[] dir, float[] point, float degrees) { vf[0] = dir[0]; vf[1] = dir[1]; *************** *** 225,228 **** --- 226,230 ---- } } + public static void MakeNormalVectors(float[] forward, float[] right, float[] up) { // this rotate and negat guarantees a vector *************** *** 287,290 **** --- 289,295 ---- dst[2] = p[2] - d * dst[2]; } + + private static final float[][] PLANE_XYZ = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; + /** assumes "src" is normalized */ public static void PerpendicularVector(float[] dst, float[] src) { *************** *** 300,308 **** } } - float tempvec[] = { 0.0f, 0.0f, 0.0f }; - tempvec[pos] = 1.0F; - // project the point onto the plane defined by src ! ProjectPointOnPlane(dst, tempvec, src); //normalize the result --- 305,310 ---- } } // project the point onto the plane defined by src ! ProjectPointOnPlane(dst, PLANE_XYZ[pos], src); //normalize the result --- NEW FILE: Vec3Cache.java --- /* * Vec3Cache.java * Copyright (C) 2003 * * $Id: Vec3Cache.java,v 1.1.2.1 2005/01/16 21:21:11 salomo Exp $ */ package jake2.util; /** * Vec3Cache contains float[3] for temporary usage. * The usage can reduce the garbage at runtime. * * @author cwei */ public final class Vec3Cache { //private static Stack cache = new Stack(); private static final float[][] cache = new float[64][3]; private static int index = 0; private static int max = 0; public static final float[] get() { //max = Math.max(index, max); return cache[index++]; } public static final void release() { index--; } public static final void release(int count) { index-=count; } public static final void debug() { System.err.println("Vec3Cache: max. " + (max + 1) + " vectors used."); } } |