From 7bc99d072699bc3fabfc2264127aa2fc26d64068 Mon Sep 17 00:00:00 2001 From: Jrius <2261279+Jrius@users.noreply.github.com> Date: Tue, 31 Aug 2021 17:01:54 +0200 Subject: [PATCH] Replace object.location with matrix_world.translation --- korman/exporter/camera.py | 2 +- korman/exporter/material.py | 2 +- korman/exporter/mesh.py | 2 +- korman/properties/modifiers/avatar.py | 5 +---- korman/properties/modifiers/gui.py | 4 ++-- korman/properties/modifiers/water.py | 8 ++++---- korman/properties/prop_camera.py | 2 +- 7 files changed, 11 insertions(+), 14 deletions(-) diff --git a/korman/exporter/camera.py b/korman/exporter/camera.py index c942fde..6b97cba 100644 --- a/korman/exporter/camera.py +++ b/korman/exporter/camera.py @@ -132,7 +132,7 @@ class CameraConverter: # specifying an actual center allows you to do interesting things like animate the center... # Fascinating! Therefore, we will expose the Plasma Object... if props.circle_center is None: - brain.center = hsVector3(*bo.location) + brain.center = hsVector3(*bo.matrix_world.translation) else: brain.centerObject = self._mgr.find_create_key(plSceneObject, bl=props.circle_center) # This flag has no effect in CWE, but I'm using it for correctness' sake diff --git a/korman/exporter/material.py b/korman/exporter/material.py index f316f0c..05095d1 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -779,7 +779,7 @@ class MaterialConverter: # will probably want to steal it for diabolical purposes... In MOUL, root objects are # allowed, but that introduces a gotcha with regard to animated roots and PotS. Also, # sharing root objects with a DCM seems to result in bad problems in game O.o - pl_env.position = hsVector3(*viewpt.location) + pl_env.position = hsVector3(*viewpt.matrix_world.translation) if layer is not None: layer.UVWSrc = plLayerInterface.kUVWReflect diff --git a/korman/exporter/mesh.py b/korman/exporter/mesh.py index 8187854..afbf7cf 100644 --- a/korman/exporter/mesh.py +++ b/korman/exporter/mesh.py @@ -658,7 +658,7 @@ class MeshConverter(_MeshManager): # FIXME: Can some of this be generalized? geospan.props |= (plGeometrySpan.kWaterHeight | plGeometrySpan.kLiteVtxNonPreshaded | plGeometrySpan.kPropReverseSort | plGeometrySpan.kPropNoShadow) - geospan.waterHeight = bo.location[2] + geospan.waterHeight = bo.matrix_world.translation[2] return [_GeoSpan(bo, blmat, geospan)], None else: geospans = [None] * len(materials) diff --git a/korman/properties/modifiers/avatar.py b/korman/properties/modifiers/avatar.py index 3bc2e80..00455e6 100644 --- a/korman/properties/modifiers/avatar.py +++ b/korman/properties/modifiers/avatar.py @@ -64,10 +64,7 @@ class PlasmaLadderModifier(PlasmaModifierProperties): ladderVec = self.facing_object.matrix_world.translation - bo.matrix_world.translation else: # Make our own artificial target -1.0 units back on the local Y axis. - world = bo.matrix_world.copy() - world.invert() - target = bo.location - (mathutils.Vector((0.0, 1.0, 0.0)) * world) - ladderVec = target - bo.matrix_local.translation + ladderVec = mathutils.Vector((0, -1, 0)) * bo.matrix_world.inverted() mod.ladderView = hsVector3(ladderVec.x, ladderVec.y, 0.0) mod.ladderView.normalize() diff --git a/korman/properties/modifiers/gui.py b/korman/properties/modifiers/gui.py index d4921d2..1fc43ab 100644 --- a/korman/properties/modifiers/gui.py +++ b/korman/properties/modifiers/gui.py @@ -230,7 +230,7 @@ class PlasmaJournalBookModifier(PlasmaModifierProperties, PlasmaModifierLogicWiz if self.clickable_region is None: with utils.bmesh_object("{}_Journal_ClkRgn".format(self.key_name)) as (rgn_obj, bm): bmesh.ops.create_cube(bm, size=(6.0)) - bmesh.ops.transform(bm, matrix=mathutils.Matrix.Translation(bo.location - rgn_obj.location), + bmesh.ops.transform(bm, matrix=mathutils.Matrix.Translation(bo.matrix_world.translation - rgn_obj.matrix_world.translation), space=rgn_obj.matrix_world, verts=bm.verts) rgn_obj.plasma_object.enabled = True rgn_obj.hide_render = True @@ -466,7 +466,7 @@ class PlasmaLinkingBookModifier(PlasmaModifierProperties, PlasmaModifierLogicWiz if self.clickable_region is None: with utils.bmesh_object("{}_LinkingBook_ClkRgn".format(self.key_name)) as (rgn_obj, bm): bmesh.ops.create_cube(bm, size=(6.0)) - rgn_offset = mathutils.Matrix.Translation(self.clickable.location - bo.location) + rgn_offset = mathutils.Matrix.Translation(self.clickable.matrix_world.translation - bo.matrix_world.translation) bmesh.ops.transform(bm, matrix=rgn_offset, space=bo.matrix_world, verts=bm.verts) rgn_obj.plasma_object.enabled = True rgn_obj.hide_render = True diff --git a/korman/properties/modifiers/water.py b/korman/properties/modifiers/water.py index 806883b..891c7fb 100644 --- a/korman/properties/modifiers/water.py +++ b/korman/properties/modifiers/water.py @@ -114,7 +114,7 @@ class PlasmaSwimRegion(idprops.IDPropObjectMixin, PlasmaModifierProperties, bpy. losdbs = ["kLOSDBSwimRegion"] member_group = "kGroupLOSOnly" if exporter.mgr.getVer() != pvMoul else "kGroupStatic" if bo.plasma_modifiers.water_basic.enabled: - exporter.physics.generate_flat_proxy(bo, so, z_coord=bo.location[2], + exporter.physics.generate_flat_proxy(bo, so, z_coord=bo.matrix_world.translation[2], member_group=member_group, losdbs=losdbs) else: @@ -125,7 +125,7 @@ class PlasmaSwimRegion(idprops.IDPropObjectMixin, PlasmaModifierProperties, bpy. # Detector region bounds if self.region is not None: region_so = exporter.mgr.find_create_object(plSceneObject, bl=self.region) - + # Good news: if this phys has already been exported, this is basically a noop member_group = "kGroupDetector" if exporter.mgr.getVer() == "pvMoul" else "kGroupLOSOnly" exporter.physics.generate_physical(self.region, region_so, @@ -258,7 +258,7 @@ class PlasmaWaterModifier(idprops.IDPropMixin, PlasmaModifierProperties, bpy.typ # Stuff we expose state = waveset.state state.rippleScale = self.ripple_scale - state.waterHeight = bo.location[2] + state.waterHeight = bo.matrix_world.translation[2] state.windDir = wind_dir state.specVector = hsVector3(self.noise / 100.0, self.specular_start, self.specular_end) state.specularTint = hsColorRGBA(*self.specular_tint, alpha=self.specular_alpha) @@ -273,7 +273,7 @@ class PlasmaWaterModifier(idprops.IDPropMixin, PlasmaModifierProperties, bpy.typ state.envCenter = dem.position state.envRefresh = dem.refreshRate else: - state.envCenter = hsVector3(*bo.location) + state.envCenter = hsVector3(*bo.matrix_world.translation) state.envRefresh = 0.0 state.envRadius = self.envmap_radius diff --git a/korman/properties/prop_camera.py b/korman/properties/prop_camera.py index 5d46fc7..0be191f 100644 --- a/korman/properties/prop_camera.py +++ b/korman/properties/prop_camera.py @@ -225,7 +225,7 @@ class PlasmaCameraProperties(bpy.types.PropertyGroup): """Gets the circle camera radius for this camera when it is attached to the given Object""" assert bo is not None if self.circle_center is not None: - vec = bo.location - self.circle_center.location + vec = bo.matrix_world.translation - self.circle_center.matrix_world.translation return vec.magnitude return self.circle_radius_value