mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
grutil: add thread safety to ShaderTerrainMesh
This commit is contained in:
parent
a6ad608207
commit
cd033c27e8
@ -22,6 +22,7 @@
|
|||||||
* @param filename Heightfield texture
|
* @param filename Heightfield texture
|
||||||
*/
|
*/
|
||||||
INLINE void ShaderTerrainMesh::set_heightfield(Texture* heightfield) {
|
INLINE void ShaderTerrainMesh::set_heightfield(Texture* heightfield) {
|
||||||
|
MutexHolder holder(_lock);
|
||||||
_heightfield_tex = heightfield;
|
_heightfield_tex = heightfield;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,6 +34,7 @@ INLINE void ShaderTerrainMesh::set_heightfield(Texture* heightfield) {
|
|||||||
* @return Path to the heightfield
|
* @return Path to the heightfield
|
||||||
*/
|
*/
|
||||||
INLINE Texture* ShaderTerrainMesh::get_heightfield() const {
|
INLINE Texture* ShaderTerrainMesh::get_heightfield() const {
|
||||||
|
MutexHolder holder(_lock);
|
||||||
return _heightfield_tex;
|
return _heightfield_tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +56,7 @@ INLINE Texture* ShaderTerrainMesh::get_heightfield() const {
|
|||||||
* @param chunk_size Size of the chunks, has to be a power of two
|
* @param chunk_size Size of the chunks, has to be a power of two
|
||||||
*/
|
*/
|
||||||
INLINE void ShaderTerrainMesh::set_chunk_size(size_t chunk_size) {
|
INLINE void ShaderTerrainMesh::set_chunk_size(size_t chunk_size) {
|
||||||
|
MutexHolder holder(_lock);
|
||||||
_chunk_size = chunk_size;
|
_chunk_size = chunk_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +66,7 @@ INLINE void ShaderTerrainMesh::set_chunk_size(size_t chunk_size) {
|
|||||||
* @return Chunk size
|
* @return Chunk size
|
||||||
*/
|
*/
|
||||||
INLINE size_t ShaderTerrainMesh::get_chunk_size() const {
|
INLINE size_t ShaderTerrainMesh::get_chunk_size() const {
|
||||||
|
MutexHolder holder(_lock);
|
||||||
return _chunk_size;
|
return _chunk_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +85,7 @@ INLINE size_t ShaderTerrainMesh::get_chunk_size() const {
|
|||||||
* @param generate_patches [description]
|
* @param generate_patches [description]
|
||||||
*/
|
*/
|
||||||
INLINE void ShaderTerrainMesh::set_generate_patches(bool generate_patches) {
|
INLINE void ShaderTerrainMesh::set_generate_patches(bool generate_patches) {
|
||||||
|
MutexHolder holder(_lock);
|
||||||
_generate_patches = generate_patches;
|
_generate_patches = generate_patches;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +97,7 @@ INLINE void ShaderTerrainMesh::set_generate_patches(bool generate_patches) {
|
|||||||
* @return Whether to generate patches
|
* @return Whether to generate patches
|
||||||
*/
|
*/
|
||||||
INLINE bool ShaderTerrainMesh::get_generate_patches() const {
|
INLINE bool ShaderTerrainMesh::get_generate_patches() const {
|
||||||
|
MutexHolder holder(_lock);
|
||||||
return _generate_patches;
|
return _generate_patches;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,6 +113,7 @@ INLINE bool ShaderTerrainMesh::get_generate_patches() const {
|
|||||||
* @param target_triangle_width Desired triangle width in pixels
|
* @param target_triangle_width Desired triangle width in pixels
|
||||||
*/
|
*/
|
||||||
INLINE void ShaderTerrainMesh::set_target_triangle_width(PN_stdfloat target_triangle_width) {
|
INLINE void ShaderTerrainMesh::set_target_triangle_width(PN_stdfloat target_triangle_width) {
|
||||||
|
MutexHolder holder(_lock);
|
||||||
_target_triangle_width = target_triangle_width;
|
_target_triangle_width = target_triangle_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,6 +125,7 @@ INLINE void ShaderTerrainMesh::set_target_triangle_width(PN_stdfloat target_tria
|
|||||||
* @return Target triangle width
|
* @return Target triangle width
|
||||||
*/
|
*/
|
||||||
INLINE PN_stdfloat ShaderTerrainMesh::get_target_triangle_width() const {
|
INLINE PN_stdfloat ShaderTerrainMesh::get_target_triangle_width() const {
|
||||||
|
MutexHolder holder(_lock);
|
||||||
return _target_triangle_width;
|
return _target_triangle_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,6 +139,7 @@ INLINE PN_stdfloat ShaderTerrainMesh::get_target_triangle_width() const {
|
|||||||
* @param update_enabled Whether to update the terrain
|
* @param update_enabled Whether to update the terrain
|
||||||
*/
|
*/
|
||||||
INLINE void ShaderTerrainMesh::set_update_enabled(bool update_enabled) {
|
INLINE void ShaderTerrainMesh::set_update_enabled(bool update_enabled) {
|
||||||
|
MutexHolder holder(_lock);
|
||||||
_update_enabled = update_enabled;
|
_update_enabled = update_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,6 +151,7 @@ INLINE void ShaderTerrainMesh::set_update_enabled(bool update_enabled) {
|
|||||||
* @return Whether to update the terrain
|
* @return Whether to update the terrain
|
||||||
*/
|
*/
|
||||||
INLINE bool ShaderTerrainMesh::get_update_enabled() const {
|
INLINE bool ShaderTerrainMesh::get_update_enabled() const {
|
||||||
|
MutexHolder holder(_lock);
|
||||||
return _update_enabled;
|
return _update_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +122,7 @@ ShaderTerrainMesh::ShaderTerrainMesh() :
|
|||||||
* @return true if the terrain was initialized, false if an error occured
|
* @return true if the terrain was initialized, false if an error occured
|
||||||
*/
|
*/
|
||||||
bool ShaderTerrainMesh::generate() {
|
bool ShaderTerrainMesh::generate() {
|
||||||
|
MutexHolder holder(_lock);
|
||||||
if (!do_check_heightfield())
|
if (!do_check_heightfield())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -461,6 +462,7 @@ bool ShaderTerrainMesh::safe_to_combine() const {
|
|||||||
* @copydoc PandaNode::add_for_draw()
|
* @copydoc PandaNode::add_for_draw()
|
||||||
*/
|
*/
|
||||||
void ShaderTerrainMesh::add_for_draw(CullTraverser *trav, CullTraverserData &data) {
|
void ShaderTerrainMesh::add_for_draw(CullTraverser *trav, CullTraverserData &data) {
|
||||||
|
MutexHolder holder(_lock);
|
||||||
|
|
||||||
// Make sure the terrain was properly initialized, and the geom was created
|
// Make sure the terrain was properly initialized, and the geom was created
|
||||||
// successfully
|
// successfully
|
||||||
@ -711,6 +713,7 @@ void ShaderTerrainMesh::do_emit_chunk(Chunk* chunk, TraversalData* data) {
|
|||||||
* @return World-Space point
|
* @return World-Space point
|
||||||
*/
|
*/
|
||||||
LPoint3 ShaderTerrainMesh::uv_to_world(const LTexCoord& coord) const {
|
LPoint3 ShaderTerrainMesh::uv_to_world(const LTexCoord& coord) const {
|
||||||
|
MutexHolder holder(_lock);
|
||||||
nassertr(_heightfield_tex != nullptr, LPoint3(0)); // Heightfield not set yet
|
nassertr(_heightfield_tex != nullptr, LPoint3(0)); // Heightfield not set yet
|
||||||
nassertr(_heightfield_tex->has_ram_image(), LPoint3(0)); // Heightfield not in memory
|
nassertr(_heightfield_tex->has_ram_image(), LPoint3(0)); // Heightfield not in memory
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include "configVariableInt.h"
|
#include "configVariableInt.h"
|
||||||
#include "pStatCollector.h"
|
#include "pStatCollector.h"
|
||||||
#include "filename.h"
|
#include "filename.h"
|
||||||
|
#include "pmutex.h"
|
||||||
|
#include "mutexHolder.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
extern ConfigVariableBool stm_use_hexagonal_layout;
|
extern ConfigVariableBool stm_use_hexagonal_layout;
|
||||||
@ -160,6 +162,7 @@ private:
|
|||||||
void do_emit_chunk(Chunk* chunk, TraversalData* data);
|
void do_emit_chunk(Chunk* chunk, TraversalData* data);
|
||||||
bool do_check_lod_matches(Chunk* chunk, TraversalData* data);
|
bool do_check_lod_matches(Chunk* chunk, TraversalData* data);
|
||||||
|
|
||||||
|
Mutex _lock;
|
||||||
Chunk _base_chunk;
|
Chunk _base_chunk;
|
||||||
size_t _size;
|
size_t _size;
|
||||||
size_t _chunk_size;
|
size_t _chunk_size;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user