fix: fix blender 4.2 mesh issue.
- fix issue that blender 4.2 lost use_auto_smooth and calc_split_normals. (it almost works but not perfect. still need more debugging) - remove depracted material blend_mode. use modern one instead. (the modern setting make me consufes but it works)
This commit is contained in:
parent
aa602a7bb8
commit
6940428b88
@ -537,8 +537,6 @@ def _rail_creator_wrapper(fct_poly_cret: typing.Callable[[bmesh.types.BMesh], No
|
|||||||
bm.free()
|
bm.free()
|
||||||
|
|
||||||
# setup smooth for mesh
|
# setup smooth for mesh
|
||||||
mesh.use_auto_smooth = True
|
|
||||||
mesh.auto_smooth_angle = math.radians(50)
|
|
||||||
mesh.shade_smooth()
|
mesh.shade_smooth()
|
||||||
|
|
||||||
# create object and assoc with it
|
# create object and assoc with it
|
||||||
|
@ -403,7 +403,14 @@ def apply_to_blender_material(mtl: bpy.types.Material):
|
|||||||
|
|
||||||
# set some alpha data
|
# set some alpha data
|
||||||
mtl.use_backface_culling = not rawdata.mEnableTwoSided
|
mtl.use_backface_culling = not rawdata.mEnableTwoSided
|
||||||
mtl.blend_method = 'BLEND' if rawdata.mEnableAlphaBlend else 'OPAQUE'
|
if rawdata.mEnableAlphaBlend:
|
||||||
|
# In old format: mtl.blend_method = 'BLEND'
|
||||||
|
mtl.surface_render_method = 'BLENDED'
|
||||||
|
mtl.use_raytrace_refraction = True
|
||||||
|
else:
|
||||||
|
# In old format: mtl.blend_method = 'OPAQUE'
|
||||||
|
mtl.surface_render_method = 'DITHERED'
|
||||||
|
mtl.use_raytrace_refraction = False
|
||||||
|
|
||||||
# set texture
|
# set texture
|
||||||
if rawdata.mTexture is not None:
|
if rawdata.mTexture is not None:
|
||||||
|
@ -157,7 +157,6 @@ class MeshReader():
|
|||||||
# triangulate temp mesh
|
# triangulate temp mesh
|
||||||
if self.is_valid():
|
if self.is_valid():
|
||||||
self.__triangulate_mesh()
|
self.__triangulate_mesh()
|
||||||
self.__mAssocMesh.calc_normals_split()
|
|
||||||
|
|
||||||
def is_valid(self) -> bool:
|
def is_valid(self) -> bool:
|
||||||
return self.__mAssocMesh is not None
|
return self.__mAssocMesh is not None
|
||||||
@ -171,7 +170,6 @@ class MeshReader():
|
|||||||
def dispose(self) -> None:
|
def dispose(self) -> None:
|
||||||
if self.is_valid():
|
if self.is_valid():
|
||||||
# reset mesh
|
# reset mesh
|
||||||
self.__mAssocMesh.free_normals_split()
|
|
||||||
self.__mAssocMesh = None
|
self.__mAssocMesh = None
|
||||||
|
|
||||||
def get_vertex_position_count(self) -> int:
|
def get_vertex_position_count(self) -> int:
|
||||||
@ -203,10 +201,10 @@ class MeshReader():
|
|||||||
raise UTIL_functions.BBPException('try to call an invalid MeshReader.')
|
raise UTIL_functions.BBPException('try to call an invalid MeshReader.')
|
||||||
|
|
||||||
cache: UTIL_virtools_types.VxVector3 = UTIL_virtools_types.VxVector3()
|
cache: UTIL_virtools_types.VxVector3 = UTIL_virtools_types.VxVector3()
|
||||||
for nml in self.__mAssocMesh.loops:
|
for nml in self.__mAssocMesh.corner_normals:
|
||||||
cache.x = nml.normal.x
|
cache.x = nml.vector.x
|
||||||
cache.y = nml.normal.y
|
cache.y = nml.vector.y
|
||||||
cache.z = nml.normal.z
|
cache.z = nml.vector.z
|
||||||
yield cache
|
yield cache
|
||||||
|
|
||||||
def get_vertex_uv_count(self) -> int:
|
def get_vertex_uv_count(self) -> int:
|
||||||
@ -446,8 +444,6 @@ class MeshWriter():
|
|||||||
self.__mAssocMesh.polygons.add(len(self.__mFaceVertexCount))
|
self.__mAssocMesh.polygons.add(len(self.__mFaceVertexCount))
|
||||||
# create uv layer
|
# create uv layer
|
||||||
self.__mAssocMesh.uv_layers.new(do_init = False)
|
self.__mAssocMesh.uv_layers.new(do_init = False)
|
||||||
# split normals, it is IMPORTANT
|
|
||||||
self.__mAssocMesh.create_normals_split()
|
|
||||||
|
|
||||||
# add vertex position data
|
# add vertex position data
|
||||||
self.__mAssocMesh.vertices.foreach_set('co', self.__mVertexPos)
|
self.__mAssocMesh.vertices.foreach_set('co', self.__mVertexPos)
|
||||||
@ -500,8 +496,6 @@ class MeshWriter():
|
|||||||
self.__mAssocMesh.normals_split_custom_set(
|
self.__mAssocMesh.normals_split_custom_set(
|
||||||
tuple(_nest_custom_split_normal(loops_normals))
|
tuple(_nest_custom_split_normal(loops_normals))
|
||||||
)
|
)
|
||||||
# enable auto smooth. it is IMPORTANT
|
|
||||||
self.__mAssocMesh.use_auto_smooth = True
|
|
||||||
|
|
||||||
def __clear_mesh(self):
|
def __clear_mesh(self):
|
||||||
if not self.is_valid():
|
if not self.is_valid():
|
||||||
|
Loading…
Reference in New Issue
Block a user