Examples of RayTracing


Examples of fr.neatmonster.nocheatplus.utilities.RayTracing

     * Mostly block-coordinate consistency checking.
     * @param coords
     * @return
     */
    public static RayTracing checkConsistency(final double[] coords){
        RayTracing rt = new RayTracing(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]) {

            protected int lbx, lby, lbz;

            protected double ldt = 0;

            protected int step = 0;

            /* (non-Javadoc)
             * @see fr.neatmonster.nocheatplus.utilities.RayTracing#set(double, double, double, double, double, double)
             */
            @Override
            public void set(double x0, double y0, double z0, double x1, double y1, double z1) {
                super.set(x0, y0, z0, x1, y1, z1);
                lbx = blockX - 1;
                lby = blockY - 1;
                lbz = blockZ - 1;
                ldt = 0;
                step = 0;
            }

//            private boolean ignEdge(double offset, double dTotal){
//                return offset == 1 && dTotal > 0 || offset == 0 && dTotal < 0;
//            }

            @Override
            protected boolean step(int blockX, int blockY, int blockZ, double oX, double oY, double oZ, double dT) {
                // TODO: This does not check last step for some occasions where it should.
                step ++;

                if (dT < 0.0){
                    doFail("dT < 0 at t = " + StringUtil.fdec3.format(t), coords);
                }
               
                // TODO: Check if this check makes sense at all (dT=0 happens during multi-transitions.)l.
//                if (dT == 0.0 && 1.0 - (t + dT) > tol){
//                    if (!ignEdge(oX, dX) && !ignEdge(oY, dY) && !ignEdge(oZ, dZ)){
//                        doFail("Premature dT = 0 at t = " + StringUtil.fdec3.format(t), coords);
//                    }
//                }

                checkOffset(oX, "x");
                checkOffset(oY, "y");
                checkOffset(oZ, "z");

                // TODO: check with last block coordinates
                if (lbx == blockX && lby == blockY && lbz == blockZ){
                    if (1.0 - (t + dT) > tol){
                        doFail("Expect block coordinates to change with each step (step=" + step + ", t=" + StringUtil.fdec3.format(t) +").", coords);
                    }
                }
                // TODO: check offsets
                // Set to current.
                lbx = blockX;
                lby = blockY;
                lbz = blockZ;
                ldt = dT;
                if (step > maxSteps(dX, dY, dZ)) doFail("max steps exceeded: " + maxSteps(dX, dY, dZ), coords);
                return true;
            }

            private void checkOffset(double offset, String name) {
                if (offset < 0.0 || offset > 1.0) doFail("Bad " + name + "-offset: " + offset, coords);
            }

            @Override
            public void loop() {
                super.loop();
                checkBlockTarget(coords[3], blockX, oX, dX, ldt, "x");
                checkBlockTarget(coords[4], blockY, oY, dY, ldt, "y");
                checkBlockTarget(coords[5], blockZ, oZ, dZ, ldt, "z");
            }

            private void checkBlockTarget(double target, int current, double offset, double dTotal, double dT, String name){
                int b = Location.locToBlock(target);
                if (current != b){
                    // TODO: Might do with or without these ?
                    //          if (current == b + 1 && dTotal > 0 && offset == 0) return;
                    //          if (current == b - 1 && dTotal < 0 && offset == 1) return;
                    if (Math.abs(dT * dTotal + offset + (double) current - target) <= 0.001){
                        // TODO: Narrow down by edge coordinates or so.
                        return;
                    }
                    System.out.println(target + "|" +  current + "|" + offset + "|" + dT * dTotal);
                    // Failure.
                    doFail("Bad target " + name + "-coordinate: " + current + " instead of " + b, coords);
                }
            }   
        };
        rt.loop();
        return rt;
    }
View Full Code Here

Examples of fr.neatmonster.nocheatplus.utilities.RayTracing

        if ("0".equals(sdt) && dT > 0) sdt = "0.X";
        System.out.println(StringUtil.fdec3.format(t) + " (+" + sdt + "): " + blockX + ", "+blockY + ", " + blockZ + " / " + StringUtil.fdec3.format(oX) + ", " + StringUtil.fdec3.format(oY)+ ", " + StringUtil.fdec3.format(oZ));
    }

    public static RayTracing dumpRawRayTracing(final double[] coords) {
        RayTracing rt = new RayTracing(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]) {
            @Override
            protected boolean step(int blockX, int blockY, int blockZ, double oX, double oY, double oZ, double dT) {
                dump(blockX, blockY, blockZ, oX, oY, oZ, t, dT);
                if (step > maxSteps(dX, dY, dZ)){
                    System.out.println("[WARNING] Max steps exceeded: " + maxSteps(dX, dY, dZ));
                    return false;
                }
                return true;
            }
        };
        rt.loop();
        return rt;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.