<commit_before>#include "aten.h"
#include "atenscene.h"

#include <cmdline.h>
#include <imgui.h>

#include "VoxelViewer.h"

static const int WIDTH = 1280;
static const int HEIGHT = 720;

static const char* TITLE = "VoxelViewer";

struct Options {
	std::string input;
	std::string output;

	std::string inputBasepath;
	std::string inputFilename;
} g_opt;

static std::vector<aten::object*> g_objs;
static aten::AcceleratedScene<aten::sbvh> g_scene;

static VoxelViewer g_viewer;
static aten::RasterizeRenderer g_rasterizer;

static aten::PinholeCamera g_camera;
static bool g_isCameraDirty = false;

static bool g_willShowGUI = true;

static int g_drawVoxelIdx = -1;
static bool g_drawMesh = false;
static bool g_isWireframe = false;

static bool g_isMouseLBtnDown = false;
static bool g_isMouseRBtnDown = false;
static int g_prevX = 0;
static int g_prevY = 0;

void onRun()
{
	if (g_isCameraDirty) {
		g_camera.update();

		auto camparam = g_camera.param();
		camparam.znear = real(0.1);
		camparam.zfar = real(10000.0);

		g_isCameraDirty = false;
	}

	const auto& nodes = g_scene.getAccel()->getNodes();
	const auto& voxels = g_scene.getAccel()->getVoxels();

	g_viewer.draw(
		&g_camera,
		nodes,
		voxels,
		g_isWireframe,
		g_drawVoxelIdx);

	if (g_drawMesh) {
		for (auto obj : g_objs) {
			g_rasterizer.draw(obj, &g_camera, false);
		}
	}

	{
		ImGui::Text("Voxel Cnt [%d]", voxels.size());
		ImGui::InputInt("Voxel", &g_drawVoxelIdx);
		ImGui::Checkbox("Wireframe,", &g_isWireframe);
		ImGui::Checkbox("Draw mesh,", &g_drawMesh);

		g_drawVoxelIdx = aten::clamp(g_drawVoxelIdx, -1, (int)voxels.size() - 1);

		if (g_drawVoxelIdx >= 0) {
			const auto& voxel = voxels[g_drawVoxelIdx];
			const auto& node = nodes[voxel.exid][voxel.nodeid];

			ImGui::Text("ExId [%d] NodeId[%d] Depth[%d]", voxel.exid, voxel.nodeid, voxel.depth);
			ImGui::Text("Box min [%f, %f, %f]", node.boxmin.x, node.boxmin.y, node.boxmin.z);
			ImGui::Text("Box max [%f, %f, %f]", node.boxmax.x, node.boxmax.y, node.boxmax.z);
		}

		aten::window::drawImGui();
	}
}

void onClose()
{

}

void onMouseBtn(bool left, bool press, int x, int y)
{
	g_isMouseLBtnDown = false;
	g_isMouseRBtnDown = false;

	if (press) {<commit_msg>Apply for changing variable.<commit_after>#include "aten.h"
#include "atenscene.h"

#include <cmdline.h>
#include <imgui.h>

#include "VoxelViewer.h"

static const int WIDTH = 1280;
static const int HEIGHT = 720;

static const char* TITLE = "VoxelViewer";

struct Options {
	std::string input;
	std::string output;

	std::string inputBasepath;
	std::string inputFilename;
} g_opt;

static std::vector<aten::object*> g_objs;
static aten::AcceleratedScene<aten::sbvh> g_scene;

static VoxelViewer g_viewer;
static aten::RasterizeRenderer g_rasterizer;

static aten::PinholeCamera g_camera;
static bool g_isCameraDirty = false;

static bool g_willShowGUI = true;

static int g_drawVoxelIdx = -1;
static bool g_drawMesh = false;
static bool g_isWireframe = false;

static bool g_isMouseLBtnDown = false;
static bool g_isMouseRBtnDown = false;
static int g_prevX = 0;
static int g_prevY = 0;

void onRun()
{
	if (g_isCameraDirty) {
		g_camera.update();

		auto camparam = g_camera.param();
		camparam.znear = real(0.1);
		camparam.zfar = real(10000.0);

		g_isCameraDirty = false;
	}

	const auto& nodes = g_scene.getAccel()->getNodes();
	const auto& voxels = g_scene.getAccel()->getVoxels();

	g_viewer.draw(
		&g_camera,
		nodes,
		voxels,
		g_isWireframe,
		g_drawVoxelIdx);

	if (g_drawMesh) {
		for (auto obj : g_objs) {
			g_rasterizer.draw(obj, &g_camera, false);
		}
	}

	{
		ImGui::Text("Voxel Cnt [%d]", voxels.size());
		ImGui::InputInt("Voxel", &g_drawVoxelIdx);
		ImGui::Checkbox("Wireframe,", &g_isWireframe);
		ImGui::Checkbox("Draw mesh,", &g_drawMesh);

		g_drawVoxelIdx = aten::clamp(g_drawVoxelIdx, -1, (int)voxels.size() - 1);

		if (g_drawVoxelIdx >= 0) {
			const auto& voxel = voxels[g_drawVoxelIdx];
			const auto& node = nodes[voxel.exid][voxel.nodeid];

			ImGui::Text("ExId [%d] NodeId[%d] Lod[%d]", voxel.exid, voxel.nodeid, voxel.lod);
			ImGui::Text("Box min [%f, %f, %f]", node.boxmin.x, node.boxmin.y, node.boxmin.z);
			ImGui::Text("Box max [%f, %f, %f]", node.boxmax.x, node.boxmax.y, node.boxmax.z);
		}

		aten::window::drawImGui();
	}
}

void onClose()
{

}

void onMouseBtn(bool left, bool press, int x, int y)
{
	g_isMouseLBtnDown = false;
	g_isMouseRBtnDown = false;

	if (press) {
{'fraction_non_alphanumeric': 0.15222800271431802, 'fraction_numerical': 0.009500113096584483, 'mean_word_length': 4.856953642384106, 'pattern_counts': {'":': 0, '<': 11, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7187414', 'n_tokens_mistral': 1977, 'n_tokens_neox': 1821, 'n_words': 387}