Skip to content

Commit

Permalink
#80 Update collision
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed Oct 5, 2021
1 parent 58faa99 commit 71bf04a
Show file tree
Hide file tree
Showing 15 changed files with 475 additions and 237 deletions.
20 changes: 0 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,26 +237,6 @@ elseif (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
endif()

option(USE_MSVC_STRING_POOLING "Use MSVC /GF string pooling option" ON)
if (USE_MSVC_STRING_POOLING)
set(CMAKE_C_FLAGS "/GF ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "/GF ${CMAKE_CXX_FLAGS}")
endif()

option(USE_MSVC_FUNCTION_LEVEL_LINKING "Use MSVC /Gy function level linking option" ON)
if (USE_MSVC_FUNCTION_LEVEL_LINKING)
set(CMAKE_C_FLAGS "/Gy ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "/Gy ${CMAKE_CXX_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:REF")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:REF")
endif()

option(USE_MSVC_COMDAT_FOLDING "Use MSVC /OPT:ICF COMDAT folding option" ON)
if (USE_MSVC_COMDAT_FOLDING)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:ICF")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:ICF")
endif()

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
endif()

Expand Down
3 changes: 2 additions & 1 deletion Projects/Editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ include_directories(
${SKYLICHT_ENGINE_SOURCE_DIR}/Projects/Skylicht/System/Source
${SKYLICHT_ENGINE_SOURCE_DIR}/Projects/Skylicht/Engine/Source
${SKYLICHT_ENGINE_SOURCE_DIR}/Projects/Skylicht/Components/Source
${SKYLICHT_ENGINE_SOURCE_DIR}/Projects/Skylicht/Collision/Source
${SKYLICHT_ENGINE_SOURCE_DIR}/Projects/Skylicht/Physics/Source
${SKYLICHT_ENGINE_SOURCE_DIR}/Projects/Skylicht/Client/Source
${SKYLICHT_ENGINE_SOURCE_DIR}/Projects/Skylicht/Lightmapper/Source
${SKYLICHT_ENGINE_SOURCE_DIR}/Projects/Skylicht/Audio/Source
${SKYLICHT_ENGINE_SOURCE_DIR}/Projects/Skylicht/Crypto/Source
#${SKYLICHT_ENGINE_SOURCE_DIR}/Projects/Skylicht/Physics/Source
)

add_definitions(-DSKYLICHT_EDITOR)
Expand Down
3 changes: 3 additions & 0 deletions Projects/Editor/Source/Editor/CEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ This file is part of the "Skylicht Engine".

#include "SpaceController/CSceneController.h"
#include "SpaceController/CPropertyController.h"
#include "SpaceController/CCollisionController.h"

#include "AssetManager/CAssetManager.h"
#include "Selection/CSelection.h"
Expand Down Expand Up @@ -72,6 +73,7 @@ namespace Skylicht
m_spriteIcon->updateTexture();

// init controller
CCollisionController::createGetInstance();
CSceneController::createGetInstance()->initContextMenu(m_canvas);
CPropertyController::createGetInstance();
CSelection::createGetInstance();
Expand All @@ -84,6 +86,7 @@ namespace Skylicht
CEditorActivator::releaseInstance();
CPropertyController::releaseInstance();
CSceneController::releaseInstance();
CCollisionController::releaseInstance();
CSelection::releaseInstance();
CProjectSettings::releaseInstance();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
!@
MIT License
Copyright (c) 2021 Skylicht Technology CO., LTD
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, including without limitation the Rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This file is part of the "Skylicht Engine".
https://github.com/skylicht-lab/skylicht-engine
!#
*/

#include "pch.h"
#include "CCollisionController.h"

namespace Skylicht
{
namespace Editor
{
CCollisionController::CCollisionController()
{
m_bbCollision = new CBBCollisionManager();
}

CCollisionController::~CCollisionController()
{
delete m_bbCollision;
}

void CCollisionController::clear()
{
m_bbCollision->clear();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
!@
MIT License
Copyright (c) 2021 Skylicht Technology CO., LTD
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, including without limitation the Rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This file is part of the "Skylicht Engine".
https://github.com/skylicht-lab/skylicht-engine
!#
*/

#pragma once

#include "Utils/CGameSingleton.h"

#include "Collision/CBBCollisionManager.h"

namespace Skylicht
{
namespace Editor
{
class CCollisionController :public CGameSingleton<CCollisionController>
{
protected:
CBBCollisionManager* m_bbCollision;

public:
CCollisionController();

virtual ~CCollisionController();

inline CBBCollisionManager* getBBCollision()
{
return m_bbCollision;
}

void clear();
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ This file is part of the "Skylicht Engine".
*/

#include "pch.h"

#include "CSceneController.h"
#include "CPropertyController.h"
#include "CCollisionController.h"

#include "Selection/CSelection.h"

#include "Scene/CSceneExporter.h"
Expand Down Expand Up @@ -137,6 +140,8 @@ namespace Skylicht
// clear current scene gui
CSelection::getInstance()->clear();
CPropertyController::getInstance()->setProperty(NULL);
CCollisionController::getInstance()->clear();

CHandles::getInstance()->end();
CHandles::getInstance()->setNullRenderer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ This file is part of the "Skylicht Engine".
#include "Editor/CEditor.h"
#include "Handles/CHandles.h"

#include "Editor/SpaceController/CCollisionController.h"

namespace Skylicht
{
namespace Editor
Expand All @@ -48,7 +50,8 @@ namespace Skylicht

CGDirectionLight::~CGDirectionLight()
{

CBBCollisionManager* bbCollision = CCollisionController::getInstance()->getBBCollision();
bbCollision->removeCollision(&m_collisionNode, 1);
}

void CGDirectionLight::initComponent()
Expand All @@ -63,6 +66,9 @@ namespace Skylicht
m_sprite->setEnableSerializable(false);

addLinkComponent(m_sprite);

CBBCollisionManager* bbCollision = CCollisionController::getInstance()->getBBCollision();
m_collisionNode = bbCollision->addBBCollision(m_gameObject, core::aabbox3df(core::vector3df(-2.0f, -2.0f, -2.0f), core::vector3df(2.0f, 2.0f, 2.0f)));
}

void CGDirectionLight::updateComponent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ This file is part of the "Skylicht Engine".
#include "EditorComponents/CGizmosComponent.h"
#include "Lighting/CDirectionalLight.h"
#include "SpriteDraw/CSprite.h"
#include "Collision/CCollisionNode.h"

namespace Skylicht
{
Expand All @@ -37,6 +38,7 @@ namespace Skylicht
protected:
CDirectionalLight* m_directionLight;
CSprite* m_sprite;
CCollisionNode* m_collisionNode;

public:
CGDirectionLight();
Expand Down
2 changes: 1 addition & 1 deletion Projects/Editor/Source/GUI/Controls/CText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace Skylicht
if (s.length() > 0 && s[s.length() - 1] != '\n')
s += '\n';

for (u32 i = 0, n = s.length(); i < n; i++)
for (u32 i = 0, n = (u32)s.length(); i < n; i++)
{
float distance = fabs(x - point.X);

Expand Down
10 changes: 5 additions & 5 deletions Projects/Editor/Source/GUI/Controls/CTextContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ namespace Skylicht
}

m_string.insert(m_caretBegin, string);
m_caretBegin += string.length();
m_caretBegin += (u32)string.length();

m_textChange = true;

Expand All @@ -357,7 +357,7 @@ namespace Skylicht
void CTextContainer::setCaretBegin(u32 line, u32 c)
{
if (line > m_lines.size())
line = m_lines.size() - 1;
line = (u32)m_lines.size() - 1;

m_caretBeginLine = line;
m_caretBeginPosition = c;
Expand All @@ -369,7 +369,7 @@ namespace Skylicht
void CTextContainer::setCaretEnd(u32 line, u32 c)
{
if (line > m_lines.size())
line = m_lines.size() - 1;
line = (u32)m_lines.size() - 1;

m_caretEndLine = line;
m_caretEndPosition = c;
Expand Down Expand Up @@ -533,7 +533,7 @@ namespace Skylicht
if (foundLine != NULL)
{
const std::wstring& s = foundLine->getString();
u32 length = s.length();
u32 length = (u32)s.length();
if (charPosition < length)
{
bool isCharacterGroup = isCharacter(s[charPosition]);
Expand Down Expand Up @@ -771,7 +771,7 @@ namespace Skylicht
{
if (m_lines.size() > 0)
{
u32 caretLineID = m_lines.size() - 1;
u32 caretLineID = (u32)m_lines.size() - 1;
u32 caretCharID = m_lines.back()->getLength();

setCaretBegin(caretLineID, caretCharID);
Expand Down
Loading

0 comments on commit 71bf04a

Please sign in to comment.