<commit_before>/*
 * Copyright (c) 2003, jMonkeyEngine - Mojo Monkey Coding
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * Neither the name of the Mojo Monkey Coding, jME, jMonkey Engine, nor the
 * names of its contributors may be used to endorse or promote products derived
 * from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */
package com.jme.scene;

import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.logging.Level;

import com.jme.math.Vector2f;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.system.DisplaySystem;
import com.jme.system.JmeException;
import com.jme.util.LoggingSystem;

/**
 * <code>Geometry</code> defines a leaf node of the scene graph. The leaf
 * node contains the geometric data for rendering objects. It manages all
 * rendering information such as a collection of states and the data for a
 * model. Subclasses define what the model data is.
 * @author <NAME>
 * @version $Id: Geometry.java,v 1.16 2004-03-12 00:31:03 renanse Exp $
 */
public class Geometry extends Spatial implements Serializable {
    protected BoundingVolume bound;
    //data that specifies how to render this leaf.
    protected Vector3f[] vertex;
    protected Vector3f[] normal;
    protected ColorRGBA[] color;
    protected Vector2f[][] texture;

    //buffers that allow for faster data processing.
    private FloatBuffer colorBuf;
    private FloatBuffer normBuf;
    private FloatBuffer vertBuf;
    private FloatBuffer[] texBuf;

    //float arrays for update phase
    float[] colorArray;

    /**
     * Constructor instantiates a new <code>Geometry</code> object. This
     * is the default object which has an empty vertex array. All other
     * data is null.
     *
      * @param name the name of the scene element. This is required for identification and
	 *                                                                                          		comparision purposes.
     *
     */
    public Geometry(String name) {
        super(name);
        vertex = new Vector3f[0];
        int textureUnits =
            DisplaySystem
                .getDisplaySystem()
                .getRenderer()
                .getTextureState()
                .getNumberOfUnits();
        texture = new Vector2f[textureUnits][0];
        texBuf = new FloatBuffer[textureUnits];
    }

    /**
     * Constructor creates a new <code>Geometry</code> object. During
     * instantiation the geometry is set including vertex, normal, color and
     * texture information. Any part may be null except for the vertex
     * information. If this is null, an exception will be thrown.
     * @param name the name of the scene element. This is required for identification and
	 *                                                                                          		comparision purposes.
     * @param vertex the points that make up the geometry.
     * @param normal the normals of the geometry.
     * @param color the color of each point of the geometry.
     * @param texture the texture coordinates of the geometry.
     */
    public Geometry(
        String name,
        Vector3f[] vertex,
        Vector3f[] normal,
        ColorRGBA[] color,
        Vector2f[] texture) {

        super(name);

        if (vertex == null) {
            LoggingSystem.getLogger().log(
                Level.WARNING,
                "Geometry must" + " include vertex information.");
            throw new JmeException("Geometry must include vertex information.");
        }

        int textureUnits =
            DisplaySystem
                .getDisplaySystem()
                .getRenderer()
                .getTextureState()
                .getNumberOfUnits();
        this.texture = new Vector2f[textureUnits][0];
        this.texBuf = new FloatBuffer[textureUnits];
        this.vertex = vertex;
        this.normal = normal;
        this.color = color;
        this.texture[0] = texture;

        updateColorBuffer();
        updateNormalBuffer();
        updateVertexBuffer();
        updateTextureBuffer();
    }

