| 24 | #if COMPILE_WITH_PHYSICS_COOKING |
| 25 | |
| 26 | bool CollisionData::CookCollision(CollisionDataType type, ModelBase* modelObj, int32 modelLodIndex, uint32 materialSlotsMask, ConvexMeshGenerationFlags convexFlags, int32 convexVertexLimit) |
| 27 | { |
| 28 | if (!IsVirtual()) |
| 29 | { |
| 30 | LOG(Warning, "Only virtual assets can be modified at runtime."); |
| 31 | return true; |
| 32 | } |
| 33 | if (IsInMainThread() && modelObj && modelObj->IsVirtual()) |
| 34 | { |
| 35 | LOG(Error, "Cannot cook collision data for virtual models on a main thread (virtual models data is stored on GPU only). Use thread pool or async task."); |
| 36 | return true; |
| 37 | } |
| 38 | PROFILE_CPU(); |
| 39 | PROFILE_MEM(Physics); |
| 40 | |
| 41 | // Prepare |
| 42 | CollisionCooking::Argument arg; |
| 43 | arg.Type = type; |
| 44 | arg.Model = modelObj; |
| 45 | arg.ModelLodIndex = modelLodIndex; |
| 46 | arg.MaterialSlotsMask = materialSlotsMask; |
| 47 | arg.ConvexFlags = convexFlags; |
| 48 | arg.ConvexVertexLimit = convexVertexLimit; |
| 49 | |
| 50 | // Cook collision |
| 51 | SerializedOptions options; |
| 52 | BytesContainer outputData; |
| 53 | if (CollisionCooking::CookCollision(arg, options, outputData)) |
| 54 | return true; |
| 55 | |
| 56 | // Load data |
| 57 | unload(true); |
| 58 | if (load(&options, outputData.Get(), outputData.Length()) != LoadResult::Ok) |
| 59 | return true; |
| 60 | |
| 61 | // Mark as loaded (eg. Mesh Colliders using this asset will update shape for physics simulation) |
| 62 | onLoaded(); |
| 63 | return false; |
| 64 | } |
| 65 | |
| 66 | bool CollisionData::CookCollision(CollisionDataType type, const Span<Float3>& vertices, const Span<uint32>& triangles, ConvexMeshGenerationFlags convexFlags, int32 convexVertexLimit) |
| 67 | { |
nothing calls this directly
no test coverage detected