Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qtquick3dphysics-cooking.qdoc
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qtquick3dphysics-cooking.html
6\title Qt Quick 3D Physics Cooking
7\brief An explanation of how Qt Quick 3D Physics handles meshes and cooking.
8
9When using a mesh as a collision shape it needs to be processed and converted into a data format for efficient collision detection.
10This is referred to as 'cooking'.
11There are three shape types that need to be cooked before they can be used, namely ConvexMeshShape, TriangleMeshShape and HeightFieldShape.
12The cooking happens automatically on the first frame of the simulation when using any of these shapes.
13This cooking can incur a noticeable performance cost so to enable faster loading times it is possible to precook the meshes and load them directly.
14There are two ways to do this, namely using a cache directory or the cooker tool.
15
16\section1 Cache directory
17
18To use the cache directory set the \c QT_PHYSICS_CACHE_PATH environment variable to a directory of choice.
19When the application runs for the first time all used meshes will be cooked and stored in this directory.
20The following times the application runs, the cooked meshes will be read from disk instead of being cooked.
21
22\section1 Cooker tool
23
24The other way is to use the \c cooker tool. Build it, then simply call the tool with the mesh or heightfield image as the input argument:
25\code
26cooker input.mesh
27\endcode
28or
29\code
30cooker input.png
31\endcode
32
33If the input is a mesh it will generate two files:
34\list
35 \li \c input.cooked.tri
36 \li \c input.cooked.cvx
37\endlist
38
39One file is a cooked triangle mesh and the other a cooked convex mesh.
40These can then simply be used as the sources of TriangleMeshShape::source and ConvexMeshShape::source and the meshes will be loaded without any need for cooking.
41Similiarily, if the input is an image file a heightfield is generated called \c input.cooked.hf which can then be loaded by referencing it in the HeightFieldShape::source property.
42
43
44*/