#5 Make automatic_rotate relative, allow setting rotation

Open
pgimeno wants to merge 1 commits from pgimeno/pg-auto-rotate-relative into pgimeno/master
1 changed files with 7 additions and 10 deletions
  1. 7 10
      src/client/content_cao.cpp

+ 7 - 10
src/client/content_cao.cpp

@@ -989,11 +989,12 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
 			updateTextures(m_previous_texture_modifier);
 		}
 	}
-	if (!getParent() && std::fabs(m_prop.automatic_rotate) > 0.001) {
-		m_rotation.Y += dtime * m_prop.automatic_rotate * 180 / M_PI;
-		rot_translator.val_current = m_rotation;
-		updateNodePos();
-	}
+
+	// This is the child node's rotation. It is only used for automatic_rotate.
+	v3f local_rot = node->getRotation();
+	local_rot.Y = modulo360f(local_rot.Y - dtime * core::RADTODEG *
+			(getParent() ? 0.f : m_prop.automatic_rotate));
+	node->setRotation(local_rot);
 
 	if (!getParent() && m_prop.automatic_face_movement_dir &&
 			(fabs(m_velocity.Z) > 0.001 || fabs(m_velocity.X) > 0.001)) {
@@ -1367,11 +1368,7 @@ void GenericCAO::processMessage(const std::string &data)
 		m_position = readV3F32(is);
 		m_velocity = readV3F32(is);
 		m_acceleration = readV3F32(is);
-
-		if (std::fabs(m_prop.automatic_rotate) < 0.001f)
-			m_rotation = readV3F32(is);
-		else
-			readV3F32(is);
+		m_rotation = readV3F32(is);
 
 		m_rotation = wrapDegrees_0_360_v3f(m_rotation);
 		bool do_interpolate = readU8(is);