Renamed set_process_mode to set_process_callback to fix conflict with newly renamed Godot4 Node method
parent
543d1b2f2f
commit
3596c13475
|
@ -155,7 +155,7 @@ VoxelLodTerrain::VoxelLodTerrain() {
|
|||
set_notify_transform(true);
|
||||
|
||||
// Doing this to setup the defaults
|
||||
set_process_mode(_process_mode);
|
||||
set_process_callback(_process_callback);
|
||||
|
||||
// Infinite by default
|
||||
_bounds_in_voxels = Box3i::from_center_extents(Vector3i(), Vector3iUtil::create(VoxelConstants::MAX_VOLUME_EXTENT));
|
||||
|
@ -966,17 +966,17 @@ Vector3i VoxelLodTerrain::voxel_to_mesh_block_position(Vector3 vpos, int lod_ind
|
|||
return bpos;
|
||||
}
|
||||
|
||||
void VoxelLodTerrain::set_process_mode(ProcessMode mode) {
|
||||
_process_mode = mode;
|
||||
set_process(_process_mode == PROCESS_MODE_IDLE);
|
||||
set_physics_process(_process_mode == PROCESS_MODE_PHYSICS);
|
||||
void VoxelLodTerrain::set_process_callback(ProcessCallback mode) {
|
||||
_process_callback = mode;
|
||||
set_process(_process_callback == PROCESS_CALLBACK_IDLE);
|
||||
set_physics_process(_process_callback == PROCESS_CALLBACK_PHYSICS);
|
||||
}
|
||||
|
||||
void VoxelLodTerrain::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
// TODO Should use NOTIFICATION_INTERNAL_PROCESS instead?
|
||||
case NOTIFICATION_PROCESS:
|
||||
if (_process_mode == PROCESS_MODE_IDLE) {
|
||||
if (_process_callback == PROCESS_CALLBACK_IDLE) {
|
||||
// Can't do that in enter tree because Godot is "still setting up children".
|
||||
// Can't do that in ready either because Godot says node state is locked.
|
||||
// This hack is quite miserable.
|
||||
|
@ -987,7 +987,7 @@ void VoxelLodTerrain::_notification(int p_what) {
|
|||
|
||||
// TODO Should use NOTIFICATION_INTERNAL_PHYSICS_PROCESS instead?
|
||||
case NOTIFICATION_PHYSICS_PROCESS:
|
||||
if (_process_mode == PROCESS_MODE_PHYSICS) {
|
||||
if (_process_callback == PROCESS_CALLBACK_PHYSICS) {
|
||||
// Can't do that in enter tree because Godot is "still setting up children".
|
||||
// Can't do that in ready either because Godot says node state is locked.
|
||||
// This hack is quite miserable.
|
||||
|
@ -3004,8 +3004,8 @@ void VoxelLodTerrain::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_voxel_bounds"), &VoxelLodTerrain::_b_set_voxel_bounds);
|
||||
ClassDB::bind_method(D_METHOD("get_voxel_bounds"), &VoxelLodTerrain::_b_get_voxel_bounds);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_process_mode", "mode"), &VoxelLodTerrain::set_process_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_process_mode"), &VoxelLodTerrain::get_process_mode);
|
||||
ClassDB::bind_method(D_METHOD("set_process_callback", "mode"), &VoxelLodTerrain::set_process_callback);
|
||||
ClassDB::bind_method(D_METHOD("get_process_callback"), &VoxelLodTerrain::get_process_callback);
|
||||
|
||||
ClassDB::bind_method(
|
||||
D_METHOD("debug_raycast_mesh_block", "origin", "dir"), &VoxelLodTerrain::debug_raycast_mesh_block);
|
||||
|
@ -3022,9 +3022,9 @@ void VoxelLodTerrain::_bind_methods() {
|
|||
|
||||
//ClassDB::bind_method(D_METHOD("_on_stream_params_changed"), &VoxelLodTerrain::_on_stream_params_changed);
|
||||
|
||||
BIND_ENUM_CONSTANT(PROCESS_MODE_IDLE);
|
||||
BIND_ENUM_CONSTANT(PROCESS_MODE_PHYSICS);
|
||||
BIND_ENUM_CONSTANT(PROCESS_MODE_DISABLED);
|
||||
BIND_ENUM_CONSTANT(PROCESS_CALLBACK_IDLE);
|
||||
BIND_ENUM_CONSTANT(PROCESS_CALLBACK_PHYSICS);
|
||||
BIND_ENUM_CONSTANT(PROCESS_CALLBACK_DISABLED);
|
||||
|
||||
ADD_GROUP("Bounds", "");
|
||||
|
||||
|
|
|
@ -150,16 +150,20 @@ public:
|
|||
void set_lod_fade_duration(float seconds);
|
||||
float get_lod_fade_duration() const;
|
||||
|
||||
enum ProcessMode { PROCESS_MODE_IDLE = 0, PROCESS_MODE_PHYSICS, PROCESS_MODE_DISABLED };
|
||||
enum ProcessCallback { //
|
||||
PROCESS_CALLBACK_IDLE = 0,
|
||||
PROCESS_CALLBACK_PHYSICS,
|
||||
PROCESS_CALLBACK_DISABLED
|
||||
};
|
||||
|
||||
// This was originally added to fix a problem with rigidbody teleportation and floating world origin:
|
||||
// The player teleported at a different rate than the rest of the world due to delays in transform updates,
|
||||
// which caused the world to unload and then reload entirely over the course of 3 frames,
|
||||
// producing flickers and CPU lag. Changing process mode allows to align update rate,
|
||||
// and freeze LOD for the duration of the teleport.
|
||||
void set_process_mode(ProcessMode mode);
|
||||
ProcessMode get_process_mode() const {
|
||||
return _process_mode;
|
||||
void set_process_callback(ProcessCallback mode);
|
||||
ProcessCallback get_process_callback() const {
|
||||
return _process_callback;
|
||||
}
|
||||
|
||||
Ref<VoxelTool> get_voxel_tool();
|
||||
|
@ -320,7 +324,7 @@ private:
|
|||
Ref<VoxelMesher> _mesher;
|
||||
|
||||
uint32_t _volume_id = 0;
|
||||
ProcessMode _process_mode = PROCESS_MODE_IDLE;
|
||||
ProcessCallback _process_callback = PROCESS_CALLBACK_IDLE;
|
||||
|
||||
// TODO Get rid of this kind of member, use threadlocal pooling instead
|
||||
// Only populated and then cleared inside _process, so lifetime of pointers should be valid
|
||||
|
@ -399,6 +403,6 @@ private:
|
|||
Stats _stats;
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VoxelLodTerrain::ProcessMode)
|
||||
VARIANT_ENUM_CAST(VoxelLodTerrain::ProcessCallback)
|
||||
|
||||
#endif // VOXEL_LOD_TERRAIN_HPP
|
||||
|
|
Loading…
Reference in New Issue