<commit_before>/*
 * This file is part of Caustic.
 *
 * Copyright (c) 2013 Spout LLC <http://www.spout.org/>
 * Caustic is licensed under the Spout License Version 1.
 *
 * Caustic is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 *
 * In addition, 180 days after any changes are published, you can use the
 * software, incorporating those changes, under the terms of the MIT license,
 * as described in the Spout License Version 1.
 *
 * Caustic is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License,
 * the MIT license and the Spout License Version 1 along with this program.
 * If not, see <http://www.gnu.org/licenses/> for the GNU Lesser General Public
 * License and see <http://spout.in/licensev1> for the full license, including
 * the MIT license.
 */
package org.spout.renderer;

import org.spout.renderer.util.RenderUtil;

/**
 *
 */
public class InstancedModel extends Model {
	private final Model instance;

	public InstancedModel(Model instance) {
		this.instance = instance;
	}

	@Override
	public void create() {
		if (!instance.isCreated()) {
			instance.create();
		}
		super.create();
	}

	@Override
	public void destroy() {
		checkCreated();
		if (instance.isCreated()) {
			instance.destroy();
		}
		super.destroy();
	}

	@Override
	public void uploadUniforms() {
		super.uploadUniforms();
		instance.getMaterial().getProgram().upload(uniforms);
	}

	@Override
	public void render() {
		checkCreated();
		instance.render();
	}

	@Override
	public Material getMaterial() {
		return instance.getMaterial();
	}

	@Override
	public void setMaterial(Material material) {
		RenderUtil.checkVersions(instance, material);
		instance.setMaterial(material);
	}

	@Override
	public VertexArray getVertexArray() {
		return instance.getVertexArray();
	}

	@Override
	public GLVersion getGLVersion() {
		return instance.getGLVersion();
	}
}<commit_msg>InstancedModel javadocs<commit_after>/*
 * This file is part of Caustic.
 *
 * Copyright (c) 2013 Spout LLC <http://www.spout.org/>
 * Caustic is licensed under the Spout License Version 1.
 *
 * Caustic is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 *
 * In addition, 180 days after any changes are published, you can use the
 * software, incorporating those changes, under the terms of the MIT license,
 * as described in the Spout License Version 1.
 *
 * Caustic is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License,
 * the MIT license and the Spout License Version 1 along with this program.
 * If not, see <http://www.gnu.org/licenses/> for the GNU Lesser General Public
 * License and see <http://spout.in/licensev1> for the full license, including
 * the MIT license.
 */
package org.spout.renderer;

import org.spout.renderer.util.RenderUtil;

/**
 * Represents an instance of another model. Model instancing can be used to reduce the amount of
 * vertex data on the GPU, by reusing the same geometry for multiple models. To use this class,
 * simply construct a new instance using the model to instance (the main model), create it, and add
 * it to the renderer. This class should work with any model type as long as it has been implemented
 * correctly.
 */
public class InstancedModel extends Model {
	private final Model main;

	/**
	 * Constructs a new instanced model from the main model.
	 *
	 * @param main The main model
	 */
	public InstancedModel(Model main) {
		this.main = main;
	}

	@Override
	public void create() {
		if (!main.isCreated()) {
			main.create();
		}
		super.create();
	}

	@Override
	public void destroy() {
		checkCreated();
		if (main.isCreated()) {
			main.destroy();
		}
		super.destroy();
	}

	@Override
	public void uploadUniforms() {
		super.uploadUniforms();
		main.getMaterial().getProgram().upload(uniforms);
	}

	@Override
	public void render() {
		checkCreated();
		main.render();
	}

	@Override
	public Material getMaterial() {
		return main.getMaterial();
	}

	@Override
	public void setMaterial(Material material) {
		RenderUtil.checkVersions(main, material);
		main.setMaterial(material);
	}

	@Override
	public VertexArray getVertexArray() {
		return main.getVertexArray();
	}

	@Override
	public GLVersion getGLVersion() {
		return main.getGLVersion();
	}
}
{'fraction_non_alphanumeric': 0.09155206286836935, 'fraction_numerical': 0.004715127701375246, 'mean_word_length': 3.8904899135446684, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6124172', 'n_tokens_mistral': 1502, 'n_tokens_neox': 1414, 'n_words': 593}