Fluid Particles: fix threading crash with viscoelastic springs.
As correctly pointed out by a comment in the code, adding new springs wasn't thread safe, and caused crashes. Fix by buffering new springs in intermediate thread-local arrays, which are flushed on the main thread. This is valid because the new springs are not used until the next sim step. Differential Revision: https://developer.blender.org/D6133
This commit is contained in:
@@ -83,4 +83,14 @@ void _bli_buffer_free(BLI_Buffer *buffer);
|
||||
} \
|
||||
(void)0
|
||||
|
||||
/* A buffer embedded in a struct. Using memcpy is allowed until first resize. */
|
||||
#define BLI_buffer_field_init(name_, type_) \
|
||||
{ \
|
||||
memset(name_, 0, sizeof(*name_)); \
|
||||
*(size_t *)&((name_)->elem_size) = sizeof(type_); \
|
||||
} \
|
||||
(void)0
|
||||
|
||||
#define BLI_buffer_field_free(name_) _bli_buffer_free(name_)
|
||||
|
||||
#endif /* __BLI_BUFFER_H__ */
|
||||
|
||||
Reference in New Issue
Block a user