Skip to content

Commit

Permalink
修改了kbe的issue:addYawRotator不正常的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxq committed Jul 13, 2016
1 parent 0cf2b20 commit c53bd28
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
8 changes: 4 additions & 4 deletions Assets/StriveGame/Lua/KbePlugins/KBEngine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ KBEngineLua.Client_onUpdateData_y = function(stream)

local eid = KBEngineLua.getAoiEntityIDFromStream(stream);

local y = stream:readPackY();
local y = stream:readInt8();

KBEngineLua._updateVolatileData(eid, 0.0, 0.0, 0.0, y, KBEngineLua.KBE_FLT_MAX, KBEngineLua.KBE_FLT_MAX, -1);
end
Expand Down Expand Up @@ -1379,17 +1379,17 @@ KBEngineLua._updateVolatileData = function(entityID, x, y, z, yaw, pitch, roll,

if(roll ~= KBEngineLua.KBE_FLT_MAX) then
changeDirection = true;
entity.direction.x = KBEngineLua.int82angle(roll, false) * 360 / (Mathf.PI * 2);
entity.direction.x = KBEngineLua.int82angle(roll, false);
end

if(pitch ~= KBEngineLua.KBE_FLT_MAX) then
changeDirection = true;
entity.direction.y = KBEngineLua.int82angle(pitch, false) * 360 / (Mathf.PI * 2);
entity.direction.y = KBEngineLua.int82angle(pitch, false);
end

if(yaw ~= KBEngineLua.KBE_FLT_MAX) then
changeDirection = true;
entity.direction.z = KBEngineLua.int82angle(yaw, false) * 360 / (Mathf.PI * 2);
entity.direction.z = KBEngineLua.int82angle(yaw, false);
end

local done = false;
Expand Down
13 changes: 12 additions & 1 deletion Assets/StriveGame/Lua/Logic/World.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ require "Logic/SkillControl"
World = {
};

local convertRad2Angle = 360 / (Mathf.PI * 2);

function World.init()
Event.AddListener("onAvatarEnterWorld", World.onAvatarEnterWorld);
Event.AddListener("onEnterWorld", World.onEnterWorld);
Expand Down Expand Up @@ -115,6 +117,12 @@ function World.InitEntity( entity )
if entity.name then
World.set_name( entity , entity.name )
end
if entity.direction then
World.set_direction( entity )
end
if entity.position then
World.set_position( entity )
end
end

function World.onLeaveWorld(entity)
Expand All @@ -138,7 +146,10 @@ function World.set_position( entity )
end

function World.set_direction( entity )
entity.gameEntity.m_destDirection = Vector3.New(entity.direction.y, entity.direction.z, entity.direction.x);
entity.gameEntity.m_destDirection = Vector3.New();
entity.gameEntity.m_destDirection.x = entity.direction.y * convertRad2Angle;
entity.gameEntity.m_destDirection.y = entity.direction.z * convertRad2Angle;
entity.gameEntity.m_destDirection.z = entity.direction.x * convertRad2Angle;
end

function World.set_name( entity , v)
Expand Down
12 changes: 4 additions & 8 deletions Assets/StriveGame/Lua/kbe/Interface/GameObject.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ function KBEngineLua.GameObject:set_position( old )
end

function KBEngineLua.GameObject:set_direction(old)
--log(self.className .. "::set_direction: " .. old.x ..old.y ..old.z);
self.direction.x = self.direction.x * 360 / (Mathf.PI * 2);
self.direction.y = self.direction.y * 360 / (Mathf.PI * 2);
self.direction.z = self.direction.z * 360 / (Mathf.PI * 2);

--Event.Brocast("set_direction", entity);
--log(className + "::set_direction: " + old + " => " + v);
-- self.direction.x = self.direction.x * 360 / (Mathf.PI * 2);
-- self.direction.y = self.direction.y * 360 / (Mathf.PI * 2);
-- self.direction.z = self.direction.z * 360 / (Mathf.PI * 2);
if(self.inWorld) then
Event.Brocast("set_direction", entity);
Event.Brocast("set_direction", self);
end
end

Expand Down

0 comments on commit c53bd28

Please sign in to comment.