<commit_before>#include "world_mgr.hpp"
#include "audio/audio_mgr.hpp"
#include "global/cfg_mgr.hpp"
#include "debug/debugdraw.hpp"
#include "hardware/device.hpp"
#include "physics/phys_mgr.hpp"
#include "physics/world.hpp"
#include "save_mgr.hpp"
#include "util/containeralgorithms.hpp"
#include "visual/visual_mgr.hpp"
#include "visual/entity_mgr.hpp"
#include "visual/camera_mgr.hpp"
#include "world_gen/workertype.hpp"
#include "worldchunk.hpp"
#include "worldentity.hpp"
#include "worldentity_mgr.hpp"
#include "worldentity_set.hpp"
#include "worldquery.hpp"

// For debug
#include "hardware/keyboard.hpp"

// For grid test
#include "physics/chunk_util.hpp"

namespace clover {
namespace game {

WorldMgr* gWorldMgr;

WorldMgr::WorldMgr()
	: chunksLocked(false)
	, worldGen(*this, resources::gCache->getSubCache<world_gen::WorkerType>().getResources())
	, propertyGrid(physics::gPhysMgr->getWorld().getGrid())
	, worldTimeForwardListener("host", "dev", "worldTimeForward", [this] (){
		time += util::gGameClock->getDeltaTime()*300;
	})
	, worldTimeRewindListener("host", "dev", "worldTimeRewind", [this] (){
		time -= util::gGameClock->getDeltaTime()*300;
	}){

	time= getDayDuration()*0.45; // Start from day

	bgDefs[0].setModel("background_sky_evening");
	bgDefs[1].setModel("background_sky_day");
	bgDefs[2].setModel("background_sky_night");

	for (uint32 i= 0; i < 3; ++i){
		bgDefs[i].setEnvLight(1.0);
		bgDefs[i].useOnlyEnvLight();
		
		bg[i].setDef(bgDefs[i]);
		bg[i].setScale(util::Vec3d(1000000));
		bg[i].setPosition(util::Vec3d({0, 0, -1000000}));
		bg[i].setDrawPriority(i);
	}

	lightBackgroundDef.setModel("lightBackground");
	lightBackgroundDef.setEnvLight(1.0);
	lightBackgroundDef.setLightAlphaAdd(0.3);
	lightBackgroundDef.setColorMul(util::Color{1.0f,0.7f,0.3f,0});
	lightBackground.setDef(lightBackgroundDef);
	lightBackground.setScale(util::Vec3d(1));
	lightBackground.setDrawPriority(-100);
	lightBackground.setCoordinateSpace(util::Coord::View_Stretch);

	sunReDef.setModel("background_sun");

	sunReDef.useOnlyEnvLight();
	sunReDef.setEnvLight(1.0);
	sunRE.setDef(sunReDef);

	visual::TriMesh gtData;
	gtData.addRectByCenter(util::Vec2f(0),util::Vec2f(2));
}

WorldMgr::~WorldMgr(){
	weMgr.removeAll();
}

void WorldMgr::update(){
	weMgr.update();

	{ // Grid test
		auto& grid= physics::gPhysMgr->getWorld().getGrid();
		auto&& chunk_positions= grid.getChunkPositions();
		for (auto& ch_pos : chunk_positions) {
			util::ArrayView<const physics::Grid::Cell> cells=
				grid.getChunkCells(ch_pos);
			uint32 width= grid.getChunkWidth();
			uint32 width_c= grid.getChunkWidth()*grid.getCellsInUnit();
			real32 half_cell= 0.5f/grid.getCellsInUnit();
			for (SizeType i= 0; i < cells.size(); ++i) {
				if (//	cells[i].staticEdge &&
						cells[i].lastStaticPortion != cells[i].staticPortion) {
					util::Vec2i cell_p{	static_cast<int32>(i%width_c),
										static_cast<int32>(i/width_c)};
					auto pos=	ch_pos.casted<util::Vec2d>()*width + 
								cell_p.casted<util::Vec2d>()/width_c*width;

					if (	cells[i].lastStaticPortion > cells[i].staticPortion &&
							cells[i].staticPortion > 0.0) {
						util::RtTransform2d t;
						t.translation= pos + util::Vec2d(half_cell);
						t.rotation= cells[i].staticNormal.rotationZ() - util::tau/4.0f;
						game::WeHandle h= weMgr.createEntity("grassClump", t.translation);
						h->setAttribute("transform", t);
					}
					/*debug::gDebugDraw->addFilledCircle(
							util::Coord(pos),
							util::Coord(0.2),
							util::Color{1.0, 0.0, 0.0, 0.5});*/
				}
			}
		}
	}

	visual::Camera& camera= visual::gVisualMgr->getCameraMgr().getSelectedCamera();
	<commit_msg>Proper worldentity for test outlines<commit_after>#include "world_mgr.hpp"
#include "audio/audio_mgr.hpp"
#include "global/cfg_mgr.hpp"
#include "debug/debugdraw.hpp"
#include "hardware/device.hpp"
#include "physics/phys_mgr.hpp"
#include "physics/world.hpp"
#include "save_mgr.hpp"
#include "util/containeralgorithms.hpp"
#include "visual/visual_mgr.hpp"
#include "visual/entity_mgr.hpp"
#include "visual/camera_mgr.hpp"
#include "world_gen/workertype.hpp"
#include "worldchunk.hpp"
#include "worldentity.hpp"
#include "worldentity_mgr.hpp"
#include "worldentity_set.hpp"
#include "worldquery.hpp"

// For debug
#include "hardware/keyboard.hpp"

// For grid test
#include "physics/chunk_util.hpp"

namespace clover {
namespace game {

WorldMgr* gWorldMgr;

WorldMgr::WorldMgr()
	: chunksLocked(false)
	, worldGen(*this, resources::gCache->getSubCache<world_gen::WorkerType>().getResources())
	, propertyGrid(physics::gPhysMgr->getWorld().getGrid())
	, worldTimeForwardListener("host", "dev", "worldTimeForward", [this] (){
		time += util::gGameClock->getDeltaTime()*300;
	})
	, worldTimeRewindListener("host", "dev", "worldTimeRewind", [this] (){
		time -= util::gGameClock->getDeltaTime()*300;
	}){

	time= getDayDuration()*0.45; // Start from day

	bgDefs[0].setModel("background_sky_evening");
	bgDefs[1].setModel("background_sky_day");
	bgDefs[2].setModel("background_sky_night");

	for (uint32 i= 0; i < 3; ++i){
		bgDefs[i].setEnvLight(1.0);
		bgDefs[i].useOnlyEnvLight();
		
		bg[i].setDef(bgDefs[i]);
		bg[i].setScale(util::Vec3d(1000000));
		bg[i].setPosition(util::Vec3d({0, 0, -1000000}));
		bg[i].setDrawPriority(i);
	}

	lightBackgroundDef.setModel("lightBackground");
	lightBackgroundDef.setEnvLight(1.0);
	lightBackgroundDef.setLightAlphaAdd(0.3);
	lightBackgroundDef.setColorMul(util::Color{1.0f,0.7f,0.3f,0});
	lightBackground.setDef(lightBackgroundDef);
	lightBackground.setScale(util::Vec3d(1));
	lightBackground.setDrawPriority(-100);
	lightBackground.setCoordinateSpace(util::Coord::View_Stretch);

	sunReDef.setModel("background_sun");

	sunReDef.useOnlyEnvLight();
	sunReDef.setEnvLight(1.0);
	sunRE.setDef(sunReDef);

	visual::TriMesh gtData;
	gtData.addRectByCenter(util::Vec2f(0),util::Vec2f(2));
}

WorldMgr::~WorldMgr(){
	weMgr.removeAll();
}

void WorldMgr::update(){
	weMgr.update();

	{ // Grid test
		auto& grid= physics::gPhysMgr->getWorld().getGrid();
		auto&& chunk_positions= grid.getChunkPositions();
		for (auto& ch_pos : chunk_positions) {
			util::ArrayView<const physics::Grid::Cell> cells=
				grid.getChunkCells(ch_pos);
			uint32 width= grid.getChunkWidth();
			uint32 width_c= grid.getChunkWidth()*grid.getCellsInUnit();
			real32 half_cell= 0.5f/grid.getCellsInUnit();
			for (SizeType i= 0; i < cells.size(); ++i) {
				if (//	cells[i].staticEdge &&
						cells[i].lastStaticPortion != cells[i].staticPortion) {
					util::Vec2i cell_p{	static_cast<int32>(i%width_c),
										static_cast<int32>(i/width_c)};
					auto pos=	ch_pos.casted<util::Vec2d>()*width + 
								cell_p.casted<util::Vec2d>()/width_c*width;

					if (	cells[i].lastStaticPortion > cells[i].staticPortion &&
							cells[i].staticPortion > 0.0) {
						util::RtTransform2d t;
						t.translation= pos + util::Vec2d(half_cell);
						t.rotation= cells[i].staticNormal.rotationZ() - util::tau/4.0f;
						game::WeHandle h= weMgr.createEntity("block_dirt_edge", t.translation);
						h->setAttribute("transform", t);
					}
					/*debug::gDebugDraw->addFilledCircle(
							util::Coord(pos),
							util::Coord(0.2),
							util::Color{1.0, 0.0, 0.0, 0.5});*/
				}
			}
		}
	}

	visual::Camera& camera= visual::gVisualMgr->getCameraMgr().getSelectedCamera();
	
{'fraction_non_alphanumeric': 0.17544338335607093, 'fraction_numerical': 0.02455661664392906, 'mean_word_length': 5.425065731814198, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 35, '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': '7195867', 'n_tokens_mistral': 3080, 'n_tokens_neox': 2756, 'n_words': 372}