Sprite Quaternion Fix
Authors: Blizzard
Version: 1.1
Type: Bug Fix
Key Term: Misc Add-on
IntroductionRGSS2Player has a problem with Sprite rotations. If the angle of a sprite is set to an angle that satisfies the condition "ANGLE % 360 == 180", then Game.exe might crash on some PCs, depending on the DirectX DLLs loaded. This mini-script is a workaround for this problem to avoid the crash by setting the Sprite angle to a value very close to the current one, but offset enough to prevent the crash.
This problem happens because of how quaternions work in orientation calculation in 3D space, because quaternions have a conceptual problem that they cannot contain the information if the angle is exactly 180° (instead the quaternion shows that it's 0°).
This work is protected by the following license:
Quote
Creative Commons - Attribution-ShareAlike 3.0 Unported
( http://creativecommons.org/licenses/by-sa/3.0/ )
You are free:
to Share - to copy, distribute and transmit the work
to Remix - to adapt the work
to make commercial use of the work
Under the following conditions:
Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
Share alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
With the understanding that:
Waiver - Any of the above conditions can be waived if you get permission from the copyright holder.
Public Domain - Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license.
Other Rights - In no way are any of the following rights affected by the license:
- Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations;
- The author's moral rights;
- Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.
Notice - For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.
Features
ScreenshotsN/A for this type of script.
DemoN/A
Script#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Sprite Quaternion Fix by Blizzard
# Version: 1.1
# Type: Bug Fix
# Date: 9.4.2013
# Date v1.1: 13.4.2013
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
# Should be compatible with anything.
#
#
# Instructions:
#
# Make a new script above all your other scripts and paste this code into it.
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#==============================================================================
# Sprite
#==============================================================================
class Sprite
attr_reader :angle
alias initialize_quaternion_fix_alias initialize
def initialize(viewport = nil)
initialize_quaternion_fix_alias(viewport)
@angle = 0.0
end
alias angle_assign_quaternion_fix_alias angle=
def angle=(value)
if @angle != value
@angle = value
value *= 1.00001 if value % 360 == 180 || value % 180 == 90
angle_assign_quaternion_fix_alias(value)
end
end
end
InstructionsMake a new script
above all your other scripts and paste this code into it.
CompatibilityShould be compatible with anything.
Credits and Thanks
Author's NotesIf you find any bugs, please report them here:
http://forum.chaos-project.comThat's it! N-Joy! =D