    /**
     *
     * @param vertices
     * @param normal
     * @param color
     * @param texture
     */
    public void reconstruct(
        Vector3f[] vertices,
        Vector3f[] normal,
        ColorRGBA[] color,
        Vector2f[] texture) {

        if (vertex == null) {
            LoggingSystem.getLogger().log(
                Level.WARNING,
                "Geometry must" + " include vertex information.");
            throw new JmeException("Geometry must include vertex information.");
        }

        int textureUnits =
            DisplaySystem
                .getDisplaySystem()
                .getRenderer()
                .getTextureState()
                .getNumberOfUnits();
        this.texture = new Vector2f[textureUnits][0];
        this.texBuf = new FloatBuffer[textureUnits];
        this.vertex = vertex;
        this.normal = normal;
        this.color = color;<commit_msg>bad assignment in reconstruct.<commit_after>/*
 * Copyright (c) 2003, jMonkeyEngine - Mojo Monkey Coding
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * Neither the name of the Mojo Monkey Coding, jME, jMonkey Engine, nor the
 * names of its contributors may be used to endorse or promote products derived
 * from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */
package com.jme.scene;

import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.logging.Level;

import com.jme.math.Vector2f;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.system.DisplaySystem;
import com.jme.system.JmeException;
import com.jme.util.LoggingSystem;

/**
 * <code>Geometry</code> defines a leaf node of the scene graph. The leaf
 * node contains the geometric data for rendering objects. It manages all
 * rendering information such as a collection of states and the data for a
 * model. Subclasses define what the model data is.
 * @author <NAME>
 * @version $Id: Geometry.java,v 1.17 2004-03-12 02:11:27 mojomonkey Exp $
 */
public class Geometry extends Spatial implements Serializable {
    protected BoundingVolume bound;
    //data that specifies how to render this leaf.
    protected Vector3f[] vertex;
    protected Vector3f[] normal;
    protected ColorRGBA[] color;
    protected Vector2f[][] texture;

    //buffers that allow for faster data processing.
    private FloatBuffer colorBuf;
    private FloatBuffer normBuf;
    private FloatBuffer vertBuf;
    private FloatBuffer[] texBuf;

    //float arrays for update phase
    float[] colorArray;

    /**
     * Constructor instantiates a new <code>Geometry</code> object. This
     * is the default object which has an empty vertex array. All other
     * data is null.
     *
      * @param name the name of the scene element. This is required for identification and
	 *                                                                                          		comparision purposes.
     *
     */
    public Geometry(String name) {
        super(name);
        vertex = new Vector3f[0];
        int textureUnits =
            DisplaySystem
                .getDisplaySystem()
                .getRenderer()
                .getTextureState()
                .getNumberOfUnits();
        texture = new Vector2f[textureUnits][0];
        texBuf = new FloatBuffer[textureUnits];
    }

    /**
     * Constructor creates a new <code>Geometry</code> object. During
     * instantiation the geometry is set including vertex, normal, color and
     * texture information. Any part may be null except for the vertex
     * information. If this is null, an exception will be thrown.
     * @param name the name of the scene element. This is required for identification and
	 *                                                                                          		comparision purposes.
     * @param vertex the points that make up the geometry.
     * @param normal the normals of the geometry.
     * @param color the color of each point of the geometry.
     * @param texture the texture coordinates of the geometry.
     */
    public Geometry(
        String name,
        Vector3f[] vertex,
        Vector3f[] normal,
        ColorRGBA[] color,
        Vector2f[] texture) {

        super(name);

        if (vertex == null) {
            LoggingSystem.getLogger().log(
                Level.WARNING,
                "Geometry must" + " include vertex information.");
            throw new JmeException("Geometry must include vertex information.");
        }

        int textureUnits =
            DisplaySystem
                .getDisplaySystem()
                .getRenderer()
                .getTextureState()
                .getNumberOfUnits();
        this.texture = new Vector2f[textureUnits][0];
        this.texBuf = new FloatBuffer[textureUnits];
        this.vertex = vertex;
        this.normal = normal;
        this.color = color;
        this.texture[0] = texture;

        updateColorBuffer();
        updateNormalBuffer();
        updateVertexBuffer();
        updateTextureBuffer();
    }

    /**
     *
     * @param vertices
     * @param normal
     * @param color
     * @param texture
     */
    public void reconstruct(
        Vector3f[] vertices,
        Vector3f[] normal,
        ColorRGBA[] color,
        Vector2f[] texture) {

        if (vertex == null) {
            LoggingSystem.getLogger().log(
                Level.WARNING,
                "Geometry must" + " include vertex information.");
            throw new JmeException("Geometry must include vertex information.");
        }

        int textureUnits =
            DisplaySystem
                .getDisplaySystem()
                .getRenderer()
                .getTextureState()
                .getNumberOfUnits();
        this.texture = new Vector2f[textureUnits][0];
        this.texBuf = new FloatBuffer[textureUnits];
        this.vertex = vertices;
        this.normal = normal;
        this.color = color;
{'fraction_non_alphanumeric': 0.07480808397305343, 'fraction_numerical': 0.006423311922293592, 'mean_word_length': 2.3500393597480977, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1187296', 'n_tokens_mistral': 3263, 'n_tokens_neox': 3080, 'n_words': 1240}