Unity3d 创建Mesh报错 Mesh.vertices is too small

本文详细介绍了在Unity中动态创建Mesh时遇到的“Mesh.vertices is too small”及“Mesh with more than 65000 Vertices”错误,并分享了具体的解决方案,包括正确的Mesh清空方式和顶点信息赋值顺序。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考链接:https://answers.unity.com/questions/423569/meshvertices-is-too-small.html

公司项目有用到动态创建mesh的地方,如下图:

总共有4层mesh,运行一段时间就会报 Mesh.vertices is too small 的错误,通过参考链接了解到需要作出如下两处改动:

改动一:mesh清空处理(下面文章大体意思就是这个错误是由于,代码不断更新mesh的时候未做清空处理。)

改动二:新建mesh,顶点三角信息信息赋值给mesh完毕后,在将新建的mesh赋值给目标Mesh Filter组件的.mesh变量;

(下文图片内容:另外还提到,一定要在给新建的mesh赋值三角信息之前,赋值顶点信息)

这两处改动之后,如下图:我项目中问题不在复现。

对了,由于我这个4层扩散模型是随着时间动态变化的,所以,如果我一直开着的话,时间长了以后,会报一个错,Mesh with more than 65000 Vertices 或者错误 triangles is too large 3528;参考链接 https://answers.unity.com/questions/471639/mesh-with-more-than-65000-vertices.html

所以代码中加上判断如下:

就酱!

It is not the mountain we conquer but ourselves.
我们要征服的不是高山,而是自己。

