mirror of
https://github.com/Relintai/voxelman.git
synced 2025-01-12 15:01:09 +01:00
Added VoxelLightJob.
This commit is contained in:
parent
3f23be12bc
commit
9cca71355f
1
SCsub
1
SCsub
@ -74,6 +74,7 @@ sources = [
|
|||||||
|
|
||||||
"world/jobs/voxel_job.cpp",
|
"world/jobs/voxel_job.cpp",
|
||||||
"world/jobs/voxel_terrarin_job.cpp",
|
"world/jobs/voxel_terrarin_job.cpp",
|
||||||
|
"world/jobs/voxel_light_job.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
if has_texture_packer:
|
if has_texture_packer:
|
||||||
|
@ -58,6 +58,7 @@ def get_doc_classes():
|
|||||||
|
|
||||||
"VoxelJob",
|
"VoxelJob",
|
||||||
"VoxelTerrarinJob",
|
"VoxelTerrarinJob",
|
||||||
|
"VoxelLightJob",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ SOFTWARE.
|
|||||||
#include "nodes/voxelman_light.h"
|
#include "nodes/voxelman_light.h"
|
||||||
|
|
||||||
#include "world/jobs/voxel_job.h"
|
#include "world/jobs/voxel_job.h"
|
||||||
|
#include "world/jobs/voxel_light_job.h"
|
||||||
#include "world/jobs/voxel_terrarin_job.h"
|
#include "world/jobs/voxel_terrarin_job.h"
|
||||||
|
|
||||||
void register_voxelman_types() {
|
void register_voxelman_types() {
|
||||||
@ -126,6 +127,7 @@ void register_voxelman_types() {
|
|||||||
|
|
||||||
ClassDB::register_class<VoxelJob>();
|
ClassDB::register_class<VoxelJob>();
|
||||||
ClassDB::register_class<VoxelTerrarinJob>();
|
ClassDB::register_class<VoxelTerrarinJob>();
|
||||||
|
ClassDB::register_class<VoxelLightJob>();
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
EditorPlugins::add_by_type<VoxelWorldEditorPlugin>();
|
EditorPlugins::add_by_type<VoxelWorldEditorPlugin>();
|
||||||
|
87
world/jobs/voxel_light_job.cpp
Normal file
87
world/jobs/voxel_light_job.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2020 Péter Magyar
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "voxel_light_job.h"
|
||||||
|
|
||||||
|
#include "../../defines.h"
|
||||||
|
|
||||||
|
#include "../../library/voxel_surface.h"
|
||||||
|
#include "../../library/voxelman_library.h"
|
||||||
|
|
||||||
|
#include "../../meshers/voxel_mesher.h"
|
||||||
|
#include "../default/voxel_chunk_default.h"
|
||||||
|
|
||||||
|
void VoxelLightJob::phase_light() {
|
||||||
|
Ref<VoxelChunkDefault> chunk = _chunk;
|
||||||
|
|
||||||
|
bool gr = (chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_AUTO_GENERATE_RAO) != 0;
|
||||||
|
|
||||||
|
if (!gr && (chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bl = (chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_BAKE_LIGHTS) != 0;
|
||||||
|
|
||||||
|
if (bl && should_do()) {
|
||||||
|
chunk->clear_baked_lights();
|
||||||
|
|
||||||
|
if (should_return())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gr && should_do()) {
|
||||||
|
chunk->generate_random_ao(chunk->get_voxel_world()->get_current_seed());
|
||||||
|
|
||||||
|
if (should_return())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bl && should_do()) {
|
||||||
|
chunk->bake_lights();
|
||||||
|
|
||||||
|
if (should_return())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
reset_stages();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelLightJob::_execute() {
|
||||||
|
ERR_FAIL_COND(!_chunk.is_valid());
|
||||||
|
|
||||||
|
Ref<VoxelmanLibrary> library = _chunk->get_library();
|
||||||
|
|
||||||
|
ERR_FAIL_COND(!library.is_valid());
|
||||||
|
|
||||||
|
phase_light();
|
||||||
|
|
||||||
|
//finish
|
||||||
|
}
|
||||||
|
|
||||||
|
VoxelLightJob::VoxelLightJob() {
|
||||||
|
}
|
||||||
|
|
||||||
|
VoxelLightJob::~VoxelLightJob() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelLightJob::_bind_methods() {
|
||||||
|
}
|
45
world/jobs/voxel_light_job.h
Normal file
45
world/jobs/voxel_light_job.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2020 Péter Magyar
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VOXEL_LIGHT_JOB_H
|
||||||
|
#define VOXEL_LIGHT_JOB_H
|
||||||
|
|
||||||
|
#include "voxel_job.h"
|
||||||
|
|
||||||
|
class VoxelMesher;
|
||||||
|
|
||||||
|
class VoxelLightJob : public VoxelJob {
|
||||||
|
GDCLASS(VoxelLightJob, VoxelJob);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void phase_light();
|
||||||
|
|
||||||
|
void _execute();
|
||||||
|
|
||||||
|
VoxelLightJob();
|
||||||
|
~VoxelLightJob();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void _bind_methods();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user