ymtan@ecs-lj-openfoam:~/OpenFOAM/ymtan-v2412/run/250425/rigidBodyHull/background$ checkMesh -allGeometry -allTopology /*---------------------------------------------------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2412 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ Build : _8dbc61e11c-20241220 OPENFOAM=2412 version=v2412 Arch : "LSB;label=32;scalar=64" Exec : checkMesh -allGeometry -allTopology Date : May 28 2025 Time : 17:22:26 Host : ecs-lj-openfoam PID : 1115230 I/O : uncollated Case : /home/ymtan/OpenFOAM/ymtan-v2412/run/250425/rigidBodyHull/background nProcs : 1 trapFpe: Floating point exception trapping enabled (FOAM_SIGFPE). fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 5, maxFileModificationPolls 20) allowSystemOperations : Allowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create mesh for time = 0 Check mesh... Enabling all (cell, face, edge, point) topology checks. Enabling all geometry checks. Time = 0 Mesh stats points: 1171077 faces: 3255026 internal faces: 3144844 cells: 1045876 faces per cell: 6.119148 boundary patches: 13 point zones: 1 face zones: 0 cell zones: 0 Overall number of cells of each type: hexahedra: 970669 prisms: 12876 wedges: 7 pyramids: 0 tet wedges: 65 tetrahedra: 0 polyhedra: 62259 Breakdown of polyhedra by number of faces: faces number of cells 4 5946 5 4504 6 14031 7 110 8 139 9 26892 10 25 11 68 12 7666 13 3 14 35 15 2620 16 1 17 6 18 212 21 1 Checking topology... ****Problem with boundary patch 0 named oversetPatch of type overset. The patch should start on face no 3144844 and the patch specifies 3243735. Possibly consecutive patches have this same problem. Suppressing future warnings. ***Boundary definition is in error. Cell to face addressing OK. Point usage OK. Upper triangular ordering OK. Face vertices OK. Topological cell zip-up check OK. <<Number of duplicate (not baffle) faces found: 22. This might indicate a problem. <<Number of faces with non-consecutive shared points: 22. This might indicate a problem. <<Writing 66 faces with non-standard edge connectivity to set edgeFaces *Number of regions: 3 The mesh has multiple regions which are not connected by any face. <<Writing region information to "0/cellToRegion" <<Writing region 0 (fully disconnected) with 517350 cells to cellSet region0 <<Writing region 1 (fully disconnected) with 383501 cells to cellSet region1 <<Writing region 2 (fully disconnected) with 145025 cells to cellSet region2 Checking patch topology for multiply connected surfaces... Patch Faces Points Surface topology Bounding box oversetPatch 11291 11345 ok (closed singly connected) (-3.5137747 -0.11385833 0.015782884) (-3.3823898 0.11380627 0.24342155) overset-1 8440 8442 ok (closed singly connected) (-4.9998287 -1.1765634 -0.4005183) (5.0000125 1.1765635 2.6677242) outlet 3060 3172 ok (non-closed singly connected) (-7 -3 -1.8) (-7 3 5.28) inlet 3060 3172 ok (non-closed singly connected) (7 -3 -1.8) (7 3 5.28) ymin 7200 7381 ok (non-closed singly connected) (-7 -3 -1.8) (7 -3 5.28) ymax 7200 7381 ok (non-closed singly connected) (-7 3 -1.8) (7 3 5.28) zmin 6120 6292 ok (non-closed singly connected) (-7 -3 -1.8) (7 3 -1.8) atmosphere 6120 6292 ok (non-closed singly connected) (-7 -3 5.28) (7 3 5.28) HULL 29179 29931 ok (non-closed singly connected) (-3.600006 -0.60945788 -1.9512023e-06) (3.5892613 0.60945883 1.933472) HULL_DISK 87 105 ok (non-closed singly connected) (-3.3732875 -0.019542581 0.10979212) (-3.3724382 0.019934195 0.14859714) BLADES 26507 33135 ok (non-closed singly connected) (-3.4375999 -0.095075928 0.041281019) (-3.4059672 0.098815381 0.23087751) HUB_DISK 88 114 ok (non-closed singly connected) (-3.3985371 -0.020660421 0.10878564) (-3.3972407 0.020647007 0.15033154) HUB 1830 2674 ok (non-closed singly connected) (-3.4603339 -0.020660421 0.10878564) (-3.39743 0.020647007 0.15033154) ".*" 98891 106359 ok (closed singly connected) (-7 -3 -1.8) (7 3 5.28) Checking faceZone topology for multiply connected surfaces... No faceZones found. Checking basic cellZone addressing... No cellZones found. Checking basic pointZone addressing... PointZone PointsBoundingBox frozenPoints 0(1e+150 1e+150 1e+150) (-1e+150 -1e+150 -1e+150) Checking geometry... Overall domain bounding box (-7 -3 -1.8) (7 3 5.28) Mesh has 3 geometric (non-empty/wedge) directions (1 1 1) Mesh has 3 solution (non-empty) directions (1 1 1) Boundary openness (-2.1191257e-16 -1.1701675e-16 1.0552411e-15) OK. Max cell openness = 3.4499493e-16 OK. Max aspect ratio = 10.58398 OK. Minimum face area = 1.8622712e-09. Maximum face area = 0.015462575. Face area magnitudes OK. Min volume = 6.7187714e-11. Max volume = 0.0020033185. Total volume = 662.9577. Cell volumes OK. Mesh non-orthogonality Max: 69.978861 average: 5.2077846 Non-orthogonality check OK. Face pyramids OK. ***Max skewness = 18.358061, 36 highly skew faces detected which may impair the quality of the results <<Writing 36 skew faces to set skewFaces Coupled point location match (average 0) OK. ***Error in face tets: 2 faces with low quality or negative volume decomposition tets. <<Writing 2 faces with low quality or negative volume decomposition tets to set lowQualityTetFaces *Edges too small, min/max edge length = 3.0158475e-06 0.12979014, number too small: 18 <<Writing 18 points on short edges to set shortEdges *There are 1128 faces with concave angles between consecutive edges. Max concave angle = 79.784669 degrees. <<Writing 1128 faces with concave angles to set concaveFaces Face flatness (1 = flat, 0 = butterfly) : min = 0.35091858 average = 0.99944701 *There are 66 faces with ratio between projected and actual area < 0.8 Minimum ratio (minimum flatness, maximum warpage) = 0.35091858 <<Writing 66 warped faces to set warpedFaces Cell determinant (wellposedness) : minimum: 0.00098934483 average: 1.3639416 ***Cells with small determinant (< 0.001) found, number of cells: 1 <<Writing 1 under-determined cells to set underdeterminedCells ***Concave cells (using face planes) found, number of cells: 854 <<Writing 854 concave cells to set concaveCells Face interpolation weight : minimum: 0.065401151 average: 0.48202057 Face interpolation weight check OK. Face volume ratio : minimum: 0.011817813 average: 0.91971027 Face volume ratio check OK. Failed 4 mesh checks. Time = 0.1 Checking geometry... Overall domain bounding box (-7.0010041 -3.0000007 -1.8081815) (6.9989959 2.9999993 5.2718185) Mesh has 3 geometric (non-empty/wedge) directions (1 1 1) Mesh has 3 solution (non-empty) directions (1 1 1) Boundary openness (-1.4247891e-16 -4.8513891e-17 1.0347421e-15) OK. Max cell openness = 3.3602158e-16 OK. Max aspect ratio = 10.65007 OK. Minimum face area = 1.8622712e-09. Maximum face area = 0.015462575. Face area magnitudes OK. Min volume = 6.7187714e-11. Max volume = 0.0020033185. Total volume = 662.9577. Cell volumes OK. Mesh non-orthogonality Max: 69.978861 average: 5.2077846 Non-orthogonality check OK. Face pyramids OK. ***Max skewness = 18.358061, 36 highly skew faces detected which may impair the quality of the results <<Writing 36 skew faces to set skewFaces Coupled point location match (average 0) OK. ***Error in face tets: 2 faces with low quality or negative volume decomposition tets. <<Writing 2 faces with low quality or negative volume decomposition tets to set lowQualityTetFaces *Edges too small, min/max edge length = 3.0158475e-06 0.12979014, number too small: 18 <<Writing 18 points on short edges to set shortEdges *There are 1128 faces with concave angles between consecutive edges. Max concave angle = 79.784669 degrees. <<Writing 1128 faces with concave angles to set concaveFaces Face flatness (1 = flat, 0 = butterfly) : min = 0.35091858 average = 0.99944701 *There are 66 faces with ratio between projected and actual area < 0.8 Minimum ratio (minimum flatness, maximum warpage) = 0.35091858 <<Writing 66 warped faces to set warpedFaces Cell determinant (wellposedness) : minimum: 0.00098934483 average: 1.3639416 ***Cells with small determinant (< 0.001) found, number of cells: 1 <<Writing 1 under-determined cells to set underdeterminedCells ***Concave cells (using face planes) found, number of cells: 854 <<Writing 854 concave cells to set concaveCells Face interpolation weight : minimum: 0.065401151 average: 0.48202057 Face interpolation weight check OK. Face volume ratio : minimum: 0.011817813 average: 0.91971027 Face volume ratio check OK. Failed 4 mesh checks. Time = 0.2 Checking geometry... Overall domain bounding box (-7.004549 -3.0000049 -1.8351793) (6.995451 2.9999951 5.2448207) Mesh has 3 geometric (non-empty/wedge) directions (1 1 1) Mesh has 3 solution (non-empty) directions (1 1 1) Boundary openness (-1.3099804e-16 -9.8277796e-17 1.0607913e-15) OK. Max cell openness = 3.2277216e-16 OK. Max aspect ratio = 10.943125 OK. Minimum face area = 1.8622712e-09. Maximum face area = 0.015462575. Face area magnitudes OK. Min volume = 6.7187714e-11. Max volume = 0.0020033185. Total volume = 662.9577. Cell volumes OK. Mesh non-orthogonality Max: 69.978861 average: 5.2077846 Non-orthogonality check OK. Face pyramids OK. ***Max skewness = 18.358061, 36 highly skew faces detected which may impair the quality of the results <<Writing 36 skew faces to set skewFaces Coupled point location match (average 0) OK. ***Error in face tets: 2 faces with low quality or negative volume decomposition tets. <<Writing 2 faces with low quality or negative volume decomposition tets to set lowQualityTetFaces *Edges too small, min/max edge length = 3.0158475e-06 0.12979014, number too small: 18 <<Writing 18 points on short edges to set shortEdges *There are 1128 faces with concave angles between consecutive edges. Max concave angle = 79.784669 degrees. <<Writing 1128 faces with concave angles to set concaveFaces Face flatness (1 = flat, 0 = butterfly) : min = 0.35091858 average = 0.99944701 *There are 66 faces with ratio between projected and actual area < 0.8 Minimum ratio (minimum flatness, maximum warpage) = 0.35091858 <<Writing 66 warped faces to set warpedFaces Cell determinant (wellposedness) : minimum: 0.00098934483 average: 1.3639416 ***Cells with small determinant (< 0.001) found, number of cells: 1 <<Writing 1 under-determined cells to set underdeterminedCells ***Concave cells (using face planes) found, number of cells: 854 <<Writing 854 concave cells to set concaveCells Face interpolation weight : minimum: 0.065401151 average: 0.48202057 Face interpolation weight check OK. Face volume ratio : minimum: 0.011817813 average: 0.91971027 Face volume ratio check OK. Failed 4 mesh checks. Time = 0.3 Checking geometry... Overall domain bounding box (-7.0097797 -3.0000129 -1.8732831) (6.9902203 2.9999871 5.2067169) Mesh has 3 geometric (non-empty/wedge) directions (1 1 1) Mesh has 3 solution (non-empty) directions (1 1 1) Boundary openness (-1.7685801e-16 -1.5646894e-16 1.0557562e-15) OK. Max cell openness = 3.6004607e-16 OK. Max aspect ratio = 8.296384 OK. Minimum face area = 1.8622712e-09. Maximum face area = 0.015462575. Face area magnitudes OK. Min volume = 6.7187714e-11. Max volume = 0.0020033185. Total volume = 662.9577. Cell volumes OK. Mesh non-orthogonality Max: 69.978861 average: 5.2077846 Non-orthogonality check OK. Face pyramids OK. ***Max skewness = 18.358061, 36 highly skew faces detected which may impair the quality of the results <<Writing 36 skew faces to set skewFaces Coupled point location match (average 0) OK. ***Error in face tets: 2 faces with low quality or negative volume decomposition tets. <<Writing 2 faces with low quality or negative volume decomposition tets to set lowQualityTetFaces *Edges too small, min/max edge length = 3.0158475e-06 0.12979014, number too small: 18 <<Writing 18 points on short edges to set shortEdges *There are 1128 faces with concave angles between consecutive edges. Max concave angle = 79.784669 degrees. <<Writing 1128 faces with concave angles to set concaveFaces Face flatness (1 = flat, 0 = butterfly) : min = 0.35091858 average = 0.99944701 *There are 66 faces with ratio between projected and actual area < 0.8 Minimum ratio (minimum flatness, maximum warpage) = 0.35091858 <<Writing 66 warped faces to set warpedFaces Cell determinant (wellposedness) : minimum: 0.00098934483 average: 1.3639416 ***Cells with small determinant (< 0.001) found, number of cells: 1 <<Writing 1 under-determined cells to set underdeterminedCells ***Concave cells (using face planes) found, number of cells: 854 <<Writing 854 concave cells to set concaveCells Face interpolation weight : minimum: 0.065401151 average: 0.48202057 Face interpolation weight check OK. Face volume ratio : minimum: 0.011817813 average: 0.91971027 Face volume ratio check OK. Failed 4 mesh checks. End
最新发布
05-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

LuckyDog阿祥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值