Merge branch 'noggit-shadowlands' into 'master'
# Conflicts: # CMakeLists.txt # src/noggit/MapChunk.cpp # src/noggit/World.cpp # src/noggit/World.h
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "src/external/dbcd-cpp"]
|
||||
path = src/external/dbcd-cpp
|
||||
url = https://gitlab.com/prophecy-rp/dbcd-cpp.git
|
||||
726
CMakeLists.txt
726
CMakeLists.txt
@@ -1,181 +1,75 @@
|
||||
# This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
#██████ █████ ███████ █████████ █████████ █████ ███████████ ███████████ ██████████ ██████████
|
||||
#░░██████ ░░███ ███░░░░░███ ███░░░░░███ ███░░░░░███░░███ ░█░░░███░░░█ ░░███░░░░░███ ░░███░░░░░█░░███░░░░███
|
||||
# ░███░███ ░███ ███ ░░███ ███ ░░░ ███ ░░░ ░███ ░ ░███ ░ ░███ ░███ ░███ █ ░ ░███ ░░███
|
||||
# ░███░░███░███ ░███ ░███░███ ░███ ░███ ░███ ░██████████ ░██████ ░███ ░███
|
||||
# ░███ ░░██████ ░███ ░███░███ █████░███ █████ ░███ ░███ ░███░░░░░███ ░███░░█ ░███ ░███
|
||||
# ░███ ░░█████ ░░███ ███ ░░███ ░░███ ░░███ ░░███ ░███ ░███ ░███ ░███ ░███ ░ █ ░███ ███
|
||||
# █████ ░░█████ ░░░███████░ ░░█████████ ░░█████████ █████ █████ █████ █████ ██████████ ██████████
|
||||
#░░░░░ ░░░░░ ░░░░░░░ ░░░░░░░░░ ░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░░░ ░░░░░░░░░░
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.3)
|
||||
CMAKE_POLICY(SET CMP0057 NEW) # "Support new IN_LIST if() operator."
|
||||
SET(CMAKE_CXX_STANDARD 20)
|
||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
SET(CMAKE_C_STANDARD 11)
|
||||
SET(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
|
||||
cmake_minimum_required(VERSION 3.3)
|
||||
cmake_policy (SET CMP0057 NEW) # "Support new IN_LIST if() operator."
|
||||
set (CMAKE_CXX_STANDARD 20)
|
||||
set (CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set (CMAKE_C_STANDARD 11)
|
||||
set (CMAKE_C_STANDARD_REQUIRED ON)
|
||||
#Including cmake dependencies
|
||||
INCLUDE(CheckCXXCompilerFlag)
|
||||
INCLUDE(cmake/cmake_function.cmake)
|
||||
INCLUDE(cmake/cmake_macro.cmake)
|
||||
|
||||
# Project name
|
||||
project(Noggit)
|
||||
|
||||
|
||||
include (CheckCXXCompilerFlag)
|
||||
macro (add_compiler_flag_if_supported _VAR _FLAG)
|
||||
string (MAKE_C_IDENTIFIER "CXX_COMPILER_SUPPORTS_${_FLAG}" _test_variable)
|
||||
check_cxx_compiler_flag ("${_FLAG}" ${_test_variable})
|
||||
if (${_test_variable})
|
||||
if ("${${_VAR}}" STREQUAL "")
|
||||
set (${_VAR} "${_FLAG}")
|
||||
else()
|
||||
set (${_VAR} "${${_VAR}} ${_FLAG}")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
function(
|
||||
collect_files
|
||||
output
|
||||
base_dir
|
||||
do_recurse
|
||||
globbing_exprs
|
||||
exclude_dirs
|
||||
)
|
||||
if("${do_recurse}")
|
||||
set(glob GLOB_RECURSE)
|
||||
else()
|
||||
set(glob GLOB)
|
||||
endif()
|
||||
|
||||
set(base_dir "${CMAKE_SOURCE_DIR}/${base_dir}")
|
||||
list(
|
||||
TRANSFORM
|
||||
globbing_exprs
|
||||
PREPEND "${base_dir}/"
|
||||
)
|
||||
file(
|
||||
${glob}
|
||||
files
|
||||
CONFIGURE_DEPENDS
|
||||
${globbing_exprs}
|
||||
)
|
||||
|
||||
foreach(
|
||||
file
|
||||
IN LISTS files
|
||||
)
|
||||
set(match FALSE)
|
||||
|
||||
foreach(
|
||||
dir
|
||||
IN LISTS exclude_dirs
|
||||
)
|
||||
if("${file}" MATCHES "/${dir}/")
|
||||
set(match TRUE)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT ${match})
|
||||
list(
|
||||
APPEND
|
||||
result
|
||||
"${file}"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(
|
||||
${output} "${result}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(
|
||||
contains_filter
|
||||
output
|
||||
files
|
||||
regex
|
||||
)
|
||||
foreach(
|
||||
file
|
||||
IN LISTS files
|
||||
)
|
||||
file(
|
||||
STRINGS
|
||||
"${file}"
|
||||
contents
|
||||
REGEX "${regex}"
|
||||
)
|
||||
|
||||
if("${contents}")
|
||||
list(
|
||||
APPEND
|
||||
result
|
||||
"${file}"
|
||||
)
|
||||
MESSAGE("Moced: ${file}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(
|
||||
${output} "${result}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endfunction()
|
||||
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -fcolor-diagnostics)
|
||||
|
||||
# covered by CMAKE_CXX_STANDARD
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-c++98-compat)
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-c++98-compat-pedantic)
|
||||
|
||||
# covered by compilers used
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-gnu-anonymous-struct)
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-variadic-macros)
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-vla)
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-vla-extension)
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-zero-length-array)
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-gnu-zero-variadic-macro-arguments)
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-nested-anon-types)
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-four-char-constants)
|
||||
|
||||
# we assume that our constructors and destructors do not access other global state
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-exit-time-destructors)
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-global-constructors)
|
||||
|
||||
# is fine with GNU, required due to our libstdc
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-disabled-macro-expansion)
|
||||
|
||||
# we can live with the compilation unit containing the vtable not being fixed
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-weak-vtables)
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-weak-template-vtables)
|
||||
#Project name
|
||||
PROJECT(Noggit)
|
||||
|
||||
#Covered by CMAKE_CXX_STANDARD
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-c++98-compat)
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-c++98-compat-pedantic)
|
||||
#Covered by compilers used
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-gnu-anonymous-struct)
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-variadic-macros)
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-vla)
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-vla-extension)
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-zero-length-array)
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-gnu-zero-variadic-macro-arguments)
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-nested-anon-types)
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-four-char-constants)
|
||||
#We assume that our constructors and destructors do not access other global state
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-exit-time-destructors)
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-global-constructors)
|
||||
#Is fine with GNU, required due to our libstdc
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-disabled-macro-expansion)
|
||||
#We can live with the compilation unit containing the vtable not being fixed
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-weak-vtables)
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-weak-template-vtables)
|
||||
# __DATE__ and __TIME__ not being reproducible is exactly why they exist.
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-date-time)
|
||||
|
||||
# we don't care for a few bytes
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-padded)
|
||||
|
||||
# msvc++ mangles struct/class into name, thus symbols may be called differently
|
||||
# with a bad forward-decl. we want compilation to fail, not linking.
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS /we4099)
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Werror=mismatched-tags)
|
||||
|
||||
# yes, we intend to use multi-character character constants
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -Wno-multichar)
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-date-time)
|
||||
#We don't care for a few bytes
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-padded)
|
||||
#Msvc++ mangles struct/class into name, thus symbols may be called differently
|
||||
#With a bad forward-decl. we want compilation to fail, not linking.
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS /we4099)
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Werror=mismatched-tags)
|
||||
#Yes, we intend to use multi-character character constants
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS -Wno-multichar)
|
||||
#Better exception handling for visual studio, particularly for the asynchronous stuff
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS /EHa)
|
||||
#Multi core building for visual studio
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS /MP)
|
||||
#Allow Big obj for msvc compilation
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS /bigobj)
|
||||
|
||||
add_compiler_flag_if_supported (CMAKE_C_FLAGS -Wno-implicit-function-declaration)
|
||||
|
||||
if(WIN32)
|
||||
IF(WIN32)
|
||||
OPTION(NAME_REUSE_AS_ERROR "Make name reuse warnings errors ?" OFF)
|
||||
if(NAME_REUSE_AS_ERROR)
|
||||
IF(NAME_REUSE_AS_ERROR)
|
||||
# declaration of 'identifier' hides previous:
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS /we4456) # local declaration
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS /we4457) # function parameter
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS /we4458) # class members
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS /we4459) # global declaration
|
||||
endif()
|
||||
endif()
|
||||
ENDIF()
|
||||
|
||||
# better exception handling for visual studio, particularly for the asynchronous stuff
|
||||
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS /EHa)
|
||||
# multi core building for visual studio
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS /MP)
|
||||
|
||||
|
||||
if(WIN32)
|
||||
# Disable opengl error log
|
||||
OPTION(ADDITIONAL_OPTIMIZATION_FLAGS "Enable OpenGL error check ?" OFF)
|
||||
IF(ADDITIONAL_OPTIMIZATION_FLAGS)
|
||||
MESSAGE( STATUS "Enabled additional optimization flags for msvc.")
|
||||
@@ -184,189 +78,152 @@ if(WIN32)
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS /Ot) # favor fast code
|
||||
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS /GL) # whole program optimization
|
||||
ENDIF()
|
||||
endif(WIN32)
|
||||
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
|
||||
set(EXECUTABLE_OUTPUT_PATH bin)
|
||||
set(LIBARY_OUTPUT_PATH bin)
|
||||
SET(EXECUTABLE_OUTPUT_PATH bin)
|
||||
SET(LIBARY_OUTPUT_PATH bin)
|
||||
SET(EXTERNAL_SOURCE_DIR src/external)
|
||||
|
||||
OPTION(USE_SQL "Enable sql uid save ? (require mysql installed)" OFF)
|
||||
|
||||
macro(includePlattform SUFFIX)
|
||||
if(UNIX)
|
||||
if(APPLE)
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/apple_${SUFFIX}.cmake")
|
||||
else(APPLE)
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/linux_${SUFFIX}.cmake")
|
||||
endif(APPLE)
|
||||
else(UNIX)
|
||||
if(WIN32)
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/win32_${SUFFIX}.cmake")
|
||||
# adds for library repo
|
||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${CMAKE_SOURCE_DIR}/../Noggit3libs/Boost/lib/")
|
||||
#storm lib
|
||||
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/../Noggit3libs/StormLib/include/")
|
||||
#boost
|
||||
include_directories (SYSTEM "${CMAKE_SOURCE_DIR}/../Noggit3libs/Boost/")
|
||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${CMAKE_SOURCE_DIR}/../Noggit3libs/Boost/libs/")
|
||||
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/../Noggit3libs/Boost/")
|
||||
endif(WIN32)
|
||||
endif(UNIX)
|
||||
endmacro(includePlattform)
|
||||
|
||||
OPTION(VALIDATE_OPENGL_PROGRAMS "Validate Opengl programs" OFF)
|
||||
|
||||
IF(VALIDATE_OPENGL_PROGRAMS)
|
||||
ADD_DEFINITIONS(-DVALIDATE_OPENGL_PROGRAMS)
|
||||
IF(APPLE)
|
||||
MESSAGE(WARNING "Noggit will most likely not work on a mac with this option enabled.")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
if(VALIDATE_OPENGL_PROGRAMS)
|
||||
add_definitions ( -DVALIDATE_OPENGL_PROGRAMS)
|
||||
|
||||
if(APPLE)
|
||||
message(WARNING "Noggit will most likely not work on a mac with this option enabled.")
|
||||
endif()
|
||||
endif()
|
||||
includePlatform("prefind")
|
||||
|
||||
includePlattform("prefind")
|
||||
FIND_PACKAGE(OpenGL REQUIRED )
|
||||
FIND_PACKAGE(Boost 1.60 COMPONENTS thread filesystem system unit_test_framework REQUIRED)
|
||||
FIND_PACKAGE(StormLib REQUIRED )
|
||||
FIND_PACKAGE(Qt5 COMPONENTS Widgets OpenGL OpenGLExtensions Network Xml REQUIRED)
|
||||
|
||||
FIND_PACKAGE( OpenGL REQUIRED )
|
||||
FIND_PACKAGE( Boost 1.60 COMPONENTS thread filesystem system unit_test_framework REQUIRED )
|
||||
FIND_PACKAGE( StormLib REQUIRED )
|
||||
find_package (Qt5 COMPONENTS Widgets OpenGL OpenGLExtensions Network Xml REQUIRED)
|
||||
IF(USE_SQL)
|
||||
FIND_LIBRARY(MYSQL_LIBRARY NAMES libmysql
|
||||
HINTS "${CMAKE_SOURCE_DIR}/../Noggit3libs/mysql")
|
||||
FIND_LIBRARY(MYSQLCPPCONN_LIBRARY NAMES mysqlcppconn
|
||||
HINTS "${CMAKE_SOURCE_DIR}/../Noggit3libs/mysql/connector")
|
||||
FIND_PATH(MYSQLCPPCONN_INCLUDE NAMES cppconn/driver.h
|
||||
HINTS "${CMAKE_SOURCE_DIR}/../Noggit3libs/mysql/connector")
|
||||
|
||||
IF(MYSQL_LIBRARY AND MYSQLCPPCONN_LIBRARY AND MYSQLCPPCONN_INCLUDE)
|
||||
ADD_DEFINITIONS(-DUSE_MYSQL_UID_STORAGE)
|
||||
SET (mysql_sources src/mysql/mysql.cpp)
|
||||
SET (mysql_headers src/mysql/mysql.h)
|
||||
SOURCE_GROUP("mysql" FILES ${mysql_sources} ${mysql_headers})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "MySQL lib or connector not found")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
if (USE_SQL)
|
||||
find_library(MYSQL_LIBRARY
|
||||
NAMES libmysql
|
||||
HINTS "${CMAKE_SOURCE_DIR}/../Noggit3libs/mysql")
|
||||
find_library(MYSQLCPPCONN_LIBRARY
|
||||
NAMES mysqlcppconn
|
||||
HINTS "${CMAKE_SOURCE_DIR}/../Noggit3libs/mysql/connector")
|
||||
find_path (MYSQLCPPCONN_INCLUDE
|
||||
NAMES cppconn/driver.h
|
||||
HINTS "${CMAKE_SOURCE_DIR}/../Noggit3libs/mysql/connector")
|
||||
|
||||
if (MYSQL_LIBRARY AND MYSQLCPPCONN_LIBRARY AND MYSQLCPPCONN_INCLUDE)
|
||||
add_definitions ( -DUSE_MYSQL_UID_STORAGE )
|
||||
|
||||
set ( mysql_sources
|
||||
src/mysql/mysql.cpp
|
||||
)
|
||||
|
||||
set ( mysql_headers
|
||||
src/mysql/mysql.h
|
||||
)
|
||||
source_group("mysql" FILES ${mysql_sources} ${mysql_headers})
|
||||
else()
|
||||
message (FATAL_ERROR "MySQL lib or connector not found")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory (src/external/qt-color-widgets)
|
||||
add_subdirectory (src/external/framelesshelper)
|
||||
add_subdirectory (src/external/qtimgui)
|
||||
add_subdirectory (src/external/QtAdvancedDockingSystem)
|
||||
add_subdirectory (src/external/NodeEditor)
|
||||
add_subdirectory (src/external/libnoise)
|
||||
ADD_SUBDIRECTORY("${EXTERNAL_SOURCE_DIR}/qt-color-widgets")
|
||||
ADD_SUBDIRECTORY("${EXTERNAL_SOURCE_DIR}/framelesshelper")
|
||||
ADD_SUBDIRECTORY("${EXTERNAL_SOURCE_DIR}/qtimgui")
|
||||
ADD_SUBDIRECTORY("${EXTERNAL_SOURCE_DIR}/QtAdvancedDockingSystem")
|
||||
ADD_SUBDIRECTORY("${EXTERNAL_SOURCE_DIR}/NodeEditor")
|
||||
ADD_SUBDIRECTORY("${EXTERNAL_SOURCE_DIR}/libnoise")
|
||||
ADD_SUBDIRECTORY("${EXTERNAL_SOURCE_DIR}/dbcd-cpp")
|
||||
ADD_SUBDIRECTORY("${EXTERNAL_SOURCE_DIR}/glm")
|
||||
|
||||
# Add the found include directories to our include list.
|
||||
include_directories (SYSTEM "${CMAKE_SOURCE_DIR}/include/")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_SOURCE_DIR}/include/")
|
||||
|
||||
OPTION(NOGGIT_BUILD_NODE_DATAMODELS "Build node data models? (turn of for faster compiling)" ON)
|
||||
IF(NOT NOGGIT_BUILD_NODE_DATAMODELS)
|
||||
MESSAGE( STATUS "Not building Node data models. Do not attempt to use Node Editor. Do not enable this for deployment!" )
|
||||
ADD_DEFINITIONS( -DDO_NOT_BUILD_NODES )
|
||||
MESSAGE(STATUS "Not building Node data models. Do not attempt to use Node Editor. Do not enable this for deployment!")
|
||||
ADD_DEFINITIONS(-DDO_NOT_BUILD_NODES )
|
||||
ENDIF(NOT NOGGIT_BUILD_NODE_DATAMODELS)
|
||||
|
||||
OPTION(NOGGIT_ENABLE_TRACY_PROFILER "Enable tracy profiler" ON)
|
||||
IF(NOGGIT_ENABLE_TRACY_PROFILER)
|
||||
MESSAGE( STATUS "Tracy profiler enabled." )
|
||||
ADD_DEFINITIONS( -DTRACY_ENABLE )
|
||||
MESSAGE(STATUS "Tracy profiler enabled." )
|
||||
ADD_DEFINITIONS(-DTRACY_ENABLE )
|
||||
ENDIF(NOGGIT_ENABLE_TRACY_PROFILER)
|
||||
|
||||
OPTION(NOGGIT_ALL_WARNINGS "Enable all warnings?" OFF)
|
||||
|
||||
# Log to console for easier debugging.
|
||||
OPTION( NOGGIT_LOGTOCONSOLE "Log to console instead of log.txt?" OFF )
|
||||
IF( NOGGIT_LOGTOCONSOLE )
|
||||
MESSAGE( STATUS "And writing log to console instead of log.txt" )
|
||||
ADD_DEFINITIONS( -DDEBUG__LOGGINGTOCONSOLE )
|
||||
ENDIF( NOGGIT_LOGTOCONSOLE )
|
||||
OPTION( NOGGIT_LOGTOCONSOLE "Log to console instead of log.txt?" OFF)
|
||||
IF(NOGGIT_LOGTOCONSOLE)
|
||||
MESSAGE(STATUS "And writing log to console instead of log.txt")
|
||||
ADD_DEFINITIONS(-DDEBUG__LOGGINGTOCONSOLE)
|
||||
ENDIF(NOGGIT_LOGTOCONSOLE)
|
||||
|
||||
# Disable opengl error log
|
||||
OPTION(NOGGIT_OPENGL_ERROR_CHECK "Enable OpenGL error check ?" ON)
|
||||
IF(NOT NOGGIT_OPENGL_ERROR_CHECK )
|
||||
MESSAGE( STATUS "OpenGL error check disabled." )
|
||||
ADD_DEFINITIONS( -DNOGGIT_DO_NOT_CHECK_FOR_OPENGL_ERRORS )
|
||||
IF(NOT NOGGIT_OPENGL_ERROR_CHECK)
|
||||
MESSAGE(STATUS "OpenGL error check disabled.")
|
||||
ADD_DEFINITIONS(-DNOGGIT_DO_NOT_CHECK_FOR_OPENGL_ERRORS)
|
||||
ENDIF()
|
||||
|
||||
includePlattform("postfind")
|
||||
includePlatform("postfind")
|
||||
|
||||
include_directories ("${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/tmp")
|
||||
include_directories(PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/tmp")
|
||||
INCLUDE_DIRECTORIES(PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# And do the job.
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/PNG2BLP" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/PNG2BLP/libimagequant" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/PNG2BLP/libpng" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/PNG2BLP/libtxc_dxtn" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/PNG2BLP/pngpp" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/PNG2BLP/zlib" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/imguizmo" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/imguipiemenu" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/libnoise/src" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/qtgradienteditor" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/tracy" )
|
||||
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/${EXTERNAL_SOURCE_DIR}/PNG2BLP" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/${EXTERNAL_SOURCE_DIR}/PNG2BLP/libimagequant")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/${EXTERNAL_SOURCE_DIR}/PNG2BLP/libpng")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/${EXTERNAL_SOURCE_DIR}/PNG2BLP/libtxc_dxtn")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/${EXTERNAL_SOURCE_DIR}/PNG2BLP/pngpp")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/${EXTERNAL_SOURCE_DIR}/PNG2BLP/zlib")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/${EXTERNAL_SOURCE_DIR}/imguizmo")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/${EXTERNAL_SOURCE_DIR}/imguipiemenu")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/${EXTERNAL_SOURCE_DIR}/libnoise/src")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/${EXTERNAL_SOURCE_DIR}/qtgradienteditor")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/${EXTERNAL_SOURCE_DIR}/tracy")
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/${EXTERNAL_SOURCE_DIR}/dbcd-cpp/include")
|
||||
INCLUDE_DIRECTORIES(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
|
||||
|
||||
|
||||
collect_files(noggit_root_sources src/noggit false "*.cpp" "")
|
||||
collect_files(noggit_ui_sources src/noggit/ui true "*.cpp" "")
|
||||
collect_files(noggit_scripting_sources src/noggit/scripting true "*.cpp" "")
|
||||
collect_files(math_sources src/math false "*.cpp" "")
|
||||
collect_files(opengl_sources src/opengl false "*.cpp" "")
|
||||
collect_files(noggit_root_sources src/noggit FALSE "*.cpp" "")
|
||||
collect_files(noggit_ui_sources src/noggit/ui TRUE "*.cpp" "")
|
||||
collect_files(noggit_scripting_sources src/noggit/scripting TRUE "*.cpp" "")
|
||||
collect_files(math_sources src/math FALSE "*.cpp" "")
|
||||
collect_files(opengl_sources src/opengl FALSE "*.cpp" "")
|
||||
|
||||
IF(NOT NOGGIT_BUILD_NODE_DATAMODELS)
|
||||
collect_files(red_sources src/noggit/Red true "*.cpp" "NodeEditor/Nodes/Containers;NodeEditor/Nodes/Data;NodeEditor/Nodes/Functions;NodeEditor/Nodes/Math;NodeEditor/Nodes/World")
|
||||
collect_files(red_sources src/noggit/Red TRUE "*.cpp" "NodeEditor/Nodes/Containers;NodeEditor/Nodes/Data;NodeEditor/Nodes/Functions;NodeEditor/Nodes/Math;NodeEditor/Nodes/World")
|
||||
ELSE()
|
||||
collect_files(red_sources src/noggit/Red true "*.cpp" "")
|
||||
collect_files(red_sources src/noggit/Red TRUE "*.cpp" "")
|
||||
ENDIF()
|
||||
|
||||
collect_files(png_blp_sources src/external/PNG2BLP true "*.c;*.cpp;" "")
|
||||
collect_files(imguizmo_sources src/external/imguizmo false "*.c;*.cpp;" "")
|
||||
collect_files(imguipiemenu_sources src/external/imguipiemenu false "*.c;*.cpp;" "")
|
||||
collect_files(gradienteditor_sources src/external/qtgradienteditor false "*.c;*.cpp;" "")
|
||||
collect_files(tracy_sources src/external/tracy false "*.c;*.cpp;" "")
|
||||
collect_files(png_blp_sources src/external/PNG2BLP TRUE "*.c;*.cpp;" "")
|
||||
collect_files(imguizmo_sources src/external/imguizmo FALSE "*.c;*.cpp;" "")
|
||||
collect_files(imguipiemenu_sources src/external/imguipiemenu FALSE "*.c;*.cpp;" "")
|
||||
collect_files(gradienteditor_sources src/external/qtgradienteditor FALSE "*.c;*.cpp;" "")
|
||||
collect_files(tracy_sources src/external/tracy FALSE "*.c;*.cpp;" "")
|
||||
|
||||
set ( util_sources
|
||||
src/util/exception_to_string.cpp
|
||||
)
|
||||
SET(util_sources src/util/exception_to_string.cpp)
|
||||
|
||||
collect_files(noggit_root_headers src/noggit false "*.h;*.hpp;*.inl" "")
|
||||
collect_files(noggit_ui_headers src/noggit/ui true "*.h;*.hpp" "")
|
||||
collect_files(noggit_scripting_headers src/noggit/scripting true "*.h;*.hpp" "")
|
||||
collect_files(math_headers src/math false "*.h;*.hpp" "")
|
||||
collect_files(opengl_headers src/opengl false "*.h;*.hpp" "")
|
||||
collect_files(shaders src/glsl false "*.glsl" "")
|
||||
collect_files(noggit_root_headers src/noggit FALSE "*.h;*.hpp;*.inl" "")
|
||||
collect_files(noggit_ui_headers src/noggit/ui TRUE "*.h;*.hpp" "")
|
||||
collect_files(noggit_scripting_headers src/noggit/scripting TRUE "*.h;*.hpp" "")
|
||||
collect_files(math_headers src/math FALSE "*.h;*.hpp" "")
|
||||
collect_files(opengl_headers src/opengl FALSE "*.h;*.hpp" "")
|
||||
collect_files(shaders src/glsl FALSE "*.glsl" "")
|
||||
|
||||
IF(NOT NOGGIT_BUILD_NODE_DATAMODELS)
|
||||
collect_files(red_headers src/noggit/Red true "*.h;*.hpp" "NodeEditor/Nodes/Containers;NodeEditor/Nodes/Data;NodeEditor/Nodes/Functions;NodeEditor/Nodes/Math;NodeEditor/Nodes/World")
|
||||
collect_files(red_headers src/noggit/Red TRUE "*.h;*.hpp" "NodeEditor/Nodes/Containers;NodeEditor/Nodes/Data;NodeEditor/Nodes/Functions;NodeEditor/Nodes/Math;NodeEditor/Nodes/World")
|
||||
ELSE()
|
||||
collect_files(red_headers src/noggit/Red true "*.h;*.hpp" "")
|
||||
collect_files(red_headers src/noggit/Red TRUE "*.h;*.hpp" "")
|
||||
ENDIF()
|
||||
|
||||
collect_files(png_blp_headers src/external/PNG2BLP true "*.h;*.hpp" "")
|
||||
collect_files(imguizmo_headers src/external/imguizmo false "*.h;*.hpp" "")
|
||||
collect_files(imguipiemenu_headers src/external/imguipiemenu false "*.h;*.hpp" "")
|
||||
collect_files(gradienteditor_headers src/external/qtgradienteditor false "*.h;*.hpp" "")
|
||||
collect_files(tracy_headers src/external/tracy false "*.h;*.hpp" "")
|
||||
|
||||
collect_files(png_blp_headers src/external/PNG2BLP TRUE "*.h;*.hpp" "")
|
||||
collect_files(imguizmo_headers src/external/imguizmo FALSE "*.h;*.hpp" "")
|
||||
collect_files(imguipiemenu_headers src/external/imguipiemenu FALSE "*.h;*.hpp" "")
|
||||
collect_files(gradienteditor_headers src/external/qtgradienteditor FALSE "*.h;*.hpp" "")
|
||||
collect_files(tracy_headers src/external/tracy FALSE "*.h;*.hpp" "")
|
||||
collect_files(blizzard_database_headers src/external/dbcd-cpp/include FALSE "*.h;*.hpp" "")
|
||||
|
||||
IF(WIN32)
|
||||
set ( os_sources
|
||||
include/win/StackWalker.cpp)
|
||||
set ( os_headers
|
||||
include/win/StackWalker.h)
|
||||
SET(os_sources include/win/StackWalker.cpp)
|
||||
SET(os_headers include/win/StackWalker.h)
|
||||
ENDIF(WIN32)
|
||||
|
||||
#collect_files(headers_to_moc src/noggit true "*.h;*.hpp" "")
|
||||
@@ -374,65 +231,66 @@ ENDIF(WIN32)
|
||||
#contains_filter(result "${headers_to_moc}" "[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]")
|
||||
|
||||
#qt5_wrap_cpp (moced ${result})
|
||||
source_group("noggit" FILES ${noggit_root_sources} ${noggit_root_headers})
|
||||
source_group("noggit\\ui" FILES ${noggit_ui_sources} ${noggit_ui_headers})
|
||||
source_group("noggit\\scripting" FILES ${noggit_scripting_sources} ${noggit_scripting_headers})
|
||||
source_group("opengl" FILES ${opengl_sources} ${opengl_headers})
|
||||
source_group("math" FILES ${math_sources} ${math_headers})
|
||||
source_group("external" FILES ${external_sources} ${external_headers})
|
||||
source_group("os" FILES ${os_sources} ${os_headers})
|
||||
source_group("util" FILES ${util_sources})
|
||||
source_group("glsl" FILES ${shaders})
|
||||
source_group("noggit/Red" FILES ${red_headers} ${red_sources})
|
||||
source_group("png_blp" FILES ${png_blp_headers} ${png_blp_sources})
|
||||
source_group("imguizmo" FILES ${imguizmo_headers} ${imguizmo_sources})
|
||||
source_group("gradient_editor" FILES ${gradienteditor_headers} ${gradienteditor_sources})
|
||||
SOURCE_GROUP("noggit" FILES ${noggit_root_sources} ${noggit_root_headers})
|
||||
SOURCE_GROUP("noggit\\ui" FILES ${noggit_ui_sources} ${noggit_ui_headers})
|
||||
SOURCE_GROUP("noggit\\scripting" FILES ${noggit_scripting_sources} ${noggit_scripting_headers})
|
||||
SOURCE_GROUP("opengl" FILES ${opengl_sources} ${opengl_headers})
|
||||
SOURCE_GROUP("math" FILES ${math_sources} ${math_headers})
|
||||
SOURCE_GROUP("external" FILES ${external_sources} ${external_headers})
|
||||
SOURCE_GROUP("os" FILES ${os_sources} ${os_headers})
|
||||
SOURCE_GROUP("util" FILES ${util_sources})
|
||||
SOURCE_GROUP("glsl" FILES ${shaders})
|
||||
SOURCE_GROUP("noggit/Red" FILES ${red_headers} ${red_sources})
|
||||
SOURCE_GROUP("png_blp" FILES ${png_blp_headers} ${png_blp_sources})
|
||||
SOURCE_GROUP("imguizmo" FILES ${imguizmo_headers} ${imguizmo_sources})
|
||||
SOURCE_GROUP("gradient_editor" FILES ${gradienteditor_headers} ${gradienteditor_sources})
|
||||
|
||||
collect_files(resource_files resources false "*.qrc" "")
|
||||
collect_files(resource_files resources FALSE "*.qrc" "")
|
||||
qt5_add_resources (compiled_resource_files ${resource_files})
|
||||
collect_files(ui_files src true "*.ui" "")
|
||||
collect_files(ui_files src TRUE "*.ui" "")
|
||||
qt5_wrap_ui(compiled_ui_files ${ui_files})
|
||||
|
||||
ADD_EXECUTABLE ( noggit
|
||||
WIN32
|
||||
MACOSX_BUNDLE
|
||||
${noggit_root_sources}
|
||||
${noggit_ui_sources}
|
||||
${noggit_scripting_sources}
|
||||
${opengl_sources}
|
||||
${math_sources}
|
||||
${external_sources}
|
||||
${mysql_sources}
|
||||
${os_sources}
|
||||
${util_sources}
|
||||
${red_sources}
|
||||
${png_blp_sources}
|
||||
${imguizmo_sources}
|
||||
${imguipiemenu_sources}
|
||||
${gradienteditor_sources}
|
||||
${tracy_sources}
|
||||
${noggit_root_headers}
|
||||
${noggit_ui_headers}
|
||||
${noggit_scripting_headers}
|
||||
${opengl_headers}
|
||||
${math_headers}
|
||||
${external_headers}
|
||||
${mysql_headers}
|
||||
${os_headers}
|
||||
${png_blp_headers}
|
||||
${ResFiles}
|
||||
${moced}
|
||||
${red_headers}
|
||||
${imguizmo_headers}
|
||||
${imguipiemenu_headers}
|
||||
${gradienteditor_headers}
|
||||
${tracy_headers}
|
||||
${compiled_resource_files}
|
||||
${compiled_ui_files}
|
||||
${shaders}
|
||||
${force_update_file}
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(noggit
|
||||
WIN32
|
||||
MACOSX_BUNDLE
|
||||
${noggit_root_sources}
|
||||
${noggit_ui_sources}
|
||||
${noggit_scripting_sources}
|
||||
${opengl_sources}
|
||||
${math_sources}
|
||||
${external_sources}
|
||||
${mysql_sources}
|
||||
${os_sources}
|
||||
${util_sources}
|
||||
${red_sources}
|
||||
${png_blp_sources}
|
||||
${imguizmo_sources}
|
||||
${imguipiemenu_sources}
|
||||
${gradienteditor_sources}
|
||||
${tracy_sources}
|
||||
${noggit_root_headers}
|
||||
${noggit_ui_headers}
|
||||
${noggit_scripting_headers}
|
||||
${opengl_headers}
|
||||
${math_headers}
|
||||
${external_headers}
|
||||
${mysql_headers}
|
||||
${os_headers}
|
||||
${png_blp_headers}
|
||||
${ResFiles}
|
||||
${moced}
|
||||
${red_headers}
|
||||
${imguizmo_headers}
|
||||
${imguipiemenu_headers}
|
||||
${gradienteditor_headers}
|
||||
${tracy_headers}
|
||||
${compiled_resource_files}
|
||||
${compiled_ui_files}
|
||||
${shaders}
|
||||
${force_update_file}
|
||||
${blizzard_database_headers}
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES (noggit
|
||||
${OPENGL_LIBRARIES}
|
||||
StormLib
|
||||
@@ -445,31 +303,33 @@ TARGET_LINK_LIBRARIES (noggit
|
||||
Qt5::Xml
|
||||
ColorWidgets-qt5
|
||||
FramelessHelper
|
||||
BlizzardDatabaseLib
|
||||
qt_imgui_widgets
|
||||
qtadvanceddocking
|
||||
nodes
|
||||
noise-static
|
||||
noiseutils-static
|
||||
glm
|
||||
)
|
||||
|
||||
set_property(TARGET noggit PROPERTY AUTOMOC ON)
|
||||
SET_PROPERTY(TARGET noggit PROPERTY AUTOMOC ON)
|
||||
|
||||
if(APPLE)
|
||||
target_include_directories(noggit PRIVATE /usr/local/Cellar/llvm/12.0.1/include/c++/v1/)
|
||||
target_link_libraries(noggit /usr/local/Cellar/llvm/12.0.1/lib/libc++.1.0.dylib)
|
||||
endif()
|
||||
IF(APPLE)
|
||||
TARGET_INCLUDE_DIRECTORIES(noggit PRIVATE /usr/local/Cellar/llvm/12.0.1/include/c++/v1/)
|
||||
TARGET_LINK_LIBRARIES(noggit /usr/local/Cellar/llvm/12.0.1/lib/libc++.1.0.dylib)
|
||||
ENDIF()
|
||||
|
||||
set (_noggit_revision_output_dir "${CMAKE_BINARY_DIR}/revision_output")
|
||||
set (_noggit_revision_template_file "${CMAKE_SOURCE_DIR}/cmake/revision.h.in")
|
||||
set (_noggit_revision_output_file "${_noggit_revision_output_dir}/revision.h")
|
||||
set (_noggit_revision_state_file "${CMAKE_BINARY_DIR}/revision.state")
|
||||
set (_noggit_revision_script_file "${CMAKE_SOURCE_DIR}/cmake/GenerateRevision.cmake")
|
||||
SET(_noggit_revision_output_dir "${CMAKE_BINARY_DIR}/revision_output")
|
||||
SET(_noggit_revision_template_file "${CMAKE_SOURCE_DIR}/cmake/revision.h.in")
|
||||
SET(_noggit_revision_output_file "${_noggit_revision_output_dir}/revision.h")
|
||||
SET(_noggit_revision_state_file "${CMAKE_BINARY_DIR}/revision.state")
|
||||
SET(_noggit_revision_script_file "${CMAKE_SOURCE_DIR}/cmake/GenerateRevision.cmake")
|
||||
|
||||
include_directories ("${_noggit_revision_output_dir}")
|
||||
INCLUDE_DIRECTORIES("${_noggit_revision_output_dir}")
|
||||
|
||||
find_package (Git)
|
||||
if (FALSE) # GIT_FOUND
|
||||
add_custom_target (update_git_revision
|
||||
FIND_PACKAGE(Git)
|
||||
IF(FALSE) # GIT_FOUND
|
||||
ADD_CUSTOM_TARGET(update_git_revision
|
||||
ALL
|
||||
DEPENDS "${_noggit_revision_template_file}"
|
||||
"${_noggit_revision_script_file}"
|
||||
@@ -483,86 +343,56 @@ if (FALSE) # GIT_FOUND
|
||||
-P "${_noggit_revision_script_file}"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
|
||||
|
||||
add_dependencies (noggit update_git_revision)
|
||||
else()
|
||||
message (WARNING "Failed to find a Git executable, will NOT produce a "
|
||||
"useful version string. Crash logs will be useless. Do NOT distribute.")
|
||||
ADD_DEPENDENCIES(noggit update_git_revision)
|
||||
ELSE()
|
||||
MESSAGE(WARNING "Failed to find a Git executable, will NOT produce a useful version string. Crash logs will be useless. Do NOT distribute.")
|
||||
|
||||
set (NOGGIT_GIT_VERSION_STRING "UNKNOWN")
|
||||
configure_file ("${_noggit_revision_template_file}"
|
||||
"${_noggit_revision_output_file}" @ONLY)
|
||||
endif()
|
||||
SET(NOGGIT_GIT_VERSION_STRING "UNKNOWN")
|
||||
CONFIGURE_FILE("${_noggit_revision_template_file}" "${_noggit_revision_output_file}" @ONLY)
|
||||
ENDIF()
|
||||
|
||||
if(APPLE)
|
||||
TARGET_LINK_LIBRARIES (noggit
|
||||
"-framework Cocoa"
|
||||
"-framework AppKit"
|
||||
"-framework Foundation"
|
||||
)
|
||||
endif()
|
||||
IF(APPLE)
|
||||
TARGET_LINK_LIBRARIES (noggit "-framework Cocoa" "-framework AppKit" "-framework Foundation")
|
||||
ENDIF()
|
||||
|
||||
if (MYSQL_LIBRARY AND MYSQLCPPCONN_LIBRARY AND MYSQLCPPCONN_INCLUDE)
|
||||
target_link_libraries (noggit ${MYSQL_LIBRARY} ${MYSQLCPPCONN_LIBRARY})
|
||||
target_include_directories (noggit SYSTEM PRIVATE ${MYSQLCPPCONN_INCLUDE})
|
||||
endif()
|
||||
IF(MYSQL_LIBRARY AND MYSQLCPPCONN_LIBRARY AND MYSQLCPPCONN_INCLUDE)
|
||||
TARGET_LINK_LIBRARIES(noggit ${MYSQL_LIBRARY} ${MYSQLCPPCONN_LIBRARY})
|
||||
TARGET_INCLUDE_DIRECTORIES(noggit SYSTEM PRIVATE ${MYSQLCPPCONN_INCLUDE})
|
||||
ENDIF()
|
||||
|
||||
if (NOGGIT_LOGTOCONSOLE AND WIN32)
|
||||
set_property (TARGET noggit APPEND PROPERTY LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
|
||||
set_property (TARGET noggit APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:"_CONSOLE">)
|
||||
endif()
|
||||
IF(NOGGIT_LOGTOCONSOLE AND WIN32)
|
||||
SET_PROPERTY(TARGET noggit APPEND PROPERTY LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
|
||||
SET_PROPERTY(TARGET noggit APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:"_CONSOLE">)
|
||||
ENDIF()
|
||||
|
||||
includePlattform("pack")
|
||||
includePlatform("pack")
|
||||
|
||||
add_library (noggit-math STATIC
|
||||
"src/math/matrix_4x4.cpp"
|
||||
"src/math/vector_2d.cpp"
|
||||
)
|
||||
add_library (noggit::math ALIAS noggit-math)
|
||||
|
||||
include (CTest)
|
||||
enable_testing()
|
||||
|
||||
add_executable (math-vector_2d.test test/math/vector_2d.cpp)
|
||||
target_compile_definitions (math-vector_2d.test PRIVATE "-DBOOST_TEST_MODULE=\"math\"")
|
||||
target_link_libraries (math-vector_2d.test Boost::unit_test_framework noggit::math)
|
||||
add_test (NAME math-vector_2d COMMAND $<TARGET_FILE:math-vector_2d.test>)
|
||||
|
||||
add_executable (math-trig.test test/math/trig.cpp)
|
||||
target_compile_definitions (math-trig.test PRIVATE "-DBOOST_TEST_MODULE=\"math\"")
|
||||
target_link_libraries (math-trig.test Boost::unit_test_framework noggit::math)
|
||||
add_test (NAME math-trig COMMAND $<TARGET_FILE:math-trig.test>)
|
||||
|
||||
add_executable (math-matrix_4x4.test test/math/matrix_4x4.cpp)
|
||||
target_compile_definitions (math-matrix_4x4.test PRIVATE "-DBOOST_TEST_MODULE=\"math\"")
|
||||
target_link_libraries (math-matrix_4x4.test Boost::unit_test_framework noggit::math)
|
||||
add_test (NAME math-matrix_4x4 COMMAND $<TARGET_FILE:math-matrix_4x4.test>)
|
||||
|
||||
include (FetchContent)
|
||||
INCLUDE(FetchContent)
|
||||
|
||||
# Dependency: json.hpp
|
||||
FetchContent_Declare (json
|
||||
GIT_REPOSITORY https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent
|
||||
GIT_TAG v3.9.1
|
||||
)
|
||||
GIT_REPOSITORY https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent
|
||||
GIT_TAG v3.9.1
|
||||
)
|
||||
FetchContent_GetProperties (json)
|
||||
if (NOT json_POPULATED)
|
||||
message (STATUS "Installing json.hpp...")
|
||||
FetchContent_Populate (json)
|
||||
endif()
|
||||
add_subdirectory (${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
IF(NOT json_POPULATED)
|
||||
MESSAGE(STATUS "Installing json.hpp...")
|
||||
FetchContent_Populate(json)
|
||||
ENDIF()
|
||||
ADD_SUBDIRECTORY(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
|
||||
# Dependency: lodepng
|
||||
FetchContent_Declare (lodepng
|
||||
GIT_REPOSITORY https://github.com/lvandeve/lodepng.git
|
||||
GIT_TAG 7fdcc96a5e5864eee72911c3ca79b1d9f0d12292
|
||||
)
|
||||
GIT_REPOSITORY https://github.com/lvandeve/lodepng.git
|
||||
GIT_TAG 7fdcc96a5e5864eee72911c3ca79b1d9f0d12292
|
||||
)
|
||||
FetchContent_GetProperties (lodepng)
|
||||
if (NOT lodepng_POPULATED)
|
||||
message (STATUS "Installing lodepng...")
|
||||
IF(NOT lodepng_POPULATED)
|
||||
MESSAGE(STATUS "Installing lodepng...")
|
||||
FetchContent_Populate (lodepng)
|
||||
endif()
|
||||
add_library (lodepng "${lodepng_SOURCE_DIR}/lodepng.cpp")
|
||||
target_include_directories (lodepng SYSTEM PUBLIC ${lodepng_SOURCE_DIR})
|
||||
ENDIF()
|
||||
ADD_LIBRARY(lodepng "${lodepng_SOURCE_DIR}/lodepng.cpp")
|
||||
TARGET_INCLUDE_DIRECTORIES(lodepng SYSTEM PUBLIC ${lodepng_SOURCE_DIR})
|
||||
|
||||
# Dependency: FastNoise2
|
||||
FetchContent_Declare (fastnoise2
|
||||
@@ -572,26 +402,26 @@ FetchContent_Declare (fastnoise2
|
||||
UPDATE_DISCONNECTED true
|
||||
)
|
||||
FetchContent_GetProperties (fastnoise2)
|
||||
if (NOT fastnoise2_POPULATED)
|
||||
message (STATUS "Installing FastNoise2... (big repo, large download)")
|
||||
IF(NOT fastnoise2_POPULATED)
|
||||
MESSAGE(STATUS "Installing FastNoise2... (big repo, large download)")
|
||||
FetchContent_Populate (fastnoise2)
|
||||
endif()
|
||||
ENDIF()
|
||||
|
||||
set(FASTNOISE2_NOISETOOL OFF)
|
||||
set(FASTNOISE2_TESTS:BOOL OFF)
|
||||
SET(FASTNOISE2_NOISETOOL OFF)
|
||||
SET(FASTNOISE2_TESTS:BOOL OFF)
|
||||
|
||||
if (FASTNOISE2_NOISETOOL)
|
||||
add_subdirectory (${fastnoise2_SOURCE_DIR} ${fastnoise2_BINARY_DIR})
|
||||
else()
|
||||
add_subdirectory (${fastnoise2_SOURCE_DIR} ${fastnoise2_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
IF(FASTNOISE2_NOISETOOL)
|
||||
ADD_SUBDIRECTORY(${fastnoise2_SOURCE_DIR} ${fastnoise2_BINARY_DIR})
|
||||
ELSE()
|
||||
ADD_SUBDIRECTORY(${fastnoise2_SOURCE_DIR} ${fastnoise2_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
ENDIF()
|
||||
|
||||
# Dependency: Lua
|
||||
find_package (Lua REQUIRED)
|
||||
add_library (Lua-Lua INTERFACE)
|
||||
add_library (Lua::Lua ALIAS Lua-Lua)
|
||||
target_link_libraries (Lua-Lua INTERFACE ${LUA_LIBRARIES})
|
||||
target_include_directories (Lua-Lua INTERFACE ${LUA_INCLUDE_DIR})
|
||||
FIND_PACKAGE(Lua REQUIRED)
|
||||
ADD_LIBRARY(Lua-Lua INTERFACE)
|
||||
ADD_LIBRARY(Lua::Lua ALIAS Lua-Lua)
|
||||
TARGET_LINK_LIBRARIES(Lua-Lua INTERFACE ${LUA_LIBRARIES})
|
||||
TARGET_INCLUDE_DIRECTORIES(Lua-Lua INTERFACE ${LUA_INCLUDE_DIR})
|
||||
|
||||
# Dependency: sol2
|
||||
FetchContent_Declare (sol2
|
||||
|
||||
@@ -105,6 +105,14 @@ If the build pass correctly without errors, you can go into build/bin/
|
||||
and run noggit. Note that `make install` will probably work but is not
|
||||
tested, and nobody has built distributable packages in years.
|
||||
|
||||
# SUBMODULES #
|
||||
|
||||
To pull the latest version of submodules use the following command at the root directory.
|
||||
|
||||
```bash
|
||||
git submodule update --recursive --remote
|
||||
```
|
||||
|
||||
# DEVELOPMENT #
|
||||
Feel free to ask the owner of the official repository
|
||||
(https://github.com/wowdev/noggit3) for write access or
|
||||
|
||||
40
cmake/cmake_function.cmake
Normal file
40
cmake/cmake_function.cmake
Normal file
@@ -0,0 +1,40 @@
|
||||
#collect source files from given directory
|
||||
FUNCTION(collect_files output base_dir do_recurse globbing_exprs exclude_dirs)
|
||||
IF("${do_recurse}")
|
||||
SET(glob GLOB_RECURSE)
|
||||
ELSE()
|
||||
SET(glob GLOB)
|
||||
ENDIF()
|
||||
|
||||
SET(base_dir "${CMAKE_SOURCE_DIR}/${base_dir}")
|
||||
LIST(TRANSFORM globbing_exprs PREPEND "${base_dir}/")
|
||||
FILE(${glob} files CONFIGURE_DEPENDS ${globbing_exprs})
|
||||
|
||||
FOREACH(file IN LISTS files)
|
||||
SET(match FALSE)
|
||||
|
||||
FOREACH(dir IN LISTS exclude_dirs)
|
||||
IF("${file}" MATCHES "/${dir}/")
|
||||
SET(match TRUE)
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
|
||||
IF(NOT ${match})
|
||||
LIST(APPEND result "${file}")
|
||||
ENDIF()
|
||||
|
||||
ENDFOREACH()
|
||||
SET(${output} "${result}" PARENT_SCOPE)
|
||||
ENDFUNCTION()
|
||||
|
||||
FUNCTION(contains_filter output files regex)
|
||||
|
||||
FOREACH(file IN LISTS files)
|
||||
FILE(STRINGS "${file}" contents REGEX "${regex}")
|
||||
IF("${contents}")
|
||||
LIST(APPEND result "${file}")
|
||||
MESSAGE("Moced: ${file}")
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
SET(${output} "${result}" PARENT_SCOPE)
|
||||
ENDFUNCTION()
|
||||
35
cmake/cmake_macro.cmake
Normal file
35
cmake/cmake_macro.cmake
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
MACRO(add_compiler_flag_if_supported _VAR _FLAG)
|
||||
STRING (MAKE_C_IDENTIFIER "CXX_COMPILER_SUPPORTS_${_FLAG}" _test_variable)
|
||||
check_cxx_compiler_flag ("${_FLAG}" ${_test_variable})
|
||||
IF(${_test_variable})
|
||||
IF("${${_VAR}}" STREQUAL "")
|
||||
SET(${_VAR} "${_FLAG}")
|
||||
ELSE()
|
||||
SET(${_VAR} "${${_VAR}} ${_FLAG}")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
|
||||
#Platform include
|
||||
MACRO(includePlatform SUFFIX)
|
||||
IF(UNIX)
|
||||
IF(APPLE)
|
||||
INCLUDE("${CMAKE_SOURCE_DIR}/cmake/apple_${SUFFIX}.cmake")
|
||||
ELSE(APPLE)
|
||||
INCLUDE("${CMAKE_SOURCE_DIR}/cmake/linux_${SUFFIX}.cmake")
|
||||
ENDIF(APPLE)
|
||||
ELSE(UNIX)
|
||||
IF(WIN32)
|
||||
INCLUDE("${CMAKE_SOURCE_DIR}/cmake/win32_${SUFFIX}.cmake")
|
||||
#adds for library repo
|
||||
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${CMAKE_SOURCE_DIR}/../Noggit3libs/Boost/lib/")
|
||||
#storm lib
|
||||
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/../Noggit3libs/StormLib/include/")
|
||||
#boost
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_SOURCE_DIR}/../Noggit3libs/Boost/")
|
||||
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${CMAKE_SOURCE_DIR}/../Noggit3libs/Boost/libs/")
|
||||
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/../Noggit3libs/Boost/")
|
||||
ENDIF(WIN32)
|
||||
ENDIF(UNIX)
|
||||
ENDMACRO(includePlatform)
|
||||
1
src/external/dbcd-cpp
vendored
Submodule
1
src/external/dbcd-cpp
vendored
Submodule
Submodule src/external/dbcd-cpp added at ff7f476d43
74
src/external/qtimgui/CMakeLists.txt
vendored
74
src/external/qtimgui/CMakeLists.txt
vendored
@@ -1,16 +1,16 @@
|
||||
cmake_minimum_required (VERSION 3.8.1)
|
||||
project(qtimgui)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.8.1)
|
||||
PROJECT(qtimgui)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
find_package(Qt5 COMPONENTS Core Quick Gui Widgets Svg REQUIRED)
|
||||
SET(CMAKE_AUTOMOC ON)
|
||||
SET(CMAKE_AUTORCC ON)
|
||||
SET(CMAKE_AUTOUIC ON)
|
||||
FIND_PACKAGE(Qt5 COMPONENTS Core Quick Gui Widgets Svg REQUIRED)
|
||||
|
||||
# imgui library: imgui is build by default, but you can
|
||||
# provide your own version by setting QTIMGUI_BUILD_IMGUI to OFF
|
||||
option(QTIMGUI_BUILD_IMGUI "Use imgui provided as qtimgui submodule" ON)
|
||||
if (QTIMGUI_BUILD_IMGUI)
|
||||
add_library(imgui
|
||||
OPTION(QTIMGUI_BUILD_IMGUI "Use imgui provided as qtimgui submodule" ON)
|
||||
IF(QTIMGUI_BUILD_IMGUI)
|
||||
ADD_LIBRARY(imgui
|
||||
STATIC
|
||||
imgui/imconfig.h
|
||||
imgui/imgui_demo.cpp
|
||||
@@ -19,45 +19,49 @@ if (QTIMGUI_BUILD_IMGUI)
|
||||
imgui/imgui_widgets.cpp
|
||||
imgui/imgui.cpp
|
||||
)
|
||||
target_include_directories(imgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
|
||||
endif(QTIMGUI_BUILD_IMGUI)
|
||||
TARGET_INCLUDE_DIRECTORIES(imgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
|
||||
ENDIF(QTIMGUI_BUILD_IMGUI)
|
||||
|
||||
set(
|
||||
qt_imgui_sources
|
||||
ImGuiRenderer.h
|
||||
ImGuiRenderer.cpp
|
||||
QtImGui.h
|
||||
QtImGui.cpp
|
||||
)
|
||||
SET(qt_imgui_sources ImGuiRenderer.h ImGuiRenderer.cpp QtImGui.h QtImGui.cpp)
|
||||
|
||||
# qt_imgui_quick: library with a qt renderer for Qml / QtQuick applications
|
||||
add_library(qt_imgui_quick STATIC ${qt_imgui_sources})
|
||||
target_include_directories(qt_imgui_quick PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(
|
||||
ADD_LIBRARY(qt_imgui_quick STATIC ${qt_imgui_sources})
|
||||
TARGET_INCLUDE_DIRECTORIES(qt_imgui_quick PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
TARGET_LINK_LIBRARIES(
|
||||
qt_imgui_quick
|
||||
PUBLIC
|
||||
imgui
|
||||
Qt5::Core Qt5::Quick Qt5::Svg
|
||||
)
|
||||
if (ANDROID)
|
||||
target_link_libraries(qt_imgui_quick PUBLIC log dl GLESv2 z)
|
||||
endif()
|
||||
|
||||
IF(ANDROID)
|
||||
TARGET_LINK_LIBRARIES(qt_imgui_quick PUBLIC log dl GLESv2 z)
|
||||
ENDIF()
|
||||
|
||||
# qt_imgui_widget: library with a qt renderer for classic Qt Widget applications
|
||||
add_library(qt_imgui_widgets STATIC ${qt_imgui_sources})
|
||||
target_include_directories(qt_imgui_widgets PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(
|
||||
ADD_LIBRARY(qt_imgui_widgets STATIC ${qt_imgui_sources})
|
||||
TARGET_INCLUDE_DIRECTORIES(qt_imgui_widgets PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
TARGET_LINK_LIBRARIES(
|
||||
qt_imgui_widgets
|
||||
PUBLIC
|
||||
imgui
|
||||
Qt5::Core Qt5::Widgets Qt5::Svg
|
||||
)
|
||||
if (ANDROID)
|
||||
target_link_libraries(qt_imgui_widgets PUBLIC log dl GLESv2 z)
|
||||
endif()
|
||||
target_compile_definitions(qt_imgui_widgets PUBLIC QT_WIDGETS_LIB)
|
||||
IF(ANDROID)
|
||||
TARGET_LINK_LIBRARIES(qt_imgui_widgets PUBLIC log dl GLESv2 z)
|
||||
ENDIF()
|
||||
TARGET_COMPILE_DEFINITIONS(qt_imgui_widgets PUBLIC QT_WIDGETS_LIB)
|
||||
|
||||
# Demo with Qt quick
|
||||
add_subdirectory(demo-window)
|
||||
# Demo with classic widgets
|
||||
add_subdirectory(demo-widget)
|
||||
OPTION(BUILD_IMGUI_QT_DEMO_WINDOW "Include demo-window Project" OFF)
|
||||
IF(NOT BUILD_IMGUI_QT_DEMO_WINDOW)
|
||||
MESSAGE(STATUS "Skipping demo-window Project")
|
||||
ELSE()
|
||||
ADD_SUBDIRECTORY(demo-window)
|
||||
ENDIF(NOT BUILD_IMGUI_QT_DEMO_WINDOW)
|
||||
|
||||
OPTION(BUILD_IMGUI_QT_DEMO_WIDGET "Include demo-widget Project" OFF)
|
||||
IF(NOT BUILD_IMGUI_QT_DEMO_WIDGET)
|
||||
MESSAGE(STATUS "Skipping demo-widget Project")
|
||||
ELSE()
|
||||
ADD_SUBDIRECTORY(demo-widget)
|
||||
ENDIF(NOT BUILD_IMGUI_QT_DEMO_WIDGET)
|
||||
@@ -1,24 +1,34 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#include <glm/common.hpp>
|
||||
#include <math/bounding_box.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
math::vector_3d min_per_dimension(std::vector<math::vector_3d> const& points)
|
||||
glm::vec3 min_per_dimension(std::vector<glm::vec3> const& points)
|
||||
{
|
||||
auto min(math::vector_3d::max());
|
||||
auto min(glm::vec3(
|
||||
std::numeric_limits<float>::max(),
|
||||
std::numeric_limits<float>::max(),
|
||||
std::numeric_limits<float>::max()
|
||||
));
|
||||
|
||||
for (auto const& point : points)
|
||||
{
|
||||
min = math::min(min, point);
|
||||
min = glm::min(min, point);
|
||||
}
|
||||
return min;
|
||||
}
|
||||
math::vector_3d max_per_dimension(std::vector<math::vector_3d> const& points)
|
||||
glm::vec3 max_per_dimension(std::vector<glm::vec3> const& points)
|
||||
{
|
||||
auto max(math::vector_3d::min());
|
||||
auto max(glm::vec3(
|
||||
std::numeric_limits<float>::min(),
|
||||
std::numeric_limits<float>::min(),
|
||||
std::numeric_limits<float>::min()
|
||||
));
|
||||
for (auto const& point : points)
|
||||
{
|
||||
max = math::max(max, point);
|
||||
max = glm::max(max, point);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
@@ -26,27 +36,27 @@ namespace
|
||||
|
||||
namespace math
|
||||
{
|
||||
aabb::aabb(math::vector_3d const& min_, math::vector_3d const& max_)
|
||||
aabb::aabb(glm::vec3 const& min_, glm::vec3 const& max_)
|
||||
: min(min_)
|
||||
, max(max_)
|
||||
{
|
||||
}
|
||||
|
||||
aabb::aabb(std::vector<math::vector_3d> points)
|
||||
aabb::aabb(std::vector<glm::vec3> points)
|
||||
: aabb(min_per_dimension(points), max_per_dimension(points))
|
||||
{
|
||||
}
|
||||
|
||||
//! \todo Optimize: iterate lazily.
|
||||
std::vector<math::vector_3d> aabb::all_corners() const
|
||||
std::vector<glm::vec3> aabb::all_corners() const
|
||||
{
|
||||
return box_points(min, max);
|
||||
}
|
||||
|
||||
|
||||
std::vector<math::vector_3d> box_points(math::vector_3d const& box_min, math::vector_3d const& box_max)
|
||||
std::vector<glm::vec3> box_points(glm::vec3 const& box_min, glm::vec3 const& box_max)
|
||||
{
|
||||
std::vector<math::vector_3d> points;
|
||||
std::vector<glm::vec3> points;
|
||||
|
||||
points.emplace_back(box_max.x, box_max.y, box_max.z);
|
||||
points.emplace_back(box_max.x, box_max.y, box_min.z);
|
||||
|
||||
@@ -2,22 +2,21 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/vector_3d.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
namespace math
|
||||
{
|
||||
struct aabb
|
||||
{
|
||||
aabb(math::vector_3d const& min_, math::vector_3d const& max_);
|
||||
aabb(std::vector<math::vector_3d> points);
|
||||
aabb(glm::vec3 const& min_, glm::vec3 const& max_);
|
||||
aabb(std::vector<glm::vec3> points);
|
||||
|
||||
std::vector<math::vector_3d> all_corners() const;
|
||||
std::vector<glm::vec3> all_corners() const;
|
||||
|
||||
math::vector_3d min;
|
||||
math::vector_3d max;
|
||||
glm::vec3 min;
|
||||
glm::vec3 max;
|
||||
};
|
||||
|
||||
std::vector<math::vector_3d> box_points(math::vector_3d const& box_min, math::vector_3d const& box_max);
|
||||
std::vector<glm::vec3> box_points(glm::vec3 const& box_min, glm::vec3 const& box_max);
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace math
|
||||
{
|
||||
namespace constants
|
||||
{
|
||||
constexpr float const pi = 3.141592653f;
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
namespace math
|
||||
{
|
||||
frustum::frustum (matrix_4x4 const& matrix)
|
||||
frustum::frustum (glm::mat4x4 const& matrix)
|
||||
{
|
||||
const vector_4d column_0 (matrix.column<0>());
|
||||
const vector_4d column_1 (matrix.column<1>());
|
||||
const vector_4d column_2 (matrix.column<2>());
|
||||
const vector_4d column_3 (matrix.column<3>());
|
||||
const glm::vec4 column_0 = matrix[0];
|
||||
const glm::vec4 column_1 = matrix[1];
|
||||
const glm::vec4 column_2 = matrix[2];
|
||||
const glm::vec4 column_3 = matrix[3];
|
||||
|
||||
_planes[RIGHT] = column_3 - column_0;
|
||||
_planes[LEFT] = column_3 + column_0;
|
||||
@@ -22,11 +22,11 @@ namespace math
|
||||
_planes[FRONT] = column_3 + column_2;
|
||||
}
|
||||
|
||||
bool frustum::contains (const vector_3d& point) const
|
||||
bool frustum::contains (const glm::vec3& point) const
|
||||
{
|
||||
for (auto const& plane : _planes)
|
||||
{
|
||||
if (plane.normal() * point <= -plane.distance())
|
||||
if (glm::dot(plane.normal() , point) <= -plane.distance())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -34,13 +34,13 @@ namespace math
|
||||
return true;
|
||||
}
|
||||
|
||||
bool frustum::intersects (const std::array<vector_3d, 8>& intersect_points) const
|
||||
bool frustum::intersects (const std::array<glm::vec3, 8>& intersect_points) const
|
||||
{
|
||||
for (auto const& plane : _planes)
|
||||
{
|
||||
for (auto const& point : intersect_points)
|
||||
{
|
||||
if (plane.normal() * point > -plane.distance())
|
||||
if (glm::dot(plane.normal(), point) > -plane.distance())
|
||||
{
|
||||
//! \note C does not know how to continue out of two loops otherwise.
|
||||
goto intersects_next_side;
|
||||
@@ -56,15 +56,15 @@ namespace math
|
||||
|
||||
}
|
||||
|
||||
bool frustum::intersects ( const vector_3d& v1
|
||||
, const vector_3d& v2
|
||||
bool frustum::intersects ( const glm::vec3& v1
|
||||
, const glm::vec3& v2
|
||||
) const
|
||||
{
|
||||
for (auto const& plane : _planes)
|
||||
{
|
||||
|
||||
glm::vec3 vmin;
|
||||
vector_3d normal = plane.normal();
|
||||
glm::vec3 normal = plane.normal();
|
||||
|
||||
// X axis
|
||||
if (normal.x > 0)
|
||||
@@ -96,9 +96,9 @@ namespace math
|
||||
vmin.z = v2.z;
|
||||
}
|
||||
|
||||
auto plane_normal = reinterpret_cast<glm::vec3*>(&normal._data);
|
||||
auto plane_normal = normal;
|
||||
|
||||
if (dot(*plane_normal, vmin) + plane.distance() <= 0)
|
||||
if (glm::dot(plane_normal, vmin) + plane.distance() <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -109,15 +109,13 @@ namespace math
|
||||
}
|
||||
|
||||
|
||||
bool frustum::intersectsSphere ( const vector_3d& position
|
||||
bool frustum::intersectsSphere ( const glm::vec3& position
|
||||
, const float& radius
|
||||
) const
|
||||
{
|
||||
for (auto const& plane : _planes)
|
||||
{
|
||||
const float distance ( plane.normal() * position
|
||||
+ plane.distance()
|
||||
);
|
||||
const float distance = glm::dot(plane.normal(), position+ plane.distance());
|
||||
if (distance < -radius)
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/vector_3d.hpp>
|
||||
#include <math/vector_4d.hpp>
|
||||
#include <math/matrix_4x4.hpp>
|
||||
|
||||
#include <array>
|
||||
@@ -27,8 +24,8 @@ namespace math
|
||||
{
|
||||
public:
|
||||
plane() = default;
|
||||
plane (vector_4d const& vec)
|
||||
: _normal (vec.xyz())
|
||||
plane (glm::vec4 const& vec)
|
||||
: _normal (glm::vec3(vec.x, vec.y, vec.z))
|
||||
, _distance (vec.w)
|
||||
{
|
||||
//normalize();
|
||||
@@ -46,26 +43,26 @@ namespace math
|
||||
return _distance;
|
||||
}
|
||||
|
||||
const vector_3d& normal() const
|
||||
const glm::vec3& normal() const
|
||||
{
|
||||
return _normal;
|
||||
}
|
||||
|
||||
private:
|
||||
vector_3d _normal;
|
||||
glm::vec3 _normal;
|
||||
float _distance;
|
||||
};
|
||||
std::array<plane, SIDES_MAX> _planes;
|
||||
|
||||
public:
|
||||
frustum (matrix_4x4 const& matrix);
|
||||
frustum (glm::mat4x4 const& matrix);
|
||||
|
||||
bool contains (const vector_3d& point) const;
|
||||
bool intersects (const std::array<vector_3d, 8>& intersect_points) const;
|
||||
bool intersects ( const vector_3d& v1
|
||||
, const vector_3d& v2
|
||||
bool contains (const glm::vec3& point) const;
|
||||
bool intersects (const std::array<glm::vec3, 8>& intersect_points) const;
|
||||
bool intersects ( const glm::vec3& v1
|
||||
, const glm::vec3& v2
|
||||
) const;
|
||||
bool intersectsSphere ( const vector_3d& position
|
||||
bool intersectsSphere ( const glm::vec3& position
|
||||
, const float& radius
|
||||
) const;
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace math
|
||||
|
||||
radians const a (acos (dot)._ * percentage);
|
||||
|
||||
return T (start * cos (a) + T (end - start * dot).normalize() * sin (a));
|
||||
return T (start * glm::cos(a._) + T (end - start * dot).normalize() * glm::sin(a._));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#include <math/matrix_4x4.hpp>
|
||||
#include <math/quaternion.hpp>
|
||||
#include <math/vector_3d.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring> // memcpy, memset
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
namespace math
|
||||
{
|
||||
@@ -19,7 +19,7 @@ namespace math
|
||||
matrix_4x4::rotation_yzx_t matrix_4x4::rotation_yzx;
|
||||
matrix_4x4::rotation_yxz_t matrix_4x4::rotation_yxz;
|
||||
|
||||
matrix_4x4::matrix_4x4 (rotation_t, quaternion const& q)
|
||||
matrix_4x4::matrix_4x4 (rotation_t, glm::quat const& q)
|
||||
{
|
||||
_m[0][0] = 1.0f - 2.0f * q.y * q.y - 2.0f * q.z * q.z;
|
||||
_m[0][1] = 2.0f * q.x * q.y + 2.0f * q.w * q.z;
|
||||
@@ -60,8 +60,8 @@ namespace math
|
||||
std::size_t const i_index (i_indices[a]);
|
||||
std::size_t const j_index (j_indices[a]);
|
||||
|
||||
float const cosV (cos (angle));
|
||||
float const sinV (sin (angle));
|
||||
float const cosV (glm::cos (angle._));
|
||||
float const sinV (glm::sin (angle._));
|
||||
|
||||
matrix_4x4 mat (matrix_4x4::unit);
|
||||
mat (j_index, j_index, cosV);
|
||||
@@ -76,34 +76,34 @@ namespace math
|
||||
matrix_4x4::matrix_4x4 (rotation_xyz_t, degrees::vec3 const& angle)
|
||||
: matrix_4x4 (unit)
|
||||
{
|
||||
*this *= rotate_axis<x> (angle.x);
|
||||
*this *= rotate_axis<y> (angle.y);
|
||||
*this *= rotate_axis<z> (angle.z);
|
||||
*this *= rotate_axis<x>(degrees(angle.x));
|
||||
*this *= rotate_axis<y>(degrees(angle.y));
|
||||
*this *= rotate_axis<z>(degrees(angle.z));
|
||||
}
|
||||
matrix_4x4::matrix_4x4 (rotation_yzx_t, degrees::vec3 const& angle)
|
||||
: matrix_4x4 (unit)
|
||||
{
|
||||
*this *= rotate_axis<y> (angle.y);
|
||||
*this *= rotate_axis<z> (angle.z);
|
||||
*this *= rotate_axis<x> (angle.x);
|
||||
*this *= rotate_axis<y> (degrees(angle.y));
|
||||
*this *= rotate_axis<z> (degrees(angle.z));
|
||||
*this *= rotate_axis<x> (degrees(angle.x));
|
||||
}
|
||||
|
||||
matrix_4x4::matrix_4x4(rotation_yxz_t, degrees::vec3 const& angle)
|
||||
: matrix_4x4(unit)
|
||||
{
|
||||
*this *= rotate_axis<y>(angle.y);
|
||||
*this *= rotate_axis<x>(angle.x);
|
||||
*this *= rotate_axis<z>(angle.z);
|
||||
*this *= rotate_axis<y>(degrees(angle.y));
|
||||
*this *= rotate_axis<x>(degrees(angle.x));
|
||||
*this *= rotate_axis<z>(degrees(angle.z));
|
||||
}
|
||||
|
||||
vector_3d matrix_4x4::operator* (vector_3d const& v) const
|
||||
glm::vec3 matrix_4x4::operator* (glm::vec3 const& v) const
|
||||
{
|
||||
return { _m[0][0] * v[0] + _m[0][1] * v[1] + _m[0][2] * v[2] + _m[0][3]
|
||||
, _m[1][0] * v[0] + _m[1][1] * v[1] + _m[1][2] * v[2] + _m[1][3]
|
||||
, _m[2][0] * v[0] + _m[2][1] * v[1] + _m[2][2] * v[2] + _m[2][3]
|
||||
};
|
||||
}
|
||||
vector_4d matrix_4x4::operator* (const vector_4d& v) const
|
||||
glm::vec4 matrix_4x4::operator* (const glm::vec4& v) const
|
||||
{
|
||||
return { _m[0][0] * v[0] + _m[0][1] * v[1] + _m[0][2] * v[2] + _m[0][3] * v[3]
|
||||
, _m[1][0] * v[0] + _m[1][1] * v[1] + _m[1][2] * v[2] + _m[1][3] * v[3]
|
||||
@@ -133,15 +133,16 @@ namespace math
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<math::vector_3d> matrix_4x4::operator*
|
||||
(std::vector<math::vector_3d> points) const
|
||||
std::vector<glm::vec3> matrix_4x4::operator* (std::vector<glm::vec3> points) const
|
||||
{
|
||||
return apply ( [&] (math::vector_3d const& point)
|
||||
{
|
||||
return *this * point;
|
||||
}
|
||||
, points
|
||||
);
|
||||
auto adjustedPoints = std::vector<glm::vec3>();
|
||||
|
||||
for(auto const &point : points)
|
||||
{
|
||||
adjustedPoints.push_back(*this * point);
|
||||
}
|
||||
|
||||
return adjustedPoints;
|
||||
}
|
||||
|
||||
namespace
|
||||
@@ -209,6 +210,24 @@ namespace math
|
||||
return adjoint() / determinant (*this);
|
||||
}
|
||||
|
||||
glm::mat4x4 matrix_4x4::Convert() const
|
||||
{
|
||||
return { _m[0][0], _m[1][0], _m[2][0], _m[3][0]
|
||||
, _m[0][1], _m[1][1], _m[2][1], _m[3][1]
|
||||
, _m[0][2], _m[1][2], _m[2][2], _m[3][2]
|
||||
, _m[0][3], _m[1][3], _m[2][3], _m[3][3]
|
||||
};
|
||||
}
|
||||
|
||||
glm::mat4x4 matrix_4x4::ConvertX() const
|
||||
{
|
||||
return { _m[0][0] , _m[0][1] , _m[0][2] , _m[0][3],
|
||||
_m[1][0] , _m[1][1] , _m[1][2] , _m[1][3] ,
|
||||
_m[2][0] , _m[2][1] , _m[2][2] , _m[2][3] ,
|
||||
_m[3][0] , _m[3][1] , _m[3][2] , _m[3][3]
|
||||
};
|
||||
}
|
||||
|
||||
matrix_4x4 matrix_4x4::transposed() const
|
||||
{
|
||||
return { _m[0][0], _m[1][0], _m[2][0], _m[3][0]
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/quaternion.hpp>
|
||||
#include <math/trig.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
namespace math
|
||||
{
|
||||
@@ -44,7 +43,7 @@ namespace math
|
||||
}
|
||||
|
||||
static struct translation_t {} translation;
|
||||
matrix_4x4 (translation_t, vector_3d const& tr)
|
||||
matrix_4x4 (translation_t, glm::vec3 const& tr)
|
||||
: matrix_4x4 ( 1.0f, 0.0f, 0.0f, tr.x
|
||||
, 0.0f, 1.0f, 0.0f, tr.y
|
||||
, 0.0f, 0.0f, 1.0f, tr.z
|
||||
@@ -53,7 +52,7 @@ namespace math
|
||||
{}
|
||||
|
||||
static struct scale_t {} scale;
|
||||
matrix_4x4 (scale_t, vector_3d const& sc)
|
||||
matrix_4x4 (scale_t, glm::vec3 const& sc)
|
||||
: matrix_4x4 ( sc.x, 0.0f, 0.0f, 0.0f
|
||||
, 0.0f, sc.y, 0.0f, 0.0f
|
||||
, 0.0f, 0.0f, sc.z, 0.0f
|
||||
@@ -65,7 +64,7 @@ namespace math
|
||||
{}
|
||||
|
||||
static struct rotation_t {} rotation;
|
||||
matrix_4x4 (rotation_t, quaternion const&);
|
||||
matrix_4x4 (rotation_t, glm::quat const& q);
|
||||
|
||||
static struct rotation_xyz_t {} rotation_xyz;
|
||||
matrix_4x4 (rotation_xyz_t, degrees::vec3 const&);
|
||||
@@ -84,14 +83,10 @@ namespace math
|
||||
return _m[j][i] = value;
|
||||
}
|
||||
|
||||
vector_3d operator* (vector_3d const&) const;
|
||||
vector_4d operator* (vector_4d const&) const;
|
||||
quaternion operator* (quaternion const& q) const
|
||||
{
|
||||
return quaternion {*this * static_cast<vector_4d> (q)};
|
||||
}
|
||||
glm::vec3 operator* (glm::vec3 const&) const;
|
||||
glm::vec4 operator* (glm::vec4 const&) const;
|
||||
matrix_4x4 operator* (matrix_4x4 const&) const;
|
||||
std::vector<math::vector_3d> operator*(std::vector<math::vector_3d> points) const;
|
||||
std::vector<glm::vec3> operator*(std::vector<glm::vec3> points) const;
|
||||
|
||||
matrix_4x4& operator* (float);
|
||||
matrix_4x4& operator/ (float);
|
||||
@@ -99,6 +94,8 @@ namespace math
|
||||
matrix_4x4 adjoint() const;
|
||||
matrix_4x4 inverted() const;
|
||||
matrix_4x4 transposed() const;
|
||||
glm::mat4x4 Convert() const;
|
||||
glm::mat4x4 ConvertX() const;
|
||||
|
||||
inline matrix_4x4& operator*= (matrix_4x4 const& p)
|
||||
{
|
||||
@@ -115,7 +112,7 @@ namespace math
|
||||
}
|
||||
|
||||
template<std::size_t i>
|
||||
vector_4d column() const
|
||||
glm::vec4 column() const
|
||||
{
|
||||
return {_m[0][i], _m[1][i], _m[2][i], _m[3][i]};
|
||||
}
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/matrix_4x4.hpp>
|
||||
#include <math/trig.hpp>
|
||||
#include <math/vector_3d.hpp>
|
||||
|
||||
namespace math
|
||||
{
|
||||
inline matrix_4x4 perspective (math::degrees fovy, float aspect, float zNear, float zFar)
|
||||
{
|
||||
// assuming
|
||||
// math::vector_3d lower_left_clipping_plane (left, bottom, -nearVal);
|
||||
// math::vector_3d upper_right_clipping_plane (right, top, -nearVal);
|
||||
// math::vector_3d eye (0, 0, 0);
|
||||
// float clipping_plane_distance (zFar - zNear);
|
||||
|
||||
// with
|
||||
float const ymax (zNear * math::tan (fovy) / 2.0f);
|
||||
// float left (-ymax * aspect);
|
||||
// float right (ymax * aspect);
|
||||
// float bottom (-ymax);
|
||||
// float top (ymax);
|
||||
// float nearVal (zNear);
|
||||
// float farVal (zFar);
|
||||
|
||||
// multiply matrix by
|
||||
// math::matrix_4x4 frustum ( 2 * nearVal / (right - left), 0.0f, (right + left) / (right - left), 0.0f
|
||||
// , 0.0f, 2 * nearVal / (top - bottom), (top + bottom) / (top - bottom), 0.0f
|
||||
// , 0.0f, 0.0f, - (farVal + nearVal) / (farVal - nearVal), - 2 * farVal * nearVal / (farVal - nearVal)
|
||||
// , 0.0f, 0.0f, -1.0f, 0.0f
|
||||
// );
|
||||
|
||||
// with optimized values
|
||||
return { zNear / (ymax * aspect), 0.0f, 0.0f, 0.0f
|
||||
, 0.0f, zNear / ymax, 0.0f, 0.0f
|
||||
, 0.0f, 0.0f, -(zFar + zNear) / (zFar - zNear), -2 * zFar * zNear / (zFar - zNear)
|
||||
, 0.0f, 0.0f, -1.0f, 0.0f
|
||||
};
|
||||
}
|
||||
|
||||
inline matrix_4x4 ortho(float left, float right, float bottom, float top, float z_near, float z_far)
|
||||
{
|
||||
float v0 = 2.f / (right - left);
|
||||
float v1 = 2.f / (top - bottom);
|
||||
float v2 = -2.f / (z_far - z_near);
|
||||
|
||||
float tx = -(right + left) / (right - left);
|
||||
float ty = -(top + bottom) / (top - bottom);
|
||||
float tz = -(z_far + z_near) / (z_far - z_near);
|
||||
|
||||
return { v0, 0.f, 0.f, tx
|
||||
, 0.f, v1, 0.f, ty
|
||||
, 0.f, 0.f, v2, tz
|
||||
, 0.f, 0.f, 0.f, 1.f
|
||||
};
|
||||
}
|
||||
|
||||
inline matrix_4x4 look_at ( vector_3d const& eye
|
||||
, vector_3d const& center
|
||||
, vector_3d const& up
|
||||
)
|
||||
{
|
||||
vector_3d const z ((eye - center).normalized());
|
||||
vector_3d const x ((up % z).normalized());
|
||||
vector_3d const y ((z % x).normalized());
|
||||
|
||||
return { x.x, x.y, x.z, x * -eye
|
||||
, y.x, y.y, y.z, y * -eye
|
||||
, z.x, z.y, z.z, z * -eye
|
||||
, 0.f, 0.f, 0.f, 1.f
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/interpolation.hpp>
|
||||
#include <math/vector_4d.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace math
|
||||
{
|
||||
struct vector_3d;
|
||||
|
||||
struct quaternion : public vector_4d
|
||||
{
|
||||
public:
|
||||
quaternion()
|
||||
: quaternion(0.f, 0.f, 0.f, 1.0f)
|
||||
{}
|
||||
|
||||
quaternion(const float& x
|
||||
, const float& y
|
||||
, const float& z
|
||||
, const float& w
|
||||
)
|
||||
: vector_4d(x, y, z, w)
|
||||
{ }
|
||||
|
||||
explicit quaternion(const vector_4d& v)
|
||||
: vector_4d(v)
|
||||
{ }
|
||||
|
||||
quaternion(const vector_3d& v, const float w)
|
||||
: vector_4d(v, w)
|
||||
{ }
|
||||
// heading = rotation around y
|
||||
// attitude = rotation around z
|
||||
// bank = rotation around x
|
||||
quaternion(math::radians bank, math::radians heading, math::radians attitude) : vector_4d()
|
||||
{
|
||||
/*yawr._ *= 0.5f;
|
||||
pitchr._ *= 0.5f;
|
||||
rollr._ *= 0.5f;
|
||||
|
||||
// Abbreviations for the various angular functions
|
||||
double cy = cos(yawr);
|
||||
double sy = sin(yawr);
|
||||
double cp = cos(pitchr);
|
||||
double sp = sin(pitchr);
|
||||
double cr = cos(rollr);
|
||||
double sr = sin(rollr);
|
||||
|
||||
w = static_cast<float>(cr * cp * cy + sr * sp * sy);
|
||||
x = static_cast<float>(sr * cp * cy - cr * sp * sy);
|
||||
y = static_cast<float>(cr * sp * cy + sr * cp * sy);
|
||||
z = static_cast<float>(cr * cp * sy - sr * sp * cy);*/
|
||||
heading._ *= 0.5;
|
||||
attitude._ *= 0.5;
|
||||
bank._ *= 0.5;
|
||||
// Assuming the angles are in radians.
|
||||
double c1 = cos(heading );
|
||||
double s1 = sin(heading );
|
||||
double c2 = cos(attitude);
|
||||
double s2 = sin(attitude );
|
||||
double c3 = cos(bank );
|
||||
double s3 = sin(bank );
|
||||
double c1c2 = c1 * c2;
|
||||
double s1s2 = s1 * s2;
|
||||
w = static_cast<float>(c1c2 * c3 - s1s2 * s3);
|
||||
x = static_cast<float>(c1c2 * s3 + s1s2 * c3);
|
||||
y = static_cast<float>(s1 * c2 * c3 + c1 * s2 * s3);
|
||||
z = static_cast<float>(c1 * s2 * c3 - s1 * c2 * s3);
|
||||
|
||||
}
|
||||
|
||||
quaternion operator% (const quaternion& q2) const
|
||||
{
|
||||
float newx = x * q2.w + y * q2.z - z * q2.y + w * q2.x;
|
||||
float newy = -x * q2.z + y * q2.w + z * q2.x + w * q2.y;
|
||||
float newz = x * q2.y - y * q2.x + z * q2.w + w * q2.z;
|
||||
float neww = -x * q2.x - y * q2.y - z * q2.z + w * q2.w;
|
||||
return quaternion(newx, newy, newz, neww);
|
||||
}
|
||||
|
||||
degrees::vec3 ToEulerAngles() const
|
||||
{
|
||||
/* // Old method, prone to gimbal lock!
|
||||
double ex, ey, ez;
|
||||
// roll (x-axis rotation)
|
||||
double sinr_cosp = 2.0 * (w * x + y * z);
|
||||
double cosr_cosp = 1.0 - 2.0 * (x * x + y * y);
|
||||
ex = std::atan2(sinr_cosp, cosr_cosp) * 180.0f / math::constants::pi;
|
||||
|
||||
// pitch (y-axis rotation)
|
||||
double sinp = 2.0 * (w * y - z * x);
|
||||
if (std::abs(sinp) >= 1)
|
||||
ey = std::copysign(math::constants::pi / 2, sinp) * 180.0f / math::constants::pi; // use 90 degrees if out of range
|
||||
else
|
||||
ey = std::asin(sinp) * 180.0f / math::constants::pi;
|
||||
|
||||
// yaw (z-axis rotation)
|
||||
double siny_cosp = 2.0 * (w * z + x * y);
|
||||
double cosy_cosp = 1.0 - 2.0 * (y * y + z * z);
|
||||
ez = std::atan2(siny_cosp, cosy_cosp) * 180.0f / math::constants::pi;
|
||||
|
||||
return vector_3d(static_cast<float>(ex), static_cast<float>(ey), static_cast<float>(ez));
|
||||
*/
|
||||
math::degrees::vec3 retVal;
|
||||
|
||||
double sqw = w * w;
|
||||
double sqx = x * x;
|
||||
double sqy = y * y;
|
||||
double sqz = z * z;
|
||||
double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor
|
||||
double test = x * y + z * w;
|
||||
if (test > 0.499 * unit) { // singularity at north pole
|
||||
retVal.y = -math::degrees(math::radians(2.0f * std::atan2(x, w)));
|
||||
retVal.x = math::degrees(math::radians(math::constants::pi / 2));
|
||||
retVal.z = 0_deg;
|
||||
}
|
||||
else if (test < -0.499 * unit) { // singularity at south pole
|
||||
retVal.y = -math::degrees(math::radians(-2.0f * std::atan2(x, w)));
|
||||
retVal.x = -math::degrees(math::radians(math::constants::pi / 2));
|
||||
retVal.z = 0_deg;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.y = -math::degrees(math::radians(std::atan2(2 * y * w - 2 * x * z, sqx - sqy - sqz + sqw)));
|
||||
retVal.x = math::degrees(math::radians(std::asin(2 * test / unit)));
|
||||
retVal.z = math::degrees(math::radians(std::atan2(2 * x * w - 2 * y * z, -sqx + sqy - sqz + sqw)));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//! \note "linear" interpolation for quaternions should be slerp by default.
|
||||
namespace interpolation
|
||||
{
|
||||
template<>
|
||||
inline quaternion linear(const float& percentage
|
||||
, const quaternion& start
|
||||
, const quaternion& end
|
||||
)
|
||||
{
|
||||
return slerp(percentage, start, end);
|
||||
}
|
||||
}
|
||||
|
||||
//! \note In WoW 2.0+ Blizzard is now storing rotation data in 16bit values instead of 32bit. I don't really understand why as its only a very minor saving in model sizes and adds extra overhead in processing the models. Need this structure to read the data into.
|
||||
struct packed_quaternion
|
||||
{
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t z;
|
||||
int16_t w;
|
||||
};
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace math
|
||||
{
|
||||
boost::optional<float> ray::intersect_bounds
|
||||
(vector_3d const& min, vector_3d const& max) const
|
||||
(glm::vec3 const& min, glm::vec3 const& max) const
|
||||
{
|
||||
float tmin (std::numeric_limits<float>::lowest());
|
||||
float tmax (std::numeric_limits<float>::max());
|
||||
@@ -48,41 +48,41 @@ namespace math
|
||||
}
|
||||
|
||||
boost::optional<float> ray::intersect_triangle
|
||||
(vector_3d const& v0, vector_3d const& v1, vector_3d const& v2) const
|
||||
(glm::vec3 const& v0, glm::vec3 const& v1, glm::vec3 const& v2) const
|
||||
{
|
||||
vector_3d const e1 (v1 - v0);
|
||||
vector_3d const e2 (v2 - v0);
|
||||
glm::vec3 e1 (v1 - v0);
|
||||
glm::vec3 e2 (v2 - v0);
|
||||
|
||||
vector_3d const P (_direction % e2);
|
||||
glm::vec3 P = glm::cross(_direction,e2);
|
||||
|
||||
float const det (e1 * P);
|
||||
float const det = glm::dot(e1, P);
|
||||
|
||||
if (det == 0.0f)
|
||||
{
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
vector_3d const T (_origin - v0);
|
||||
float const u ((T * P) / det);
|
||||
glm::vec3 const T (_origin - v0);
|
||||
float const dotu = glm::dot(T , P) / det;
|
||||
|
||||
if (u < 0.0f || u > 1.0f)
|
||||
if (dotu < 0.0f || dotu > 1.0f)
|
||||
{
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
vector_3d const Q (T % e1);
|
||||
float const v ((_direction * Q) / det);
|
||||
glm::vec3 const Q (glm::cross(T, e1));
|
||||
float const dotv = glm::dot(_direction , Q) / det;
|
||||
|
||||
if (v < 0.0f || u + v > 1.0f)
|
||||
if (dotv < 0.0f || dotu + dotv > 1.0f)
|
||||
{
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
float const t ((e2 * Q) / det);
|
||||
float const dott = glm::dot(e2 , Q) / det;
|
||||
|
||||
if (t > std::numeric_limits<float>::min())
|
||||
if (dott > std::numeric_limits<float>::min())
|
||||
{
|
||||
return t;
|
||||
return dott;
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
|
||||
@@ -1,39 +1,34 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/matrix_4x4.hpp>
|
||||
#include <math/vector_3d.hpp>
|
||||
|
||||
#include <boost/optional/optional.hpp>
|
||||
|
||||
namespace math
|
||||
{
|
||||
struct ray
|
||||
{
|
||||
ray (vector_3d origin, vector_3d const& direction)
|
||||
: _origin (std::move (origin))
|
||||
, _direction (direction.normalized())
|
||||
ray (glm::vec3 origin, glm::vec3 const& direction): _origin (std::move (origin)), _direction (glm::normalize(direction))
|
||||
{}
|
||||
|
||||
ray (matrix_4x4 const& transform, ray const& other)
|
||||
: ray ( (transform * math::vector_4d (other._origin, 1.0)).xyz()
|
||||
, (transform * math::vector_4d (other._direction, 0.0)).xyz()
|
||||
ray (matrix_4x4 const& transform, ray const& other): ray (
|
||||
glm::vec3(
|
||||
(transform * glm::vec4(other._origin.x, other._origin.y, other._origin.z, 1.0))),
|
||||
glm::vec3((transform * glm::vec4(other._direction.x, other._direction.y, other._direction.z, 0.0)))
|
||||
)
|
||||
{}
|
||||
|
||||
boost::optional<float> intersect_bounds
|
||||
(vector_3d const& _min, vector_3d const& _max) const;
|
||||
(glm::vec3 const& _min, glm::vec3 const& _max) const;
|
||||
boost::optional<float> intersect_triangle
|
||||
(vector_3d const& _v0, vector_3d const& _v1, vector_3d const& _v2) const;
|
||||
(glm::vec3 const& _v0, glm::vec3 const& _v1, glm::vec3 const& _v2) const;
|
||||
|
||||
vector_3d position (float distance) const
|
||||
glm::vec3 position (float distance) const
|
||||
{
|
||||
return _origin + _direction * distance;
|
||||
}
|
||||
|
||||
private:
|
||||
vector_3d _origin;
|
||||
vector_3d _direction;
|
||||
glm::vec3 _origin;
|
||||
glm::vec3 _direction;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/constants.hpp>
|
||||
#include <math/vector_3d.hpp>
|
||||
#include <string>
|
||||
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <glm/common.hpp>
|
||||
#include <glm/trigonometric.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/ext/scalar_constants.hpp>
|
||||
|
||||
namespace math
|
||||
{
|
||||
@@ -54,11 +55,10 @@ namespace math
|
||||
|
||||
friend std::ostream& operator<< (std::ostream& os, degrees const& v)
|
||||
{
|
||||
return os << std::to_string(v._) << "°";
|
||||
return os << std::to_string(v._) << std::string("Degrees");
|
||||
}
|
||||
|
||||
|
||||
using vec3 = vector_3d_base<degrees>;
|
||||
using vec3 = glm::vec3;
|
||||
};
|
||||
|
||||
struct radians
|
||||
@@ -68,44 +68,24 @@ namespace math
|
||||
|
||||
float _;
|
||||
|
||||
using vec3 = vector_3d_base<radians>;
|
||||
using vec3 = glm::vec3;
|
||||
};
|
||||
|
||||
inline degrees::degrees (radians x) : _ (x._ * 180.0f / math::constants::pi) {}
|
||||
inline radians::radians (degrees x) : _ (x._ * math::constants::pi / 180.0f) {}
|
||||
inline degrees::degrees (radians x) : _ (x._ * 180.0f / glm::pi<float>()) {}
|
||||
inline radians::radians (degrees x) : _ (x._ * glm::pi<float>() / 180.0f) {}
|
||||
|
||||
inline float sin (radians x)
|
||||
inline void rotate(float x0, float y0, float* x, float* y, radians angle)
|
||||
{
|
||||
return std::sin (x._);
|
||||
const float xa(*x - x0);
|
||||
const float ya(*y - y0);
|
||||
*x = xa * glm::cos(angle._) - ya * glm::sin(angle._) + x0;
|
||||
*y = xa * glm::sin(angle._) + ya * glm::cos(angle._) + y0;
|
||||
}
|
||||
inline float cos (radians x)
|
||||
|
||||
inline bool is_inside_of(const glm::vec3& pos, const glm::vec3& a, const glm::vec3& b)
|
||||
{
|
||||
return std::cos (x._);
|
||||
}
|
||||
inline float tan (radians x)
|
||||
{
|
||||
return std::tan (x._);
|
||||
}
|
||||
inline radians asin (float x)
|
||||
{
|
||||
return radians {std::asin (x)};
|
||||
}
|
||||
inline radians acos (float x)
|
||||
{
|
||||
return radians {std::acos (x)};
|
||||
}
|
||||
inline radians atan2 (float y, float x)
|
||||
{
|
||||
return radians {std::atan2 (y, x)};
|
||||
return a.x < pos.x&& b.x > pos.x
|
||||
&& a.y < pos.y&& b.y > pos.y
|
||||
&& a.z < pos.z&& b.z > pos.z;
|
||||
}
|
||||
}
|
||||
|
||||
inline math::degrees operator"" _deg (long double v)
|
||||
{
|
||||
return math::degrees {static_cast<float> (v)};
|
||||
}
|
||||
|
||||
inline math::degrees operator"" _deg (unsigned long long int v)
|
||||
{
|
||||
return math::degrees {static_cast<float> (v)};
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#include <math/vector_2d.hpp>
|
||||
#include <math/trig.hpp>
|
||||
|
||||
namespace math
|
||||
{
|
||||
void rotate (float x0, float y0, float* x, float* y, radians angle)
|
||||
{
|
||||
const float xa (*x - x0);
|
||||
const float ya (*y - y0);
|
||||
*x = xa * cos (angle) - ya * sin (angle) + x0;
|
||||
*y = xa * sin (angle) + ya * cos (angle) + y0;
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/trig.hpp>
|
||||
|
||||
#include <ostream>
|
||||
#include <tuple>
|
||||
|
||||
namespace math
|
||||
{
|
||||
struct vector_2d
|
||||
{
|
||||
union
|
||||
{
|
||||
float _data[2];
|
||||
struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
};
|
||||
|
||||
vector_2d() : vector_2d (0.f, 0.f) {}
|
||||
vector_2d (float x_, float y_)
|
||||
: x (x_)
|
||||
, y (y_)
|
||||
{}
|
||||
|
||||
inline operator float*()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
inline operator float const*() const
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
vector_2d operator* (float factor) const
|
||||
{
|
||||
return {x * factor, y * factor};
|
||||
}
|
||||
vector_2d operator+ (vector_2d const& other) const
|
||||
{
|
||||
return {x + other.x, y + other.y};
|
||||
}
|
||||
|
||||
bool operator== (vector_2d const& rhs) const
|
||||
{
|
||||
return std::tie (x, y) == std::tie (rhs.x, rhs.y);
|
||||
}
|
||||
friend std::ostream& operator<< (std::ostream& os, vector_2d const& x)
|
||||
{
|
||||
return os << x.x << ", " << x.y;
|
||||
}
|
||||
};
|
||||
|
||||
void rotate (float x0, float y0, float* x, float* y, radians);
|
||||
inline vector_2d rotate (vector_2d const& around, vector_2d point, radians angle)
|
||||
{
|
||||
rotate (around.x, around.y, &point.x, &point.y, angle);
|
||||
return point;
|
||||
}
|
||||
}
|
||||
@@ -1,225 +0,0 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <ostream>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
namespace math
|
||||
{
|
||||
template<typename T>
|
||||
struct vector_3d_base
|
||||
{
|
||||
union
|
||||
{
|
||||
T _data[3];
|
||||
struct
|
||||
{
|
||||
T x;
|
||||
T y;
|
||||
T z;
|
||||
};
|
||||
};
|
||||
|
||||
vector_3d_base<T> (T x_, T y_, T z_)
|
||||
: x (x_)
|
||||
, y (y_)
|
||||
, z (z_)
|
||||
{};
|
||||
vector_3d_base<T>() : x (T(0)), y(T(0)), z(T(0)) {};
|
||||
|
||||
template<typename U>
|
||||
explicit vector_3d_base<T> (vector_3d_base<U> const& other)
|
||||
: x (other.x)
|
||||
, y (other.y)
|
||||
, z (other.z)
|
||||
{};
|
||||
|
||||
inline static vector_3d_base<T> min()
|
||||
{
|
||||
return {std::numeric_limits<T>::lowest(), std::numeric_limits<T>::lowest(), std::numeric_limits<T>::lowest()};
|
||||
}
|
||||
inline static vector_3d_base<T> max()
|
||||
{
|
||||
return {std::numeric_limits<T>::max(), std::numeric_limits<T>::max(), std::numeric_limits<T>::max()};
|
||||
}
|
||||
|
||||
vector_3d_base<T> (vector_3d_base<T> const&) = default;
|
||||
vector_3d_base<T> (vector_3d_base<T>&&) = default;
|
||||
vector_3d_base<T>& operator= (vector_3d_base<T> const&) = default;
|
||||
vector_3d_base<T>& operator= (vector_3d_base<T>&&) = default;
|
||||
|
||||
inline vector_3d_base<T> operator+ (const vector_3d_base<T> &v) const
|
||||
{
|
||||
return vector_3d_base<T> (x + v.x, y + v.y, z + v.z);
|
||||
}
|
||||
|
||||
inline vector_3d_base<T> operator- (const vector_3d_base<T> &v) const
|
||||
{
|
||||
return vector_3d_base<T> (x - v.x, y - v.y, z - v.z);
|
||||
}
|
||||
|
||||
inline vector_3d_base<T> operator-() const
|
||||
{
|
||||
return vector_3d_base<T> (-x, -y, -z);
|
||||
}
|
||||
|
||||
inline T operator* (const vector_3d_base<T> &v) const
|
||||
{
|
||||
return x * v.x + y * v.y + z * v.z;
|
||||
}
|
||||
|
||||
inline T operator/ (const vector_3d_base<T>& v) const
|
||||
{
|
||||
return x / v.x + y / v.y + z / v.z;
|
||||
}
|
||||
|
||||
inline vector_3d_base<T> operator* (const T& d) const
|
||||
{
|
||||
return vector_3d_base<T> (x * d, y * d, z * d);
|
||||
}
|
||||
|
||||
inline vector_3d_base<T> operator/ (const T& d) const
|
||||
{
|
||||
return vector_3d_base<T>(x / d, y / d, z / d);
|
||||
}
|
||||
|
||||
friend vector_3d_base<T> operator* (const T& d, const vector_3d_base<T>& v)
|
||||
{
|
||||
return v * d;
|
||||
}
|
||||
|
||||
friend vector_3d_base<T> operator/ (const T& d, const vector_3d_base<T>& v)
|
||||
{
|
||||
return v / d;
|
||||
}
|
||||
|
||||
inline vector_3d_base<T> operator% (const vector_3d_base<T>& v) const
|
||||
{
|
||||
return vector_3d_base<T> ( y * v.z - z * v.y
|
||||
, z * v.x - x * v.z
|
||||
, x * v.y - y * v.x
|
||||
);
|
||||
}
|
||||
|
||||
inline vector_3d_base<T>& operator+= (const vector_3d_base<T>& v)
|
||||
{
|
||||
x += v.x;
|
||||
y += v.y;
|
||||
z += v.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vector_3d_base<T>& operator-= (const vector_3d_base<T>& v)
|
||||
{
|
||||
x -= v.x;
|
||||
y -= v.y;
|
||||
z -= v.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vector_3d_base<T>& operator*= (T d)
|
||||
{
|
||||
x *= d;
|
||||
y *= d;
|
||||
z *= d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline vector_3d_base<T>& operator/= (T d)
|
||||
{
|
||||
x /= d;
|
||||
y /= d;
|
||||
z /= d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline T length_squared() const
|
||||
{
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
|
||||
inline T length() const
|
||||
{
|
||||
return std::sqrt (length_squared());
|
||||
}
|
||||
|
||||
inline vector_3d_base<T>& normalize()
|
||||
{
|
||||
return operator *= (1.0f / length());
|
||||
}
|
||||
|
||||
vector_3d_base<T> normalized() const
|
||||
{
|
||||
return *this * (1.0f / length());
|
||||
}
|
||||
|
||||
inline operator T*()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
inline operator const T*() const
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
inline bool is_inside_of (const vector_3d_base<T>& a, const vector_3d_base<T>& b ) const
|
||||
{
|
||||
return a.x < x && b.x > x
|
||||
&& a.y < y && b.y > y
|
||||
&& a.z < z && b.z > z;
|
||||
}
|
||||
|
||||
bool operator== (vector_3d_base<T> const& rhs) const
|
||||
{
|
||||
return std::tie (x, y, z) == std::tie (rhs.x, rhs.y, rhs.z);
|
||||
}
|
||||
friend std::ostream& operator<< (std::ostream& os, vector_3d_base<T> const& x)
|
||||
{
|
||||
return os << x.x << ", " << x.y << ", " << x.z;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline vector_3d_base<T> min (vector_3d_base<T> const& lhs, vector_3d_base<T> const& rhs)
|
||||
{
|
||||
return { std::min (lhs.x, rhs.x)
|
||||
, std::min (lhs.y, rhs.y)
|
||||
, std::min (lhs.z, rhs.z)
|
||||
};
|
||||
}
|
||||
template<typename T>
|
||||
inline vector_3d_base<T> max (vector_3d_base<T> const& lhs, vector_3d_base<T> const& rhs)
|
||||
{
|
||||
return { std::max (lhs.x, rhs.x)
|
||||
, std::max (lhs.y, rhs.y)
|
||||
, std::max (lhs.z, rhs.z)
|
||||
};
|
||||
}
|
||||
|
||||
struct vector_3d : public vector_3d_base<float>
|
||||
{
|
||||
public:
|
||||
using vector_3d_base<float>::vector_3d_base;
|
||||
vector_3d (vector_3d_base<float> x) : vector_3d_base<float> (std::move (x)) {}
|
||||
vector_3d() : vector_3d_base<float>() {}
|
||||
};
|
||||
|
||||
|
||||
template<typename Fun>
|
||||
std::vector<math::vector_3d> apply
|
||||
(Fun&& fun, std::vector<math::vector_3d> points)
|
||||
{
|
||||
for (auto& point : points)
|
||||
{
|
||||
point = fun (point);
|
||||
}
|
||||
return points;
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/vector_3d.hpp>
|
||||
|
||||
namespace math
|
||||
{
|
||||
struct vector_4d
|
||||
{
|
||||
union
|
||||
{
|
||||
float _data[4];
|
||||
struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float w;
|
||||
};
|
||||
};
|
||||
|
||||
vector_4d() : vector_4d (0.f, 0.f, 0.f, 0.f) {}
|
||||
vector_4d (float x_, float y_, float z_, float w_)
|
||||
: x (x_)
|
||||
, y (y_)
|
||||
, z (z_)
|
||||
, w (w_)
|
||||
{ }
|
||||
|
||||
vector_4d (const vector_4d& v)
|
||||
: x (v.x)
|
||||
, y (v.y)
|
||||
, z (v.z)
|
||||
, w (v.w)
|
||||
{ }
|
||||
|
||||
vector_4d (const ::math::vector_3d& v, const float w)
|
||||
: x (v.x)
|
||||
, y (v.y)
|
||||
, z (v.z)
|
||||
, w (w)
|
||||
{ }
|
||||
|
||||
vector_4d& operator= (const vector_4d &v)
|
||||
{
|
||||
x = v.x;
|
||||
y = v.y;
|
||||
z = v.z;
|
||||
w = v.w;
|
||||
return *this;
|
||||
}
|
||||
|
||||
vector_3d xyz() const
|
||||
{
|
||||
return vector_3d (x, y, z);
|
||||
}
|
||||
const vector_3d& xyz (const vector_3d& xyz_)
|
||||
{
|
||||
x = xyz_.x;
|
||||
y = xyz_.y;
|
||||
z = xyz_.z;
|
||||
return xyz_;
|
||||
}
|
||||
vector_3d xyz_normalized_by_w() const
|
||||
{
|
||||
return vector_3d (x / w, y / w, z / w);
|
||||
}
|
||||
|
||||
vector_4d operator+ (const vector_4d &v) const
|
||||
{
|
||||
return vector_4d (x + v.x, y + v.y, z + v.z, w + v.w);
|
||||
}
|
||||
|
||||
vector_4d operator- (const vector_4d &v) const
|
||||
{
|
||||
return vector_4d (x - v.x, y - v.y, z - v.z, w - v.w);
|
||||
}
|
||||
|
||||
vector_4d operator* (float d) const
|
||||
{
|
||||
return vector_4d (x * d, y * d, z * d, w * d);
|
||||
}
|
||||
|
||||
float operator* (const vector_4d& v) const
|
||||
{
|
||||
return x * v.x + y * v.y + z * v.z + w * v.w;
|
||||
}
|
||||
|
||||
vector_4d& operator*= (float d)
|
||||
{
|
||||
x *= d;
|
||||
y *= d;
|
||||
z *= d;
|
||||
w *= d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
vector_4d& normalize()
|
||||
{
|
||||
return operator *= (1.0f / std::sqrt (x * x + y * y + z * z + w * w));
|
||||
}
|
||||
|
||||
operator const float*() const
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
operator float*()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <algorithm>
|
||||
#include <external/tsl/robin_map.h>
|
||||
#include <boost/optional.hpp>
|
||||
#include <math/vector_2d.hpp>
|
||||
#include <noggit/TextureManager.h>
|
||||
#include <noggit/texture_set.hpp>
|
||||
#include <noggit/SceneObject.hpp>
|
||||
@@ -18,7 +17,6 @@
|
||||
#include <noggit/ChunkWater.hpp>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class MapView;
|
||||
class MapChunk;
|
||||
|
||||
@@ -69,7 +67,7 @@ namespace noggit
|
||||
struct ObjectInstanceCache
|
||||
{
|
||||
std::string filename;
|
||||
math::vector_3d pos;
|
||||
glm::vec3 pos;
|
||||
math::degrees::vec3 dir;
|
||||
float scale;
|
||||
};
|
||||
@@ -79,8 +77,8 @@ namespace noggit
|
||||
std::unordered_set<MapTile*> vertex_tiles;
|
||||
std::unordered_set<MapChunk*> vertex_chunks;
|
||||
std::unordered_set<MapChunk*> vertex_border_chunks;
|
||||
std::unordered_set<math::vector_3d*> vertices_selected;
|
||||
math::vector_3d vertex_center;
|
||||
std::unordered_set<glm::vec3*> vertices_selected;
|
||||
glm::vec3 vertex_center;
|
||||
};
|
||||
|
||||
class Action : public QObject
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/quaternion.hpp>
|
||||
#include <noggit/MPQ.h>
|
||||
#include <noggit/ModelHeaders.h>
|
||||
|
||||
#include <math/interpolation.hpp>
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
namespace Animation
|
||||
{
|
||||
@@ -38,10 +37,10 @@ namespace Animation
|
||||
};
|
||||
|
||||
template<>
|
||||
inline math::quaternion Conversion<math::packed_quaternion, math::quaternion>::operator()(const math::packed_quaternion& value)
|
||||
inline glm::quat Conversion<packed_quaternion, glm::quat>::operator()(const packed_quaternion& value)
|
||||
{
|
||||
//! \todo Check if this is really correct.
|
||||
return math::quaternion(
|
||||
return glm::quat(
|
||||
static_cast<float>((value.x > 0 ? value.x - 32767 : value.x + 32767) / 32767.0f),
|
||||
static_cast<float>((value.y > 0 ? value.y - 32767 : value.y + 32767) / 32767.0f),
|
||||
static_cast<float>((value.z > 0 ? value.z - 32767 : value.z + 32767) / 32767.0f),
|
||||
|
||||
@@ -20,7 +20,7 @@ ChunkWater::ChunkWater(MapChunk* chunk, TileWater* water_tile, float x, float z,
|
||||
|
||||
void ChunkWater::from_mclq(std::vector<mclq>& layers)
|
||||
{
|
||||
math::vector_3d pos(xbase, 0.0f, zbase);
|
||||
glm::vec3 pos(xbase, 0.0f, zbase);
|
||||
|
||||
for (mclq& liquid : layers)
|
||||
{
|
||||
@@ -105,7 +105,7 @@ void ChunkWater::fromFile(MPQFile &f, size_t basePos)
|
||||
f.read(&infoMask, bitmask_size);
|
||||
}
|
||||
|
||||
math::vector_3d pos(xbase, 0.0f, zbase);
|
||||
glm::vec3 pos(xbase, 0.0f, zbase);
|
||||
_water_tile->registerNewChunk(_layers.size());
|
||||
_layers.emplace_back(this, f, basePos, pos, info, infoMask);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ void ChunkWater::setType(int type, size_t layer)
|
||||
|
||||
bool ChunkWater::is_visible ( const float& cull_distance
|
||||
, const math::frustum& frustum
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, display_mode display
|
||||
) const
|
||||
{
|
||||
@@ -227,14 +227,14 @@ bool ChunkWater::hasData(size_t layer) const
|
||||
}
|
||||
|
||||
|
||||
void ChunkWater::paintLiquid( math::vector_3d const& pos
|
||||
void ChunkWater::paintLiquid( glm::vec3 const& pos
|
||||
, float radius
|
||||
, int liquid_id
|
||||
, bool add
|
||||
, math::radians const& angle
|
||||
, math::radians const& orientation
|
||||
, bool lock
|
||||
, math::vector_3d const& origin
|
||||
, glm::vec3 const& origin
|
||||
, bool override_height
|
||||
, bool override_liquid_id
|
||||
, MapChunk* chunk
|
||||
@@ -256,7 +256,7 @@ void ChunkWater::paintLiquid( math::vector_3d const& pos
|
||||
|
||||
if (!layer_found)
|
||||
{
|
||||
liquid_layer layer(this, math::vector_3d(xbase, 0.0f, zbase), pos.y, liquid_id);
|
||||
liquid_layer layer(this, glm::vec3(xbase, 0.0f, zbase), pos.y, liquid_id);
|
||||
copy_height_to_layer(layer, pos, radius);
|
||||
_water_tile->registerNewChunk(_layers.size());
|
||||
_layers.push_back(layer);
|
||||
@@ -297,7 +297,7 @@ void ChunkWater::paintLiquid( math::vector_3d const& pos
|
||||
}
|
||||
else
|
||||
{
|
||||
liquid_layer layer(this, math::vector_3d(xbase, 0.0f, zbase), pos.y, liquid_id);
|
||||
liquid_layer layer(this, glm::vec3(xbase, 0.0f, zbase), pos.y, liquid_id);
|
||||
layer.paintLiquid(pos, radius, true, angle, orientation, lock, origin, override_height, chunk, opacity_factor);
|
||||
_water_tile->registerNewChunk(_layers.size());
|
||||
_layers.push_back(layer);
|
||||
@@ -318,7 +318,7 @@ void ChunkWater::cleanup()
|
||||
}
|
||||
}
|
||||
|
||||
void ChunkWater::copy_height_to_layer(liquid_layer& target, math::vector_3d const& pos, float radius)
|
||||
void ChunkWater::copy_height_to_layer(liquid_layer& target, glm::vec3 const& pos, float radius)
|
||||
{
|
||||
for (liquid_layer& layer : _layers)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/frustum.hpp>
|
||||
#include <math/vector_3d.hpp>
|
||||
#include <noggit/liquid_layer.hpp>
|
||||
#include <noggit/MapHeaders.h>
|
||||
#include <noggit/tool_enums.hpp>
|
||||
@@ -33,7 +30,7 @@ public:
|
||||
|
||||
bool is_visible ( const float& cull_distance
|
||||
, const math::frustum& frustum
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, display_mode display
|
||||
) const;
|
||||
|
||||
@@ -51,14 +48,14 @@ public:
|
||||
float getMinHeight() { return vmin.y; };
|
||||
float getMaxHeight() { return vmax.y; }
|
||||
|
||||
void paintLiquid( math::vector_3d const& pos
|
||||
void paintLiquid( glm::vec3 const& pos
|
||||
, float radius
|
||||
, int liquid_id
|
||||
, bool add
|
||||
, math::radians const& angle
|
||||
, math::radians const& orientation
|
||||
, bool lock
|
||||
, math::vector_3d const& origin
|
||||
, glm::vec3 const& origin
|
||||
, bool override_height
|
||||
, bool override_liquid_id
|
||||
, MapChunk* chunk
|
||||
@@ -72,13 +69,13 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
math::vector_3d vmin, vmax, vcenter;
|
||||
glm::vec3 vmin, vmax, vcenter;
|
||||
bool _use_mclq_green_lava;
|
||||
|
||||
// remove empty layers
|
||||
void cleanup();
|
||||
|
||||
void copy_height_to_layer(liquid_layer& target, math::vector_3d const& pos, float radius);
|
||||
void copy_height_to_layer(liquid_layer& target, glm::vec3 const& pos, float radius);
|
||||
|
||||
|
||||
MH2O_Render Render;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <opengl/context.inl>
|
||||
#include <noggit/DBC.h>
|
||||
#include <boost/format.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
|
||||
LiquidTextureManager::LiquidTextureManager(noggit::NoggitRenderContext context)
|
||||
@@ -22,7 +23,7 @@ void LiquidTextureManager::upload()
|
||||
const DBCFile::Record record = gLiquidTypeDB.getRecord(i);
|
||||
unsigned liquid_type_id = record.getInt(LiquidTypeDB::ID);
|
||||
int type = record.getInt(LiquidTypeDB::Type);
|
||||
math::vector_2d anim = {record.getFloat(LiquidTypeDB::AnimationX), record.getFloat(LiquidTypeDB::AnimationY)};
|
||||
glm::vec2 anim = {record.getFloat(LiquidTypeDB::AnimationX), record.getFloat(LiquidTypeDB::AnimationY)};
|
||||
int shader_type = record.getInt(LiquidTypeDB::ShaderType);
|
||||
|
||||
std::string filename;
|
||||
@@ -32,7 +33,7 @@ void LiquidTextureManager::upload()
|
||||
{
|
||||
filename = "XTextures\\river\\lake_a.%d.blp";
|
||||
// default param for water
|
||||
anim = math::vector_2d(1.f, 0.f);
|
||||
anim = glm::vec2(1.f, 0.f);
|
||||
}
|
||||
else
|
||||
[[likely]]
|
||||
|
||||
@@ -5,12 +5,10 @@
|
||||
|
||||
#include <noggit/TextureManager.h>
|
||||
#include <noggit/ContextObject.hpp>
|
||||
#include <math/vector_2d.hpp>
|
||||
#include <opengl/context.hpp>
|
||||
#include <opengl/scoped.hpp>
|
||||
#include <external/tsl/robin_map.h>
|
||||
|
||||
#include <tuple>
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
class LiquidTextureManager
|
||||
{
|
||||
@@ -22,13 +20,13 @@ public:
|
||||
void upload();
|
||||
void unload();
|
||||
|
||||
tsl::robin_map<unsigned, std::tuple<GLuint, math::vector_2d, int, unsigned>> const& getTextureFrames() { return _texture_frames_map; };
|
||||
tsl::robin_map<unsigned, std::tuple<GLuint, glm::vec2, int, unsigned>> const& getTextureFrames() { return _texture_frames_map; };
|
||||
|
||||
private:
|
||||
bool _uploaded = false;
|
||||
|
||||
// liquidTypeRecID : (array, (animation_x, animation_y), liquid_type)
|
||||
tsl::robin_map<unsigned, std::tuple<GLuint, math::vector_2d, int, unsigned>> _texture_frames_map;
|
||||
tsl::robin_map<unsigned, std::tuple<GLuint, glm::vec2, int, unsigned>> _texture_frames_map;
|
||||
|
||||
noggit::NoggitRenderContext _context;
|
||||
};
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#include <math/frustum.hpp>
|
||||
#include <math/quaternion.hpp>
|
||||
#include <math/vector_3d.hpp>
|
||||
#include <noggit/Brush.h>
|
||||
#include <noggit/TileWater.hpp>
|
||||
#include <noggit/Log.h>
|
||||
@@ -80,10 +77,10 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
|
||||
xbase = xbase*-1.0f + ZEROPOINT;
|
||||
|
||||
vmin.y = 0.0f;
|
||||
vmin = math::vector_3d(9999999.0f, 9999999.0f, 9999999.0f);
|
||||
vmax = math::vector_3d(-9999999.0f, -9999999.0f, -9999999.0f);
|
||||
vmin = glm::vec3(9999999.0f, 9999999.0f, 9999999.0f);
|
||||
vmax = glm::vec3(-9999999.0f, -9999999.0f, -9999999.0f);
|
||||
|
||||
math::vector_3d *ttv = mVertices;
|
||||
glm::vec3 *ttv = mVertices;
|
||||
|
||||
for (int j = 0; j < 17; ++j) {
|
||||
for (int i = 0; i < ((j % 2) ? 8 : 9); ++i) {
|
||||
@@ -93,7 +90,7 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
|
||||
if (j % 2) {
|
||||
xpos += UNITSIZE*0.5f;
|
||||
}
|
||||
math::vector_3d v = math::vector_3d(xbase + xpos, ybase + 0.0f, zbase + zpos);
|
||||
glm::vec3 v = glm::vec3(xbase + xpos, ybase + 0.0f, zbase + zpos);
|
||||
*ttv++ = v;
|
||||
vmin.y = std::min(vmin.y, v.y);
|
||||
vmax.y = std::max(vmax.y, v.y);
|
||||
@@ -149,8 +146,8 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
|
||||
zbase = zbase*-1.0f + ZEROPOINT;
|
||||
xbase = xbase*-1.0f + ZEROPOINT;
|
||||
|
||||
vmin = math::vector_3d(std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
|
||||
vmax = math::vector_3d(std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest());
|
||||
vmin = glm::vec3(std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
|
||||
vmax = glm::vec3(std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest());
|
||||
}
|
||||
|
||||
texture_set = std::make_unique<TextureSet>(this, f, base, maintile, bigAlpha,
|
||||
@@ -164,7 +161,7 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
|
||||
|
||||
assert(fourcc == 'MCVT');
|
||||
|
||||
math::vector_3d *ttv = mVertices;
|
||||
glm::vec3 *ttv = mVertices;
|
||||
|
||||
// vertices
|
||||
for (int j = 0; j < 17; ++j) {
|
||||
@@ -176,7 +173,7 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
|
||||
if (j % 2) {
|
||||
xpos += UNITSIZE*0.5f;
|
||||
}
|
||||
math::vector_3d v = math::vector_3d(xbase + xpos, ybase + h, zbase + zpos);
|
||||
glm::vec3 v = glm::vec3(xbase + xpos, ybase + h, zbase + zpos);
|
||||
*ttv++ = v;
|
||||
vmin.y = std::min(vmin.y, v.y);
|
||||
vmax.y = std::max(vmax.y, v.y);
|
||||
@@ -279,12 +276,12 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
|
||||
for (int i = 0; i < mapbufsize; ++i)
|
||||
{
|
||||
f->read(t, 4);
|
||||
mccv[i] = math::vector_3d((float)t[2] / 127.0f, (float)t[1] / 127.0f, (float)t[0] / 127.0f);
|
||||
mccv[i] = glm::vec3((float)t[2] / 127.0f, (float)t[1] / 127.0f, (float)t[0] / 127.0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
math::vector_3d mccv_default(1.f, 1.f, 1.f);
|
||||
glm::vec3 mccv_default(1.f, 1.f, 1.f);
|
||||
for (int i = 0; i < mapbufsize; ++i)
|
||||
{
|
||||
mccv[i] = mccv_default;
|
||||
@@ -357,7 +354,7 @@ bool MapChunk::has_shadows() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MapChunk::GetVertex(float x, float z, math::vector_3d *V)
|
||||
bool MapChunk::GetVertex(float x, float z, glm::vec3 *V)
|
||||
{
|
||||
float xdiff, zdiff;
|
||||
|
||||
@@ -373,7 +370,7 @@ bool MapChunk::GetVertex(float x, float z, math::vector_3d *V)
|
||||
return true;
|
||||
}
|
||||
|
||||
void MapChunk::getVertexInternal(float x, float z, math::vector_3d* v)
|
||||
void MapChunk::getVertexInternal(float x, float z, glm::vec3* v)
|
||||
{
|
||||
float xdiff, zdiff;
|
||||
|
||||
@@ -411,7 +408,7 @@ void MapChunk::clearHeight()
|
||||
void MapChunk::draw ( math::frustum const& frustum
|
||||
, opengl::scoped::use_program& mcnk_shader
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, bool need_visibility_update
|
||||
, bool show_unpaintable_chunks
|
||||
, bool draw_paintability_overlay
|
||||
@@ -611,7 +608,7 @@ void MapChunk::recalcExtents()
|
||||
}
|
||||
}
|
||||
|
||||
math::vector_3d MapChunk::getNeighborVertex(int i, unsigned dir)
|
||||
glm::vec3 MapChunk::getNeighborVertex(int i, unsigned dir)
|
||||
{
|
||||
// i - vertex index
|
||||
// 0 - up_left
|
||||
@@ -633,7 +630,7 @@ math::vector_3d MapChunk::getNeighborVertex(int i, unsigned dir)
|
||||
float vertex_z = mVertices[i].z + zdiff[dir];
|
||||
|
||||
tile_index tile({vertex_x, 0, vertex_z});
|
||||
math::vector_3d result{};
|
||||
glm::vec3 result{};
|
||||
|
||||
if (tile.x == mt->index.x && tile.z == mt->index.z)
|
||||
{
|
||||
@@ -667,13 +664,13 @@ math::vector_3d MapChunk::getNeighborVertex(int i, unsigned dir)
|
||||
|
||||
if (!mt->_world->mapIndex.tileLoaded(tile))
|
||||
{
|
||||
return math::vector_3d( mVertices[i].x + xdiff[dir], mVertices[i].y, mVertices[i].z + zdiff[dir]);
|
||||
return glm::vec3( mVertices[i].x + xdiff[dir], mVertices[i].y, mVertices[i].z + zdiff[dir]);
|
||||
}
|
||||
|
||||
math::vector_3d vertex{};
|
||||
glm::vec3 vertex{};
|
||||
mt->_world->mapIndex.getTile(tile)->getVertexInternal(mVertices[i].x + xdiff[dir], mVertices[i].z + zdiff[dir], &vertex);
|
||||
|
||||
return math::vector_3d( mVertices[i].x + xdiff[dir], vertex.y, mVertices[i].z + zdiff[dir]);
|
||||
return glm::vec3( mVertices[i].x + xdiff[dir], vertex.y, mVertices[i].z + zdiff[dir]);
|
||||
|
||||
}
|
||||
|
||||
@@ -755,18 +752,18 @@ void MapChunk::recalcNorms()
|
||||
|
||||
for (int i = 0; i < mapbufsize; ++i)
|
||||
{
|
||||
math::vector_3d const P1 (getNeighborVertex(i, 0)); // up_left
|
||||
math::vector_3d const P2 (getNeighborVertex(i, 1)); // up_right
|
||||
math::vector_3d const P3 (getNeighborVertex(i, 2)); // down_left
|
||||
math::vector_3d const P4 (getNeighborVertex(i, 3)); // down_right
|
||||
glm::vec3 const P1 (getNeighborVertex(i, 0)); // up_left
|
||||
glm::vec3 const P2 (getNeighborVertex(i, 1)); // up_right
|
||||
glm::vec3 const P3 (getNeighborVertex(i, 2)); // down_left
|
||||
glm::vec3 const P4 (getNeighborVertex(i, 3)); // down_right
|
||||
|
||||
math::vector_3d const N1 ((P2 - mVertices[i]) % (P1 - mVertices[i]));
|
||||
math::vector_3d const N2 ((P3 - mVertices[i]) % (P2 - mVertices[i]));
|
||||
math::vector_3d const N3 ((P4 - mVertices[i]) % (P3 - mVertices[i]));
|
||||
math::vector_3d const N4 ((P1 - mVertices[i]) % (P4 - mVertices[i]));
|
||||
glm::vec3 const N1 = glm::cross((P2 - mVertices[i]) , (P1 - mVertices[i]));
|
||||
glm::vec3 const N2 = glm::cross((P3 - mVertices[i]) , (P2 - mVertices[i]));
|
||||
glm::vec3 const N3 = glm::cross((P4 - mVertices[i]) , (P3 - mVertices[i]));
|
||||
glm::vec3 const N4 = glm::cross((P1 - mVertices[i]) , (P4 - mVertices[i]));
|
||||
|
||||
math::vector_3d Norm (N1 + N2 + N3 + N4);
|
||||
Norm.normalize();
|
||||
glm::vec3 Norm (N1 + N2 + N3 + N4);
|
||||
Norm = glm::normalize(Norm);
|
||||
|
||||
Norm.x = std::floor(Norm.x * 127) / 127;
|
||||
Norm.y = std::floor(Norm.y * 127) / 127;
|
||||
@@ -790,7 +787,7 @@ void MapChunk::updateNormalsData()
|
||||
//gl.texSubImage2D(GL_TEXTURE_2D, 0, 0, px * 16 + py, mapbufsize, 1, GL_RGB, GL_FLOAT, mNormals);
|
||||
}
|
||||
|
||||
bool MapChunk::changeTerrain(math::vector_3d const& pos, float change, float radius, int BrushType, float inner_radius)
|
||||
bool MapChunk::changeTerrain(glm::vec3 const& pos, float change, float radius, int BrushType, float inner_radius)
|
||||
{
|
||||
float dist, xdiff, zdiff;
|
||||
bool changed = false;
|
||||
@@ -811,7 +808,7 @@ bool MapChunk::changeTerrain(math::vector_3d const& pos, float change, float rad
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool MapChunk::ChangeMCCV(math::vector_3d const& pos, math::vector_4d const& color, float change, float radius, bool editMode)
|
||||
bool MapChunk::ChangeMCCV(glm::vec3 const& pos, glm::vec4 const& color, float change, float radius, bool editMode)
|
||||
{
|
||||
float dist;
|
||||
bool changed = false;
|
||||
@@ -864,7 +861,7 @@ bool MapChunk::ChangeMCCV(math::vector_3d const& pos, math::vector_4d const& col
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool MapChunk::stampMCCV(math::vector_3d const& pos, math::vector_4d const& color, float change, float radius, bool editMode, QImage* img, bool paint, bool use_image_colors)
|
||||
bool MapChunk::stampMCCV(glm::vec3 const& pos, glm::vec4 const& color, float change, float radius, bool editMode, QImage* img, bool paint, bool use_image_colors)
|
||||
{
|
||||
float dist;
|
||||
bool changed = false;
|
||||
@@ -890,7 +887,7 @@ bool MapChunk::stampMCCV(math::vector_3d const& pos, math::vector_4d const& colo
|
||||
if(std::abs(pos.x - mVertices[i].x) > radius || std::abs(pos.z - mVertices[i].z) > radius)
|
||||
continue;
|
||||
|
||||
math::vector_3d const diff{mVertices[i] - pos};
|
||||
glm::vec3 const diff{mVertices[i] - pos};
|
||||
|
||||
int pixel_x = std::round(((diff.x + radius) / (2.f * radius)) * img->width());
|
||||
int pixel_y = std::round(((diff.z + radius) / (2.f * radius)) * img->height());
|
||||
@@ -965,14 +962,14 @@ void MapChunk::update_vertex_colors()
|
||||
gl.texSubImage2D(GL_TEXTURE_2D, 0, 0, px * 16 + py, mapbufsize, 1, GL_RGB, GL_FLOAT, mccv);
|
||||
}
|
||||
|
||||
math::vector_3d MapChunk::pickMCCV(math::vector_3d const& pos)
|
||||
glm::vec3 MapChunk::pickMCCV(glm::vec3 const& pos)
|
||||
{
|
||||
float dist;
|
||||
float cur_dist = UNITSIZE;
|
||||
|
||||
if (!hasMCCV)
|
||||
{
|
||||
return math::vector_3d(1.0f, 1.0f, 1.0f);
|
||||
return glm::vec3(1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
int v_index = 0;
|
||||
@@ -990,12 +987,12 @@ math::vector_3d MapChunk::pickMCCV(math::vector_3d const& pos)
|
||||
|
||||
}
|
||||
|
||||
bool MapChunk::flattenTerrain ( math::vector_3d const& pos
|
||||
bool MapChunk::flattenTerrain ( glm::vec3 const& pos
|
||||
, float remain
|
||||
, float radius
|
||||
, int BrushType
|
||||
, flatten_mode const& mode
|
||||
, math::vector_3d const& origin
|
||||
, glm::vec3 const& origin
|
||||
, math::degrees angle
|
||||
, math::degrees orientation
|
||||
)
|
||||
@@ -1012,9 +1009,9 @@ bool MapChunk::flattenTerrain ( math::vector_3d const& pos
|
||||
}
|
||||
|
||||
float const ah(origin.y
|
||||
+ ((mVertices[i].x - origin.x) * math::cos(orientation)
|
||||
+ (mVertices[i].z - origin.z) * math::sin(orientation)
|
||||
) * math::tan(angle)
|
||||
+ ((mVertices[i].x - origin.x) * glm::cos(math::radians(orientation)._)
|
||||
+ (mVertices[i].z - origin.z) * glm::sin(math::radians(orientation)._)
|
||||
) * glm::tan(math::radians(angle)._)
|
||||
);
|
||||
|
||||
if ((!mode.lower && ah < mVertices[i].y)
|
||||
@@ -1051,7 +1048,7 @@ bool MapChunk::flattenTerrain ( math::vector_3d const& pos
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool MapChunk::blurTerrain ( math::vector_3d const& pos
|
||||
bool MapChunk::blurTerrain ( glm::vec3 const& pos
|
||||
, float remain
|
||||
, float radius
|
||||
, int BrushType
|
||||
@@ -1124,7 +1121,7 @@ bool MapChunk::blurTerrain ( math::vector_3d const& pos
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool MapChunk::changeTerrainProcessVertex(math::vector_3d const& pos, math::vector_3d const& vertex, float& dt,
|
||||
bool MapChunk::changeTerrainProcessVertex(glm::vec3 const& pos, glm::vec3 const& vertex, float& dt,
|
||||
float radiusOuter, float radiusInner, int brushType)
|
||||
{
|
||||
float dist, xdiff, zdiff;
|
||||
@@ -1180,7 +1177,7 @@ bool MapChunk::changeTerrainProcessVertex(math::vector_3d const& pos, math::vect
|
||||
return changed;
|
||||
}
|
||||
|
||||
auto MapChunk::stamp(math::vector_3d const& pos, float dt, QImage const* img, float radiusOuter
|
||||
auto MapChunk::stamp(glm::vec3 const& pos, float dt, QImage const* img, float radiusOuter
|
||||
, float radiusInner, int brushType, bool sculpt) -> void
|
||||
{
|
||||
if (sculpt)
|
||||
@@ -1193,7 +1190,7 @@ auto MapChunk::stamp(math::vector_3d const& pos, float dt, QImage const* img, fl
|
||||
float delta = dt;
|
||||
changeTerrainProcessVertex(pos, mVertices[i], delta, radiusOuter, radiusInner, brushType);
|
||||
|
||||
math::vector_3d const diff{mVertices[i] - pos};
|
||||
glm::vec3 const diff{mVertices[i] - pos};
|
||||
|
||||
int pixel_x = std::round(((diff.x + radiusOuter) / (2.f * radiusOuter)) * img->width());
|
||||
int pixel_y = std::round(((diff.z + radiusOuter) / (2.f * radiusOuter)) * img->height());
|
||||
@@ -1230,7 +1227,7 @@ auto MapChunk::stamp(math::vector_3d const& pos, float dt, QImage const* img, fl
|
||||
|
||||
changeTerrainProcessVertex(pos, mVertices[i], delta, radiusOuter, radiusInner, brushType);
|
||||
|
||||
math::vector_3d const diff{math::vector_3d{original_heightmap[i * 3], original_heightmap[i * 3 + 1], original_heightmap[i * 3 + 2]} - pos};
|
||||
glm::vec3 const diff{glm::vec3{original_heightmap[i * 3], original_heightmap[i * 3 + 1], original_heightmap[i * 3 + 2]} - pos};
|
||||
|
||||
|
||||
int pixel_x = std::round(((diff.x + radiusOuter) / (2.f * radiusOuter)) * img->width());
|
||||
@@ -1275,17 +1272,17 @@ void MapChunk::switchTexture(scoped_blp_texture_reference const& oldTexture, sco
|
||||
texture_set->replace_texture(oldTexture, std::move (newTexture));
|
||||
}
|
||||
|
||||
bool MapChunk::paintTexture(math::vector_3d const& pos, Brush* brush, float strength, float pressure, scoped_blp_texture_reference texture)
|
||||
bool MapChunk::paintTexture(glm::vec3 const& pos, Brush* brush, float strength, float pressure, scoped_blp_texture_reference texture)
|
||||
{
|
||||
return texture_set->paintTexture(xbase, zbase, pos.x, pos.z, brush, strength, pressure, std::move (texture));
|
||||
}
|
||||
|
||||
bool MapChunk::stampTexture(math::vector_3d const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint)
|
||||
bool MapChunk::stampTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint)
|
||||
{
|
||||
return texture_set->stampTexture(xbase, zbase, pos.x, pos.z, brush, strength, pressure, std::move (texture), img, paint);
|
||||
}
|
||||
|
||||
bool MapChunk::replaceTexture(math::vector_3d const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture)
|
||||
bool MapChunk::replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture)
|
||||
{
|
||||
return texture_set->replace_texture(xbase, zbase, pos.x, pos.z, radius, old_texture, std::move (new_texture));
|
||||
}
|
||||
@@ -1313,7 +1310,7 @@ bool MapChunk::isHole(int i, int j)
|
||||
return (holes & ((1 << ((j * 4) + i)))) != 0;
|
||||
}
|
||||
|
||||
void MapChunk::setHole(math::vector_3d const& pos, float radius, bool big, bool add)
|
||||
void MapChunk::setHole(glm::vec3 const& pos, float radius, bool big, bool add)
|
||||
{
|
||||
if (big)
|
||||
{
|
||||
@@ -1552,9 +1549,9 @@ void MapChunk::save(sExtendableArray &lADTFile, int &lCurrentPosition, int &lMCI
|
||||
std::list<int> lDoodadIDs;
|
||||
std::list<int> lObjectIDs;
|
||||
|
||||
math::vector_3d lChunkExtents[2];
|
||||
lChunkExtents[0] = math::vector_3d(xbase, 0.0f, zbase);
|
||||
lChunkExtents[1] = math::vector_3d(xbase + CHUNKSIZE, 0.0f, zbase + CHUNKSIZE);
|
||||
glm::vec3 lChunkExtents[2];
|
||||
lChunkExtents[0] = glm::vec3(xbase, 0.0f, zbase);
|
||||
lChunkExtents[1] = glm::vec3(xbase + CHUNKSIZE, 0.0f, zbase + CHUNKSIZE);
|
||||
|
||||
// search all wmos that are inside this chunk
|
||||
lID = 0;
|
||||
@@ -1723,7 +1720,7 @@ bool MapChunk::fixGapAbove(const MapChunk* chunk)
|
||||
}
|
||||
|
||||
|
||||
void MapChunk::selectVertex(math::vector_3d const& pos, float radius, std::unordered_set<math::vector_3d*>& vertices)
|
||||
void MapChunk::selectVertex(glm::vec3 const& pos, float radius, std::unordered_set<glm::vec3*>& vertices)
|
||||
{
|
||||
if (misc::getShortestDist(pos.x, pos.z, xbase, zbase, CHUNKSIZE) > radius)
|
||||
{
|
||||
@@ -1739,7 +1736,7 @@ void MapChunk::selectVertex(math::vector_3d const& pos, float radius, std::unord
|
||||
}
|
||||
}
|
||||
|
||||
void MapChunk::fixVertices(std::unordered_set<math::vector_3d*>& selected)
|
||||
void MapChunk::fixVertices(std::unordered_set<glm::vec3*>& selected)
|
||||
{
|
||||
std::vector<int> ids ={ 0, 1, 17, 18 };
|
||||
// iterate through each "square" of vertices
|
||||
@@ -1773,7 +1770,7 @@ void MapChunk::fixVertices(std::unordered_set<math::vector_3d*>& selected)
|
||||
}
|
||||
}
|
||||
|
||||
bool MapChunk::isBorderChunk(std::unordered_set<math::vector_3d*>& selected)
|
||||
bool MapChunk::isBorderChunk(std::unordered_set<glm::vec3*>& selected)
|
||||
{
|
||||
for (int i = 0; i < mapbufsize; ++i)
|
||||
{
|
||||
@@ -1789,7 +1786,7 @@ bool MapChunk::isBorderChunk(std::unordered_set<math::vector_3d*>& selected)
|
||||
|
||||
QImage MapChunk::getHeightmapImage(float min_height, float max_height)
|
||||
{
|
||||
math::vector_3d* heightmap = getHeightmap();
|
||||
glm::vec3* heightmap = getHeightmap();
|
||||
|
||||
QImage image(17, 17, QImage::Format_RGBA64);
|
||||
|
||||
@@ -1833,7 +1830,7 @@ QImage MapChunk::getAlphamapImage(unsigned layer)
|
||||
|
||||
void MapChunk::setHeightmapImage(QImage const& image, float multiplier, int mode)
|
||||
{
|
||||
math::vector_3d* heightmap = getHeightmap();
|
||||
glm::vec3* heightmap = getHeightmap();
|
||||
|
||||
unsigned const LONG{9}, SHORT{8}, SUM{LONG + SHORT}, DSUM{SUM * 2};
|
||||
|
||||
@@ -1905,7 +1902,7 @@ void MapChunk::setAlphamapImage(const QImage &image, unsigned int layer)
|
||||
|
||||
QImage MapChunk::getVertexColorImage()
|
||||
{
|
||||
math::vector_3d* colors = getVertexColors();
|
||||
glm::vec3* colors = getVertexColors();
|
||||
|
||||
QImage image(17, 17, QImage::Format_RGBA8888);
|
||||
|
||||
@@ -1930,7 +1927,7 @@ QImage MapChunk::getVertexColorImage()
|
||||
|
||||
void MapChunk::setVertexColorImage(const QImage &image)
|
||||
{
|
||||
math::vector_3d* colors = getVertexColors();
|
||||
glm::vec3* colors = getVertexColors();
|
||||
|
||||
unsigned const LONG{9}, SHORT{8}, SUM{LONG + SHORT}, DSUM{SUM * 2};
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/quaternion.hpp> // math::vector_4d
|
||||
#include <noggit/map_enums.hpp>
|
||||
#include <noggit/MapTile.h> // MapTile
|
||||
#include <noggit/ModelInstance.h>
|
||||
@@ -66,7 +64,7 @@ public:
|
||||
|
||||
auto getHoleMask(void) const -> unsigned { return static_cast<unsigned>(holes); }
|
||||
MapTile *mt;
|
||||
math::vector_3d vmin, vmax, vcenter;
|
||||
glm::vec3 vmin, vmax, vcenter;
|
||||
int px, py;
|
||||
|
||||
MapChunkHeader header;
|
||||
@@ -83,9 +81,9 @@ public:
|
||||
|
||||
unsigned int areaID;
|
||||
|
||||
math::vector_3d mVertices[mapbufsize];
|
||||
math::vector_3d mNormals[mapbufsize];
|
||||
math::vector_3d mccv[mapbufsize];
|
||||
glm::vec3 mVertices[mapbufsize];
|
||||
glm::vec3 mNormals[mapbufsize];
|
||||
glm::vec3 mccv[mapbufsize];
|
||||
|
||||
uint8_t _shadow_map[64 * 64];
|
||||
|
||||
@@ -109,7 +107,7 @@ public:
|
||||
void draw ( math::frustum const& frustum
|
||||
, opengl::scoped::use_program& mcnk_shader
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, bool need_visibility_update
|
||||
, bool show_unpaintable_chunks
|
||||
, bool draw_paintability_overlay
|
||||
@@ -123,9 +121,9 @@ public:
|
||||
//! \todo only this function should be public, all others should be called from it
|
||||
|
||||
bool intersect (math::ray const&, selection_result*);
|
||||
bool ChangeMCCV(math::vector_3d const& pos, math::vector_4d const& color, float change, float radius, bool editMode);
|
||||
bool stampMCCV(math::vector_3d const& pos, math::vector_4d const& color, float change, float radius, bool editMode, QImage* img, bool paint, bool use_image_colors);
|
||||
math::vector_3d pickMCCV(math::vector_3d const& pos);
|
||||
bool ChangeMCCV(glm::vec3 const& pos, glm::vec4 const& color, float change, float radius, bool editMode);
|
||||
bool stampMCCV(glm::vec3 const& pos, glm::vec4 const& color, float change, float radius, bool editMode, QImage* img, bool paint, bool use_image_colors);
|
||||
glm::vec3 pickMCCV(glm::vec3 const& pos);
|
||||
|
||||
ChunkWater* liquid_chunk() const;
|
||||
|
||||
@@ -135,27 +133,27 @@ public:
|
||||
void recalcExtents();
|
||||
void recalcNorms();
|
||||
void updateNormalsData();
|
||||
math::vector_3d getNeighborVertex(int i, unsigned dir);
|
||||
glm::vec3 getNeighborVertex(int i, unsigned dir);
|
||||
|
||||
//! \todo implement Action stack for these
|
||||
bool changeTerrain(math::vector_3d const& pos, float change, float radius, int BrushType, float inner_radius);
|
||||
bool flattenTerrain(math::vector_3d const& pos, float remain, float radius, int BrushType, flatten_mode const& mode, const math::vector_3d& origin, math::degrees angle, math::degrees orientation);
|
||||
bool blurTerrain ( math::vector_3d const& pos, float remain, float radius, int BrushType, flatten_mode const& mode
|
||||
bool changeTerrain(glm::vec3 const& pos, float change, float radius, int BrushType, float inner_radius);
|
||||
bool flattenTerrain(glm::vec3 const& pos, float remain, float radius, int BrushType, flatten_mode const& mode, const glm::vec3& origin, math::degrees angle, math::degrees orientation);
|
||||
bool blurTerrain ( glm::vec3 const& pos, float remain, float radius, int BrushType, flatten_mode const& mode
|
||||
, std::function<boost::optional<float> (float, float)> height
|
||||
);
|
||||
|
||||
bool changeTerrainProcessVertex(math::vector_3d const& pos, math::vector_3d const& vertex, float& dt, float radiusOuter, float radiusInner, int brushType);
|
||||
auto stamp(math::vector_3d const& pos, float dt, QImage const* img, float radiusOuter
|
||||
bool changeTerrainProcessVertex(glm::vec3 const& pos, glm::vec3 const& vertex, float& dt, float radiusOuter, float radiusInner, int brushType);
|
||||
auto stamp(glm::vec3 const& pos, float dt, QImage const* img, float radiusOuter
|
||||
, float radiusInner, int brushType, bool sculpt) -> void;
|
||||
void selectVertex(math::vector_3d const& pos, float radius, std::unordered_set<math::vector_3d*>& vertices);
|
||||
void fixVertices(std::unordered_set<math::vector_3d*>& selected);
|
||||
void selectVertex(glm::vec3 const& pos, float radius, std::unordered_set<glm::vec3*>& vertices);
|
||||
void fixVertices(std::unordered_set<glm::vec3*>& selected);
|
||||
// for the vertex tool
|
||||
bool isBorderChunk(std::unordered_set<math::vector_3d*>& selected);
|
||||
bool isBorderChunk(std::unordered_set<glm::vec3*>& selected);
|
||||
|
||||
//! \todo implement Action stack for these
|
||||
bool paintTexture(math::vector_3d const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture);
|
||||
bool stampTexture(math::vector_3d const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint);
|
||||
bool replaceTexture(math::vector_3d const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture);
|
||||
bool paintTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture);
|
||||
bool stampTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint);
|
||||
bool replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture);
|
||||
bool canPaintTexture(scoped_blp_texture_reference texture);
|
||||
int addTexture(scoped_blp_texture_reference texture);
|
||||
void switchTexture(scoped_blp_texture_reference const& oldTexture, scoped_blp_texture_reference newTexture);
|
||||
@@ -165,19 +163,19 @@ public:
|
||||
void clear_shadows();
|
||||
|
||||
bool isHole(int i, int j);
|
||||
void setHole(math::vector_3d const& pos, float radius, bool big, bool add);
|
||||
void setHole(glm::vec3 const& pos, float radius, bool big, bool add);
|
||||
|
||||
void setFlag(bool value, uint32_t);
|
||||
|
||||
int getAreaID();
|
||||
void setAreaID(int ID);
|
||||
|
||||
bool GetVertex(float x, float z, math::vector_3d *V);
|
||||
void getVertexInternal(float x, float z, math::vector_3d * v);
|
||||
bool GetVertex(float x, float z, glm::vec3 *V);
|
||||
void getVertexInternal(float x, float z, glm::vec3 * v);
|
||||
float getHeight(int x, int z);
|
||||
float getMinHeight() { return vmin.y; };
|
||||
float getMaxHeight() { return vmax.y; };
|
||||
math::vector_3d getCenter() { return vcenter; };
|
||||
glm::vec3 getCenter() { return vcenter; };
|
||||
|
||||
void clearHeight();
|
||||
|
||||
@@ -189,9 +187,9 @@ public:
|
||||
// fix the gaps with the chunk above
|
||||
bool fixGapAbove(const MapChunk* chunk);
|
||||
|
||||
math::vector_3d* getHeightmap() { return &mVertices[0]; };
|
||||
math::vector_3d const* getNormals() const { return &mNormals[0]; }
|
||||
math::vector_3d* getVertexColors() { return &mccv[0]; };
|
||||
glm::vec3* getHeightmap() { return &mVertices[0]; };
|
||||
glm::vec3 const* getNormals() const { return &mNormals[0]; }
|
||||
glm::vec3* getVertexColors() { return &mccv[0]; };
|
||||
|
||||
void update_vertex_colors();
|
||||
|
||||
|
||||
@@ -55,12 +55,12 @@ MapTile::MapTile( int pX
|
||||
| ChunkUpdateFlags::SHADOW | ChunkUpdateFlags::MCCV
|
||||
| ChunkUpdateFlags::NORMALS| ChunkUpdateFlags::HOLES
|
||||
| ChunkUpdateFlags::AREA_ID| ChunkUpdateFlags::FLAGS)
|
||||
, _extents{math::vector_3d{pX * TILESIZE, std::numeric_limits<float>::max(), pZ * TILESIZE},
|
||||
math::vector_3d{pX * TILESIZE + TILESIZE, std::numeric_limits<float>::lowest(), pZ * TILESIZE + TILESIZE}}
|
||||
, _combined_extents{math::vector_3d{pX * TILESIZE, std::numeric_limits<float>::max(), pZ * TILESIZE},
|
||||
math::vector_3d{pX * TILESIZE + TILESIZE, std::numeric_limits<float>::lowest(), pZ * TILESIZE + TILESIZE}}
|
||||
, _object_instance_extents{math::vector_3d{std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max()}
|
||||
, math::vector_3d{std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest()}}
|
||||
, _extents{glm::vec3{pX * TILESIZE, std::numeric_limits<float>::max(), pZ * TILESIZE},
|
||||
glm::vec3{pX * TILESIZE + TILESIZE, std::numeric_limits<float>::lowest(), pZ * TILESIZE + TILESIZE}}
|
||||
, _combined_extents{glm::vec3{pX * TILESIZE, std::numeric_limits<float>::max(), pZ * TILESIZE},
|
||||
glm::vec3{pX * TILESIZE + TILESIZE, std::numeric_limits<float>::lowest(), pZ * TILESIZE + TILESIZE}}
|
||||
, _object_instance_extents{glm::vec3{std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max()}
|
||||
, glm::vec3{std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest()}}
|
||||
,_center{pX * TILESIZE + TILESIZE / 2.f, 0.f, pZ * TILESIZE + TILESIZE / 2.f}
|
||||
{
|
||||
}
|
||||
@@ -420,7 +420,7 @@ void MapTile::convert_alphamap(bool to_big_alpha)
|
||||
}
|
||||
|
||||
void MapTile::draw (opengl::scoped::use_program& mcnk_shader
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, bool show_unpaintable_chunks
|
||||
, bool draw_paintability_overlay
|
||||
, bool is_selected
|
||||
@@ -759,12 +759,12 @@ void MapTile::drawMFBO (opengl::scoped::use_program& mfbo_shader)
|
||||
|
||||
|
||||
gl.bufferData<GL_ARRAY_BUFFER>( _mfbo_bottom_vbo
|
||||
, 9 * sizeof(math::vector_3d)
|
||||
, 9 * sizeof(glm::vec3)
|
||||
, mMinimumValues
|
||||
, GL_STATIC_DRAW
|
||||
);
|
||||
gl.bufferData<GL_ARRAY_BUFFER>( _mfbo_top_vbo
|
||||
, 9 * sizeof(math::vector_3d)
|
||||
, 9 * sizeof(glm::vec3)
|
||||
, mMaximumValues
|
||||
, GL_STATIC_DRAW
|
||||
);
|
||||
@@ -793,7 +793,7 @@ void MapTile::drawMFBO (opengl::scoped::use_program& mfbo_shader)
|
||||
opengl::scoped::vao_binder const _(_mfbo_bottom_vao);
|
||||
opengl::scoped::buffer_binder<GL_ELEMENT_ARRAY_BUFFER> ibo_binder(_mfbo_indices);
|
||||
|
||||
mfbo_shader.uniform("color", math::vector_4d(1.0f, 1.0f, 0.0f, 0.2f));
|
||||
mfbo_shader.uniform("color", glm::vec4(1.0f, 1.0f, 0.0f, 0.2f));
|
||||
gl.drawElements(GL_TRIANGLE_FAN, indices.size(), GL_UNSIGNED_BYTE, nullptr);
|
||||
}
|
||||
|
||||
@@ -801,7 +801,7 @@ void MapTile::drawMFBO (opengl::scoped::use_program& mfbo_shader)
|
||||
opengl::scoped::vao_binder const _(_mfbo_top_vao);
|
||||
opengl::scoped::buffer_binder<GL_ELEMENT_ARRAY_BUFFER> ibo_binder(_mfbo_indices);
|
||||
|
||||
mfbo_shader.uniform("color", math::vector_4d(0.0f, 1.0f, 1.0f, 0.2f));
|
||||
mfbo_shader.uniform("color", glm::vec4(0.0f, 1.0f, 1.0f, 0.2f));
|
||||
gl.drawElements(GL_TRIANGLE_FAN, indices.size(), GL_UNSIGNED_BYTE, nullptr);
|
||||
}
|
||||
|
||||
@@ -809,7 +809,7 @@ void MapTile::drawMFBO (opengl::scoped::use_program& mfbo_shader)
|
||||
|
||||
void MapTile::drawWater ( math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, bool camera_moved
|
||||
, opengl::scoped::use_program& water_shader
|
||||
, int animtime
|
||||
@@ -848,7 +848,7 @@ MapChunk* MapTile::getChunk(unsigned int x, unsigned int z)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<MapChunk*> MapTile::chunks_in_range (math::vector_3d const& pos, float radius) const
|
||||
std::vector<MapChunk*> MapTile::chunks_in_range (glm::vec3 const& pos, float radius) const
|
||||
{
|
||||
std::vector<MapChunk*> chunks;
|
||||
|
||||
@@ -866,7 +866,7 @@ std::vector<MapChunk*> MapTile::chunks_in_range (math::vector_3d const& pos, flo
|
||||
return chunks;
|
||||
}
|
||||
|
||||
std::vector<MapChunk*> MapTile::chunks_in_rect (math::vector_3d const& pos, float radius) const
|
||||
std::vector<MapChunk*> MapTile::chunks_in_rect (glm::vec3 const& pos, float radius) const
|
||||
{
|
||||
std::vector<MapChunk*> chunks;
|
||||
|
||||
@@ -875,11 +875,11 @@ std::vector<MapChunk*> MapTile::chunks_in_rect (math::vector_3d const& pos, floa
|
||||
for (size_t tx (0); tx < 16; ++tx)
|
||||
{
|
||||
MapChunk* chunk = mChunks[ty][tx].get();
|
||||
math::vector_2d l_rect{pos.x - radius, pos.z - radius};
|
||||
math::vector_2d r_rect{pos.x + radius, pos.z + radius};
|
||||
glm::vec2 l_rect{pos.x - radius, pos.z - radius};
|
||||
glm::vec2 r_rect{pos.x + radius, pos.z + radius};
|
||||
|
||||
math::vector_2d l_chunk{chunk->xbase, chunk->zbase};
|
||||
math::vector_2d r_chunk{chunk->xbase + CHUNKSIZE, chunk->zbase + CHUNKSIZE};
|
||||
glm::vec2 l_chunk{chunk->xbase, chunk->zbase};
|
||||
glm::vec2 r_chunk{chunk->xbase + CHUNKSIZE, chunk->zbase + CHUNKSIZE};
|
||||
|
||||
if ((l_rect.x < r_chunk.x) && (r_rect.x >= l_chunk.x) && (l_rect.y < r_chunk.y) && (r_rect.y >= l_chunk.y))
|
||||
{
|
||||
@@ -891,7 +891,7 @@ std::vector<MapChunk*> MapTile::chunks_in_rect (math::vector_3d const& pos, floa
|
||||
return chunks;
|
||||
}
|
||||
|
||||
bool MapTile::GetVertex(float x, float z, math::vector_3d *V)
|
||||
bool MapTile::GetVertex(float x, float z, glm::vec3 *V)
|
||||
{
|
||||
int xcol = (int)((x - xbase) / CHUNKSIZE);
|
||||
int ycol = (int)((z - zbase) / CHUNKSIZE);
|
||||
@@ -899,7 +899,7 @@ bool MapTile::GetVertex(float x, float z, math::vector_3d *V)
|
||||
return xcol >= 0 && xcol <= 15 && ycol >= 0 && ycol <= 15 && mChunks[ycol][xcol]->GetVertex(x, z, V);
|
||||
}
|
||||
|
||||
void MapTile::getVertexInternal(float x, float z, math::vector_3d* v)
|
||||
void MapTile::getVertexInternal(float x, float z, glm::vec3* v)
|
||||
{
|
||||
int xcol = (int)((x - xbase) / CHUNKSIZE);
|
||||
int ycol = (int)((z - zbase) / CHUNKSIZE);
|
||||
@@ -918,9 +918,9 @@ void MapTile::saveTile(World* world)
|
||||
std::vector<ModelInstance> lModelInstances;
|
||||
|
||||
// Check which doodads and WMOs are on this ADT.
|
||||
math::vector_3d lTileExtents[2];
|
||||
lTileExtents[0] = math::vector_3d(xbase, 0.0f, zbase);
|
||||
lTileExtents[1] = math::vector_3d(xbase + TILESIZE, 0.0f, zbase + TILESIZE);
|
||||
glm::vec3 lTileExtents[2];
|
||||
lTileExtents[0] = glm::vec3(xbase, 0.0f, zbase);
|
||||
lTileExtents[1] = glm::vec3(xbase + TILESIZE, 0.0f, zbase + TILESIZE);
|
||||
|
||||
// get every models on the tile
|
||||
for (std::uint32_t uid : uids)
|
||||
@@ -1168,9 +1168,9 @@ void MapTile::saveTile(World* world)
|
||||
lMDDF_Data[lID].pos[0] = model.pos.x;
|
||||
lMDDF_Data[lID].pos[1] = model.pos.y;
|
||||
lMDDF_Data[lID].pos[2] = model.pos.z;
|
||||
lMDDF_Data[lID].rot[0] = model.dir.x._;
|
||||
lMDDF_Data[lID].rot[1] = model.dir.y._;
|
||||
lMDDF_Data[lID].rot[2] = model.dir.z._;
|
||||
lMDDF_Data[lID].rot[0] = model.dir.x;
|
||||
lMDDF_Data[lID].rot[1] = model.dir.y;
|
||||
lMDDF_Data[lID].rot[2] = model.dir.z;
|
||||
lMDDF_Data[lID].scale = (uint16_t)(model.scale * 1024);
|
||||
lMDDF_Data[lID].flags = 0;
|
||||
lID++;
|
||||
@@ -1205,9 +1205,9 @@ void MapTile::saveTile(World* world)
|
||||
lMODF_Data[lID].pos[1] = object.pos.y;
|
||||
lMODF_Data[lID].pos[2] = object.pos.z;
|
||||
|
||||
lMODF_Data[lID].rot[0] = object.dir.x._;
|
||||
lMODF_Data[lID].rot[1] = object.dir.y._;
|
||||
lMODF_Data[lID].rot[2] = object.dir.z._;
|
||||
lMODF_Data[lID].rot[0] = object.dir.x;
|
||||
lMODF_Data[lID].rot[1] = object.dir.y;
|
||||
lMODF_Data[lID].rot[2] = object.dir.z;
|
||||
|
||||
lMODF_Data[lID].extents[0][0] = object.extents[0].x;
|
||||
lMODF_Data[lID].extents[0][1] = object.extents[0].y;
|
||||
@@ -1456,7 +1456,7 @@ QImage MapTile::getHeightmapImage(float min_height, float max_height)
|
||||
{
|
||||
MapChunk* chunk = getChunk(k, l);
|
||||
|
||||
math::vector_3d* heightmap = chunk->getHeightmap();
|
||||
glm::vec3* heightmap = chunk->getHeightmap();
|
||||
|
||||
for (unsigned y = 0; y < SUM; ++y)
|
||||
{
|
||||
@@ -1489,7 +1489,7 @@ QImage MapTile::getNormalmapImage()
|
||||
{
|
||||
MapChunk* chunk = getChunk(k, l);
|
||||
|
||||
const math::vector_3d* normals = chunk->getNormals();
|
||||
const glm::vec3* normals = chunk->getNormals();
|
||||
|
||||
for (unsigned y = 0; y < SUM; ++y)
|
||||
{
|
||||
@@ -1500,8 +1500,8 @@ QImage MapTile::getNormalmapImage()
|
||||
bool const erp = plain % DSUM / SUM;
|
||||
unsigned const idx {(plain - (is_virtual ? (erp ? SUM : 1) : 0)) / 2};
|
||||
|
||||
auto normal = normals[idx].normalized();
|
||||
auto normal_inner = normals[idx + (erp ? SUM : 1)].normalized();
|
||||
auto normal = glm::normalize(normals[idx]);
|
||||
auto normal_inner = glm::normalize(normals[idx + (erp ? SUM : 1)]);
|
||||
|
||||
float value_r = is_virtual ? (normal.x + normal_inner.x) / 2.f : normal.x;
|
||||
float value_g = is_virtual ? (normal.y + normal_inner.y) / 2.f : normal.y;
|
||||
@@ -1600,7 +1600,7 @@ void MapTile::setHeightmapImage(QImage const& image, float multiplier, int mode)
|
||||
{
|
||||
MapChunk* chunk = getChunk(k, l);
|
||||
|
||||
math::vector_3d* heightmap = chunk->getHeightmap();
|
||||
glm::vec3* heightmap = chunk->getHeightmap();
|
||||
|
||||
for (unsigned y = 0; y < SUM; ++y)
|
||||
for (unsigned x = 0; x < SUM; ++x)
|
||||
@@ -1717,7 +1717,7 @@ QImage MapTile::getVertexColorsImage()
|
||||
if (!chunk->header_flags.flags.has_mccv)
|
||||
continue;
|
||||
|
||||
math::vector_3d* colors = chunk->getVertexColors();
|
||||
glm::vec3* colors = chunk->getVertexColors();
|
||||
|
||||
for (unsigned y = 0; y < SUM; ++y)
|
||||
{
|
||||
@@ -1749,7 +1749,7 @@ void MapTile::setVertexColorImage(QImage const& image, int mode)
|
||||
{
|
||||
MapChunk* chunk = getChunk(k, l);
|
||||
|
||||
math::vector_3d* colors = chunk->getVertexColors();
|
||||
glm::vec3* colors = chunk->getVertexColors();
|
||||
|
||||
for (unsigned y = 0; y < SUM; ++y)
|
||||
for (unsigned x = 0; x < SUM; ++x)
|
||||
@@ -1948,8 +1948,8 @@ void MapTile::recalcObjectInstanceExtents()
|
||||
|
||||
instance->ensureExtents();
|
||||
|
||||
math::vector_3d& min = instance->extents[0];
|
||||
math::vector_3d& max = instance->extents[1];
|
||||
glm::vec3& min = instance->extents[0];
|
||||
glm::vec3& max = instance->extents[1];
|
||||
|
||||
_object_instance_extents[0].x = std::min(_object_instance_extents[0].x, min.x);
|
||||
_object_instance_extents[0].y = std::min(_object_instance_extents[0].y, min.y);
|
||||
@@ -1978,7 +1978,7 @@ void MapTile::doTileOcclusionQuery(opengl::scoped::use_program& occlusion_shader
|
||||
gl.endQuery(GL_ANY_SAMPLES_PASSED);
|
||||
}
|
||||
|
||||
bool MapTile::getTileOcclusionQueryResult(math::vector_3d const& camera)
|
||||
bool MapTile::getTileOcclusionQueryResult(glm::vec3 const& camera)
|
||||
{
|
||||
// returns true if tile is not occluded by other tiles
|
||||
|
||||
@@ -2021,7 +2021,7 @@ bool MapTile::getTileOcclusionQueryResult(math::vector_3d const& camera)
|
||||
}
|
||||
|
||||
|
||||
void MapTile::calcCamDist(math::vector_3d const& camera)
|
||||
void MapTile::calcCamDist(glm::vec3 const& camera)
|
||||
{
|
||||
_cam_dist = (camera - _center).length();
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ public:
|
||||
//! \brief Get chunk for sub offset x,z.
|
||||
MapChunk* getChunk(unsigned int x, unsigned int z);
|
||||
//! \todo map_index style iterators
|
||||
std::vector<MapChunk*> chunks_in_range (math::vector_3d const& pos, float radius) const;
|
||||
std::vector<MapChunk*> chunks_in_rect (math::vector_3d const& pos, float radius) const;
|
||||
std::vector<MapChunk*> chunks_in_range (glm::vec3 const& pos, float radius) const;
|
||||
std::vector<MapChunk*> chunks_in_rect (glm::vec3 const& pos, float radius) const;
|
||||
|
||||
const tile_index index;
|
||||
float xbase, zbase;
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
bool tile_occlusion_cull_override = true;
|
||||
|
||||
void draw (opengl::scoped::use_program& mcnk_shader
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, bool show_unpaintable_chunks
|
||||
, bool draw_paintability_overlay
|
||||
, bool is_selected
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
bool intersect (math::ray const&, selection_result*) const;
|
||||
void drawWater ( math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, bool camera_moved
|
||||
, opengl::scoped::use_program& water_shader
|
||||
, int animtime
|
||||
@@ -111,8 +111,8 @@ public:
|
||||
|
||||
void drawMFBO (opengl::scoped::use_program&);
|
||||
|
||||
bool GetVertex(float x, float z, math::vector_3d *V);
|
||||
void getVertexInternal(float x, float z, math::vector_3d* v);
|
||||
bool GetVertex(float x, float z, glm::vec3 *V);
|
||||
void getVertexInternal(float x, float z, glm::vec3* v);
|
||||
|
||||
void saveTile(World*);
|
||||
void CropWater();
|
||||
@@ -159,8 +159,8 @@ public:
|
||||
void recalcExtents();
|
||||
void recalcObjectInstanceExtents();
|
||||
void recalcCombinedExtents();
|
||||
std::array<math::vector_3d, 2>& getExtents() { return _extents; };
|
||||
std::array<math::vector_3d, 2>& getCombinedExtents() { return _combined_extents; };
|
||||
std::array<glm::vec3, 2>& getExtents() { return _extents; };
|
||||
std::array<glm::vec3, 2>& getCombinedExtents() { return _combined_extents; };
|
||||
|
||||
void unload();
|
||||
|
||||
@@ -172,11 +172,11 @@ public:
|
||||
tsl::robin_map<AsyncObject*, std::vector<SceneObject*>> const& getObjectInstances() const { return object_instances; };
|
||||
|
||||
void doTileOcclusionQuery(opengl::scoped::use_program& occlusion_shader);
|
||||
bool getTileOcclusionQueryResult(math::vector_3d const& camera);
|
||||
bool getTileOcclusionQueryResult(glm::vec3 const& camera);
|
||||
void discardTileOcclusionQuery() { _tile_occlusion_query_in_use = false; }
|
||||
|
||||
float camDist() { return _cam_dist; }
|
||||
void calcCamDist(math::vector_3d const& camera);
|
||||
void calcCamDist(glm::vec3 const& camera);
|
||||
void markExtentsDirty() { _extents_dirty = true; }
|
||||
void tagCombinedExtents(bool state) { _combined_extents_dirty = state; };
|
||||
|
||||
@@ -197,15 +197,15 @@ private:
|
||||
bool _extents_dirty = true;
|
||||
bool _combined_extents_dirty = true;
|
||||
|
||||
std::array<math::vector_3d, 2> _extents;
|
||||
std::array<math::vector_3d, 2> _object_instance_extents;
|
||||
std::array<math::vector_3d, 2> _combined_extents;
|
||||
math::vector_3d _center;
|
||||
std::array<glm::vec3, 2> _extents;
|
||||
std::array<glm::vec3, 2> _object_instance_extents;
|
||||
std::array<glm::vec3, 2> _combined_extents;
|
||||
glm::vec3 _center;
|
||||
float _cam_dist;
|
||||
|
||||
// MFBO:
|
||||
math::vector_3d mMinimumValues[3 * 3];
|
||||
math::vector_3d mMaximumValues[3 * 3];
|
||||
glm::vec3 mMinimumValues[3 * 3];
|
||||
glm::vec3 mMaximumValues[3 * 3];
|
||||
|
||||
bool _mfbo_buffer_are_setup = false;
|
||||
opengl::scoped::deferred_upload_vertex_arrays<2> _mfbo_vaos;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#include <math/projection.hpp>
|
||||
#include <noggit/DBC.h>
|
||||
#include <noggit/MapChunk.h>
|
||||
#include <noggit/MapView.h>
|
||||
@@ -2342,7 +2340,7 @@ void MapView::setupMinimap()
|
||||
_minimap->set_resizeable(true);
|
||||
|
||||
connect ( _minimap, &noggit::ui::minimap_widget::map_clicked
|
||||
, [this] (math::vector_3d const& pos)
|
||||
, [this] (glm::vec3 const& pos)
|
||||
{
|
||||
move_camera_with_auto_height (pos);
|
||||
}
|
||||
@@ -2458,7 +2456,7 @@ void MapView::on_exit_prompt()
|
||||
|
||||
MapView::MapView( math::degrees camera_yaw0
|
||||
, math::degrees camera_pitch0
|
||||
, math::vector_3d camera_pos
|
||||
, glm::vec3 camera_pos
|
||||
, noggit::ui::main_window* main_window
|
||||
, std::unique_ptr<World> world
|
||||
, uid_fix_mode uid_fix
|
||||
@@ -2584,7 +2582,7 @@ auto MapView::setBrushTexture(QImage const* img) -> void
|
||||
gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
void MapView::move_camera_with_auto_height (math::vector_3d const& pos)
|
||||
void MapView::move_camera_with_auto_height (glm::vec3 const& pos)
|
||||
{
|
||||
makeCurrent();
|
||||
opengl::context::scoped_setter const _ (::gl, context());
|
||||
@@ -3005,7 +3003,7 @@ void MapView::paintGL()
|
||||
_transform_gizmo.setUseMultiselectionPivot(_use_median_pivot_point.get());
|
||||
|
||||
auto pivot = _world->multi_select_pivot().is_initialized() ?
|
||||
_world->multi_select_pivot().get() : math::vector_3d(0.f, 0.f, 0.f);
|
||||
_world->multi_select_pivot().get() : glm::vec3(0.f, 0.f, 0.f);
|
||||
|
||||
_transform_gizmo.setMultiselectionPivot(pivot);
|
||||
|
||||
@@ -3188,9 +3186,9 @@ void MapView::tick (float dt)
|
||||
|
||||
math::degrees yaw (-_camera.yaw()._);
|
||||
|
||||
math::vector_3d dir(1.0f, 0.0f, 0.0f);
|
||||
math::vector_3d dirUp(1.0f, 0.0f, 0.0f);
|
||||
math::vector_3d dirRight(0.0f, 0.0f, 1.0f);
|
||||
glm::vec3 dir(1.0f, 0.0f, 0.0f);
|
||||
glm::vec3 dirUp(1.0f, 0.0f, 0.0f);
|
||||
glm::vec3 dirRight(0.0f, 0.0f, 1.0f);
|
||||
math::rotate(0.0f, 0.0f, &dir.x, &dir.y, _camera.pitch());
|
||||
math::rotate(0.0f, 0.0f, &dir.x, &dir.z, yaw);
|
||||
|
||||
@@ -3924,7 +3922,7 @@ void MapView::tick (float dt)
|
||||
}
|
||||
}
|
||||
|
||||
math::vector_4d MapView::normalized_device_coords (int x, int y) const
|
||||
glm::vec4 MapView::normalized_device_coords (int x, int y) const
|
||||
{
|
||||
return {2.0f * x / width() - 1.0f, 1.0f - 2.0f * y / height(), 0.0f, 1.0f};
|
||||
}
|
||||
@@ -3942,26 +3940,22 @@ math::ray MapView::intersect_ray() const
|
||||
{
|
||||
// during rendering we multiply perspective * view
|
||||
// so we need the same order here and then invert.
|
||||
math::vector_3d const pos
|
||||
(
|
||||
( ( projection()
|
||||
* model_view()
|
||||
).inverted()
|
||||
* normalized_device_coords (mx, mz)
|
||||
).xyz_normalized_by_w()
|
||||
);
|
||||
glm::mat4x4 const invertedViewMatrix = glm::inverse(projection() * model_view());
|
||||
auto normalisedView = invertedViewMatrix * normalized_device_coords(mx, mz);
|
||||
|
||||
auto pos = glm::vec3(normalisedView.x / normalisedView.w, normalisedView.y / normalisedView.w, normalisedView.z / normalisedView.w);
|
||||
|
||||
return { _camera.position, pos - _camera.position };
|
||||
}
|
||||
else
|
||||
{
|
||||
math::vector_3d const pos
|
||||
glm::vec3 const pos
|
||||
( _camera.position.x - (width() * 0.5f - mx) * _2d_zoom
|
||||
, _camera.position.y
|
||||
, _camera.position.z - (height() * 0.5f - mz) * _2d_zoom
|
||||
);
|
||||
|
||||
return { pos, math::vector_3d(0.f, -1.f, 0.f) };
|
||||
return { pos, glm::vec3(0.f, -1.f, 0.f) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3969,7 +3963,7 @@ selection_result MapView::intersect_result(bool terrain_only)
|
||||
{
|
||||
selection_result results
|
||||
( _world->intersect
|
||||
( model_view().transposed()
|
||||
( glm::transpose(model_view())
|
||||
, intersect_ray()
|
||||
, terrain_only
|
||||
, terrainMode == editing_mode::object || terrainMode == editing_mode::minimap
|
||||
@@ -4097,11 +4091,10 @@ void MapView::update_cursor_pos()
|
||||
glm::vec4 viewport = glm::vec4(0, 0, width(), height());
|
||||
glm::vec3 wincoord = glm::vec3(mx, height() - mz - 1, static_cast<float>(*ptr) / std::numeric_limits<unsigned short>::max());
|
||||
|
||||
math::matrix_4x4 model_view_ = model_view().transposed();
|
||||
math::matrix_4x4 projection_ = projection().transposed();
|
||||
glm::mat4x4 model_view_ = model_view();
|
||||
glm::mat4x4 projection_ = projection();
|
||||
|
||||
glm::vec3 objcoord = glm::unProject(wincoord, glm::make_mat4(reinterpret_cast<float*>(&model_view_)),
|
||||
glm::make_mat4(reinterpret_cast<float*>(&projection_)), viewport);
|
||||
glm::vec3 objcoord = glm::unProject(wincoord, model_view_,projection_, viewport);
|
||||
|
||||
|
||||
tile_index tile({objcoord.x, objcoord.y, objcoord.z});
|
||||
@@ -4137,23 +4130,34 @@ void MapView::update_cursor_pos()
|
||||
}
|
||||
}
|
||||
|
||||
math::matrix_4x4 MapView::model_view() const
|
||||
glm::mat4x4 MapView::model_view() const
|
||||
{
|
||||
if (_display_mode == display_mode::in_2D)
|
||||
{
|
||||
math::vector_3d eye = _camera.position;
|
||||
math::vector_3d target = eye;
|
||||
glm::vec3 eye = _camera.position;
|
||||
glm::vec3 target = eye;
|
||||
target.y -= 1.f;
|
||||
target.z -= 0.001f;
|
||||
|
||||
return math::look_at(eye, target, {0.f,1.f, 0.f});
|
||||
auto center = target;
|
||||
auto up = glm::vec3(0.f, 1.f, 0.f);
|
||||
|
||||
glm::vec3 const z = glm::normalize(eye - center);
|
||||
glm::vec3 const x = glm::normalize(glm::cross(up, z));
|
||||
glm::vec3 const y = glm::normalize(glm::cross(z, x));
|
||||
|
||||
return glm::transpose(glm::mat4x4(x.x, x.y, x.z, glm::dot(x, glm::vec3(-eye.x, -eye.y, -eye.z))
|
||||
, y.x, y.y, y.z, glm::dot(y, glm::vec3(-eye.x, -eye.y, -eye.z))
|
||||
, z.x, z.y, z.z, glm::dot(z, glm::vec3(-eye.x, -eye.y, -eye.z))
|
||||
, 0.f, 0.f, 0.f, 1.f
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
return _camera.look_at_matrix();
|
||||
}
|
||||
}
|
||||
math::matrix_4x4 MapView::projection() const
|
||||
glm::mat4x4 MapView::projection() const
|
||||
{
|
||||
float far_z = _settings->value("farZ", 2048).toFloat();
|
||||
|
||||
@@ -4162,11 +4166,11 @@ math::matrix_4x4 MapView::projection() const
|
||||
float half_width = width() * 0.5f * _2d_zoom;
|
||||
float half_height = height() * 0.5f * _2d_zoom;
|
||||
|
||||
return math::ortho(-half_width, half_width, -half_height, half_height, -1.f, far_z);
|
||||
return glm::ortho(-half_width, half_width, -half_height, half_height, -1.f, far_z);
|
||||
}
|
||||
else
|
||||
{
|
||||
return math::perspective(_camera.fov(), aspect_ratio(), 1.f, far_z);
|
||||
return glm::perspective(_camera.fov()._, aspect_ratio(), 1.f, far_z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4175,7 +4179,7 @@ void MapView::draw_map()
|
||||
ZoneScoped;
|
||||
//! \ todo: make the current tool return the radius
|
||||
float radius = 0.0f, inner_radius = 0.0f, angle = 0.0f, orientation = 0.0f;
|
||||
math::vector_3d ref_pos;
|
||||
glm::vec3 ref_pos;
|
||||
bool angled_mode = false, use_ref_pos = false;
|
||||
|
||||
_cursorType = CursorType::CIRCLE;
|
||||
@@ -4248,8 +4252,9 @@ void MapView::draw_map()
|
||||
doSelection(true);
|
||||
}
|
||||
|
||||
_world->draw ( model_view().transposed()
|
||||
, projection().transposed()
|
||||
|
||||
_world->draw ( model_view()
|
||||
, projection()
|
||||
, _cursor_pos
|
||||
, _cursorRotation
|
||||
, terrainMode == editing_mode::mccv ? shaderTool->shaderColor() : cursor_color
|
||||
@@ -4417,7 +4422,7 @@ void MapView::keyPressEvent (QKeyEvent *event)
|
||||
}
|
||||
if (event->key() == Qt::Key_Home)
|
||||
{
|
||||
_camera.position = math::vector_3d(_cursor_pos.x, _cursor_pos.y + 50, _cursor_pos.z);
|
||||
_camera.position = glm::vec3(_cursor_pos.x, _cursor_pos.y + 50, _cursor_pos.z);
|
||||
_camera_moved_since_last_draw = true;
|
||||
_minimap->update();
|
||||
}
|
||||
@@ -4434,28 +4439,28 @@ void MapView::keyPressEvent (QKeyEvent *event)
|
||||
if (event->key() == Qt::Key_Up)
|
||||
{
|
||||
auto next_z = cur_tile.z - 1;
|
||||
_camera.position = math::vector_3d((cur_tile.x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (next_z * TILESIZE) + (TILESIZE / 2));
|
||||
_camera.position = glm::vec3((cur_tile.x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (next_z * TILESIZE) + (TILESIZE / 2));
|
||||
_camera_moved_since_last_draw = true;
|
||||
_minimap->update();
|
||||
}
|
||||
else if (event->key() == Qt::Key_Down)
|
||||
{
|
||||
auto next_z = cur_tile.z + 1;
|
||||
_camera.position = math::vector_3d((cur_tile.x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (next_z * TILESIZE) + (TILESIZE / 2));
|
||||
_camera.position = glm::vec3((cur_tile.x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (next_z * TILESIZE) + (TILESIZE / 2));
|
||||
_camera_moved_since_last_draw = true;
|
||||
_minimap->update();
|
||||
}
|
||||
else if (event->key() == Qt::Key_Left)
|
||||
{
|
||||
auto next_x = cur_tile.x - 1;
|
||||
_camera.position = math::vector_3d((next_x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (cur_tile.z * TILESIZE) + (TILESIZE / 2));
|
||||
_camera.position = glm::vec3((next_x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (cur_tile.z * TILESIZE) + (TILESIZE / 2));
|
||||
_camera_moved_since_last_draw = true;
|
||||
_minimap->update();
|
||||
}
|
||||
else if (event->key() == Qt::Key_Right)
|
||||
{
|
||||
auto next_x = cur_tile.x + 1;
|
||||
_camera.position = math::vector_3d((next_x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (cur_tile.z * TILESIZE) + (TILESIZE / 2));
|
||||
_camera.position = glm::vec3((next_x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (cur_tile.z * TILESIZE) + (TILESIZE / 2));
|
||||
_camera_moved_since_last_draw = true;
|
||||
_minimap->update();
|
||||
}
|
||||
@@ -5211,7 +5216,7 @@ void MapView::onSettingsSave()
|
||||
params->wireframe_width = _settings->value ("wireframe/width", 1.f).toFloat();
|
||||
|
||||
QColor c = _settings->value("wireframe/color").value<QColor>();
|
||||
math::vector_4d wireframe_color(c.redF(), c.greenF(), c.blueF(), c.alphaF());
|
||||
glm::vec4 wireframe_color(c.redF(), c.greenF(), c.blueF(), c.alphaF());
|
||||
params->wireframe_color = wireframe_color;
|
||||
|
||||
_world->markTerrainParamsUniformBlockDirty();
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <math/ray.hpp>
|
||||
#include <math/vector_4d.hpp>
|
||||
#include <noggit/Misc.h>
|
||||
#include <noggit/Selection.h>
|
||||
#include <noggit/bool_toggle_property.hpp>
|
||||
@@ -119,7 +118,7 @@ private:
|
||||
float _2d_zoom = 1.f;
|
||||
float moving, strafing, updown, mousedir, turn, lookat;
|
||||
CursorType _cursorType;
|
||||
math::vector_3d _cursor_pos;
|
||||
glm::vec3 _cursor_pos;
|
||||
float _cursorRotation;
|
||||
bool look, freelook;
|
||||
bool ui_hidden = false;
|
||||
@@ -153,8 +152,8 @@ private:
|
||||
|
||||
display_mode _display_mode;
|
||||
|
||||
math::matrix_4x4 model_view() const;
|
||||
math::matrix_4x4 projection() const;
|
||||
glm::mat4x4 model_view() const;
|
||||
glm::mat4x4 projection() const;
|
||||
|
||||
void draw_map();
|
||||
|
||||
@@ -177,7 +176,7 @@ private:
|
||||
bool MoveObj;
|
||||
float numpad_moveratio = 0.001f;
|
||||
|
||||
math::vector_3d objMove;
|
||||
glm::vec3 objMove;
|
||||
|
||||
std::vector<selection_type> lastSelected;
|
||||
|
||||
@@ -227,11 +226,11 @@ public slots:
|
||||
void on_exit_prompt();
|
||||
|
||||
public:
|
||||
math::vector_4d cursor_color;
|
||||
glm::vec4 cursor_color;
|
||||
|
||||
MapView ( math::degrees ah0
|
||||
, math::degrees av0
|
||||
, math::vector_3d camera_pos
|
||||
, glm::vec3 camera_pos
|
||||
, noggit::ui::main_window*
|
||||
, std::unique_ptr<World>
|
||||
, uid_fix_mode uid_fix = uid_fix_mode::none
|
||||
@@ -316,7 +315,7 @@ private:
|
||||
|
||||
noggit::ui::main_window* _main_window;
|
||||
|
||||
math::vector_4d normalized_device_coords (int x, int y) const;
|
||||
glm::vec4 normalized_device_coords (int x, int y) const;
|
||||
float aspect_ratio() const;
|
||||
|
||||
noggit::TabletManager* _tablet_manager;
|
||||
@@ -354,7 +353,7 @@ private:
|
||||
QDockWidget* _texture_palette_dock;
|
||||
QDockWidget* _object_palette_dock;
|
||||
|
||||
void move_camera_with_auto_height (math::vector_3d const&);
|
||||
void move_camera_with_auto_height (glm::vec3 const&);
|
||||
|
||||
void setToolPropertyWidgetVisibility(editing_mode mode);
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
namespace misc
|
||||
{
|
||||
|
||||
bool pointInside(math::vector_3d point, std::array<math::vector_3d, 2> const& extents)
|
||||
bool pointInside(glm::vec3 point, std::array<glm::vec3, 2> const& extents)
|
||||
{
|
||||
return point.x >= extents[0].x && point.z >= extents[0].z &&
|
||||
point.x <= extents[1].x && point.z <= extents[1].z;
|
||||
}
|
||||
|
||||
void minmax(math::vector_3d* a, math::vector_3d* b)
|
||||
void minmax(glm::vec3* a, glm::vec3* b)
|
||||
{
|
||||
if (a->x > b->x)
|
||||
{
|
||||
@@ -68,7 +68,7 @@ namespace misc
|
||||
return std::sqrt(xdiff*xdiff + zdiff*zdiff);
|
||||
}
|
||||
|
||||
float dist(math::vector_3d const& p1, math::vector_3d const& p2)
|
||||
float dist(glm::vec3 const& p1, glm::vec3 const& p2)
|
||||
{
|
||||
return dist(p1.x, p1.z, p2.x, p2.z);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ namespace misc
|
||||
return (px == x && pz == z) ? 0.0f : dist(x, z, px, pz);
|
||||
}
|
||||
|
||||
float getShortestDist(math::vector_3d const& pos, math::vector_3d const& square_pos, float unitSize)
|
||||
float getShortestDist(glm::vec3 const& pos, glm::vec3 const& square_pos, float unitSize)
|
||||
{
|
||||
return getShortestDist(pos.x, pos.z, square_pos.x, square_pos.z, unitSize);
|
||||
}
|
||||
@@ -132,7 +132,7 @@ namespace misc
|
||||
return d <= radius;
|
||||
}
|
||||
|
||||
bool rectOverlap(math::vector_3d const* r1, math::vector_3d const* r2)
|
||||
bool rectOverlap(glm::vec3 const* r1, glm::vec3 const* r2)
|
||||
{
|
||||
return r1[0].x <= r2[1].x
|
||||
&& r2[0].x <= r1[1].x
|
||||
@@ -140,15 +140,15 @@ namespace misc
|
||||
&& r2[0].z <= r1[1].z;
|
||||
}
|
||||
|
||||
float angledHeight(math::vector_3d const& origin, math::vector_3d const& pos, math::radians const& angle, math::radians const& orientation)
|
||||
float angledHeight(glm::vec3 const& origin, glm::vec3 const& pos, math::radians const& angle, math::radians const& orientation)
|
||||
{
|
||||
return ( origin.y
|
||||
+ ( (pos.x - origin.x) * math::cos(orientation)
|
||||
+ (pos.z - origin.z) * math::sin(orientation)
|
||||
) * math::tan(angle));
|
||||
+ ( (pos.x - origin.x) * glm::cos(orientation._)
|
||||
+ (pos.z - origin.z) * glm::sin(orientation._)
|
||||
) * glm::tan(angle._));
|
||||
}
|
||||
|
||||
void extract_v3d_min_max(math::vector_3d const& point, math::vector_3d& min, math::vector_3d& max)
|
||||
void extract_v3d_min_max(glm::vec3 const& point, glm::vec3& min, glm::vec3& max)
|
||||
{
|
||||
min.x = std::min(min.x, point.x);
|
||||
max.x = std::max(max.x, point.x);
|
||||
@@ -158,9 +158,9 @@ namespace misc
|
||||
max.z = std::max(max.z, point.z);
|
||||
}
|
||||
|
||||
std::vector<math::vector_3d> intersection_points(math::vector_3d const& vmin, math::vector_3d const& vmax)
|
||||
std::vector<glm::vec3> intersection_points(glm::vec3 const& vmin, glm::vec3 const& vmax)
|
||||
{
|
||||
std::vector<math::vector_3d> points;
|
||||
std::vector<glm::vec3> points;
|
||||
|
||||
points.emplace_back (vmin.x, vmin.y, vmin.z);
|
||||
points.emplace_back (vmin.x, vmin.y, vmax.z);
|
||||
@@ -174,7 +174,7 @@ namespace misc
|
||||
return points;
|
||||
}
|
||||
|
||||
math::vector_3d transform_model_box_coords(math::vector_3d const& pos)
|
||||
glm::vec3 transform_model_box_coords(glm::vec3 const& pos)
|
||||
{
|
||||
return {pos.x, pos.z, -pos.y};
|
||||
}
|
||||
@@ -191,14 +191,14 @@ namespace misc
|
||||
return filename;
|
||||
}
|
||||
|
||||
bool vec3d_equals(math::vector_3d const& v1, math::vector_3d const& v2)
|
||||
bool vec3d_equals(glm::vec3 const& v1, glm::vec3 const& v2)
|
||||
{
|
||||
return float_equals(v1.x, v2.x) && float_equals(v1.y, v2.y) && float_equals(v1.z, v2.z);
|
||||
}
|
||||
|
||||
bool deg_vec3d_equals(math::degrees::vec3 const& v1, math::degrees::vec3 const& v2)
|
||||
{
|
||||
return float_equals(v1.x._, v2.x._) && float_equals(v1.y._, v2.y._) && float_equals(v1.z._, v2.z._);
|
||||
return float_equals(v1.x, v2.x) && float_equals(v1.y, v2.y) && float_equals(v1.z, v2.z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <math/trig.hpp>
|
||||
#include <math/vector_3d.hpp>
|
||||
#include <math/vector_4d.hpp>
|
||||
#include <noggit/Log.h>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -15,6 +13,7 @@
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <noggit/Selection.h>
|
||||
|
||||
// namespace for static helper functions.
|
||||
@@ -26,16 +25,16 @@ namespace misc
|
||||
float randfloat(float lower, float upper);
|
||||
int randint(int lower, int upper);
|
||||
float dist(float x1, float z1, float x2, float z2);
|
||||
float dist(math::vector_3d const& p1, math::vector_3d const& p2);
|
||||
float dist(glm::vec3 const& p1, glm::vec3 const& p2);
|
||||
float getShortestDist(float x, float z, float squareX, float squareZ, float unitSize);
|
||||
float getShortestDist(math::vector_3d const& pos, math::vector_3d const& square_pos, float unitSize);
|
||||
float getShortestDist(glm::vec3 const& pos, glm::vec3 const& square_pos, float unitSize);
|
||||
bool square_is_in_circle(float x, float z, float radius, float square_x, float square_z, float square_size);
|
||||
bool rectOverlap(math::vector_3d const*, math::vector_3d const*);
|
||||
bool rectOverlap(glm::vec3 const*, glm::vec3 const*);
|
||||
// used for angled tools, get the height a point (pos) should be given an origin, angle and orientation
|
||||
float angledHeight(math::vector_3d const& origin, math::vector_3d const& pos, math::radians const& angle, math::radians const& orientation);
|
||||
void extract_v3d_min_max(math::vector_3d const& point, math::vector_3d& min, math::vector_3d& max);
|
||||
std::vector<math::vector_3d> intersection_points(math::vector_3d const& vmin, math::vector_3d const& vmax);
|
||||
math::vector_3d transform_model_box_coords(math::vector_3d const& pos);
|
||||
float angledHeight(glm::vec3 const& origin, glm::vec3 const& pos, math::radians const& angle, math::radians const& orientation);
|
||||
void extract_v3d_min_max(glm::vec3 const& point, glm::vec3& min, glm::vec3& max);
|
||||
std::vector<glm::vec3> intersection_points(glm::vec3 const& vmin, glm::vec3 const& vmax);
|
||||
glm::vec3 transform_model_box_coords(glm::vec3 const& pos);
|
||||
// normalize the filename used in adts since TC extractors don't accept /
|
||||
std::string normalize_adt_filename(std::string filename);
|
||||
|
||||
@@ -45,11 +44,11 @@ namespace misc
|
||||
return std::abs(a - b) < (std::max(1.f, std::max(a, b)) * std::numeric_limits<float>::epsilon());
|
||||
}
|
||||
|
||||
bool vec3d_equals(math::vector_3d const& v1, math::vector_3d const& v2);
|
||||
bool vec3d_equals(glm::vec3 const& v1, glm::vec3 const& v2);
|
||||
bool deg_vec3d_equals(math::degrees::vec3 const& v1, math::degrees::vec3 const& v2);
|
||||
|
||||
bool pointInside(math::vector_3d point, std::array<math::vector_3d, 2> const& extents);
|
||||
void minmax(math::vector_3d* a, math::vector_3d* b);
|
||||
bool pointInside(glm::vec3 point, std::array<glm::vec3, 2> const& extents);
|
||||
void minmax(glm::vec3* a, glm::vec3* b);
|
||||
|
||||
inline int rounded_int_div(int value, int div)
|
||||
{
|
||||
@@ -74,10 +73,10 @@ namespace misc
|
||||
}
|
||||
}
|
||||
|
||||
struct random_color : math::vector_4d
|
||||
struct random_color : glm::vec4
|
||||
{
|
||||
random_color()
|
||||
: math::vector_4d ( misc::randfloat(0.0f, 1.0f)
|
||||
: glm::vec4( misc::randfloat(0.0f, 1.0f)
|
||||
, misc::randfloat(0.0f, 1.0f)
|
||||
, misc::randfloat(0.0f, 1.0f)
|
||||
, 0.7f
|
||||
|
||||
@@ -176,21 +176,21 @@ bool Model::isAnimated(const MPQFile& f)
|
||||
}
|
||||
|
||||
|
||||
math::vector_3d fixCoordSystem(math::vector_3d v)
|
||||
glm::vec3 fixCoordSystem(glm::vec3 v)
|
||||
{
|
||||
return math::vector_3d(v.x, v.z, -v.y);
|
||||
return glm::vec3(v.x, v.z, -v.y);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
math::vector_3d fixCoordSystem2(math::vector_3d v)
|
||||
glm::vec3 fixCoordSystem2(glm::vec3 v)
|
||||
{
|
||||
return math::vector_3d(v.x, v.z, v.y);
|
||||
return glm::vec3(v.x, v.z, v.y);
|
||||
}
|
||||
|
||||
math::quaternion fixCoordSystemQuat(math::quaternion v)
|
||||
glm::quat fixCoordSystemQuat(glm::quat v)
|
||||
{
|
||||
return math::quaternion(-v.x, -v.z, v.y, v.w);
|
||||
return glm::quat(-v.x, -v.z, v.y, v.w);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,15 +626,15 @@ bool ModelRenderPass::prepare_draw(opengl::scoped::use_program& m2_shader, Model
|
||||
|
||||
// COLOUR
|
||||
// Get the colour and transparency and check that we should even render
|
||||
math::vector_4d mesh_color = math::vector_4d(1.0f, 1.0f, 1.0f, m->trans); // ??
|
||||
math::vector_4d emissive_color = math::vector_4d(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glm::vec4 mesh_color = glm::vec4(1.0f, 1.0f, 1.0f, m->trans); // ??
|
||||
glm::vec4 emissive_color = glm::vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
auto const& renderflag(m->_render_flags[renderflag_index]);
|
||||
|
||||
// emissive colors
|
||||
if (color_index != -1 && m->_colors[color_index].color.uses(0))
|
||||
{
|
||||
::math::vector_3d c (m->_colors[color_index].color.getValue (0, m->_anim_time, m->_global_animtime));
|
||||
::glm::vec3 c (m->_colors[color_index].color.getValue (0, m->_anim_time, m->_global_animtime));
|
||||
if (m->_colors[color_index].opacity.uses (m->_current_anim_seq))
|
||||
{
|
||||
mesh_color.w = m->_colors[color_index].opacity.getValue (m->_current_anim_seq, m->_anim_time, m->_global_animtime);
|
||||
@@ -649,7 +649,7 @@ bool ModelRenderPass::prepare_draw(opengl::scoped::use_program& m2_shader, Model
|
||||
mesh_color.x = mesh_color.y = mesh_color.z = 0;
|
||||
}
|
||||
|
||||
emissive_color = math::vector_4d(c, mesh_color.w);
|
||||
emissive_color = glm::vec4(c.x,c.y,c.z, mesh_color.w);
|
||||
}
|
||||
|
||||
// opacity
|
||||
@@ -911,7 +911,7 @@ void ModelRenderPass::init_uv_types(Model* m)
|
||||
|
||||
FakeGeometry::FakeGeometry(Model* m)
|
||||
{
|
||||
math::vector_3d min = m->header.bounding_box_min, max = m->header.bounding_box_max;
|
||||
glm::vec3 min = m->header.bounding_box_min, max = m->header.bounding_box_max;
|
||||
|
||||
vertices.emplace_back(min.x, max.y, min.z);
|
||||
vertices.emplace_back(min.x, max.y, max.z);
|
||||
@@ -1174,7 +1174,7 @@ void Model::initAnimated(const MPQFile& f)
|
||||
animcalc = false;
|
||||
}
|
||||
|
||||
void Model::calcBones( math::matrix_4x4 const& model_view
|
||||
void Model::calcBones(glm::mat4x4 const& model_view
|
||||
, int _anim
|
||||
, int time
|
||||
, int animation_time
|
||||
@@ -1191,7 +1191,7 @@ void Model::calcBones( math::matrix_4x4 const& model_view
|
||||
}
|
||||
}
|
||||
|
||||
void Model::animate(math::matrix_4x4 const& model_view, int anim_id, int anim_time)
|
||||
void Model::animate(glm::mat4x4 const& model_view, int anim_id, int anim_time)
|
||||
{
|
||||
if (_animations_seq_per_id.empty() || _animations_seq_per_id[anim_id].empty())
|
||||
{
|
||||
@@ -1247,15 +1247,15 @@ void Model::animate(math::matrix_4x4 const& model_view, int anim_id, int anim_ti
|
||||
|
||||
for (auto& vertex : _current_vertices)
|
||||
{
|
||||
::math::vector_3d v(0, 0, 0), n(0, 0, 0);
|
||||
::glm::vec3 v(0, 0, 0), n(0, 0, 0);
|
||||
|
||||
for (size_t b (0); b < 4; ++b)
|
||||
{
|
||||
if (vertex.weights[b] <= 0)
|
||||
continue;
|
||||
|
||||
::math::vector_3d tv = bones[vertex.bones[b]].mat * vertex.position;
|
||||
::math::vector_3d tn = bones[vertex.bones[b]].mrot * vertex.normal;
|
||||
::glm::vec3 tv = bones[vertex.bones[b]].mat * vertex.position;
|
||||
::glm::vec3 tn = bones[vertex.bones[b]].mrot * vertex.normal;
|
||||
|
||||
v += tv * (static_cast<float> (vertex.weights[b]) / 255.0f);
|
||||
n += tn * (static_cast<float> (vertex.weights[b]) / 255.0f);
|
||||
@@ -1332,8 +1332,8 @@ ModelLight::ModelLight(const MPQFile& f, const ModelLightDef &mld, int *global)
|
||||
, parent (mld.bone)
|
||||
, pos (fixCoordSystem(mld.pos))
|
||||
, tpos (fixCoordSystem(mld.pos))
|
||||
, dir (::math::vector_3d(0,1,0))
|
||||
, tdir (::math::vector_3d(0,1,0)) // obviously wrong
|
||||
, dir (::glm::vec3(0,1,0))
|
||||
, tdir (::glm::vec3(0,1,0)) // obviously wrong
|
||||
, diffColor (mld.color, f, global)
|
||||
, ambColor (mld.ambColor, f, global)
|
||||
, diffIntensity (mld.intensity, f, global)
|
||||
@@ -1342,9 +1342,12 @@ ModelLight::ModelLight(const MPQFile& f, const ModelLightDef &mld, int *global)
|
||||
|
||||
void ModelLight::setup(int time, opengl::light, int animtime)
|
||||
{
|
||||
math::vector_4d ambcol(ambColor.getValue(0, time, animtime) * ambIntensity.getValue(0, time, animtime), 1.0f);
|
||||
math::vector_4d diffcol(diffColor.getValue(0, time, animtime) * diffIntensity.getValue(0, time, animtime), 1.0f);
|
||||
math::vector_4d p;
|
||||
auto ambient = ambColor.getValue(0, time, animtime) * ambIntensity.getValue(0, time, animtime);
|
||||
auto diffuse = diffColor.getValue(0, time, animtime) * diffIntensity.getValue(0, time, animtime);
|
||||
|
||||
glm::vec4 ambcol(ambient.x, ambient.y,ambient.z, 1.0f);
|
||||
glm::vec4 diffcol(diffuse.x, diffuse.y, diffuse.z, 1.0f);
|
||||
glm::vec4 p;
|
||||
|
||||
enum ModelLightTypes {
|
||||
MODELLIGHT_DIRECTIONAL = 0,
|
||||
@@ -1353,14 +1356,14 @@ void ModelLight::setup(int time, opengl::light, int animtime)
|
||||
|
||||
if (type == MODELLIGHT_DIRECTIONAL) {
|
||||
// directional
|
||||
p = math::vector_4d(tdir, 0.0f);
|
||||
p = glm::vec4(tdir.x, tdir.y, tdir.z, 0.0f);
|
||||
}
|
||||
else if (type == MODELLIGHT_POINT) {
|
||||
// point
|
||||
p = math::vector_4d(tpos, 1.0f);
|
||||
p = glm::vec4(tpos.x, tpos.y,tpos.z, 1.0f);
|
||||
}
|
||||
else {
|
||||
p = math::vector_4d(tpos, 1.0f);
|
||||
p = glm::vec4(tpos.x, tpos.y, tpos.z, 1.0f);
|
||||
LogError << "Light type " << type << " is unknown." << std::endl;
|
||||
}
|
||||
|
||||
@@ -1391,7 +1394,7 @@ Bone::Bone( const MPQFile& f,
|
||||
scale.apply(fixCoordSystem2);
|
||||
}
|
||||
|
||||
void Bone::calcMatrix( math::matrix_4x4 const& model_view
|
||||
void Bone::calcMatrix(glm::mat4x4 const& model_view
|
||||
, Bone *allbones
|
||||
, int anim
|
||||
, int time
|
||||
@@ -1401,7 +1404,7 @@ void Bone::calcMatrix( math::matrix_4x4 const& model_view
|
||||
if (calc) return;
|
||||
|
||||
math::matrix_4x4 m {math::matrix_4x4::unit};
|
||||
math::quaternion q;
|
||||
glm::quat q;
|
||||
|
||||
if ( flags.transformed
|
||||
|| flags.billboard
|
||||
@@ -1429,10 +1432,10 @@ void Bone::calcMatrix( math::matrix_4x4 const& model_view
|
||||
|
||||
if (flags.billboard)
|
||||
{
|
||||
math::vector_3d vRight (model_view[0], model_view[4], model_view[8]);
|
||||
math::vector_3d vUp (model_view[1], model_view[5], model_view[9]); // Spherical billboarding
|
||||
//math::vector_3d vUp = math::vector_3d(0,1,0); // Cylindrical billboarding
|
||||
vRight = vRight * -1;
|
||||
glm::vec3 vRight (model_view[0][0], model_view[1][0], model_view[2][0]);
|
||||
glm::vec3 vUp (model_view[0][1], model_view[1][1], model_view[2][1]); // Spherical billboarding
|
||||
//glm::vec3 vUp = glm::vec3(0,1,0); // Cylindrical billboarding
|
||||
vRight = glm::vec3(vRight.x * -1, vRight.y * -1, vRight.z * -1);
|
||||
m (0, 2, vRight.x);
|
||||
m (1, 2, vRight.y);
|
||||
m (2, 2, vRight.z);
|
||||
@@ -1474,13 +1477,13 @@ void Bone::calcMatrix( math::matrix_4x4 const& model_view
|
||||
calc = true;
|
||||
}
|
||||
|
||||
void Model::draw( math::matrix_4x4 const& model_view
|
||||
void Model::draw( glm::mat4x4 const& model_view
|
||||
, ModelInstance& instance
|
||||
, opengl::scoped::use_program& m2_shader
|
||||
, opengl::M2RenderState& model_render_state
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, int animtime
|
||||
, display_mode display
|
||||
, bool no_cull
|
||||
@@ -1514,11 +1517,11 @@ void Model::draw( math::matrix_4x4 const& model_view
|
||||
{
|
||||
opengl::scoped::buffer_binder<GL_ARRAY_BUFFER> const binder(_vertices_buffer);
|
||||
m2_shader.attrib("pos", 3, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), 0);
|
||||
m2_shader.attrib("bones_weight", 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d)));
|
||||
m2_shader.attrib("bones_indices", 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) + 4));
|
||||
m2_shader.attrib("normal", 3, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::math::vector_3d) + 8));
|
||||
m2_shader.attrib("texcoord1", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::math::vector_3d) * 2 + 8));
|
||||
m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::math::vector_3d) * 2 + 8 + sizeof(::math::vector_2d)));
|
||||
m2_shader.attrib("bones_weight", 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3)));
|
||||
m2_shader.attrib("bones_indices", 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3) + 4));
|
||||
m2_shader.attrib("normal", 3, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::glm::vec3) + 8));
|
||||
m2_shader.attrib("texcoord1", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::glm::vec3) * 2 + 8));
|
||||
m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::glm::vec3) * 2 + 8 + sizeof(glm::vec2)));
|
||||
}
|
||||
|
||||
opengl::scoped::buffer_binder<GL_ELEMENT_ARRAY_BUFFER> indices_binder(_indices_buffer);
|
||||
@@ -1537,13 +1540,13 @@ void Model::draw( math::matrix_4x4 const& model_view
|
||||
gl.depthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
void Model::draw ( math::matrix_4x4 const& model_view
|
||||
void Model::draw (glm::mat4x4 const& model_view
|
||||
, std::vector<math::matrix_4x4> const& instances
|
||||
, opengl::scoped::use_program& m2_shader
|
||||
, opengl::M2RenderState& model_render_state
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, int animtime
|
||||
, bool all_boxes
|
||||
, std::unordered_map<Model*, std::size_t>& model_boxes_to_draw
|
||||
@@ -1674,7 +1677,7 @@ void Model::draw_box (opengl::scoped::use_program& m2_box_shader, std::size_t bo
|
||||
}
|
||||
|
||||
|
||||
std::vector<float> Model::intersect (math::matrix_4x4 const& model_view, math::ray const& ray, int animtime)
|
||||
std::vector<float> Model::intersect (glm::mat4x4 const& model_view, math::ray const& ray, int animtime)
|
||||
{
|
||||
std::vector<float> results;
|
||||
|
||||
@@ -1763,7 +1766,7 @@ void Model::upload()
|
||||
|
||||
{
|
||||
opengl::scoped::buffer_binder<GL_ARRAY_BUFFER> const binder (_box_vbo);
|
||||
gl.bufferData (GL_ARRAY_BUFFER, _vertex_box_points.size() * sizeof (math::vector_3d), _vertex_box_points.data(), GL_STATIC_DRAW);
|
||||
gl.bufferData (GL_ARRAY_BUFFER, _vertex_box_points.size() * sizeof (glm::vec3), _vertex_box_points.data(), GL_STATIC_DRAW);
|
||||
}
|
||||
|
||||
opengl::scoped::buffer_binder<GL_ELEMENT_ARRAY_BUFFER> indices_binder(_indices_buffer);
|
||||
@@ -1817,11 +1820,11 @@ void Model::setupVAO(opengl::scoped::use_program& m2_shader)
|
||||
{
|
||||
opengl::scoped::buffer_binder<GL_ARRAY_BUFFER> const binder (_vertices_buffer);
|
||||
m2_shader.attrib("pos", 3, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), 0);
|
||||
m2_shader.attribi("bones_weight", 4, GL_UNSIGNED_BYTE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d)));
|
||||
m2_shader.attribi("bones_indices",4, GL_UNSIGNED_BYTE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) + 4));
|
||||
m2_shader.attrib("normal", 3, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) + 8));
|
||||
m2_shader.attrib("texcoord1", 2, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) * 2 + 8));
|
||||
m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) * 2 + 8 + sizeof(::math::vector_2d)));
|
||||
m2_shader.attribi("bones_weight", 4, GL_UNSIGNED_BYTE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3)));
|
||||
m2_shader.attribi("bones_indices",4, GL_UNSIGNED_BYTE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3) + 4));
|
||||
m2_shader.attrib("normal", 3, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3) + 8));
|
||||
m2_shader.attrib("texcoord1", 2, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3) * 2 + 8));
|
||||
m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3) * 2 + 8 + sizeof(glm::vec2)));
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
#include <math/frustum.hpp>
|
||||
#include <math/matrix_4x4.hpp>
|
||||
#include <math/quaternion.hpp>
|
||||
#include <math/ray.hpp>
|
||||
#include <math/vector_3d.hpp>
|
||||
#include <noggit/Animated.h> // Animation::M2Value
|
||||
#include <noggit/AsyncObject.h> // AsyncObject
|
||||
#include <noggit/MPQ.h>
|
||||
@@ -27,15 +25,15 @@ class ModelInstance;
|
||||
class ParticleSystem;
|
||||
class RibbonEmitter;
|
||||
|
||||
math::vector_3d fixCoordSystem(math::vector_3d v);
|
||||
glm::vec3 fixCoordSystem(glm::vec3 v);
|
||||
|
||||
class Bone {
|
||||
Animation::M2Value<math::vector_3d> trans;
|
||||
Animation::M2Value<math::quaternion, math::packed_quaternion> rot;
|
||||
Animation::M2Value<math::vector_3d> scale;
|
||||
Animation::M2Value<glm::vec3> trans;
|
||||
Animation::M2Value<glm::quat, packed_quaternion> rot;
|
||||
Animation::M2Value<glm::vec3> scale;
|
||||
|
||||
public:
|
||||
math::vector_3d pivot;
|
||||
glm::vec3 pivot;
|
||||
int parent;
|
||||
|
||||
typedef struct
|
||||
@@ -58,7 +56,7 @@ public:
|
||||
math::matrix_4x4 mrot = math::matrix_4x4::uninitialized;
|
||||
|
||||
bool calc;
|
||||
void calcMatrix( math::matrix_4x4 const& model_view
|
||||
void calcMatrix(glm::mat4x4 const& model_view
|
||||
, Bone* allbones
|
||||
, int anim
|
||||
, int time
|
||||
@@ -74,9 +72,9 @@ public:
|
||||
|
||||
|
||||
class TextureAnim {
|
||||
Animation::M2Value<math::vector_3d> trans;
|
||||
Animation::M2Value<math::quaternion, math::packed_quaternion> rot;
|
||||
Animation::M2Value<math::vector_3d> scale;
|
||||
Animation::M2Value<glm::vec3> trans;
|
||||
Animation::M2Value<glm::quat, packed_quaternion> rot;
|
||||
Animation::M2Value<glm::vec3> scale;
|
||||
|
||||
public:
|
||||
math::matrix_4x4 mat;
|
||||
@@ -86,7 +84,7 @@ public:
|
||||
};
|
||||
|
||||
struct ModelColor {
|
||||
Animation::M2Value<math::vector_3d> color;
|
||||
Animation::M2Value<glm::vec3> color;
|
||||
Animation::M2Value<float, int16_t> opacity;
|
||||
|
||||
ModelColor(const MPQFile& f, const ModelColorDef &mcd, int *global);
|
||||
@@ -186,14 +184,14 @@ struct FakeGeometry
|
||||
{
|
||||
FakeGeometry(Model* m);
|
||||
|
||||
std::vector<math::vector_3d> vertices;
|
||||
std::vector<glm::vec3> vertices;
|
||||
std::vector<uint16_t> indices;
|
||||
};
|
||||
|
||||
struct ModelLight {
|
||||
int type, parent;
|
||||
math::vector_3d pos, tpos, dir, tdir;
|
||||
Animation::M2Value<math::vector_3d> diffColor, ambColor;
|
||||
glm::vec3 pos, tpos, dir, tdir;
|
||||
Animation::M2Value<glm::vec3> diffColor, ambColor;
|
||||
Animation::M2Value<float> diffIntensity, ambIntensity;
|
||||
//Animation::M2Value<float> attStart,attEnd;
|
||||
//Animation::M2Value<bool> Enabled;
|
||||
@@ -214,24 +212,24 @@ public:
|
||||
|
||||
Model(const std::string& name, noggit::NoggitRenderContext context );
|
||||
|
||||
void draw( math::matrix_4x4 const& model_view
|
||||
void draw(glm::mat4x4 const& model_view
|
||||
, ModelInstance& instance
|
||||
, opengl::scoped::use_program& m2_shader
|
||||
, opengl::M2RenderState& model_render_state
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, int animtime
|
||||
, display_mode display
|
||||
, bool no_cull = false
|
||||
);
|
||||
void draw ( math::matrix_4x4 const& model_view
|
||||
void draw (glm::mat4x4 const& model_view
|
||||
, std::vector<math::matrix_4x4> const& instances
|
||||
, opengl::scoped::use_program& m2_shader
|
||||
, opengl::M2RenderState& model_render_state
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, int animtime
|
||||
, bool all_boxes
|
||||
, std::unordered_map<Model*, std::size_t>& model_boxes_to_draw
|
||||
@@ -248,7 +246,7 @@ public:
|
||||
|
||||
void draw_box (opengl::scoped::use_program& m2_box_shader, std::size_t box_count);
|
||||
|
||||
std::vector<float> intersect (math::matrix_4x4 const& model_view, math::ray const&, int animtime);
|
||||
std::vector<float> intersect (glm::mat4x4 const& model_view, math::ray const&, int animtime);
|
||||
|
||||
void updateEmitters(float dt);
|
||||
|
||||
@@ -311,8 +309,8 @@ private:
|
||||
void fix_shader_id_layer();
|
||||
void compute_pixel_shader_ids();
|
||||
|
||||
void animate(math::matrix_4x4 const& model_view, int anim_id, int anim_time);
|
||||
void calcBones(math::matrix_4x4 const& model_view, int anim, int time, int animation_time);
|
||||
void animate(glm::mat4x4 const& model_view, int anim_id, int anim_time);
|
||||
void calcBones(glm::mat4x4 const& model_view, int anim, int time, int animation_time);
|
||||
|
||||
void lightsOn(opengl::light lbase);
|
||||
void lightsOff(opengl::light lbase);
|
||||
@@ -323,7 +321,7 @@ private:
|
||||
bool _finished_upload = false;
|
||||
bool _vao_setup = false;
|
||||
|
||||
std::vector<math::vector_3d> _vertex_box_points;
|
||||
std::vector<glm::vec3> _vertex_box_points;
|
||||
|
||||
// buffers
|
||||
opengl::scoped::deferred_upload_buffers<6> _buffers;
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/vector_2d.hpp>
|
||||
#include <math/vector_3d.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
@@ -14,6 +10,14 @@ struct Vertex {
|
||||
float x, y, z;
|
||||
};
|
||||
|
||||
struct packed_quaternion
|
||||
{
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t z;
|
||||
int16_t w;
|
||||
};
|
||||
|
||||
struct ModelHeader {
|
||||
char id[4];
|
||||
uint8_t version[4];
|
||||
@@ -64,11 +68,11 @@ struct ModelHeader {
|
||||
uint32_t nTexAnimLookup;
|
||||
uint32_t ofsTexAnimLookup;
|
||||
|
||||
math::vector_3d bounding_box_min;
|
||||
math::vector_3d bounding_box_max;
|
||||
glm::vec3 bounding_box_min;
|
||||
glm::vec3 bounding_box_max;
|
||||
float bounding_box_radius;
|
||||
math::vector_3d collision_box_min;
|
||||
math::vector_3d collision_box_max;
|
||||
glm::vec3 collision_box_min;
|
||||
glm::vec3 collision_box_max;
|
||||
float collision_box_radius;
|
||||
|
||||
uint32_t nBoundingTriangles;
|
||||
@@ -118,7 +122,7 @@ struct ModelAnimation {
|
||||
uint32_t d2;
|
||||
uint32_t playSpeed; // note: this can't be play speed because it's 0 for some models
|
||||
|
||||
math::vector_3d boxA, boxB;
|
||||
glm::vec3 boxA, boxB;
|
||||
float rad;
|
||||
|
||||
int16_t NextAnimation;
|
||||
@@ -156,11 +160,11 @@ struct ModelTexAnimDef {
|
||||
};
|
||||
|
||||
struct ModelVertex {
|
||||
math::vector_3d position;
|
||||
glm::vec3 position;
|
||||
uint8_t weights[4];
|
||||
uint8_t bones[4];
|
||||
math::vector_3d normal;
|
||||
math::vector_2d texcoords[2];
|
||||
glm::vec3 normal;
|
||||
glm::vec2 texcoords[2];
|
||||
};
|
||||
|
||||
struct ModelView {
|
||||
@@ -185,7 +189,7 @@ struct ModelGeoset {
|
||||
uint16_t d4; // ? always 1 to 4
|
||||
uint16_t d5; // ?
|
||||
uint16_t d6; // root bone?
|
||||
math::vector_3d BoundingBox[2];
|
||||
glm::vec3 BoundingBox[2];
|
||||
float radius;
|
||||
};
|
||||
|
||||
@@ -242,7 +246,7 @@ struct ModelTextureDef {
|
||||
struct ModelLightDef {
|
||||
int16_t type;
|
||||
int16_t bone;
|
||||
math::vector_3d pos;
|
||||
glm::vec3 pos;
|
||||
AnimationBlock ambColor;
|
||||
AnimationBlock ambIntensity;
|
||||
AnimationBlock color;
|
||||
@@ -256,9 +260,9 @@ struct ModelCameraDef {
|
||||
int32_t id;
|
||||
float fov, farclip, nearclip;
|
||||
AnimationBlock transPos;
|
||||
math::vector_3d pos;
|
||||
glm::vec3 pos;
|
||||
AnimationBlock transTarget;
|
||||
math::vector_3d target;
|
||||
glm::vec3 target;
|
||||
AnimationBlock rot;
|
||||
};
|
||||
|
||||
@@ -288,7 +292,7 @@ struct ModelParticleParams {
|
||||
struct ModelParticleEmitterDef {
|
||||
int32_t id;
|
||||
int32_t flags;
|
||||
math::vector_3d pos; // The position. Relative to the following bone.
|
||||
glm::vec3 pos; // The position. Relative to the following bone.
|
||||
int16_t bone; // The bone its attached to.
|
||||
int16_t texture; // And the texture that is used.
|
||||
int32_t nModelFileName;
|
||||
@@ -323,7 +327,7 @@ struct ModelParticleEmitterDef {
|
||||
struct ModelRibbonEmitterDef {
|
||||
int32_t id;
|
||||
int32_t bone;
|
||||
math::vector_3d pos;
|
||||
glm::vec3 pos;
|
||||
int32_t nTextures;
|
||||
int32_t ofsTextures;
|
||||
int32_t nMaterials;
|
||||
@@ -344,7 +348,7 @@ struct ModelEvents {
|
||||
char id[4];
|
||||
int32_t data;
|
||||
int32_t bone;
|
||||
math::vector_3d pos;
|
||||
glm::vec3 pos;
|
||||
int16_t type;
|
||||
int16_t seq;
|
||||
uint32_t nTimes;
|
||||
@@ -354,7 +358,7 @@ struct ModelEvents {
|
||||
struct ModelAttachmentDef {
|
||||
int32_t id;
|
||||
int32_t bone;
|
||||
math::vector_3d pos;
|
||||
glm::vec3 pos;
|
||||
AnimationBlock Enabled;
|
||||
};
|
||||
|
||||
@@ -366,7 +370,7 @@ struct ModelBoneDef {
|
||||
AnimationBlock translation;
|
||||
AnimationBlock rotation;
|
||||
AnimationBlock scaling;
|
||||
math::vector_3d pivot;
|
||||
glm::vec3 pivot;
|
||||
};
|
||||
|
||||
struct ModelBoundTriangle {
|
||||
|
||||
@@ -23,11 +23,8 @@ ModelInstance::ModelInstance(std::string const& filename, ENTRY_MDDF const*d, no
|
||||
, model (filename, context)
|
||||
{
|
||||
uid = d->uniqueID;
|
||||
pos = math::vector_3d(d->pos[0], d->pos[1], d->pos[2]);
|
||||
dir = math::degrees::vec3( math::degrees(d->rot[0])
|
||||
, math::degrees(d->rot[1])
|
||||
, math::degrees(d->rot[2])
|
||||
);
|
||||
pos = glm::vec3(d->pos[0], d->pos[1], d->pos[2]);
|
||||
dir = math::degrees::vec3( math::degrees(d->rot[0])._, math::degrees(d->rot[1])._, math::degrees(d->rot[2])._);
|
||||
// scale factor - divide by 1024. blizzard devs must be on crack, why not just use a float?
|
||||
scale = d->scale / 1024.0f;
|
||||
|
||||
@@ -42,8 +39,8 @@ ModelInstance::ModelInstance(std::string const& filename, ENTRY_MDDF const*d, no
|
||||
}
|
||||
|
||||
|
||||
void ModelInstance::draw_box ( math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
void ModelInstance::draw_box (glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, bool is_current_selection
|
||||
)
|
||||
{
|
||||
@@ -88,7 +85,7 @@ void ModelInstance::draw_box ( math::matrix_4x4 const& model_view
|
||||
}
|
||||
}
|
||||
|
||||
void ModelInstance::intersect ( math::matrix_4x4 const& model_view
|
||||
void ModelInstance::intersect (glm::mat4x4 const& model_view
|
||||
, math::ray const& ray
|
||||
, selection_result* results
|
||||
, int animtime
|
||||
@@ -126,7 +123,7 @@ bool ModelInstance::isInFrustum(const math::frustum& frustum)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ModelInstance::isInRenderDist(const float& cull_distance, const math::vector_3d& camera, display_mode display)
|
||||
bool ModelInstance::isInRenderDist(const float& cull_distance, const glm::vec3& camera, display_mode display)
|
||||
{
|
||||
float dist;
|
||||
|
||||
@@ -178,20 +175,22 @@ void ModelInstance::recalcExtents()
|
||||
updateTransformMatrix();
|
||||
|
||||
math::aabb const relative_to_model
|
||||
( math::min ( model->header.collision_box_min
|
||||
, model->header.bounding_box_min
|
||||
)
|
||||
, math::max ( model->header.collision_box_max
|
||||
, model->header.bounding_box_max
|
||||
)
|
||||
( glm::min ( model->header.collision_box_min, model->header.bounding_box_min)
|
||||
, glm::max ( model->header.collision_box_max, model->header.bounding_box_max)
|
||||
);
|
||||
|
||||
//! \todo If both boxes are {inf, -inf}, or well, if any min.c > max.c,
|
||||
//! the model is bad itself. We *could* detect that case and explicitly
|
||||
//! assume {-1, 1} then, to be nice to fuckported models.
|
||||
|
||||
auto const corners_in_world (math::apply (misc::transform_model_box_coords, relative_to_model.all_corners()));
|
||||
|
||||
auto corners_in_world = std::vector<glm::vec3>();
|
||||
auto transform = misc::transform_model_box_coords;
|
||||
auto points = relative_to_model.all_corners();
|
||||
for (auto& point : points)
|
||||
{
|
||||
point = transform(point);
|
||||
corners_in_world.push_back(point);
|
||||
}
|
||||
auto const rotated_corners_in_world (_transform_mat_transposed.transposed() * corners_in_world);
|
||||
|
||||
math::aabb const bounding_of_rotated_points (rotated_corners_in_world);
|
||||
@@ -212,7 +211,7 @@ void ModelInstance::ensureExtents()
|
||||
}
|
||||
}
|
||||
|
||||
math::vector_3d* ModelInstance::getExtents()
|
||||
glm::vec3* ModelInstance::getExtents()
|
||||
{
|
||||
if (_need_recalc_extents && model->finishedLoading())
|
||||
{
|
||||
@@ -228,10 +227,10 @@ wmo_doodad_instance::wmo_doodad_instance(std::string const& filename, MPQFile* f
|
||||
float ff[4];
|
||||
|
||||
f->read(ff, 12);
|
||||
pos = math::vector_3d(ff[0], ff[2], -ff[1]);
|
||||
pos = glm::vec3(ff[0], ff[2], -ff[1]);
|
||||
|
||||
f->read(ff, 16);
|
||||
doodad_orientation = math::quaternion (-ff[0], -ff[2], ff[1], ff[3]);
|
||||
doodad_orientation = glm::quat (-ff[0], -ff[2], ff[1], ff[3]);
|
||||
|
||||
f->read(&scale, 4);
|
||||
|
||||
@@ -246,7 +245,7 @@ wmo_doodad_instance::wmo_doodad_instance(std::string const& filename, MPQFile* f
|
||||
|
||||
f->read(&color.packed, 4);
|
||||
|
||||
light_color = math::vector_3d(color.bgra.r / 255.f, color.bgra.g / 255.f, color.bgra.b / 255.f);
|
||||
light_color = glm::vec3(color.bgra.r / 255.f, color.bgra.g / 255.f, color.bgra.b / 255.f);
|
||||
}
|
||||
|
||||
void wmo_doodad_instance::update_transform_matrix_wmo(WMOInstance* wmo)
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <math/ray.hpp>
|
||||
#include <math/vector_3d.hpp> // math::vector_3d
|
||||
#include <noggit/MPQ.h> // MPQFile
|
||||
#include <noggit/MapHeaders.h> // ENTRY_MDDF
|
||||
#include <noggit/ModelManager.h>
|
||||
@@ -28,7 +27,7 @@ public:
|
||||
|
||||
scoped_model_reference model;
|
||||
|
||||
math::vector_3d light_color = { 1.f, 1.f, 1.f };
|
||||
glm::vec3 light_color = { 1.f, 1.f, 1.f };
|
||||
|
||||
// used when flag 0x8 is set in wdt
|
||||
// longest side of an AABB transformed model's bounding box from the M2 header
|
||||
@@ -76,12 +75,12 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
void draw_box ( math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
void draw_box (glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, bool is_current_selection
|
||||
);
|
||||
|
||||
void intersect ( math::matrix_4x4 const& model_view
|
||||
void intersect (glm::mat4x4 const& model_view
|
||||
, math::ray const&
|
||||
, selection_result*
|
||||
, int animtime
|
||||
@@ -89,15 +88,15 @@ public:
|
||||
|
||||
|
||||
bool isInFrustum(math::frustum const& frustum);
|
||||
bool isInRenderDist(const float& cull_distance, const math::vector_3d& camera, display_mode display);
|
||||
bool isInRenderDist(const float& cull_distance, const glm::vec3& camera, display_mode display);
|
||||
|
||||
[[nodiscard]]
|
||||
virtual math::vector_3d const& get_pos() const { return pos; }
|
||||
virtual glm::vec3 const& get_pos() const { return pos; }
|
||||
|
||||
void recalcExtents() override;
|
||||
void ensureExtents() override;
|
||||
bool finishedLoading() override { return model->finishedLoading(); };
|
||||
math::vector_3d* getExtents();
|
||||
glm::vec3* getExtents();
|
||||
|
||||
[[nodiscard]]
|
||||
virtual bool isWMODoodad() const { return false; };
|
||||
@@ -118,8 +117,8 @@ protected:
|
||||
class wmo_doodad_instance : public ModelInstance
|
||||
{
|
||||
public:
|
||||
math::quaternion doodad_orientation;
|
||||
math::vector_3d world_pos;
|
||||
glm::quat doodad_orientation;
|
||||
glm::vec3 world_pos;
|
||||
|
||||
explicit wmo_doodad_instance(std::string const& filename
|
||||
, MPQFile* f
|
||||
@@ -158,7 +157,7 @@ public:
|
||||
|
||||
void update_transform_matrix_wmo(WMOInstance* wmo);
|
||||
|
||||
virtual math::vector_3d const& get_pos() const override { return world_pos; };
|
||||
virtual glm::vec3 const& get_pos() const override { return world_pos; };
|
||||
|
||||
[[nodiscard]]
|
||||
virtual bool isWMODoodad() const override { return true; };
|
||||
|
||||
@@ -57,11 +57,11 @@ ParticleSystem::ParticleSystem(Model* model_
|
||||
, tofs (misc::frand())
|
||||
, _context(context)
|
||||
{
|
||||
math::vector_3d colors2[3];
|
||||
memcpy(colors2, f.getBuffer() + mta.p.colors.ofsKeys, sizeof(math::vector_3d) * 3);
|
||||
glm::vec3 colors2[3];
|
||||
memcpy(colors2, f.getBuffer() + mta.p.colors.ofsKeys, sizeof(glm::vec3) * 3);
|
||||
for (size_t i = 0; i<3; ++i) {
|
||||
float opacity = *reinterpret_cast<int16_t const*>(f.getBuffer() + mta.p.opacity.ofsKeys + i * 2);
|
||||
colors[i] = math::vector_4d(colors2[i].x / 255.0f, colors2[i].y / 255.0f, colors2[i].z / 255.0f, opacity / 32767.0f);
|
||||
colors[i] = glm::vec4(colors2[i].x / 255.0f, colors2[i].y / 255.0f, colors2[i].z / 255.0f, opacity / 32767.0f);
|
||||
sizes[i] = (*reinterpret_cast<float const*>(f.getBuffer() + mta.p.sizes.ofsKeys + i * 4))*mta.p.scales[i];
|
||||
}
|
||||
|
||||
@@ -160,10 +160,10 @@ ParticleSystem::ParticleSystem(ParticleSystem&& other)
|
||||
|
||||
}
|
||||
|
||||
void ParticleSystem::initTile(math::vector_2d *tc, int num)
|
||||
void ParticleSystem::initTile(glm::vec2 *tc, int num)
|
||||
{
|
||||
math::vector_2d otc[4];
|
||||
math::vector_2d a, b;
|
||||
glm::vec2 otc[4];
|
||||
glm::vec2 a, b;
|
||||
int x = num % cols;
|
||||
int y = num / cols;
|
||||
a.x = x * (1.0f / cols);
|
||||
@@ -247,7 +247,7 @@ void ParticleSystem::update(float dt)
|
||||
float rlife = p.life / p.maxlife;
|
||||
// calculate size and color based on lifetime
|
||||
p.size = lifeRamp<float>(rlife, mid, sizes[0], sizes[1], sizes[2]);
|
||||
p.color = lifeRamp<math::vector_4d>(rlife, mid, colors[0], colors[1], colors[2]);
|
||||
p.color = lifeRamp<glm::vec4>(rlife, mid, colors[0], colors[1], colors[2]);
|
||||
|
||||
// kill off old particles
|
||||
if (rlife >= 1.0f)
|
||||
@@ -307,27 +307,27 @@ void ParticleSystem::draw( math::matrix_4x4 const& model_view
|
||||
|
||||
//model->_textures[_texture_id]->bind();
|
||||
|
||||
math::vector_3d vRight(1, 0, 0);
|
||||
math::vector_3d vUp(0, 1, 0);
|
||||
glm::vec3 vRight(1, 0, 0);
|
||||
glm::vec3 vUp(0, 1, 0);
|
||||
|
||||
// position stuff
|
||||
const float f = 1;//0.707106781f; // sqrt(2)/2
|
||||
math::vector_3d bv0 = math::vector_3d(-f, +f, 0);
|
||||
math::vector_3d bv1 = math::vector_3d(+f, +f, 0);
|
||||
glm::vec3 bv0 = glm::vec3(-f, +f, 0);
|
||||
glm::vec3 bv1 = glm::vec3(+f, +f, 0);
|
||||
|
||||
std::vector<std::uint16_t> indices;
|
||||
std::vector<math::vector_3d> vertices;
|
||||
std::vector<math::vector_3d> offsets;
|
||||
std::vector<math::vector_4d> colors_data;
|
||||
std::vector<math::vector_2d> texcoords;
|
||||
std::vector<glm::vec3> vertices;
|
||||
std::vector<glm::vec3> offsets;
|
||||
std::vector<glm::vec4> colors_data;
|
||||
std::vector<glm::vec2> texcoords;
|
||||
|
||||
std::uint16_t indice = 0;
|
||||
|
||||
if (billboard)
|
||||
{
|
||||
vRight = math::vector_3d(model_view[0], model_view[4], model_view[8]);
|
||||
vUp = math::vector_3d(model_view[1], model_view[5], model_view[9]); // Spherical billboarding
|
||||
//vUp = math::vector_3d(0,1,0); // Cylindrical billboarding
|
||||
vRight = glm::vec3(model_view[0], model_view[4], model_view[8]);
|
||||
vUp = glm::vec3(model_view[1], model_view[5], model_view[9]); // Spherical billboarding
|
||||
//vUp = glm::vec3(0,1,0); // Cylindrical billboarding
|
||||
}
|
||||
|
||||
auto add_quad_indices([] (std::vector<std::uint16_t>& indices, std::uint16_t& start)
|
||||
@@ -423,12 +423,12 @@ void ParticleSystem::draw( math::matrix_4x4 const& model_view
|
||||
{ // Sphere particles
|
||||
// particles from origin to position
|
||||
/*
|
||||
bv0 = mbb * math::vector_3d(0,-1.0f,0);
|
||||
bv1 = mbb * math::vector_3d(0,+1.0f,0);
|
||||
bv0 = mbb * glm::vec3(0,-1.0f,0);
|
||||
bv1 = mbb * glm::vec3(0,+1.0f,0);
|
||||
|
||||
|
||||
bv0 = mbb * math::vector_3d(-1.0f,0,0);
|
||||
bv1 = mbb * math::vector_3d(1.0f,0,0);
|
||||
bv0 = mbb * glm::vec3(-1.0f,0,0);
|
||||
bv1 = mbb * glm::vec3(1.0f,0,0);
|
||||
*/
|
||||
|
||||
for (ParticleList::iterator it = particles.begin(); it != particles.end(); ++it)
|
||||
@@ -458,9 +458,9 @@ void ParticleSystem::draw( math::matrix_4x4 const& model_view
|
||||
}
|
||||
}
|
||||
|
||||
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d>(_vertices_vbo, vertices, GL_STREAM_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER, math::vector_4d>(_colors_vbo, colors_data, GL_STREAM_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER, math::vector_2d>(_texcoord_vbo, texcoords, GL_STREAM_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER, glm::vec3>(_vertices_vbo, vertices, GL_STREAM_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER, glm::vec4>(_colors_vbo, colors_data, GL_STREAM_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER, glm::vec2>(_texcoord_vbo, texcoords, GL_STREAM_DRAW);
|
||||
gl.bufferData<GL_ELEMENT_ARRAY_BUFFER, std::uint16_t>(_indices_vbo, indices, GL_STREAM_DRAW);
|
||||
|
||||
shader.uniform("alpha_test", alpha_test);
|
||||
@@ -474,7 +474,7 @@ void ParticleSystem::draw( math::matrix_4x4 const& model_view
|
||||
}
|
||||
if(billboard)
|
||||
{
|
||||
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d>(_offsets_vbo, offsets, GL_STREAM_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER, glm::vec3>(_offsets_vbo, offsets, GL_STREAM_DRAW);
|
||||
|
||||
opengl::scoped::buffer_binder<GL_ARRAY_BUFFER> const offset_binder (_offsets_vbo);
|
||||
shader.attrib("offset", 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
@@ -610,57 +610,57 @@ Particle PlaneParticleEmitter::newParticle(ParticleSystem* sys, int anim, int ti
|
||||
auto mrot = sys->parent->mrot*CalcSpreadMatrix(spr, spr, 1.0f, 1.0f);
|
||||
|
||||
if (sys->flags == 1041) { // Trans Halo
|
||||
p.pos = sys->parent->mat * (sys->pos + math::vector_3d(misc::randfloat(-l, l), 0, misc::randfloat(-w, w)));
|
||||
p.pos = sys->parent->mat * (sys->pos + glm::vec3(misc::randfloat(-l, l), 0, misc::randfloat(-w, w)));
|
||||
|
||||
const float t = misc::randfloat(0.0f, 2.0f * (float)math::constants::pi);
|
||||
const float t = misc::randfloat(0.0f, 2.0f * glm::pi<float>());
|
||||
|
||||
p.pos = math::vector_3d(0.0f, sys->pos.y + 0.15f, sys->pos.z) + math::vector_3d(cos(t) / 8, 0.0f, sin(t) / 8); // Need to manually correct for the halo - why?
|
||||
p.pos = glm::vec3(0.0f, sys->pos.y + 0.15f, sys->pos.z) + glm::vec3(cos(t) / 8, 0.0f, sin(t) / 8); // Need to manually correct for the halo - why?
|
||||
|
||||
// var isn't being used, which is set to 1.0f, whats the importance of this?
|
||||
// why does this set of values differ from other particles
|
||||
|
||||
math::vector_3d dir(0.0f, 1.0f, 0.0f);
|
||||
glm::vec3 dir(0.0f, 1.0f, 0.0f);
|
||||
p.dir = dir;
|
||||
|
||||
p.speed = dir.normalize() * spd * misc::randfloat(0, var);
|
||||
p.speed = glm::normalize(dir) * spd * misc::randfloat(0, var);
|
||||
}
|
||||
else if (sys->flags == 25 && sys->parent->parent<1) { // Weapon Flame
|
||||
p.pos = sys->parent->pivot + (sys->pos + math::vector_3d(misc::randfloat(-l, l), misc::randfloat(-l, l), misc::randfloat(-w, w)));
|
||||
math::vector_3d dir = mrot * math::vector_3d(0.0f, 1.0f, 0.0f);
|
||||
p.dir = dir.normalize();
|
||||
//math::vector_3d dir = sys->model->bones[sys->parent->parent].mrot * sys->parent->mrot * math::vector_3d(0.0f, 1.0f, 0.0f);
|
||||
p.pos = sys->parent->pivot + (sys->pos + glm::vec3(misc::randfloat(-l, l), misc::randfloat(-l, l), misc::randfloat(-w, w)));
|
||||
glm::vec3 dir = mrot * glm::vec3(0.0f, 1.0f, 0.0f);
|
||||
p.dir = glm::normalize(dir);
|
||||
//glm::vec3 dir = sys->model->bones[sys->parent->parent].mrot * sys->parent->mrot * glm::vec3(0.0f, 1.0f, 0.0f);
|
||||
//p.speed = dir.normalize() * spd;
|
||||
|
||||
}
|
||||
else if (sys->flags == 25 && sys->parent->parent > 0) { // Weapon with built-in Flame (Avenger lightsaber!)
|
||||
p.pos = sys->parent->mat * (sys->pos + math::vector_3d(misc::randfloat(-l, l), misc::randfloat(-l, l), misc::randfloat(-w, w)));
|
||||
math::vector_3d dir = math::vector_3d(sys->parent->mat (1, 0), sys->parent->mat (1, 1), sys->parent->mat (1, 2)) + math::vector_3d(0.0f, 1.0f, 0.0f);
|
||||
p.speed = dir.normalize() * spd * misc::randfloat(0, var * 2);
|
||||
p.pos = sys->parent->mat * (sys->pos + glm::vec3(misc::randfloat(-l, l), misc::randfloat(-l, l), misc::randfloat(-w, w)));
|
||||
glm::vec3 dir = glm::vec3(sys->parent->mat (1, 0), sys->parent->mat (1, 1), sys->parent->mat (1, 2)) + glm::vec3(0.0f, 1.0f, 0.0f);
|
||||
p.speed = glm::normalize(dir) * spd * misc::randfloat(0, var * 2);
|
||||
|
||||
}
|
||||
else if (sys->flags == 17 && sys->parent->parent<1) { // Weapon Glow
|
||||
p.pos = sys->parent->pivot + (sys->pos + math::vector_3d(misc::randfloat(-l, l), misc::randfloat(-l, l), misc::randfloat(-w, w)));
|
||||
math::vector_3d dir = mrot * math::vector_3d(0, 1, 0);
|
||||
p.dir = dir.normalize();
|
||||
p.pos = sys->parent->pivot + (sys->pos + glm::vec3(misc::randfloat(-l, l), misc::randfloat(-l, l), misc::randfloat(-w, w)));
|
||||
glm::vec3 dir = mrot * glm::vec3(0, 1, 0);
|
||||
p.dir = glm::normalize(dir);
|
||||
|
||||
}
|
||||
else {
|
||||
p.pos = sys->pos + math::vector_3d(misc::randfloat(-l, l), 0, misc::randfloat(-w, w));
|
||||
p.pos = sys->pos + glm::vec3(misc::randfloat(-l, l), 0, misc::randfloat(-w, w));
|
||||
p.pos = sys->parent->mat * p.pos;
|
||||
|
||||
//math::vector_3d dir = mrot * math::vector_3d(0,1,0);
|
||||
math::vector_3d dir = sys->parent->mrot * math::vector_3d(0, 1, 0);
|
||||
//glm::vec3 dir = mrot * glm::vec3(0,1,0);
|
||||
glm::vec3 dir = sys->parent->mrot * glm::vec3(0, 1, 0);
|
||||
|
||||
p.dir = dir;//.normalize();
|
||||
p.down = math::vector_3d(0, -1.0f, 0); // dir * -1.0f;
|
||||
p.speed = dir.normalize() * spd * (1.0f + misc::randfloat(-var, var));
|
||||
p.down = glm::vec3(0, -1.0f, 0); // dir * -1.0f;
|
||||
p.speed = glm::normalize(dir) * spd * (1.0f + misc::randfloat(-var, var));
|
||||
}
|
||||
|
||||
if (!sys->billboard) {
|
||||
p.corners[0] = mrot * math::vector_3d(-1, 0, +1);
|
||||
p.corners[1] = mrot * math::vector_3d(+1, 0, +1);
|
||||
p.corners[2] = mrot * math::vector_3d(+1, 0, -1);
|
||||
p.corners[3] = mrot * math::vector_3d(-1, 0, -1);
|
||||
p.corners[0] = mrot * glm::vec3(-1, 0, +1);
|
||||
p.corners[1] = mrot * glm::vec3(+1, 0, +1);
|
||||
p.corners[2] = mrot * glm::vec3(+1, 0, -1);
|
||||
p.corners[3] = mrot * glm::vec3(-1, 0, -1);
|
||||
}
|
||||
|
||||
p.life = 0;
|
||||
@@ -675,7 +675,7 @@ Particle PlaneParticleEmitter::newParticle(ParticleSystem* sys, int anim, int ti
|
||||
Particle SphereParticleEmitter::newParticle(ParticleSystem* sys, int anim, int time, int animtime, float w, float l, float spd, float var, float spr, float spr2)
|
||||
{
|
||||
Particle p;
|
||||
math::vector_3d dir;
|
||||
glm::vec3 dir;
|
||||
float radius;
|
||||
|
||||
radius = misc::randfloat(0, 1);
|
||||
@@ -687,7 +687,7 @@ Particle SphereParticleEmitter::newParticle(ParticleSystem* sys, int anim, int t
|
||||
// Spread should never be zero for sphere particles ?
|
||||
math::radians t (0);
|
||||
if (spr == 0)
|
||||
t._ = misc::randfloat((float)-math::constants::pi, (float)math::constants::pi);
|
||||
t._ = misc::randfloat(-glm::pi<float>(), glm::pi<float>());
|
||||
else
|
||||
t._ = misc::randfloat(-spr, spr);
|
||||
|
||||
@@ -700,18 +700,18 @@ Particle SphereParticleEmitter::newParticle(ParticleSystem* sys, int anim, int t
|
||||
// l = w;
|
||||
|
||||
// New method
|
||||
// math::vector_3d bdir(w*math::cos(t), 0.0f, l*math::sin(t));
|
||||
// glm::vec3 bdir(w*math::cos(t), 0.0f, l*math::sin(t));
|
||||
// --
|
||||
|
||||
//! \todo fix shpere emitters to work properly
|
||||
/* // Old Method
|
||||
//math::vector_3d bdir(l*math::cos(t), 0, w*math::sin(t));
|
||||
//math::vector_3d bdir(0, w*math::cos(t), l*math::sin(t));
|
||||
//glm::vec3 bdir(l*math::cos(t), 0, w*math::sin(t));
|
||||
//glm::vec3 bdir(0, w*math::cos(t), l*math::sin(t));
|
||||
|
||||
|
||||
float theta_range = sys->spread.getValue(anim, time, animtime);
|
||||
float theta = -0.5f* theta_range + misc::randfloat(0, theta_range);
|
||||
math::vector_3d bdir(0, l*math::cos(theta), w*math::sin(theta));
|
||||
glm::vec3 bdir(0, l*math::cos(theta), w*math::sin(theta));
|
||||
|
||||
float phi_range = sys->lat.getValue(anim, time, animtime);
|
||||
float phi = misc::randfloat(0, phi_range);
|
||||
@@ -719,24 +719,24 @@ Particle SphereParticleEmitter::newParticle(ParticleSystem* sys, int anim, int t
|
||||
*/
|
||||
|
||||
if (sys->flags == 57 || sys->flags == 313) { // Faith Halo
|
||||
math::vector_3d bdir(w*math::cos(t)*1.6f, 0.0f, l*math::sin(t)*1.6f);
|
||||
glm::vec3 bdir(w*glm::cos(t._)*1.6f, 0.0f, l*glm::sin(t._)*1.6f);
|
||||
|
||||
p.pos = sys->pos + bdir;
|
||||
p.pos = sys->parent->mat * p.pos;
|
||||
|
||||
if (bdir.length_squared() == 0)
|
||||
p.speed = math::vector_3d(0, 0, 0);
|
||||
if (glm::length(bdir) * glm::length(bdir) == 0)
|
||||
p.speed = glm::vec3(0, 0, 0);
|
||||
else {
|
||||
dir = sys->parent->mrot * (bdir.normalize());//mrot * math::vector_3d(0, 1.0f,0);
|
||||
p.speed = dir.normalize() * spd * (1.0f + misc::randfloat(-var, var)); // ?
|
||||
dir = sys->parent->mrot * (glm::normalize(bdir));//mrot * glm::vec3(0, 1.0f,0);
|
||||
p.speed = glm::normalize(dir) * spd * (1.0f + misc::randfloat(-var, var)); // ?
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
math::vector_3d bdir;
|
||||
glm::vec3 bdir;
|
||||
float temp;
|
||||
|
||||
bdir = mrot * math::vector_3d(0, 1, 0) * radius;
|
||||
bdir = mrot * glm::vec3(0, 1, 0) * radius;
|
||||
temp = bdir.z;
|
||||
bdir.z = bdir.y;
|
||||
bdir.y = temp;
|
||||
@@ -748,24 +748,24 @@ Particle SphereParticleEmitter::newParticle(ParticleSystem* sys, int anim, int t
|
||||
//p.pos = sys->parent->mat * p.pos;
|
||||
|
||||
|
||||
if (!bdir.length_squared() && !(sys->flags & 0x100))
|
||||
if (!(glm::length(bdir) * glm::length(bdir)) && !(sys->flags & 0x100))
|
||||
{
|
||||
p.speed = math::vector_3d(0, 0, 0);
|
||||
dir = sys->parent->mrot * math::vector_3d(0, 1, 0);
|
||||
p.speed = glm::vec3(0, 0, 0);
|
||||
dir = sys->parent->mrot * glm::vec3(0, 1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sys->flags & 0x100)
|
||||
dir = sys->parent->mrot * math::vector_3d(0, 1, 0);
|
||||
dir = sys->parent->mrot * glm::vec3(0, 1, 0);
|
||||
else
|
||||
dir = bdir.normalize();
|
||||
dir = glm::normalize(bdir);
|
||||
|
||||
p.speed = dir.normalize() * spd * (1.0f + misc::randfloat(-var, var)); // ?
|
||||
p.speed = glm::normalize(dir) * spd * (1.0f + misc::randfloat(-var, var)); // ?
|
||||
}
|
||||
}
|
||||
|
||||
p.dir = dir.normalize();//mrot * math::vector_3d(0, 1.0f,0);
|
||||
p.down = math::vector_3d(0, -1.0f, 0);
|
||||
p.dir = glm::normalize(dir);//mrot * glm::vec3(0, 1.0f,0);
|
||||
p.down = glm::vec3(0, -1.0f, 0);
|
||||
|
||||
p.life = 0;
|
||||
p.maxlife = sys->lifespan.getValue(anim, time, animtime);
|
||||
@@ -855,10 +855,10 @@ RibbonEmitter::RibbonEmitter(RibbonEmitter&& other)
|
||||
|
||||
void RibbonEmitter::setup(int anim, int time, int animtime)
|
||||
{
|
||||
math::vector_3d ntpos = parent->mat * pos;
|
||||
math::vector_3d ntup = parent->mat * (pos + math::vector_3d(0, 0, 1));
|
||||
glm::vec3 ntpos = parent->mat * pos;
|
||||
glm::vec3 ntup = parent->mat * (pos + glm::vec3(0, 0, 1));
|
||||
ntup -= ntpos;
|
||||
ntup.normalize();
|
||||
ntup = glm::normalize(ntup);
|
||||
float dlen = (ntpos - tpos).length();
|
||||
|
||||
manim = anim;
|
||||
@@ -868,7 +868,7 @@ void RibbonEmitter::setup(int anim, int time, int animtime)
|
||||
RibbonSegment &first = *segs.begin();
|
||||
if (first.len > seglen) {
|
||||
// add new segment
|
||||
first.back = (tpos - ntpos).normalize();
|
||||
first.back = glm::normalize((tpos - ntpos));
|
||||
first.len0 = first.len;
|
||||
RibbonSegment newseg (ntpos, dlen);
|
||||
newseg.up = ntup;
|
||||
@@ -898,7 +898,8 @@ void RibbonEmitter::setup(int anim, int time, int animtime)
|
||||
}
|
||||
|
||||
tpos = ntpos;
|
||||
tcolor = math::vector_4d(color.getValue(anim, time, animtime), opacity.getValue(anim, time, animtime));
|
||||
auto col = color.getValue(anim, time, animtime);
|
||||
tcolor = glm::vec4(col.x,col.y,col.z, opacity.getValue(anim, time, animtime));
|
||||
|
||||
tabove = above.getValue(anim, time, animtime);
|
||||
tbelow = below.getValue(anim, time, animtime);
|
||||
@@ -915,8 +916,8 @@ void RibbonEmitter::draw( opengl::scoped::use_program& shader
|
||||
}
|
||||
|
||||
std::vector<std::uint16_t> indices;
|
||||
std::vector<math::vector_3d> vertices;
|
||||
std::vector<math::vector_2d> texcoords;
|
||||
std::vector<glm::vec3> vertices;
|
||||
std::vector<glm::vec2> texcoords;
|
||||
|
||||
//model->_textures[_texture_ids[0]]->bind();
|
||||
|
||||
@@ -964,8 +965,8 @@ void RibbonEmitter::draw( opengl::scoped::use_program& shader
|
||||
vertices.push_back(it->pos - tbelow * it->up + (it->len / it->len0) * it->back);
|
||||
}
|
||||
|
||||
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d>(_vertices_vbo, vertices, GL_STREAM_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER, math::vector_2d>(_texcoord_vbo, texcoords, GL_STREAM_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER, glm::vec3>(_vertices_vbo, vertices, GL_STREAM_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER, glm::vec2>(_texcoord_vbo, texcoords, GL_STREAM_DRAW);
|
||||
gl.bufferData<GL_ELEMENT_ARRAY_BUFFER, std::uint16_t>(_indices_vbo, indices, GL_STREAM_DRAW);
|
||||
|
||||
opengl::scoped::vao_binder const _(_vao);
|
||||
|
||||
@@ -18,12 +18,12 @@ class ParticleSystem;
|
||||
class RibbonEmitter;
|
||||
|
||||
struct Particle {
|
||||
math::vector_3d pos, speed, down, origin, dir;
|
||||
math::vector_3d corners[4];
|
||||
//math::vector_3d tpos;
|
||||
glm::vec3 pos, speed, down, origin, dir;
|
||||
glm::vec3 corners[4];
|
||||
//glm::vec3 tpos;
|
||||
float size, life, maxlife;
|
||||
unsigned int tile;
|
||||
math::vector_4d color;
|
||||
glm::vec4 color;
|
||||
};
|
||||
|
||||
typedef std::list<Particle> ParticleList;
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
};
|
||||
|
||||
struct TexCoordSet {
|
||||
math::vector_2d tc[4];
|
||||
glm::vec2 tc[4];
|
||||
};
|
||||
|
||||
class ParticleSystem
|
||||
@@ -58,10 +58,10 @@ class ParticleSystem
|
||||
std::unique_ptr<ParticleEmitter> emitter;
|
||||
Animation::M2Value<float> speed, variation, spread, lat, gravity, lifespan, rate, areal, areaw, deacceleration;
|
||||
Animation::M2Value<uint8_t> enabled;
|
||||
std::array<math::vector_4d, 3> colors;
|
||||
std::array<glm::vec4, 3> colors;
|
||||
std::array<float,3> sizes;
|
||||
float mid, slowdown;
|
||||
math::vector_3d pos;
|
||||
glm::vec3 pos;
|
||||
uint16_t _texture_id;
|
||||
ParticleList particles;
|
||||
int blend, order, type;
|
||||
@@ -69,7 +69,7 @@ class ParticleSystem
|
||||
int manimtime;
|
||||
int rows, cols;
|
||||
std::vector<TexCoordSet> tiles;
|
||||
void initTile(math::vector_2d *tc, int num);
|
||||
void initTile(glm::vec2 *tc, int num);
|
||||
bool billboard;
|
||||
|
||||
float rem;
|
||||
@@ -122,9 +122,9 @@ private:
|
||||
|
||||
struct RibbonSegment
|
||||
{
|
||||
math::vector_3d pos, up, back;
|
||||
glm::vec3 pos, up, back;
|
||||
float len, len0;
|
||||
RibbonSegment (::math::vector_3d pos_, float len_)
|
||||
RibbonSegment (::glm::vec3 pos_, float len_)
|
||||
: pos (pos_)
|
||||
, len (len_)
|
||||
{}
|
||||
@@ -134,20 +134,20 @@ class RibbonEmitter
|
||||
{
|
||||
Model *model;
|
||||
|
||||
Animation::M2Value<math::vector_3d> color;
|
||||
Animation::M2Value<glm::vec3> color;
|
||||
Animation::M2Value<float, int16_t> opacity;
|
||||
Animation::M2Value<float> above, below;
|
||||
|
||||
Bone *parent;
|
||||
|
||||
math::vector_3d pos;
|
||||
glm::vec3 pos;
|
||||
|
||||
int manim, mtime;
|
||||
int seglen;
|
||||
float length;
|
||||
|
||||
math::vector_3d tpos;
|
||||
math::vector_4d tcolor;
|
||||
glm::vec3 tpos;
|
||||
glm::vec4 tcolor;
|
||||
float tabove, tbelow;
|
||||
|
||||
std::vector<uint16_t> _texture_ids;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "ModelView.hpp"
|
||||
#include <opengl/scoped.hpp>
|
||||
#include <math/projection.hpp>
|
||||
#include <noggit/Selection.h>
|
||||
#include <noggit/tool_enums.hpp>
|
||||
#include <noggit/ContextObject.hpp>
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
#include <QElapsedTimer>
|
||||
#include <QTimer>
|
||||
#include <QStringList>
|
||||
|
||||
#include <math/matrix_4x4.hpp>
|
||||
#include <math/vector_3d.hpp>
|
||||
#include <noggit/camera.hpp>
|
||||
#include <noggit/WMOInstance.h>
|
||||
#include <noggit/Selection.h>
|
||||
@@ -22,7 +20,6 @@
|
||||
#include <noggit/Model.h>
|
||||
#include <noggit/Red/PreviewRenderer/PreviewRenderer.hpp>
|
||||
|
||||
|
||||
namespace noggit
|
||||
{
|
||||
namespace Red::AssetBrowser
|
||||
|
||||
@@ -229,7 +229,7 @@ void BrushStack::addAction(BrushStackItem* brush_stack_item)
|
||||
|
||||
}
|
||||
|
||||
void BrushStack::execute(math::vector_3d const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map)
|
||||
void BrushStack::execute(glm::vec3 const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map)
|
||||
{
|
||||
for (int i = 0; i < _ui.brushList->layout()->count(); ++i)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <QWidget>
|
||||
#include <QComboBox>
|
||||
#include <QButtonGroup>
|
||||
#include <math/vector_3d.hpp>
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
@@ -24,7 +23,7 @@ namespace noggit::Red
|
||||
public:
|
||||
BrushStack(MapView* map_view, QWidget* parent = nullptr);
|
||||
|
||||
void execute(math::vector_3d const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map);
|
||||
void execute(glm::vec3 const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map);
|
||||
|
||||
void changeRadius(float change);
|
||||
void changeInnerRadius(float change);
|
||||
|
||||
@@ -386,7 +386,7 @@ void BrushStackItem::setMaskRotation(int rot)
|
||||
}
|
||||
}
|
||||
|
||||
void BrushStackItem::execute(math::vector_3d const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map)
|
||||
void BrushStackItem::execute(glm::vec3 const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map)
|
||||
{
|
||||
auto action = noggit::ActionManager::instance()->getCurrentAction();
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include <noggit/ui/ZoneIDBrowser.h>
|
||||
#include <noggit/ui/Water.h>
|
||||
#include <noggit/ui/TexturingGUI.h>
|
||||
#include <math/vector_3d.hpp>
|
||||
|
||||
|
||||
class World;
|
||||
|
||||
@@ -58,7 +56,7 @@ namespace noggit::Red
|
||||
void setSpeed(float speed);
|
||||
void setMaskRotation(int rot);
|
||||
void setBrushMode(bool sculpt);
|
||||
void execute(math::vector_3d const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map);
|
||||
void execute(glm::vec3 const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map);
|
||||
void syncSliders(double radius, double inner_radius, double speed, int rot, int brushMode);
|
||||
|
||||
bool isRadiusAffecting() { return _is_radius_affecting->isChecked(); };
|
||||
|
||||
@@ -200,7 +200,7 @@ void ChunkAddDetailDoodads::compute()
|
||||
subchunkStatuses |= mask;
|
||||
unsigned const curOfs{curSplat[1] * 17 + curSplat[0]};
|
||||
using namespace math;
|
||||
vector_3d const* curOrigin{chunk->getHeightmap() + curOfs};
|
||||
glm::vec3 const* curOrigin{chunk->getHeightmap() + curOfs};
|
||||
float const ref{curOrigin[9].y};
|
||||
std::array<float, 2> rels;
|
||||
std::array<float, 2> relHs;
|
||||
@@ -331,7 +331,7 @@ void ChunkAddDetailDoodads::compute()
|
||||
filename = filename.replace(".mdx", ".m2", Qt::CaseInsensitive);
|
||||
|
||||
world->addM2(filename.toStdString(), {chunk->xbase - inMinichunkCoords[0]
|
||||
, 0, chunk->zbase - inMinichunkCoords[1]}, 1.0, {0_deg, 0_deg, 0_deg}, nullptr);
|
||||
, 0, chunk->zbase - inMinichunkCoords[1]}, 1.0, {math::degrees(0)._, math::degrees(0)._, math::degrees(0)._ }, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ void ChunkGetHeightmapNode::compute()
|
||||
|
||||
MapChunk* chunk = defaultPortData<ChunkData>(PortType::In, 1)->value();
|
||||
|
||||
math::vector_3d* heightmap = chunk->getHeightmap();
|
||||
glm::vec3* heightmap = chunk->getHeightmap();
|
||||
|
||||
_heightmap.clear();
|
||||
_heightmap.resize(mapbufsize);
|
||||
|
||||
@@ -30,14 +30,14 @@ void ChunkGetVertexColorsNode::compute()
|
||||
opengl::context::scoped_setter const _ (::gl, gCurrentContext->getViewport()->context());
|
||||
|
||||
MapChunk* chunk = defaultPortData<ChunkData>(PortType::In, 1)->value();
|
||||
math::vector_3d* colors = chunk->getVertexColors();
|
||||
glm::vec3* colors = chunk->getVertexColors();
|
||||
|
||||
_colors.clear();
|
||||
_colors.resize(mapbufsize);
|
||||
|
||||
for (int i = 0; i < mapbufsize; ++i)
|
||||
{
|
||||
math::vector_3d& color = colors[i];
|
||||
glm::vec3& color = colors[i];
|
||||
_colors[i] = std::make_shared<ColorData>(glm::vec4(color.x, color.y, color.z, 1.0));
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ void ChunkSetHeightmapNode::compute()
|
||||
MapChunk* chunk = defaultPortData<ChunkData>(PortType::In, 1)->value();
|
||||
auto list = defaultPortData<ListData>(PortType::In, 2)->value();
|
||||
|
||||
math::vector_3d* heightmap = chunk->getHeightmap();
|
||||
glm::vec3* heightmap = chunk->getHeightmap();
|
||||
|
||||
for (int i = 0; i < mapbufsize; ++i)
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ void ChunkSetVertexColorsNode::compute()
|
||||
MapChunk* chunk = defaultPortData<ChunkData>(PortType::In, 1)->value();
|
||||
auto list = defaultPortData<ListData>(PortType::In, 2)->value();
|
||||
|
||||
math::vector_3d* colors = chunk->getVertexColors();
|
||||
glm::vec3* colors = chunk->getVertexColors();
|
||||
|
||||
for (int i = 0; i < mapbufsize; ++i)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ void GetChunkFromPosNode::compute()
|
||||
auto pos_data = defaultPortData<Vector3DData>(PortType::In, 1);
|
||||
glm::vec3 const& pos = pos_data->value();
|
||||
|
||||
math::vector_3d n_pos(pos.x, pos.y, pos.z);
|
||||
glm::vec3 n_pos(pos.x, pos.y, pos.z);
|
||||
|
||||
MapTile* tile(world->mapIndex.getTile(n_pos));
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ void GetTileFromPosNode::compute()
|
||||
auto pos_data = defaultPortData<Vector3DData>(PortType::In, 1);
|
||||
glm::vec3 const& pos = pos_data->value();
|
||||
|
||||
math::vector_3d n_pos(pos.x, pos.y, pos.z);
|
||||
glm::vec3 n_pos(pos.x, pos.y, pos.z);
|
||||
|
||||
world->mapIndex.loadTile(n_pos);
|
||||
MapTile* tile(world->mapIndex.getTile(n_pos));
|
||||
|
||||
@@ -34,7 +34,7 @@ void HasTileAtPosNode::compute()
|
||||
_out_ports[0].out_value = std::make_shared<LogicData>(true);
|
||||
_node->onDataUpdated(0);
|
||||
|
||||
_out_ports[1].out_value = std::make_shared<BooleanData>(world->mapIndex.hasTile(math::vector_3d(pos.x, pos.y, pos.z)));
|
||||
_out_ports[1].out_value = std::make_shared<BooleanData>(world->mapIndex.hasTile(glm::vec3(pos.x, pos.y, pos.z)));
|
||||
_node->onDataUpdated(1);
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ void CropWaterADTAtPosNode::compute()
|
||||
auto pos_data = defaultPortData<Vector3DData>(PortType::In, 1);
|
||||
glm::vec3 const& pos = pos_data->value();
|
||||
|
||||
math::vector_3d n_pos(pos.x, pos.y, pos.z);
|
||||
glm::vec3 n_pos(pos.x, pos.y, pos.z);
|
||||
|
||||
world->mapIndex.loadTile(n_pos);
|
||||
MapTile* tile(world->mapIndex.getTile(n_pos));
|
||||
|
||||
@@ -31,7 +31,7 @@ void GetWaterTypeNode::compute()
|
||||
|
||||
unsigned layer = defaultPortData<UnsignedIntegerData>(PortType::In, 1)->value();
|
||||
|
||||
math::vector_3d n_pos(pos.x, pos.y, pos.z);
|
||||
glm::vec3 n_pos(pos.x, pos.y, pos.z);
|
||||
|
||||
world->mapIndex.loadTile(n_pos);
|
||||
MapTile* tile(world->mapIndex.getTile(n_pos));
|
||||
|
||||
@@ -46,7 +46,7 @@ void SetWaterTypeNode::compute()
|
||||
|
||||
unsigned layer = defaultPortData<UnsignedIntegerData>(PortType::In, 2)->value();
|
||||
|
||||
math::vector_3d n_pos(pos.x, pos.y, pos.z);
|
||||
glm::vec3 n_pos(pos.x, pos.y, pos.z);
|
||||
|
||||
world->mapIndex.loadTile(n_pos);
|
||||
MapTile* tile(world->mapIndex.getTile(n_pos));
|
||||
|
||||
@@ -58,11 +58,11 @@ void AddObjectInstanceNode::compute()
|
||||
if (QString(path.c_str()).endsWith(".m2", Qt::CaseInsensitive))
|
||||
{
|
||||
noggit::object_paste_params paste_params;
|
||||
obj = world->addM2AndGetInstance(path, {pos.x, pos.y, pos.z}, scale, {math::degrees(dir.x), math::degrees(dir.y), math::degrees(dir.z)}, &paste_params);
|
||||
obj = world->addM2AndGetInstance(path, {pos.x, pos.y, pos.z}, scale, {math::degrees(dir.x)._, math::degrees(dir.y)._, math::degrees(dir.z)._ }, &paste_params);
|
||||
}
|
||||
else if (QString(path.c_str()).endsWith(".wmo", Qt::CaseInsensitive))
|
||||
{
|
||||
obj = world->addWMOAndGetInstance(path, {pos.x, pos.y, pos.z}, {math::degrees(dir.x), math::degrees(dir.y), math::degrees(dir.z)});
|
||||
obj = world->addWMOAndGetInstance(path, {pos.x, pos.y, pos.z}, {math::degrees(dir.x)._, math::degrees(dir.y)._, math::degrees(dir.z)._ });
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -36,13 +36,13 @@ void ObjectInstanceInfoNode::compute()
|
||||
|
||||
if (_out_ports[0].connected)
|
||||
{
|
||||
_out_ports[0].out_value = std::make_shared<Vector3DData>(glm::vec3(obj->pos.x, obj->pos.y, obj->pos.z));
|
||||
_out_ports[0].out_value = std::make_shared<Vector3DData>(obj->pos);
|
||||
_node->onDataUpdated(0);
|
||||
}
|
||||
|
||||
if (_out_ports[1].connected)
|
||||
{
|
||||
_out_ports[1].out_value = std::make_shared<Vector3DData>(glm::vec3(obj->dir.x._, obj->dir.y._, obj->dir.z._));
|
||||
_out_ports[1].out_value = std::make_shared<Vector3DData>(obj->dir);
|
||||
_node->onDataUpdated(1);
|
||||
}
|
||||
|
||||
@@ -54,17 +54,13 @@ void ObjectInstanceInfoNode::compute()
|
||||
|
||||
if (_out_ports[3].connected)
|
||||
{
|
||||
_out_ports[3].out_value = std::make_shared<Vector3DData>(glm::vec3(obj->extents[0].x,
|
||||
obj->extents[0].y,
|
||||
obj->extents[0].z));
|
||||
_out_ports[3].out_value = std::make_shared<Vector3DData>(obj->extents[0]);
|
||||
_node->onDataUpdated(3);
|
||||
}
|
||||
|
||||
if (_out_ports[4].connected)
|
||||
{
|
||||
_out_ports[4].out_value = std::make_shared<Vector3DData>(glm::vec3(obj->extents[1].x,
|
||||
obj->extents[1].y,
|
||||
obj->extents[1].z));
|
||||
_out_ports[4].out_value = std::make_shared<Vector3DData>(obj->extents[1]);
|
||||
_node->onDataUpdated(4);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ void ObjectInstanceSetRotationNode::compute()
|
||||
auto rot_data = defaultPortData<Vector3DData>(PortType::In, 2);
|
||||
glm::vec3 const& rotation = rot_data->value();
|
||||
|
||||
obj->dir.x = math::degrees(rotation.x);
|
||||
obj->dir.y = math::degrees(rotation.y);
|
||||
obj->dir.z = math::degrees(rotation.z);
|
||||
obj->dir.x = math::degrees(rotation.x)._;
|
||||
obj->dir.y = math::degrees(rotation.y)._;
|
||||
obj->dir.z = math::degrees(rotation.z)._;
|
||||
|
||||
obj->recalcExtents();
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ void TileGetVertexNode::compute()
|
||||
auto xy_data = defaultPortData<Vector2DData>(PortType::In, 2);
|
||||
glm::vec2 const& xy = xy_data->value();
|
||||
|
||||
math::vector_3d n_pos(0.0f, 0.0f, 0.0f);
|
||||
glm::vec3 n_pos(0.0f, 0.0f, 0.0f);
|
||||
|
||||
tile->GetVertex(xy.x, xy.y, &n_pos);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "ModelView.hpp"
|
||||
#include <math/projection.hpp>
|
||||
#include <external/qtimgui/imgui/imgui.h>
|
||||
#include <external/imguizmo/ImGuizmo.h>
|
||||
|
||||
@@ -31,16 +30,16 @@ void ModelViewer::paintGL()
|
||||
|
||||
if (_world)
|
||||
{
|
||||
_world->draw(world_model_view().transposed()
|
||||
, world_projection().transposed()
|
||||
, math::vector_3d(0.f, 0.f, 0.f)
|
||||
_world->draw(world_model_view()
|
||||
, world_projection()
|
||||
, glm::vec3(0.f, 0.f, 0.f)
|
||||
, 0.f
|
||||
, math::vector_4d(1.f, 1.f, 1.f, 1.f)
|
||||
, glm::vec4(1.f, 1.f, 1.f, 1.f)
|
||||
, CursorType::CIRCLE
|
||||
, 0.f
|
||||
, false
|
||||
, 0.f
|
||||
, math::vector_3d(0.f, 0.f, 0.f)
|
||||
, glm::vec3(0.f, 0.f, 0.f)
|
||||
, 0.f
|
||||
, 0.f
|
||||
, false
|
||||
@@ -122,15 +121,15 @@ void ModelViewer::loadWorldUnderlay(const std::string& internal_name, int map_id
|
||||
|
||||
}
|
||||
|
||||
math::matrix_4x4 ModelViewer::world_model_view() const
|
||||
glm::mat4x4 ModelViewer::world_model_view() const
|
||||
{
|
||||
return _world_camera.look_at_matrix();
|
||||
}
|
||||
|
||||
math::matrix_4x4 ModelViewer::world_projection() const
|
||||
glm::mat4x4 ModelViewer::world_projection() const
|
||||
{
|
||||
float far_z = _settings->value("farZ", 2048).toFloat();
|
||||
return math::perspective(_world_camera.fov(), aspect_ratio(), 0.1f, far_z);
|
||||
return glm::perspective(_camera.fov()._, aspect_ratio(), 1.f, far_z);
|
||||
}
|
||||
|
||||
void ModelViewer::tick(float dt)
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace noggit
|
||||
|
||||
void tick(float dt) override;
|
||||
|
||||
math::matrix_4x4 world_model_view() const;
|
||||
math::matrix_4x4 world_projection() const;
|
||||
glm::mat4x4 world_model_view() const;
|
||||
glm::mat4x4 world_projection() const;
|
||||
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ void PresetEditorWidget::setupConnectsCommon()
|
||||
);
|
||||
|
||||
connect(ui->minimapWidget, &minimap_widget::map_clicked
|
||||
, [this] (::math::vector_3d const& pos)
|
||||
, [this] (::glm::vec3 const& pos)
|
||||
{
|
||||
ui->viewport->getWorldCamera()->position = pos;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <opengl/scoped.hpp>
|
||||
#include <opengl/primitives.hpp>
|
||||
#include <math/projection.hpp>
|
||||
#include <noggit/Selection.h>
|
||||
#include <noggit/tool_enums.hpp>
|
||||
#include <noggit/AsyncLoader.h>
|
||||
@@ -25,7 +24,7 @@ using namespace noggit::Red;
|
||||
|
||||
PreviewRenderer::PreviewRenderer(int width, int height, noggit::NoggitRenderContext context, QWidget* parent)
|
||||
: noggit::Red::ViewportManager::Viewport(parent)
|
||||
, _camera (math::vector_3d(0.0f, 0.0f, 0.0f), math::degrees(0.0f), math::degrees(0.0f))
|
||||
, _camera (glm::vec3(0.0f, 0.0f, 0.0f), math::degrees(0.0f), math::degrees(0.0f))
|
||||
, _settings (new QSettings())
|
||||
, _width(width)
|
||||
, _height(height)
|
||||
@@ -45,7 +44,7 @@ PreviewRenderer::PreviewRenderer(int width, int height, noggit::NoggitRenderCont
|
||||
|
||||
opengl::context::scoped_setter const context_set (::gl, &_offscreen_context);
|
||||
|
||||
_light_dir = math::vector_3d(0.0f, 1.0f, 0.0f);
|
||||
_light_dir = glm::vec3(0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
|
||||
void PreviewRenderer::setModel(std::string const &filename)
|
||||
@@ -113,7 +112,7 @@ void PreviewRenderer::resetCamera(float x, float y, float z, float roll, float y
|
||||
_camera.reset(x, y, z, roll, yaw, pitch);
|
||||
float radius = 0.f;
|
||||
|
||||
std::vector<math::vector_3d> extents = calcSceneExtents();
|
||||
std::vector<glm::vec3> extents = calcSceneExtents();
|
||||
_camera.position = (extents[0] + extents[1]) / 2.0f;
|
||||
radius = std::max((_camera.position - extents[0]).length(), (_camera.position - extents[1]).length());
|
||||
|
||||
@@ -130,7 +129,7 @@ void PreviewRenderer::draw()
|
||||
|
||||
float culldistance = 10000000;
|
||||
|
||||
math::matrix_4x4 const mvp(model_view().transposed() * projection().transposed());
|
||||
glm::mat4x4 const mvp(model_view() * projection());
|
||||
math::frustum const frustum (mvp);
|
||||
|
||||
if (!_m2_program)
|
||||
@@ -211,10 +210,10 @@ void PreviewRenderer::draw()
|
||||
//water_shader.uniform("model_view", model_view().transposed());
|
||||
//water_shader.uniform("projection", projection().transposed());
|
||||
|
||||
math::vector_4d ocean_color_light(math::vector_3d(1.0f, 1.0f, 1.0f), 1.f);
|
||||
math::vector_4d ocean_color_dark(math::vector_3d(1.0f, 1.0f, 1.0f), 1.f);
|
||||
math::vector_4d river_color_light(math::vector_3d(1.0f, 1.0f, 1.0f), 1.f);
|
||||
math::vector_4d river_color_dark(math::vector_3d(1.0f, 1.0f, 1.0f), 1.f);
|
||||
glm::vec4ocean_color_light(glm::vec3(1.0f, 1.0f, 1.0f), 1.f);
|
||||
glm::vec4ocean_color_dark(glm::vec3(1.0f, 1.0f, 1.0f), 1.f);
|
||||
glm::vec4river_color_light(glm::vec3(1.0f, 1.0f, 1.0f), 1.f);
|
||||
glm::vec4river_color_dark(glm::vec3(1.0f, 1.0f, 1.0f), 1.f);
|
||||
|
||||
//water_shader.uniform("ocean_color_light", ocean_color_light);
|
||||
//water_shader.uniform("ocean_color_dark", ocean_color_dark);
|
||||
@@ -242,8 +241,8 @@ void PreviewRenderer::draw()
|
||||
for (auto& wmo_instance : _wmo_instances)
|
||||
{
|
||||
wmo_instance.draw(
|
||||
wmo_program, model_view().transposed(), projection().transposed(), frustum, culldistance,
|
||||
math::vector_3d(0.0f, 0.0f, 0.0f), _draw_boxes.get(), _draw_models.get() // doodads
|
||||
wmo_program, model_view(), projection(), frustum, culldistance,
|
||||
glm::vec3(0.0f, 0.0f, 0.0f), _draw_boxes.get(), _draw_models.get() // doodads
|
||||
, false, std::vector<selection_type>(), 0, false, display_mode::in_3D
|
||||
);
|
||||
|
||||
@@ -339,19 +338,19 @@ void PreviewRenderer::draw()
|
||||
{
|
||||
opengl::scoped::use_program m2_box_shader{ *_m2_box_program.get() };
|
||||
|
||||
m2_box_shader.uniform ("model_view", model_view().transposed());
|
||||
m2_box_shader.uniform ("projection", projection().transposed());
|
||||
m2_box_shader.uniform ("model_view", model_view());
|
||||
m2_box_shader.uniform("projection", projection());
|
||||
|
||||
opengl::scoped::bool_setter<GL_LINE_SMOOTH, GL_TRUE> const line_smooth;
|
||||
gl.hint (GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||
|
||||
for (auto& it : model_boxes_to_draw)
|
||||
{
|
||||
math::vector_4d color = it.first->is_hidden()
|
||||
? math::vector_4d(0.f, 0.f, 1.f, 1.f)
|
||||
glm::vec4 color = it.first->is_hidden()
|
||||
? glm::vec4(0.f, 0.f, 1.f, 1.f)
|
||||
: ( it.first->use_fake_geometry()
|
||||
? math::vector_4d(1.f, 0.f, 0.f, 1.f)
|
||||
: math::vector_4d(0.75f, 0.75f, 0.75f, 1.f)
|
||||
? glm::vec4(1.f, 0.f, 0.f, 1.f)
|
||||
: glm::vec4(0.75f, 0.75f, 0.75f, 1.f)
|
||||
)
|
||||
;
|
||||
|
||||
@@ -410,22 +409,22 @@ void PreviewRenderer::draw()
|
||||
|
||||
if (_draw_grid.get())
|
||||
{
|
||||
_grid.draw(mvp, math::vector_3d(0.f, 0.f, 0.f),
|
||||
math::vector_4d(0.7f, 0.7f, 0.7f, 1.0f), 30.f);
|
||||
_grid.draw(mvp, glm::vec3(0.f, 0.f, 0.f),
|
||||
glm::vec4(0.7f, 0.7f, 0.7f, 1.0f), 30.f);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
math::matrix_4x4 PreviewRenderer::model_view() const
|
||||
glm::mat4x4 PreviewRenderer::model_view() const
|
||||
{
|
||||
return _camera.look_at_matrix();
|
||||
}
|
||||
|
||||
math::matrix_4x4 PreviewRenderer::projection() const
|
||||
glm::mat4x4 PreviewRenderer::projection() const
|
||||
{
|
||||
float far_z = _settings->value("farZ", 2048).toFloat();
|
||||
return math::perspective(_camera.fov(), aspect_ratio(), 0.1f, far_z);
|
||||
return glm::perspective(_camera.fov()._, aspect_ratio(), 1.f, far_z);
|
||||
}
|
||||
|
||||
float PreviewRenderer::aspect_ratio() const
|
||||
@@ -433,13 +432,13 @@ float PreviewRenderer::aspect_ratio() const
|
||||
return static_cast<float>(_width) / static_cast<float>(_height);
|
||||
}
|
||||
|
||||
std::vector<math::vector_3d> PreviewRenderer::calcSceneExtents()
|
||||
std::vector<glm::vec3> PreviewRenderer::calcSceneExtents()
|
||||
{
|
||||
math::vector_3d min = {std::numeric_limits<float>::max(),
|
||||
glm::vec3 min = {std::numeric_limits<float>::max(),
|
||||
std::numeric_limits<float>::max(),
|
||||
std::numeric_limits<float>::max()};
|
||||
|
||||
math::vector_3d max = {std::numeric_limits<float>::min(),
|
||||
glm::vec3 max = {std::numeric_limits<float>::min(),
|
||||
std::numeric_limits<float>::min(),
|
||||
std::numeric_limits<float>::min()};
|
||||
|
||||
@@ -461,7 +460,7 @@ std::vector<math::vector_3d> PreviewRenderer::calcSceneExtents()
|
||||
}
|
||||
}
|
||||
|
||||
return std::move(std::vector<math::vector_3d>{min, max});
|
||||
return std::move(std::vector<glm::vec3>{min, max});
|
||||
}
|
||||
|
||||
QPixmap* PreviewRenderer::renderToPixmap()
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define NOGGIT_PREVIEWRENDERER_HPP
|
||||
|
||||
#include <math/matrix_4x4.hpp>
|
||||
#include <math/vector_3d.hpp>
|
||||
#include <noggit/camera.hpp>
|
||||
#include <noggit/WMOInstance.h>
|
||||
#include <noggit/ModelInstance.h>
|
||||
@@ -74,11 +73,11 @@ class PreviewRenderer : public noggit::Red::ViewportManager::Viewport
|
||||
|
||||
bool _destroying = false;
|
||||
|
||||
std::vector<math::vector_3d> calcSceneExtents();
|
||||
std::vector<glm::vec3> calcSceneExtents();
|
||||
virtual void draw();
|
||||
virtual void tick(float dt);
|
||||
virtual math::matrix_4x4 model_view() const;
|
||||
virtual math::matrix_4x4 projection() const;
|
||||
virtual glm::mat4x4 model_view() const;
|
||||
virtual glm::mat4x4 projection() const;
|
||||
virtual float aspect_ratio() const;
|
||||
|
||||
void update_emitters(float dt);
|
||||
@@ -97,10 +96,10 @@ class PreviewRenderer : public noggit::Red::ViewportManager::Viewport
|
||||
QOpenGLFramebufferObjectFormat _fmt;
|
||||
QOffscreenSurface _offscreen_surface;
|
||||
|
||||
math::vector_3d _background_color;
|
||||
math::vector_3d _diffuse_light;
|
||||
math::vector_3d _ambient_light;
|
||||
math::vector_3d _light_dir;
|
||||
glm::vec3 _background_color;
|
||||
glm::vec3 _diffuse_light;
|
||||
glm::vec3 _ambient_light;
|
||||
glm::vec3 _light_dir;
|
||||
|
||||
bool _gl_initialized = false;
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ auto Tool::getInnerRadius(void) const -> float
|
||||
return _radiusInner;
|
||||
}
|
||||
|
||||
auto Tool::stamp(World* world, math::vector_3d const& pos, float dt, bool doAdd) const -> void
|
||||
auto Tool::stamp(World* world, glm::vec3 const& pos, float dt, bool doAdd) const -> void
|
||||
{
|
||||
if(!_curPixmap)
|
||||
return;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <QSlider>
|
||||
#include <QDial>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
class QPixmap;
|
||||
class World;
|
||||
@@ -31,7 +32,7 @@ namespace noggit
|
||||
Tool(bool_toggle_property* showPalette, float* cursorRotation, QWidget* parent = nullptr);
|
||||
auto getOuterRadius(void) const -> float;
|
||||
auto getInnerRadius(void) const -> float;
|
||||
auto stamp(World* world, math::vector_3d const& pos, float dt, bool doAdd) const -> void;
|
||||
auto stamp(World* world, glm::vec3 const& pos, float dt, bool doAdd) const -> void;
|
||||
public slots:
|
||||
void setPixmap(QPixmap const* pixmap);
|
||||
private:
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "noggit/WMOInstance.h"
|
||||
#include "noggit/ActionManager.hpp"
|
||||
#include "noggit/Action.hpp"
|
||||
#include "math/vector_3d.hpp"
|
||||
#include "external/glm/glm.hpp"
|
||||
#include <external/glm/gtx/matrix_decompose.hpp>
|
||||
#include <external/glm/gtc/type_ptr.hpp>
|
||||
@@ -23,8 +22,8 @@ ViewportGizmo::ViewportGizmo(noggit::Red::ViewportGizmo::GizmoContext gizmo_cont
|
||||
|
||||
void ViewportGizmo::handleTransformGizmo(MapView* map_view
|
||||
, const std::vector<selection_type>& selection
|
||||
, math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection)
|
||||
, glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection)
|
||||
{
|
||||
|
||||
if (!isUsing())
|
||||
@@ -34,8 +33,8 @@ void ViewportGizmo::handleTransformGizmo(MapView* map_view
|
||||
|
||||
GizmoInternalMode gizmo_selection_type;
|
||||
|
||||
auto model_view_trs = model_view.transposed();
|
||||
auto projection_trs = projection.transposed();
|
||||
auto model_view_trs = model_view;
|
||||
auto projection_trs = projection;
|
||||
|
||||
int n_selected = selection.size();
|
||||
|
||||
@@ -80,7 +79,7 @@ void ViewportGizmo::handleTransformGizmo(MapView* map_view
|
||||
obj_instance = boost::get<selected_object_type>(selection[0]);
|
||||
obj_instance->recalcExtents();
|
||||
object_matrix = obj_instance->transformMatrixTransposed();
|
||||
ImGuizmo::Manipulate(model_view_trs, projection_trs, _gizmo_operation, _gizmo_mode, object_matrix, delta_matrix, nullptr);
|
||||
ImGuizmo::Manipulate(glm::value_ptr(model_view_trs), glm::value_ptr(projection_trs), _gizmo_operation, _gizmo_mode, object_matrix, delta_matrix, nullptr);
|
||||
break;
|
||||
}
|
||||
case MULTISELECTION:
|
||||
@@ -88,7 +87,7 @@ void ViewportGizmo::handleTransformGizmo(MapView* map_view
|
||||
if (isUsing())
|
||||
_last_pivot_scale = ImGuizmo::GetOperationScaleLast();
|
||||
|
||||
ImGuizmo::Manipulate(model_view_trs, projection_trs, _gizmo_operation, _gizmo_mode, pivot_matrix, delta_matrix, nullptr);
|
||||
ImGuizmo::Manipulate(glm::value_ptr(model_view_trs), glm::value_ptr(projection_trs), _gizmo_operation, _gizmo_mode, pivot_matrix, delta_matrix, nullptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -118,7 +117,7 @@ void ViewportGizmo::handleTransformGizmo(MapView* map_view
|
||||
|
||||
glm::mat4 glm_transform_mat = glm::make_mat4(static_cast<float*>(delta_matrix));
|
||||
|
||||
math::vector_3d& pos = obj_instance->pos;
|
||||
glm::vec3& pos = obj_instance->pos;
|
||||
math::degrees::vec3& rotation = obj_instance->dir;
|
||||
float wmo_scale = 0.f;
|
||||
float& scale = obj_instance->which() == eMODEL ? obj_instance->scale : wmo_scale;
|
||||
@@ -146,7 +145,7 @@ void ViewportGizmo::handleTransformGizmo(MapView* map_view
|
||||
{
|
||||
case ImGuizmo::TRANSLATE:
|
||||
{
|
||||
pos += {new_translation.x, new_translation.y, new_translation.z};
|
||||
pos += glm::vec3(new_translation.x, new_translation.y, new_translation.z);
|
||||
break;
|
||||
}
|
||||
case ImGuizmo::ROTATE:
|
||||
@@ -156,12 +155,12 @@ void ViewportGizmo::handleTransformGizmo(MapView* map_view
|
||||
|
||||
if (!_use_multiselection_pivot)
|
||||
{
|
||||
rotation += {math::degrees(rot_euler.x), math::degrees(rot_euler.y), math::degrees(rot_euler.z)};
|
||||
rotation += glm::vec3(math::degrees(rot_euler.x)._, math::degrees(rot_euler.y)._, math::degrees(rot_euler.z)._);
|
||||
}
|
||||
else
|
||||
{
|
||||
//LogDebug << rot_euler.x << " " << rot_euler.y << " " << rot_euler.z << std::endl;
|
||||
rotation.y += math::degrees(rot_euler.y);
|
||||
rotation.y += math::degrees(rot_euler.y)._;
|
||||
|
||||
// building model matrix
|
||||
glm::mat4 model_transform = glm::make_mat4(static_cast<float*>(object_matrix));
|
||||
@@ -237,7 +236,7 @@ void ViewportGizmo::handleTransformGizmo(MapView* map_view
|
||||
|
||||
glm::mat4 glm_transform_mat = glm::make_mat4(static_cast<float*>(delta_matrix));
|
||||
|
||||
math::vector_3d& pos = obj_instance->pos;
|
||||
glm::vec3& pos = obj_instance->pos;
|
||||
math::degrees::vec3& rotation = obj_instance->dir;
|
||||
float wmo_scale = 0.f;
|
||||
float& scale = obj_instance->which() == eMODEL ? obj_instance->scale : wmo_scale;
|
||||
@@ -266,13 +265,13 @@ void ViewportGizmo::handleTransformGizmo(MapView* map_view
|
||||
|
||||
case ImGuizmo::TRANSLATE:
|
||||
{
|
||||
pos += {new_translation.x, new_translation.y, new_translation.z};
|
||||
pos += glm::vec3(new_translation.x, new_translation.y, new_translation.z);
|
||||
break;
|
||||
}
|
||||
case ImGuizmo::ROTATE:
|
||||
{
|
||||
auto rot_euler = glm::eulerAngles(new_orientation) * 57.2957795f;
|
||||
rotation += {math::degrees(rot_euler.x), math::degrees(rot_euler.y), math::degrees(rot_euler.z)};
|
||||
rotation += glm::vec3(math::degrees(rot_euler.x)._, math::degrees(rot_euler.y)._, math::degrees(rot_euler.z)._);
|
||||
break;
|
||||
}
|
||||
case ImGuizmo::SCALE:
|
||||
|
||||
@@ -41,15 +41,15 @@ namespace noggit
|
||||
|
||||
void handleTransformGizmo(MapView* map_view
|
||||
, std::vector<selection_type> const& selection
|
||||
, math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection);
|
||||
, glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection);
|
||||
|
||||
void setCurrentGizmoOperation(ImGuizmo::OPERATION operation) { _gizmo_operation = operation; }
|
||||
void setCurrentGizmoMode(ImGuizmo::MODE mode) { _gizmo_mode = mode; }
|
||||
bool isOver() {ImGuizmo::SetID(_gizmo_context); return ImGuizmo::IsOver();};
|
||||
bool isUsing() {ImGuizmo::SetID(_gizmo_context); return ImGuizmo::IsUsing();};
|
||||
void setUseMultiselectionPivot(bool use_pivot) { _use_multiselection_pivot = use_pivot; };
|
||||
void setMultiselectionPivot(math::vector_3d const& pivot) { _multiselection_pivot = pivot; };
|
||||
void setMultiselectionPivot(glm::vec3 const& pivot) { _multiselection_pivot = pivot; };
|
||||
void setWorld(World* world) { _world = world; }
|
||||
|
||||
private:
|
||||
@@ -59,7 +59,7 @@ namespace noggit
|
||||
ImGuizmo::MODE _gizmo_mode;
|
||||
GizmoContext _gizmo_context;
|
||||
bool _use_multiselection_pivot;
|
||||
math::vector_3d _multiselection_pivot;
|
||||
glm::vec3 _multiselection_pivot;
|
||||
float _last_pivot_scale;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ SceneObject::SceneObject(SceneObjectTypes type, noggit::NoggitRenderContext cont
|
||||
{
|
||||
}
|
||||
|
||||
bool SceneObject::isInsideRect(math::vector_3d rect[2]) const
|
||||
bool SceneObject::isInsideRect(glm::vec3 rect[2]) const
|
||||
{
|
||||
return misc::rectOverlap(extents, rect);
|
||||
}
|
||||
@@ -30,7 +30,7 @@ void SceneObject::updateTransformMatrix()
|
||||
* math::matrix_4x4
|
||||
( math::matrix_4x4::rotation_yzx
|
||||
, { -dir.z
|
||||
, dir.y - 90.0_deg
|
||||
, dir.y - math::degrees(90.0)._
|
||||
, dir.x
|
||||
})
|
||||
|
||||
@@ -44,7 +44,7 @@ void SceneObject::updateTransformMatrix()
|
||||
|
||||
void SceneObject::resetDirection()
|
||||
{
|
||||
dir = math::degrees::vec3(0_deg, dir.y, 0.0_deg);
|
||||
dir = math::degrees::vec3(math::degrees(0)._, dir.y, math::degrees(0)._);
|
||||
recalcExtents();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#ifndef NOGGIT_3DOBJECT_HPP
|
||||
#define NOGGIT_3DOBJECT_HPP
|
||||
|
||||
#include <math/vector_3d.hpp>
|
||||
#include <math/matrix_4x4.hpp>
|
||||
#include <math/ray.hpp>
|
||||
#include <noggit/Selection.h>
|
||||
@@ -27,7 +26,7 @@ public:
|
||||
SceneObject(SceneObjectTypes type, noggit::NoggitRenderContext context, std::string filename = "");
|
||||
|
||||
[[nodiscard]]
|
||||
bool isInsideRect(math::vector_3d rect[2]) const;
|
||||
bool isInsideRect(glm::vec3 rect[2]) const;
|
||||
|
||||
[[nodiscard]]
|
||||
bool isDuplicateOf(SceneObject const& other);
|
||||
@@ -60,9 +59,9 @@ public:
|
||||
virtual AsyncObject* instance_model() = 0;
|
||||
|
||||
public:
|
||||
math::vector_3d pos;
|
||||
math::vector_3d extents[2];
|
||||
math::degrees::vec3 dir;
|
||||
glm::vec3 pos;
|
||||
glm::vec3 extents[2];
|
||||
glm::vec3 dir;
|
||||
float scale = 1.f;
|
||||
unsigned int uid;
|
||||
int frame;
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/vector_3d.hpp>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <glm/vec3.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -14,7 +10,7 @@ class MapChunk;
|
||||
|
||||
struct selected_chunk_type
|
||||
{
|
||||
selected_chunk_type(MapChunk* _chunk, std::tuple<int, int, int> _triangle, math::vector_3d _position)
|
||||
selected_chunk_type(MapChunk* _chunk, std::tuple<int, int, int> _triangle, glm::vec3 _position)
|
||||
: chunk(_chunk)
|
||||
, triangle(_triangle)
|
||||
, position(_position)
|
||||
@@ -22,7 +18,7 @@ struct selected_chunk_type
|
||||
|
||||
MapChunk* chunk;
|
||||
std::tuple<int,int,int> triangle; // mVertices[i] points of the hit triangle
|
||||
math::vector_3d position;
|
||||
glm::vec3 position;
|
||||
|
||||
bool operator== (selected_chunk_type const& other) const
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <noggit/Sky.h>
|
||||
#include <noggit/World.h>
|
||||
#include <opengl/shader.hpp>
|
||||
#include <external/glm/glm.hpp>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
@@ -33,7 +33,7 @@ Sky::Sky(DBCFile::Iterator data, noggit::NoggitRenderContext context)
|
||||
: _context(context)
|
||||
, _selected(false)
|
||||
{
|
||||
pos = math::vector_3d(data->getFloat(LightDB::PositionX) / skymul, data->getFloat(LightDB::PositionY) / skymul, data->getFloat(LightDB::PositionZ) / skymul);
|
||||
pos = glm::vec3(data->getFloat(LightDB::PositionX) / skymul, data->getFloat(LightDB::PositionY) / skymul, data->getFloat(LightDB::PositionZ) / skymul);
|
||||
r1 = data->getFloat(LightDB::RadiusInner) / skymul;
|
||||
r2 = data->getFloat(LightDB::RadiusOuter) / skymul;
|
||||
|
||||
@@ -209,13 +209,13 @@ float Sky::floatParamFor(int r, int t) const
|
||||
return c1 + ((c2 - c1) * tt);
|
||||
}
|
||||
|
||||
math::vector_3d Sky::colorFor(int r, int t) const
|
||||
glm::vec3 Sky::colorFor(int r, int t) const
|
||||
{
|
||||
if (mmin[r]<0)
|
||||
{
|
||||
return math::vector_3d(0, 0, 0);
|
||||
return glm::vec3(0, 0, 0);
|
||||
}
|
||||
math::vector_3d c1, c2;
|
||||
glm::vec3 c1, c2;
|
||||
int t1, t2;
|
||||
size_t last = colorRows[r].size() - 1;
|
||||
|
||||
@@ -285,7 +285,7 @@ Skies::Skies(unsigned int mapid, noggit::NoggitRenderContext context)
|
||||
skies.push_back(s);
|
||||
numSkies++;
|
||||
|
||||
if (s.pos == math::vector_3d(0, 0, 0))
|
||||
if (s.pos == glm::vec3(0, 0, 0))
|
||||
has_global = true;
|
||||
}
|
||||
}
|
||||
@@ -309,13 +309,13 @@ Skies::Skies(unsigned int mapid, noggit::NoggitRenderContext context)
|
||||
std::sort(skies.begin(), skies.end());
|
||||
}
|
||||
|
||||
Sky* Skies::findSkyWeights(math::vector_3d pos)
|
||||
Sky* Skies::findSkyWeights(glm::vec3 pos)
|
||||
{
|
||||
Sky* default_sky = nullptr;
|
||||
|
||||
for (auto& sky : skies)
|
||||
{
|
||||
if (sky.pos == math::vector_3d(0, 0, 0))
|
||||
if (sky.pos == glm::vec3(0, 0, 0))
|
||||
{
|
||||
default_sky = &sky;
|
||||
break;
|
||||
@@ -350,7 +350,7 @@ Sky* Skies::findSkyWeights(math::vector_3d pos)
|
||||
return default_sky;
|
||||
}
|
||||
|
||||
void Skies::update_sky_colors(math::vector_3d pos, int time)
|
||||
void Skies::update_sky_colors(glm::vec3 pos, int time)
|
||||
{
|
||||
if (numSkies == 0 || (_last_time == time && _last_pos == pos))
|
||||
{
|
||||
@@ -382,7 +382,7 @@ void Skies::update_sky_colors(math::vector_3d pos, int time)
|
||||
|
||||
for (int i = 0; i < NUM_SkyColorNames; ++i)
|
||||
{
|
||||
color_set[i] = math::vector_3d(1, 1, 1);
|
||||
color_set[i] = glm::vec3(1, 1, 1);
|
||||
}
|
||||
|
||||
_fog_multiplier = 0.f;
|
||||
@@ -411,12 +411,8 @@ void Skies::update_sky_colors(math::vector_3d pos, int time)
|
||||
LogDebug << "Sky " << j << " " << i << " is out of bounds!" << std::endl;
|
||||
continue;
|
||||
}
|
||||
auto original_col = reinterpret_cast<glm::vec3*>(&color_set[i]._data[0]);
|
||||
auto timed_color = sky.colorFor(i, time);
|
||||
auto new_col = reinterpret_cast<glm::vec3*>(&timed_color._data[0]);
|
||||
glm::vec3 final_color = glm::mix(*original_col, *new_col, sky.weight);
|
||||
|
||||
color_set[i] = *reinterpret_cast<math::vector_3d*>(&final_color);
|
||||
color_set[i] = glm::mix(color_set[i], timed_color, sky.weight);
|
||||
}
|
||||
|
||||
_fog_distance = (_fog_distance * (1.0f - sky.weight)) + (sky.floatParamFor(0, time) * sky.weight);
|
||||
@@ -452,9 +448,9 @@ void Skies::update_sky_colors(math::vector_3d pos, int time)
|
||||
_need_color_buffer_update = true;
|
||||
}
|
||||
|
||||
bool Skies::draw( math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
, math::vector_3d const& camera_pos
|
||||
bool Skies::draw(glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, glm::vec3 const& camera_pos
|
||||
, opengl::scoped::use_program& m2_shader
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
@@ -487,9 +483,9 @@ bool Skies::draw( math::matrix_4x4 const& model_view
|
||||
|
||||
{
|
||||
opengl::scoped::vao_binder const _ (_vao);
|
||||
|
||||
shader.uniform("model_view_projection", model_view*projection);
|
||||
shader.uniform("camera_pos", camera_pos);
|
||||
|
||||
shader.uniform("model_view_projection", projection * model_view);
|
||||
shader.uniform("camera_pos", glm::vec3(camera_pos.x, camera_pos.y, camera_pos.z));
|
||||
|
||||
gl.drawElements(GL_TRIANGLES, _indices_count, GL_UNSIGNED_SHORT, nullptr);
|
||||
}
|
||||
@@ -554,8 +550,8 @@ bool Skies::draw( math::matrix_4x4 const& model_view
|
||||
}
|
||||
|
||||
void Skies::drawLightingSpheres (math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
, math::vector_3d const& camera_pos
|
||||
, glm::mat4x4 const& projection
|
||||
, glm::vec3 const& camera_pos
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
)
|
||||
@@ -564,17 +560,17 @@ void Skies::drawLightingSpheres (math::matrix_4x4 const& model_view
|
||||
{
|
||||
if ((sky.pos - camera_pos).length() - sky.r2 <= cull_distance) // TODO: frustum cull here
|
||||
{
|
||||
math::vector_3d diffuse = color_set[LIGHT_GLOBAL_DIFFUSE];
|
||||
math::vector_3d ambient = color_set[LIGHT_GLOBAL_AMBIENT];
|
||||
_sphere_render.draw(model_view * projection, sky.pos, {ambient.x, ambient.y, ambient.z, 0.3}, sky.r1);
|
||||
_sphere_render.draw(model_view * projection, sky.pos, {diffuse.x, diffuse.y, diffuse.z, 0.3}, sky.r2);
|
||||
glm::vec3 diffuse = color_set[LIGHT_GLOBAL_DIFFUSE];
|
||||
glm::vec3 ambient = color_set[LIGHT_GLOBAL_AMBIENT];
|
||||
_sphere_render.draw(model_view.Convert() * projection, sky.pos, {ambient.x, ambient.y, ambient.z, 0.3}, sky.r1);
|
||||
_sphere_render.draw(model_view.Convert() * projection, sky.pos, {diffuse.x, diffuse.y, diffuse.z, 0.3}, sky.r2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Skies::drawLightingSphereHandles (math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
, math::vector_3d const& camera_pos
|
||||
, glm::mat4x4 const& projection
|
||||
, glm::vec3 const& camera_pos
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, bool draw_spheres)
|
||||
@@ -584,15 +580,15 @@ void Skies::drawLightingSphereHandles (math::matrix_4x4 const& model_view
|
||||
if ((sky.pos - camera_pos).length() - sky.r2 <= cull_distance) // TODO: frustum cull here
|
||||
{
|
||||
|
||||
_sphere_render.draw(model_view * projection, sky.pos, {1.f, 0.f, 0.f, 1.f}, 5.f);
|
||||
_sphere_render.draw(model_view.Convert() * projection, sky.pos, {1.f, 0.f, 0.f, 1.f}, 5.f);
|
||||
|
||||
if (sky.selected())
|
||||
{
|
||||
math::vector_3d diffuse = color_set[LIGHT_GLOBAL_DIFFUSE];
|
||||
math::vector_3d ambient = color_set[LIGHT_GLOBAL_AMBIENT];
|
||||
glm::vec3 diffuse = color_set[LIGHT_GLOBAL_DIFFUSE];
|
||||
glm::vec3 ambient = color_set[LIGHT_GLOBAL_AMBIENT];
|
||||
|
||||
_sphere_render.draw(model_view * projection, sky.pos, {ambient.x, ambient.y, ambient.z, 0.3}, sky.r1);
|
||||
_sphere_render.draw(model_view * projection, sky.pos, {diffuse.x, diffuse.y, diffuse.z, 0.3}, sky.r2);
|
||||
_sphere_render.draw(model_view.Convert() * projection, sky.pos, {ambient.x, ambient.y, ambient.z, 0.3}, sky.r1);
|
||||
_sphere_render.draw(model_view.Convert() * projection, sky.pos, {diffuse.x, diffuse.y, diffuse.z, 0.3}, sky.r2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -628,7 +624,7 @@ out vec3 f_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 pos = vec4(position+camera_pos, 1.f);
|
||||
vec4 pos = vec4(position + camera_pos, 1.f);
|
||||
gl_Position = model_view_projection * pos;
|
||||
f_color = color;
|
||||
}
|
||||
@@ -651,18 +647,19 @@ void main()
|
||||
_vertex_array.upload();
|
||||
_buffers.upload();
|
||||
|
||||
std::vector<math::vector_3d> vertices;
|
||||
std::vector<glm::vec3> vertices;
|
||||
std::vector<std::uint16_t> indices;
|
||||
|
||||
math::vector_3d basepos1[cnum], basepos2[cnum];
|
||||
glm::vec3 basepos1[cnum], basepos2[cnum];
|
||||
|
||||
for (int h = 0; h < hseg; h++)
|
||||
{
|
||||
for (int i = 0; i < cnum; ++i)
|
||||
{
|
||||
basepos1[i] = basepos2[i] = math::vector_3d(math::cos(angles[i])*rad, math::sin(angles[i])*rad, 0);
|
||||
math::rotate(0, 0, &basepos1[i].x, &basepos1[i].z, math::radians(math::constants::pi*2.0f / hseg * h));
|
||||
math::rotate(0, 0, &basepos2[i].x, &basepos2[i].z, math::radians(math::constants::pi*2.0f / hseg * (h + 1)));
|
||||
basepos1[i] = basepos2[i] = glm::vec3(glm::cos(math::radians(angles[i])._) * rad, glm::sin(math::radians(angles[i])._)*rad, 0);
|
||||
|
||||
math::rotate(0, 0, &basepos1[i].x, &basepos1[i].z, math::radians(glm::pi<float>() *2.0f / hseg * h));
|
||||
math::rotate(0, 0, &basepos2[i].x, &basepos2[i].z, math::radians(glm::pi<float>() *2.0f / hseg * (h + 1)));
|
||||
}
|
||||
|
||||
for (int v = 0; v < cnum - 1; v++)
|
||||
@@ -684,7 +681,7 @@ void main()
|
||||
}
|
||||
}
|
||||
|
||||
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d>(_vertices_vbo, vertices, GL_STATIC_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER, glm::vec3>(_vertices_vbo, vertices, GL_STATIC_DRAW);
|
||||
gl.bufferData<GL_ELEMENT_ARRAY_BUFFER, std::uint16_t>(_indices_vbo, indices, GL_STATIC_DRAW);
|
||||
|
||||
_indices_count = indices.size();
|
||||
@@ -714,7 +711,7 @@ void Skies::update_vao(opengl::scoped::use_program& shader)
|
||||
|
||||
void Skies::update_color_buffer()
|
||||
{
|
||||
std::vector<math::vector_3d> colors;
|
||||
std::vector<glm::vec3> colors;
|
||||
|
||||
for (int h = 0; h < hseg; h++)
|
||||
{
|
||||
@@ -727,7 +724,7 @@ void Skies::update_color_buffer()
|
||||
}
|
||||
}
|
||||
|
||||
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d>(_colors_vbo, colors, GL_STATIC_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER, glm::vec3>(_colors_vbo, colors, GL_STATIC_DRAW);
|
||||
|
||||
_need_vao_update = true;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/vector_3d.hpp>
|
||||
#include <noggit/DBCFile.h>
|
||||
#include <noggit/MPQ.h>
|
||||
#include <noggit/ModelInstance.h>
|
||||
@@ -19,7 +16,7 @@
|
||||
struct OutdoorLightStats
|
||||
{
|
||||
float nightIntensity;
|
||||
math::vector_3d dayDir;
|
||||
glm::vec3 dayDir;
|
||||
|
||||
void interpolate(OutdoorLightStats *a, OutdoorLightStats *b, float r);
|
||||
};
|
||||
@@ -37,7 +34,7 @@ public:
|
||||
|
||||
struct SkyColor
|
||||
{
|
||||
math::vector_3d color;
|
||||
glm::vec3 color;
|
||||
int time;
|
||||
|
||||
SkyColor(int t, int col);
|
||||
@@ -56,7 +53,7 @@ class Sky
|
||||
public:
|
||||
boost::optional<ModelInstance> skybox;
|
||||
|
||||
math::vector_3d pos;
|
||||
glm::vec3 pos;
|
||||
float r1, r2;
|
||||
|
||||
explicit Sky(DBCFile::Iterator data, noggit::NoggitRenderContext context);
|
||||
@@ -68,7 +65,7 @@ public:
|
||||
|
||||
char name[32];
|
||||
|
||||
math::vector_3d colorFor(int r, int t) const;
|
||||
glm::vec3 colorFor(int r, int t) const;
|
||||
float floatParamFor(int r, int t) const;
|
||||
|
||||
float weight;
|
||||
@@ -142,7 +139,7 @@ private:
|
||||
ModelInstance stars;
|
||||
|
||||
int _last_time = -1;
|
||||
math::vector_3d _last_pos;
|
||||
glm::vec3 _last_pos;
|
||||
|
||||
float _river_shallow_alpha;
|
||||
float _river_deep_alpha;
|
||||
@@ -156,16 +153,16 @@ private:
|
||||
|
||||
public:
|
||||
std::vector<Sky> skies;
|
||||
std::vector<math::vector_3d> color_set = std::vector<math::vector_3d>(NUM_SkyColorNames);
|
||||
std::vector<glm::vec3> color_set = std::vector<glm::vec3>(NUM_SkyColorNames);
|
||||
|
||||
explicit Skies(unsigned int mapid, noggit::NoggitRenderContext context);
|
||||
|
||||
Sky* findSkyWeights(math::vector_3d pos);
|
||||
void update_sky_colors(math::vector_3d pos, int time);
|
||||
Sky* findSkyWeights(glm::vec3 pos);
|
||||
void update_sky_colors(glm::vec3 pos, int time);
|
||||
|
||||
bool draw ( math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
, math::vector_3d const& camera_pos
|
||||
bool draw ( glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, glm::vec3 const& camera_pos
|
||||
, opengl::scoped::use_program& m2_shader
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
@@ -174,15 +171,15 @@ public:
|
||||
);
|
||||
|
||||
void drawLightingSpheres (math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
, math::vector_3d const& camera_pos
|
||||
, glm::mat4x4 const& projection
|
||||
, glm::vec3 const& camera_pos
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
);
|
||||
|
||||
void drawLightingSphereHandles (math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
, math::vector_3d const& camera_pos
|
||||
, glm::mat4x4 const& projection
|
||||
, glm::vec3 const& camera_pos
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, bool draw_spheres
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#include <math/vector_2d.hpp>
|
||||
#include <noggit/TextureManager.h>
|
||||
#include <noggit/Log.h> // LogDebug
|
||||
|
||||
@@ -8,6 +6,7 @@
|
||||
#include <QtGui/QPixmap>
|
||||
|
||||
#include <algorithm>
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
decltype (TextureManager::_) TextureManager::_;
|
||||
decltype (TextureManager::_tex_arrays) TextureManager::_tex_arrays;
|
||||
@@ -479,14 +478,14 @@ namespace noggit
|
||||
GLuint const& vertices_vbo = _buffers[1];
|
||||
GLuint const& texcoords_vbo = _buffers[2];
|
||||
|
||||
std::vector<math::vector_2d> vertices =
|
||||
std::vector<glm::vec2> vertices =
|
||||
{
|
||||
{-1.0f, -1.0f}
|
||||
,{-1.0f, 1.0f}
|
||||
,{ 1.0f, 1.0f}
|
||||
,{ 1.0f, -1.0f}
|
||||
};
|
||||
std::vector<math::vector_2d> texcoords =
|
||||
std::vector<glm::vec2> texcoords =
|
||||
{
|
||||
{0.f, 0.f}
|
||||
,{0.f, 1.0f}
|
||||
@@ -495,8 +494,8 @@ namespace noggit
|
||||
};
|
||||
std::vector<std::uint16_t> indices = {0,1,2, 2,3,0};
|
||||
|
||||
gl.bufferData<GL_ARRAY_BUFFER, math::vector_2d>(vertices_vbo, vertices, GL_STATIC_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER, math::vector_2d>(texcoords_vbo, texcoords, GL_STATIC_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER,glm::vec2>(vertices_vbo, vertices, GL_STATIC_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER,glm::vec2>(texcoords_vbo, texcoords, GL_STATIC_DRAW);
|
||||
gl.bufferData<GL_ELEMENT_ARRAY_BUFFER, std::uint16_t>(indices_vbo, indices, GL_STATIC_DRAW);
|
||||
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ TileWater::TileWater(MapTile *pTile, float pXbase, float pZbase, bool use_mclq_g
|
||||
: tile(pTile)
|
||||
, xbase(pXbase)
|
||||
, zbase(pZbase)
|
||||
, _extents{math::vector_3d{pXbase, std::numeric_limits<float>::max(), pZbase},
|
||||
math::vector_3d{pXbase + TILESIZE, std::numeric_limits<float>::lowest(), pZbase + TILESIZE}}
|
||||
, _extents{glm::vec3{pXbase, std::numeric_limits<float>::max(), pZbase},
|
||||
glm::vec3{pXbase + TILESIZE, std::numeric_limits<float>::lowest(), pZbase + TILESIZE}}
|
||||
{
|
||||
for (int z = 0; z < 16; ++z)
|
||||
{
|
||||
@@ -42,7 +42,7 @@ void TileWater::readFromFile(MPQFile &theFile, size_t basePos)
|
||||
|
||||
void TileWater::draw ( math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, bool camera_moved
|
||||
, opengl::scoped::use_program& water_shader
|
||||
, int animtime
|
||||
@@ -59,8 +59,8 @@ void TileWater::draw ( math::frustum const& frustum
|
||||
|
||||
if (_extents_changed)
|
||||
{
|
||||
_extents = {math::vector_3d{xbase, std::numeric_limits<float>::max(), zbase},
|
||||
math::vector_3d{xbase + TILESIZE, std::numeric_limits<float>::lowest(), zbase + TILESIZE}};
|
||||
_extents = {glm::vec3{xbase, std::numeric_limits<float>::max(), zbase},
|
||||
glm::vec3{xbase + TILESIZE, std::numeric_limits<float>::lowest(), zbase + TILESIZE}};
|
||||
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
@@ -211,7 +211,7 @@ int TileWater::getType(size_t layer)
|
||||
|
||||
void TileWater::updateLayerData(LiquidTextureManager* tex_manager)
|
||||
{
|
||||
tsl::robin_map<unsigned, std::tuple<GLuint, math::vector_2d, int, unsigned>> const& tex_frames = tex_manager->getTextureFrames();
|
||||
tsl::robin_map<unsigned, std::tuple<GLuint, glm::vec2, int, unsigned>> const& tex_frames = tex_manager->getTextureFrames();
|
||||
|
||||
// create opengl resources if needed
|
||||
if (_need_buffer_update)
|
||||
@@ -256,7 +256,7 @@ void TileWater::updateLayerData(LiquidTextureManager* tex_manager)
|
||||
auto& layer_params = _render_layers[layer_counter];
|
||||
|
||||
// fill per-chunk data
|
||||
std::tuple<GLuint, math::vector_2d, int, unsigned> const& tex_profile = tex_frames.at(layer.liquidID());
|
||||
std::tuple<GLuint, glm::vec2, int, unsigned> const& tex_profile = tex_frames.at(layer.liquidID());
|
||||
opengl::LiquidChunkInstanceDataUniformBlock& params_data = layer_params.chunk_data[n_chunks];
|
||||
|
||||
params_data.xbase = layer.getChunk()->xbase;
|
||||
@@ -281,7 +281,7 @@ void TileWater::updateLayerData(LiquidTextureManager* tex_manager)
|
||||
params_data.type = std::get<2>(tex_profile);
|
||||
params_data.n_texture_frames = std::get<3>(tex_profile);
|
||||
|
||||
math::vector_2d anim = std::get<1>(tex_profile);
|
||||
glm::vec2 anim = std::get<1>(tex_profile);
|
||||
params_data.anim_u = anim.x;
|
||||
params_data.anim_v = anim.y;
|
||||
|
||||
@@ -300,8 +300,8 @@ void TileWater::updateLayerData(LiquidTextureManager* tex_manager)
|
||||
for (int x_v = 0; x_v < 9; ++x_v)
|
||||
{
|
||||
const unsigned v_index = z_v * 9 + x_v;
|
||||
math::vector_2d& tex_coord = tex_coords[v_index];
|
||||
layer_params.vertex_data[n_chunks][v_index] = math::vector_4d(vertices[v_index].y, depth[v_index], tex_coord.x, tex_coord.y);
|
||||
glm::vec2& tex_coord = tex_coords[v_index];
|
||||
layer_params.vertex_data[n_chunks][v_index] = glm::vec4(vertices[v_index].y, depth[v_index], tex_coord.x, tex_coord.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/vector_3d.hpp>
|
||||
#include <math/vector_4d.hpp>
|
||||
#include <noggit/ChunkWater.hpp>
|
||||
#include <noggit/MPQ.h>
|
||||
#include <noggit/MapHeaders.h>
|
||||
@@ -27,7 +23,7 @@ struct LiquidLayerDrawCallData
|
||||
{
|
||||
unsigned n_used_chunks = 0;
|
||||
std::array<opengl::LiquidChunkInstanceDataUniformBlock, 256> chunk_data;
|
||||
std::array<std::array<math::vector_4d, 9 * 9>, 256> vertex_data ;
|
||||
std::array<std::array<glm::vec4, 9 * 9>, 256> vertex_data ;
|
||||
std::vector<int> texture_samplers;
|
||||
GLuint chunk_data_buf = 0;
|
||||
GLuint vertex_data_tex = 0;
|
||||
@@ -46,7 +42,7 @@ public:
|
||||
|
||||
void draw ( math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, bool camera_moved
|
||||
, opengl::scoped::use_program& water_shader
|
||||
, int animtime
|
||||
@@ -70,7 +66,7 @@ public:
|
||||
|
||||
void updateLayerData(LiquidTextureManager* tex_manager);
|
||||
|
||||
std::array<math::vector_3d, 2>& getExtents() { return _extents; };
|
||||
std::array<glm::vec3, 2>& getExtents() { return _extents; };
|
||||
|
||||
void unload();
|
||||
|
||||
@@ -84,7 +80,7 @@ private:
|
||||
MapTile *tile;
|
||||
|
||||
std::unique_ptr<ChunkWater> chunks[16][16];
|
||||
std::array<math::vector_3d, 2> _extents;
|
||||
std::array<glm::vec3, 2> _extents;
|
||||
|
||||
std::vector<LiquidLayerDrawCallData> _render_layers;
|
||||
|
||||
|
||||
@@ -74,9 +74,9 @@ void WMO::finishLoading ()
|
||||
f.read (&ambient_color, 4);
|
||||
f.read (&nX, 4);
|
||||
f.read (ff, 12);
|
||||
extents[0] = ::math::vector_3d (ff[0], ff[1], ff[2]);
|
||||
extents[0] = ::glm::vec3 (ff[0], ff[1], ff[2]);
|
||||
f.read (ff, 12);
|
||||
extents[1] = ::math::vector_3d (ff[0], ff[1], ff[2]);
|
||||
extents[1] = ::glm::vec3 (ff[0], ff[1], ff[2]);
|
||||
f.read(&flags, 2);
|
||||
|
||||
f.seekRelative (2);
|
||||
@@ -195,11 +195,11 @@ void WMO::finishLoading ()
|
||||
f.seekRelative (size);
|
||||
|
||||
/*
|
||||
std::vector<math::vector_3d> portal_vertices;
|
||||
std::vector<glm::vec3> portal_vertices;
|
||||
|
||||
for (size_t i (0); i < size / 12; ++i) {
|
||||
f.read (ff, 12);
|
||||
portal_vertices.push_back(math::vector_3d(ff[0], ff[2], -ff[1]));
|
||||
portal_vertices.push_back(glm::vec3(ff[0], ff[2], -ff[1]));
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -349,14 +349,14 @@ void WMO::waitForChildrenLoaded()
|
||||
}
|
||||
|
||||
void WMO::draw ( opengl::scoped::use_program& wmo_shader
|
||||
, math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
, glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, math::matrix_4x4 const& transform_matrix
|
||||
, math::matrix_4x4 const& transform_matrix_transposed
|
||||
, bool boundingbox
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, bool // draw_doodads
|
||||
, bool draw_fog
|
||||
, int animtime
|
||||
@@ -365,7 +365,7 @@ void WMO::draw ( opengl::scoped::use_program& wmo_shader
|
||||
)
|
||||
{
|
||||
|
||||
wmo_shader.uniform("ambient_color", ambient_light_color.xyz());
|
||||
wmo_shader.uniform("ambient_color",glm::vec3(ambient_light_color));
|
||||
|
||||
for (auto& group : groups)
|
||||
{
|
||||
@@ -417,8 +417,8 @@ void WMO::draw ( opengl::scoped::use_program& wmo_shader
|
||||
, projection
|
||||
, transform_matrix_transposed
|
||||
, {1.0f, 0.0f, 0.0f, 1.0f}
|
||||
, math::vector_3d(extents[0].x, extents[0].z, -extents[0].y)
|
||||
, math::vector_3d(extents[1].x, extents[1].z, -extents[1].y)
|
||||
, glm::vec3(extents[0].x, extents[0].z, -extents[0].y)
|
||||
, glm::vec3(extents[1].x, extents[1].z, -extents[1].y)
|
||||
);
|
||||
|
||||
}
|
||||
@@ -441,19 +441,22 @@ std::vector<float> WMO::intersect (math::ray const& ray) const
|
||||
return results;
|
||||
}
|
||||
|
||||
bool WMO::draw_skybox ( math::matrix_4x4 const& model_view
|
||||
, math::vector_3d const& camera_pos
|
||||
bool WMO::draw_skybox (glm::mat4x4 const& model_view
|
||||
, glm::vec3 const& camera_pos
|
||||
, opengl::scoped::use_program& m2_shader
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, int animtime
|
||||
, bool draw_particles
|
||||
, math::vector_3d aabb_min
|
||||
, math::vector_3d aabb_max
|
||||
, std::map<int, std::pair<math::vector_3d, math::vector_3d>> const& group_extents
|
||||
, glm::vec3 aabb_min
|
||||
, glm::vec3 aabb_max
|
||||
, std::map<int, std::pair<glm::vec3, glm::vec3>> const& group_extents
|
||||
) const
|
||||
{
|
||||
if (!skybox || !camera_pos.is_inside_of(aabb_min, aabb_max))
|
||||
|
||||
|
||||
|
||||
if (!skybox || !math::is_inside_of(camera_pos,aabb_min, aabb_max))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -469,7 +472,7 @@ bool WMO::draw_skybox ( math::matrix_4x4 const& model_view
|
||||
|
||||
auto& extent(group_extents.at(i));
|
||||
|
||||
if (camera_pos.is_inside_of(extent.first, extent.second))
|
||||
if (math::is_inside_of(camera_pos, extent.first, extent.second))
|
||||
{
|
||||
ModelInstance sky(skybox.get()->filename, _context);
|
||||
sky.pos = camera_pos;
|
||||
@@ -539,12 +542,12 @@ void WMOLight::init(MPQFile* f)
|
||||
char type[4];
|
||||
f->read(&type, 4);
|
||||
f->read(&color, 4);
|
||||
f->read(pos, 12);
|
||||
f->read(&pos, 12);
|
||||
f->read(&intensity, 4);
|
||||
f->read(unk, 4 * 5);
|
||||
f->read(&r, 4);
|
||||
|
||||
pos = math::vector_3d(pos.x, pos.z, -pos.y);
|
||||
pos = glm::vec3(pos.x, pos.z, -pos.y);
|
||||
|
||||
// rgb? bgr? hm
|
||||
float fa = ((color & 0xff000000) >> 24) / 255.0f;
|
||||
@@ -552,7 +555,7 @@ void WMOLight::init(MPQFile* f)
|
||||
float fg = ((color & 0x0000ff00) >> 8) / 255.0f;
|
||||
float fb = ((color & 0x000000ff)) / 255.0f;
|
||||
|
||||
fcolor = math::vector_4d(fr, fg, fb, fa);
|
||||
fcolor = glm::vec4(fr, fg, fb, fa);
|
||||
fcolor *= intensity;
|
||||
fcolor.w = 1.0f;
|
||||
|
||||
@@ -570,13 +573,13 @@ void WMOLight::setup(GLint)
|
||||
// not used right now -_-
|
||||
}
|
||||
|
||||
void WMOLight::setupOnce(GLint, math::vector_3d, math::vector_3d)
|
||||
void WMOLight::setupOnce(GLint, glm::vec3, glm::vec3)
|
||||
{
|
||||
//math::vector_4d position(dir, 0);
|
||||
//math::vector_4d position(0,1,0,0);
|
||||
//glm::vec4position(dir, 0);
|
||||
//glm::vec4position(0,1,0,0);
|
||||
|
||||
//math::vector_4d ambient = math::vector_4d(light_color * 0.3f, 1);
|
||||
//math::vector_4d diffuse = math::vector_4d(light_color, 1);
|
||||
//glm::vec4ambient = glm::vec4(light_color * 0.3f, 1);
|
||||
//glm::vec4diffuse = glm::vec4(light_color, 1);
|
||||
|
||||
|
||||
//gl.enable(light);
|
||||
@@ -593,9 +596,9 @@ WMOGroup::WMOGroup(WMO *_wmo, MPQFile* f, int _num, char const* names)
|
||||
f->read(&flags, 4);
|
||||
float ff[3];
|
||||
f->read(ff, 12);
|
||||
VertexBoxMax = math::vector_3d(ff[0], ff[1], ff[2]);
|
||||
VertexBoxMax = glm::vec3(ff[0], ff[1], ff[2]);
|
||||
f->read(ff, 12);
|
||||
VertexBoxMin = math::vector_3d(ff[0], ff[1], ff[2]);
|
||||
VertexBoxMin = glm::vec3(ff[0], ff[1], ff[2]);
|
||||
int nameOfs;
|
||||
f->read(&nameOfs, 4);
|
||||
|
||||
@@ -638,14 +641,14 @@ WMOGroup::WMOGroup(WMOGroup const& other)
|
||||
|
||||
namespace
|
||||
{
|
||||
math::vector_4d colorFromInt(unsigned int col)
|
||||
glm::vec4 colorFromInt(unsigned int col)
|
||||
{
|
||||
GLubyte r, g, b, a;
|
||||
a = (col & 0xFF000000) >> 24;
|
||||
r = (col & 0x00FF0000) >> 16;
|
||||
g = (col & 0x0000FF00) >> 8;
|
||||
b = (col & 0x000000FF);
|
||||
return math::vector_4d(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
||||
return glm::vec4(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -813,7 +816,7 @@ void WMOGroup::upload()
|
||||
|
||||
if (header.flags.has_two_motv)
|
||||
{
|
||||
gl.bufferData<GL_ARRAY_BUFFER, math::vector_2d> ( _texcoords_buffer_2
|
||||
gl.bufferData<GL_ARRAY_BUFFER, glm::vec2> ( _texcoords_buffer_2
|
||||
, _texcoords_2
|
||||
, GL_STATIC_DRAW
|
||||
);
|
||||
@@ -917,8 +920,8 @@ void WMOGroup::load()
|
||||
if (wf.r2 <= 0) fog = -1; // default outdoor fog..?
|
||||
else fog = header.fogs[0];
|
||||
|
||||
BoundingBoxMin = ::math::vector_3d (header.box1[0], header.box1[2], -header.box1[1]);
|
||||
BoundingBoxMax = ::math::vector_3d (header.box2[0], header.box2[2], -header.box2[1]);
|
||||
BoundingBoxMin = ::glm::vec3 (header.box1[0], header.box1[2], -header.box1[1]);
|
||||
BoundingBoxMax = ::glm::vec3 (header.box2[0], header.box2[2], -header.box2[1]);
|
||||
|
||||
// - MOPY ----------------------------------------------
|
||||
|
||||
@@ -948,20 +951,20 @@ void WMOGroup::load()
|
||||
assert (fourcc == 'MOVT');
|
||||
|
||||
// let's hope it's padded to 12 bytes, not 16...
|
||||
::math::vector_3d const* vertices = reinterpret_cast< ::math::vector_3d const*>(f.getPointer ());
|
||||
::glm::vec3 const* vertices = reinterpret_cast< ::glm::vec3 const*>(f.getPointer ());
|
||||
|
||||
VertexBoxMin = ::math::vector_3d (std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
|
||||
VertexBoxMax = ::math::vector_3d (std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest());
|
||||
VertexBoxMin = ::glm::vec3 (std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
|
||||
VertexBoxMax = ::glm::vec3 (std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest());
|
||||
|
||||
rad = 0;
|
||||
|
||||
_vertices.resize(size / sizeof (::math::vector_3d));
|
||||
_vertices.resize(size / sizeof (::glm::vec3));
|
||||
|
||||
for (size_t i = 0; i < _vertices.size(); ++i)
|
||||
{
|
||||
_vertices[i] = math::vector_3d(vertices[i].x, vertices[i].z, -vertices[i].y);
|
||||
_vertices[i] = glm::vec3(vertices[i].x, vertices[i].z, -vertices[i].y);
|
||||
|
||||
::math::vector_3d& v = _vertices[i];
|
||||
::glm::vec3& v = _vertices[i];
|
||||
|
||||
if (v.x < VertexBoxMin.x) VertexBoxMin.x = v.x;
|
||||
if (v.y < VertexBoxMin.y) VertexBoxMin.y = v.y;
|
||||
@@ -983,7 +986,7 @@ void WMOGroup::load()
|
||||
|
||||
assert (fourcc == 'MONR');
|
||||
|
||||
_normals.resize (size / sizeof (::math::vector_3d));
|
||||
_normals.resize (size / sizeof (::glm::vec3));
|
||||
|
||||
f.read (_normals.data (), size);
|
||||
|
||||
@@ -999,7 +1002,7 @@ void WMOGroup::load()
|
||||
|
||||
assert (fourcc == 'MOTV');
|
||||
|
||||
_texcoords.resize (size / sizeof (::math::vector_2d));
|
||||
_texcoords.resize (size / sizeof (glm::vec2));
|
||||
|
||||
f.read (_texcoords.data (), size);
|
||||
|
||||
@@ -1293,7 +1296,7 @@ void WMOGroup::load()
|
||||
}
|
||||
else
|
||||
{
|
||||
_texcoords_2.resize(size / sizeof(::math::vector_2d));
|
||||
_texcoords_2.resize(size / sizeof(glm::vec2));
|
||||
f.read(_texcoords_2.data(), size);
|
||||
}
|
||||
|
||||
@@ -1336,7 +1339,7 @@ void WMOGroup::load()
|
||||
// "real" lighting?
|
||||
if (header.flags.indoor && header.flags.has_vertex_color)
|
||||
{
|
||||
::math::vector_3d dirmin(1, 1, 1);
|
||||
::glm::vec3 dirmin(1, 1, 1);
|
||||
float lenmin;
|
||||
|
||||
for (auto doodad : _doodad_ref)
|
||||
@@ -1352,8 +1355,9 @@ void WMOGroup::load()
|
||||
for (unsigned int j = 0; j < wmo->lights.size(); j++)
|
||||
{
|
||||
WMOLight& l = wmo->lights[j];
|
||||
::math::vector_3d dir = l.pos - mi.pos;
|
||||
float ll = dir.length_squared ();
|
||||
::glm::vec3 dir = l.pos - mi.pos;
|
||||
|
||||
float ll = glm::length(dir) * glm::length(dir);
|
||||
if (ll < lenmin)
|
||||
{
|
||||
lenmin = ll;
|
||||
@@ -1413,7 +1417,7 @@ void WMOGroup::fix_vertex_color_alpha()
|
||||
interior_batchs_start = _batches[header.transparency_batches_count - 1].vertex_end + 1;
|
||||
}
|
||||
|
||||
math::vector_4d wmo_ambient_color;
|
||||
glm::vec4 wmo_ambient_color;
|
||||
|
||||
if (wmo->flags.use_unified_render_path)
|
||||
{
|
||||
@@ -1463,11 +1467,11 @@ void WMOGroup::fix_vertex_color_alpha()
|
||||
bool WMOGroup::is_visible( math::matrix_4x4 const& transform
|
||||
, math::frustum const& frustum
|
||||
, float const& cull_distance
|
||||
, math::vector_3d const& camera
|
||||
, glm::vec3 const& camera
|
||||
, display_mode display
|
||||
) const
|
||||
{
|
||||
math::vector_3d pos = transform * center;
|
||||
glm::vec3 pos = transform * center;
|
||||
|
||||
if (!frustum.intersects(pos + BoundingBoxMin, pos + BoundingBoxMax))
|
||||
{
|
||||
@@ -1484,7 +1488,7 @@ bool WMOGroup::is_visible( math::matrix_4x4 const& transform
|
||||
void WMOGroup::draw( opengl::scoped::use_program& wmo_shader
|
||||
, math::frustum const& // frustum
|
||||
, const float& //cull_distance
|
||||
, const math::vector_3d& //camera
|
||||
, const glm::vec3& //camera
|
||||
, bool // draw_fog
|
||||
, bool // world_has_skies
|
||||
)
|
||||
@@ -1605,7 +1609,7 @@ void WMOGroup::setupFog (bool draw_fog, std::function<void (bool)> setup_fog)
|
||||
void WMOFog::init(MPQFile* f)
|
||||
{
|
||||
f->read(this, 0x30);
|
||||
color = math::vector_4d(((color1 & 0x00FF0000) >> 16) / 255.0f, ((color1 & 0x0000FF00) >> 8) / 255.0f,
|
||||
color = glm::vec4(((color1 & 0x00FF0000) >> 16) / 255.0f, ((color1 & 0x0000FF00) >> 8) / 255.0f,
|
||||
(color1 & 0x000000FF) / 255.0f, ((color1 & 0xFF000000) >> 24) / 255.0f);
|
||||
float temp;
|
||||
temp = pos.y;
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/quaternion.hpp>
|
||||
#include <math/ray.hpp>
|
||||
#include <math/vector_3d.hpp>
|
||||
#include <noggit/MPQ.h>
|
||||
#include <noggit/ModelInstance.h> // ModelInstance
|
||||
#include <noggit/ModelManager.h>
|
||||
@@ -144,7 +140,7 @@ public:
|
||||
void draw( opengl::scoped::use_program& wmo_shader
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, bool draw_fog
|
||||
, bool world_has_skies
|
||||
);
|
||||
@@ -166,16 +162,16 @@ public:
|
||||
bool is_visible( math::matrix_4x4 const& transform_matrix
|
||||
, math::frustum const& frustum
|
||||
, float const& cull_distance
|
||||
, math::vector_3d const& camera
|
||||
, glm::vec3 const& camera
|
||||
, display_mode display
|
||||
) const;
|
||||
|
||||
std::vector<uint16_t> doodad_ref() const { return _doodad_ref; }
|
||||
|
||||
math::vector_3d BoundingBoxMin;
|
||||
math::vector_3d BoundingBoxMax;
|
||||
math::vector_3d VertexBoxMin;
|
||||
math::vector_3d VertexBoxMax;
|
||||
glm::vec3 BoundingBoxMin;
|
||||
glm::vec3 BoundingBoxMax;
|
||||
glm::vec3 VertexBoxMin;
|
||||
glm::vec3 VertexBoxMax;
|
||||
|
||||
bool use_outdoor_lights;
|
||||
std::string name;
|
||||
@@ -190,7 +186,7 @@ private:
|
||||
|
||||
WMO *wmo;
|
||||
wmo_group_header header;
|
||||
::math::vector_3d center;
|
||||
::glm::vec3 center;
|
||||
float rad;
|
||||
int32_t num;
|
||||
int32_t fog;
|
||||
@@ -199,11 +195,11 @@ private:
|
||||
|
||||
std::vector<wmo_batch> _batches;
|
||||
|
||||
std::vector<::math::vector_3d> _vertices;
|
||||
std::vector<::math::vector_3d> _normals;
|
||||
std::vector<::math::vector_2d> _texcoords;
|
||||
std::vector<::math::vector_2d> _texcoords_2;
|
||||
std::vector<::math::vector_4d> _vertex_colors;
|
||||
std::vector<::glm::vec3> _vertices;
|
||||
std::vector<::glm::vec3> _normals;
|
||||
std::vector<glm::vec2> _texcoords;
|
||||
std::vector<glm::vec2> _texcoords_2;
|
||||
std::vector<glm::vec4> _vertex_colors;
|
||||
std::vector<unsigned> _render_batch_mapping;
|
||||
std::vector<uint16_t> _indices;
|
||||
std::vector<WMORenderBatch> _render_batches;
|
||||
@@ -233,21 +229,21 @@ private:
|
||||
|
||||
struct WMOLight {
|
||||
uint32_t flags, color;
|
||||
math::vector_3d pos;
|
||||
glm::vec3 pos;
|
||||
float intensity;
|
||||
float unk[5];
|
||||
float r;
|
||||
|
||||
math::vector_4d fcolor;
|
||||
glm::vec4 fcolor;
|
||||
|
||||
void init(MPQFile* f);
|
||||
void setup(GLint light);
|
||||
|
||||
static void setupOnce(GLint light, math::vector_3d dir, math::vector_3d light_color);
|
||||
static void setupOnce(GLint light, glm::vec3 dir, glm::vec3 light_color);
|
||||
};
|
||||
|
||||
struct WMOPV {
|
||||
math::vector_3d a, b, c, d;
|
||||
glm::vec3 a, b, c, d;
|
||||
};
|
||||
|
||||
struct WMOPR {
|
||||
@@ -263,14 +259,14 @@ struct WMODoodadSet {
|
||||
|
||||
struct WMOFog {
|
||||
unsigned int flags;
|
||||
math::vector_3d pos;
|
||||
glm::vec3 pos;
|
||||
float r1, r2, fogend, fogstart;
|
||||
unsigned int color1;
|
||||
float f2;
|
||||
float f3;
|
||||
unsigned int color2;
|
||||
// read to here (0x30 bytes)
|
||||
math::vector_4d color;
|
||||
glm::vec4 color;
|
||||
void init(MPQFile* f);
|
||||
void setup();
|
||||
};
|
||||
@@ -297,14 +293,14 @@ public:
|
||||
explicit WMO(const std::string& name, noggit::NoggitRenderContext context );
|
||||
|
||||
void draw ( opengl::scoped::use_program& wmo_shader
|
||||
, math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
, glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, math::matrix_4x4 const& transform_matrix
|
||||
, math::matrix_4x4 const& transform_matrix_transposed
|
||||
, bool boundingbox
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, bool draw_doodads
|
||||
, bool draw_fog
|
||||
, int animtime
|
||||
@@ -312,16 +308,16 @@ public:
|
||||
, display_mode display
|
||||
);
|
||||
|
||||
bool draw_skybox( math::matrix_4x4 const& model_view
|
||||
, math::vector_3d const& camera_pos
|
||||
bool draw_skybox(glm::mat4x4 const& model_view
|
||||
, glm::vec3 const& camera_pos
|
||||
, opengl::scoped::use_program& m2_shader
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, int animtime
|
||||
, bool draw_particles
|
||||
, math::vector_3d aabb_min
|
||||
, math::vector_3d aabb_max
|
||||
, std::map<int, std::pair<math::vector_3d, math::vector_3d>> const& group_extents
|
||||
, glm::vec3 aabb_min
|
||||
, glm::vec3 aabb_max
|
||||
, std::map<int, std::pair<glm::vec3, glm::vec3>> const& group_extents
|
||||
) const;
|
||||
|
||||
std::vector<float> intersect (math::ray const&) const;
|
||||
@@ -340,14 +336,14 @@ public:
|
||||
|
||||
std::vector<WMOGroup> groups;
|
||||
std::vector<WMOMaterial> materials;
|
||||
math::vector_3d extents[2];
|
||||
glm::vec3 extents[2];
|
||||
std::vector<scoped_blp_texture_reference> textures;
|
||||
std::vector<std::string> models;
|
||||
std::vector<wmo_doodad_instance> modelis;
|
||||
std::vector<math::vector_3d> model_nearest_light_vector;
|
||||
std::vector<glm::vec3> model_nearest_light_vector;
|
||||
|
||||
std::vector<WMOLight> lights;
|
||||
math::vector_4d ambient_light_color;
|
||||
glm::vec4 ambient_light_color;
|
||||
|
||||
mohd_flags flags;
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@ WMOInstance::WMOInstance(std::string const& filename, ENTRY_MODF const* d, noggi
|
||||
, mUnknown(d->unknown), mNameset(d->nameSet)
|
||||
, _doodadset(d->doodadSet)
|
||||
{
|
||||
pos = math::vector_3d(d->pos[0], d->pos[1], d->pos[2]);
|
||||
dir = math::degrees::vec3{math::degrees(d->rot[0]), math::degrees(d->rot[1]), math::degrees(d->rot[2])};
|
||||
pos = glm::vec3(d->pos[0], d->pos[1], d->pos[2]);
|
||||
dir = math::degrees::vec3{math::degrees(d->rot[0])._, math::degrees(d->rot[1])._, math::degrees(d->rot[2])._ };
|
||||
|
||||
uid = d->uniqueID;
|
||||
|
||||
extents[0] = math::vector_3d(d->extents[0][0], d->extents[0][1], d->extents[0][2]);
|
||||
extents[1] = math::vector_3d(d->extents[1][0], d->extents[1][1], d->extents[1][2]);
|
||||
extents[0] = glm::vec3(d->extents[0][0], d->extents[0][1], d->extents[0][2]);
|
||||
extents[1] = glm::vec3(d->extents[1][0], d->extents[1][1], d->extents[1][2]);
|
||||
|
||||
updateTransformMatrix();
|
||||
change_doodadset(_doodadset);
|
||||
@@ -39,19 +39,19 @@ WMOInstance::WMOInstance(std::string const& filename, noggit::NoggitRenderContex
|
||||
, _doodadset(0)
|
||||
{
|
||||
change_doodadset(_doodadset);
|
||||
pos = math::vector_3d(0.0f, 0.0f, 0.0f);
|
||||
dir = math::degrees::vec3(0_deg, 0_deg, 0_deg);
|
||||
pos = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
dir = math::degrees::vec3(math::degrees(0)._, math::degrees(0)._, math::degrees(0)._);
|
||||
uid = 0;
|
||||
_context = context;
|
||||
}
|
||||
|
||||
|
||||
void WMOInstance::draw ( opengl::scoped::use_program& wmo_shader
|
||||
, math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
, glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, bool force_box
|
||||
, bool draw_doodads
|
||||
, bool draw_fog
|
||||
@@ -119,8 +119,8 @@ void WMOInstance::draw ( opengl::scoped::use_program& wmo_shader
|
||||
//gl.enable(GL_BLEND);
|
||||
//gl.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
math::vector_4d color = force_box ? math::vector_4d(0.0f, 0.0f, 1.0f, 1.0f)
|
||||
: math::vector_4d(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
glm::vec4 color = force_box ? glm::vec4(0.0f, 0.0f, 1.0f, 1.0f)
|
||||
: glm::vec4(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
|
||||
opengl::primitives::wire_box::getInstance(_context).draw(model_view
|
||||
, projection
|
||||
@@ -164,10 +164,10 @@ void WMOInstance::recalcExtents()
|
||||
updateTransformMatrix();
|
||||
update_doodads();
|
||||
|
||||
std::vector<math::vector_3d> points;
|
||||
std::vector<glm::vec3> points;
|
||||
|
||||
math::vector_3d wmo_min(misc::transform_model_box_coords(wmo->extents[0]));
|
||||
math::vector_3d wmo_max(misc::transform_model_box_coords(wmo->extents[1]));
|
||||
glm::vec3 wmo_min(misc::transform_model_box_coords(wmo->extents[0]));
|
||||
glm::vec3 wmo_max(misc::transform_model_box_coords(wmo->extents[1]));
|
||||
|
||||
auto&& root_points = _transform_mat * math::aabb(wmo_min, wmo_max).all_corners();
|
||||
|
||||
@@ -233,7 +233,7 @@ void WMOInstance::update_doodads()
|
||||
std::vector<wmo_doodad_instance*> WMOInstance::get_visible_doodads
|
||||
( math::frustum const& frustum
|
||||
, float const& cull_distance
|
||||
, math::vector_3d const& camera
|
||||
, glm::vec3 const& camera
|
||||
, bool draw_hidden_models
|
||||
, display_mode display
|
||||
)
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <noggit/SceneObject.hpp>
|
||||
#include <math/ray.hpp>
|
||||
#include <math/vector_3d.hpp> // math::vector_3d
|
||||
#include <noggit/WMO.h>
|
||||
#include <noggit/ContextObject.hpp>
|
||||
|
||||
@@ -18,7 +15,7 @@ class WMOInstance : public SceneObject
|
||||
{
|
||||
public:
|
||||
scoped_wmo_reference wmo;
|
||||
std::map<int, std::pair<math::vector_3d, math::vector_3d>> group_extents;
|
||||
std::map<int, std::pair<glm::vec3, glm::vec3>> group_extents;
|
||||
uint16_t mFlags;
|
||||
uint16_t mUnknown;
|
||||
uint16_t mNameset;
|
||||
@@ -87,11 +84,11 @@ public:
|
||||
}
|
||||
|
||||
void draw ( opengl::scoped::use_program& wmo_shader
|
||||
, math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
, glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, bool force_box
|
||||
, bool draw_doodads
|
||||
, bool draw_fog
|
||||
@@ -112,7 +109,7 @@ public:
|
||||
|
||||
std::vector<wmo_doodad_instance*> get_visible_doodads( math::frustum const& frustum
|
||||
, float const& cull_distance
|
||||
, math::vector_3d const& camera
|
||||
, glm::vec3 const& camera
|
||||
, bool draw_hidden_models
|
||||
, display_mode display
|
||||
);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -95,23 +95,23 @@ public:
|
||||
void initDisplay();
|
||||
|
||||
void update_models_emitters(float dt);
|
||||
void draw (math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
, math::vector_3d const& cursor_pos
|
||||
void draw (glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, glm::vec3 const& cursor_pos
|
||||
, float cursorRotation
|
||||
, math::vector_4d const& cursor_color
|
||||
, glm::vec4 const& cursor_color
|
||||
, CursorType cursor_type
|
||||
, float brush_radius
|
||||
, bool show_unpaintable_chunks
|
||||
, float inner_radius_ratio
|
||||
, math::vector_3d const& ref_pos
|
||||
, glm::vec3 const& ref_pos
|
||||
, float angle
|
||||
, float orientation
|
||||
, bool use_ref_pos
|
||||
, bool angled_mode
|
||||
, bool draw_paintability_overlay
|
||||
, editing_mode terrainMode
|
||||
, math::vector_3d const& camera_pos
|
||||
, glm::vec3 const& camera_pos
|
||||
, bool camera_moved
|
||||
, bool draw_mfbo
|
||||
, bool draw_terrain
|
||||
@@ -131,12 +131,12 @@ public:
|
||||
, bool minimap_render = false
|
||||
);
|
||||
|
||||
unsigned int getAreaID (math::vector_3d const&);
|
||||
void setAreaID(math::vector_3d const& pos, int id, bool adt, float radius = -1.0f);
|
||||
unsigned int getAreaID (glm::vec3 const&);
|
||||
void setAreaID(glm::vec3 const& pos, int id, bool adt, float radius = -1.0f);
|
||||
|
||||
noggit::NoggitRenderContext getRenderContext() { return _context; };
|
||||
|
||||
selection_result intersect ( math::matrix_4x4 const& model_view
|
||||
selection_result intersect (glm::mat4x4 const& model_view
|
||||
, math::ray const&
|
||||
, bool only_map
|
||||
, bool do_objects
|
||||
@@ -146,18 +146,18 @@ public:
|
||||
, bool draw_hidden_models
|
||||
);
|
||||
|
||||
MapChunk* getChunkAt(math::vector_3d const& pos);
|
||||
MapChunk* getChunkAt(glm::vec3 const& pos);
|
||||
|
||||
private:
|
||||
// Information about the currently selected model / WMO / triangle.
|
||||
int _selected_model_count = 0;
|
||||
boost::optional<math::vector_3d> _multi_select_pivot;
|
||||
boost::optional<glm::vec3> _multi_select_pivot;
|
||||
public:
|
||||
|
||||
void unload_shaders();
|
||||
|
||||
void update_selection_pivot();
|
||||
boost::optional<math::vector_3d> const& multi_select_pivot() const { return _multi_select_pivot; }
|
||||
boost::optional<glm::vec3> const& multi_select_pivot() const { return _multi_select_pivot; }
|
||||
|
||||
// Selection related methods.
|
||||
bool is_selected(selection_type selection) const;
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
void remove_from_selection(std::uint32_t uid);
|
||||
void reset_selection();
|
||||
void delete_selected_models();
|
||||
void range_add_to_selection(math::vector_3d const& pos, float radius, bool remove);
|
||||
void range_add_to_selection(glm::vec3 const& pos, float radius, bool remove);
|
||||
noggit::world_model_instances_storage& getModelInstanceStorage() { return _model_instance_storage; };
|
||||
|
||||
enum class m2_scaling_type
|
||||
@@ -186,7 +186,7 @@ public:
|
||||
void snap_selected_models_to_the_ground();
|
||||
void scale_selected_models(float v, m2_scaling_type type);
|
||||
void move_selected_models(float dx, float dy, float dz);
|
||||
void move_selected_models(math::vector_3d const& delta)
|
||||
void move_selected_models(glm::vec3 const& delta)
|
||||
{
|
||||
move_selected_models(delta.x, delta.y, delta.z);
|
||||
}
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
{
|
||||
return set_selected_models_pos({x,y,z}, change_height);
|
||||
}
|
||||
void set_selected_models_pos(math::vector_3d const& pos, bool change_height = true);
|
||||
void set_selected_models_pos(glm::vec3 const& pos, bool change_height = true);
|
||||
void rotate_selected_models(math::degrees rx, math::degrees ry, math::degrees rz, bool use_pivot);
|
||||
void rotate_selected_models_randomly(float minX, float maxX, float minY, float maxY, float minZ, float maxZ);
|
||||
void set_selected_models_rotation(math::degrees rx, math::degrees ry, math::degrees rz);
|
||||
@@ -202,118 +202,118 @@ public:
|
||||
// Checks the normal of the terrain on model origin and rotates to that spot.
|
||||
void rotate_selected_models_to_ground_normal(bool smoothNormals);
|
||||
|
||||
bool GetVertex(float x, float z, math::vector_3d *V) const;
|
||||
bool GetVertex(float x, float z, glm::vec3 *V) const;
|
||||
|
||||
// check if the cursor is under map or in an unloaded tile
|
||||
bool isUnderMap(math::vector_3d const& pos);
|
||||
bool isUnderMap(glm::vec3 const& pos);
|
||||
|
||||
template<typename Fun>
|
||||
bool for_all_chunks_in_range ( math::vector_3d const& pos
|
||||
bool for_all_chunks_in_range ( glm::vec3 const& pos
|
||||
, float radius
|
||||
, Fun&& /* MapChunk* -> bool changed */
|
||||
);
|
||||
template<typename Fun, typename Post>
|
||||
bool for_all_chunks_in_range ( math::vector_3d const& pos
|
||||
bool for_all_chunks_in_range ( glm::vec3 const& pos
|
||||
, float radius
|
||||
, Fun&& /* MapChunk* -> bool changed */
|
||||
, Post&& /* MapChunk* -> void; called for all changed chunks */
|
||||
);
|
||||
|
||||
template<typename Fun>
|
||||
bool for_all_chunks_in_rect ( math::vector_3d const& pos
|
||||
bool for_all_chunks_in_rect ( glm::vec3 const& pos
|
||||
, float radius
|
||||
, Fun&& /* MapChunk* -> bool changed */
|
||||
);
|
||||
|
||||
template<typename Fun, typename Post>
|
||||
bool for_all_chunks_in_rect ( math::vector_3d const& pos
|
||||
bool for_all_chunks_in_rect (glm::vec3 const& pos
|
||||
, float radius
|
||||
, Fun&& /* MapChunk* -> bool changed */
|
||||
, Post&& /* MapChunk* -> void; called for all changed chunks */
|
||||
);
|
||||
|
||||
template<typename Fun>
|
||||
void for_all_chunks_on_tile (math::vector_3d const& pos, Fun&&);
|
||||
void for_all_chunks_on_tile (glm::vec3 const& pos, Fun&&);
|
||||
|
||||
template<typename Fun>
|
||||
void for_chunk_at(math::vector_3d const& pos, Fun&& fun);
|
||||
void for_chunk_at(glm::vec3 const& pos, Fun&& fun);
|
||||
template<typename Fun>
|
||||
auto for_maybe_chunk_at (math::vector_3d const& pos, Fun&& fun) -> boost::optional<decltype (fun (nullptr))>;
|
||||
auto for_maybe_chunk_at (glm::vec3 const& pos, Fun&& fun) -> boost::optional<decltype (fun (nullptr))>;
|
||||
|
||||
template<typename Fun>
|
||||
void for_tile_at(const tile_index& pos, Fun&&);
|
||||
|
||||
void changeTerrain(math::vector_3d const& pos, float change, float radius, int BrushType, float inner_radius);
|
||||
void changeShader(math::vector_3d const& pos, math::vector_4d const& color, float change, float radius, bool editMode);
|
||||
void stampShader(math::vector_3d const& pos, math::vector_4d const& color, float change, float radius, bool editMode, QImage* img, bool paint, bool use_image_colors);
|
||||
math::vector_3d pickShaderColor(math::vector_3d const& pos);
|
||||
void flattenTerrain(math::vector_3d const& pos, float remain, float radius, int BrushType, flatten_mode const& mode, const math::vector_3d& origin, math::degrees angle, math::degrees orientation);
|
||||
void blurTerrain(math::vector_3d const& pos, float remain, float radius, int BrushType, flatten_mode const& mode);
|
||||
bool paintTexture(math::vector_3d const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture);
|
||||
bool stampTexture(math::vector_3d const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint);
|
||||
bool sprayTexture(math::vector_3d const& pos, Brush *brush, float strength, float pressure, float spraySize, float sprayPressure, scoped_blp_texture_reference texture);
|
||||
bool replaceTexture(math::vector_3d const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture);
|
||||
void changeTerrain(glm::vec3 const& pos, float change, float radius, int BrushType, float inner_radius);
|
||||
void changeShader(glm::vec3 const& pos, glm::vec4 const& color, float change, float radius, bool editMode);
|
||||
void stampShader(glm::vec3 const& pos, glm::vec4 const& color, float change, float radius, bool editMode, QImage* img, bool paint, bool use_image_colors);
|
||||
glm::vec3 pickShaderColor(glm::vec3 const& pos);
|
||||
void flattenTerrain(glm::vec3 const& pos, float remain, float radius, int BrushType, flatten_mode const& mode, const glm::vec3& origin, math::degrees angle, math::degrees orientation);
|
||||
void blurTerrain(glm::vec3 const& pos, float remain, float radius, int BrushType, flatten_mode const& mode);
|
||||
bool paintTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture);
|
||||
bool stampTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint);
|
||||
bool sprayTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, float spraySize, float sprayPressure, scoped_blp_texture_reference texture);
|
||||
bool replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture);
|
||||
|
||||
void eraseTextures(math::vector_3d const& pos);
|
||||
void overwriteTextureAtCurrentChunk(math::vector_3d const& pos, scoped_blp_texture_reference const& oldTexture, scoped_blp_texture_reference newTexture);
|
||||
void setBaseTexture(math::vector_3d const& pos);
|
||||
void clear_shadows(math::vector_3d const& pos);
|
||||
void clearTextures(math::vector_3d const& pos);
|
||||
void swapTexture(math::vector_3d const& pos, scoped_blp_texture_reference tex);
|
||||
void removeTexDuplicateOnADT(math::vector_3d const& pos);
|
||||
void change_texture_flag(math::vector_3d const& pos, scoped_blp_texture_reference const& tex, std::size_t flag, bool add);
|
||||
void eraseTextures(glm::vec3 const& pos);
|
||||
void overwriteTextureAtCurrentChunk(glm::vec3 const& pos, scoped_blp_texture_reference const& oldTexture, scoped_blp_texture_reference newTexture);
|
||||
void setBaseTexture(glm::vec3 const& pos);
|
||||
void clear_shadows(glm::vec3 const& pos);
|
||||
void clearTextures(glm::vec3 const& pos);
|
||||
void swapTexture(glm::vec3 const& pos, scoped_blp_texture_reference tex);
|
||||
void removeTexDuplicateOnADT(glm::vec3 const& pos);
|
||||
void change_texture_flag(glm::vec3 const& pos, scoped_blp_texture_reference const& tex, std::size_t flag, bool add);
|
||||
|
||||
void setHole(math::vector_3d const& pos, float radius, bool big, bool hole);
|
||||
void setHoleADT(math::vector_3d const& pos, bool hole);
|
||||
void setHole(glm::vec3 const& pos, float radius, bool big, bool hole);
|
||||
void setHoleADT(glm::vec3 const& pos, bool hole);
|
||||
|
||||
void exportADTAlphamap(math::vector_3d const& pos);
|
||||
void exportADTNormalmap(math::vector_3d const& pos);
|
||||
void exportADTAlphamap(math::vector_3d const& pos, std::string const& filename);
|
||||
void exportADTHeightmap(math::vector_3d const& pos, float min_height, float max_height);
|
||||
void exportADTVertexColorMap(math::vector_3d const& pos);
|
||||
void exportADTAlphamap(glm::vec3 const& pos);
|
||||
void exportADTNormalmap(glm::vec3 const& pos);
|
||||
void exportADTAlphamap(glm::vec3 const& pos, std::string const& filename);
|
||||
void exportADTHeightmap(glm::vec3 const& pos, float min_height, float max_height);
|
||||
void exportADTVertexColorMap(glm::vec3 const& pos);
|
||||
void exportAllADTsAlphamap();
|
||||
void exportAllADTsAlphamap(std::string const& filename);
|
||||
void exportAllADTsHeightmap();
|
||||
void exportAllADTsVertexColorMap();
|
||||
|
||||
void importADTAlphamap(math::vector_3d const& pos, QImage const& image, unsigned layer);
|
||||
void importADTAlphamap(math::vector_3d const& pos);
|
||||
void importADTHeightmap(math::vector_3d const& pos, QImage const& image, float multiplier, unsigned mode);
|
||||
void importADTHeightmap(math::vector_3d const& pos, float multiplier, unsigned mode);
|
||||
void importADTVertexColorMap(math::vector_3d const& pos, int mode);
|
||||
void importADTVertexColorMap(math::vector_3d const& pos, QImage const& image, int mode);
|
||||
void importADTAlphamap(glm::vec3 const& pos, QImage const& image, unsigned layer);
|
||||
void importADTAlphamap(glm::vec3 const& pos);
|
||||
void importADTHeightmap(glm::vec3 const& pos, QImage const& image, float multiplier, unsigned mode);
|
||||
void importADTHeightmap(glm::vec3 const& pos, float multiplier, unsigned mode);
|
||||
void importADTVertexColorMap(glm::vec3 const& pos, int mode);
|
||||
void importADTVertexColorMap(glm::vec3 const& pos, QImage const& image, int mode);
|
||||
|
||||
void importAllADTsAlphamaps();
|
||||
void importAllADTsHeightmaps(float multiplier, unsigned mode);
|
||||
void importAllADTVertexColorMaps(unsigned mode);
|
||||
|
||||
void ensureAllTilesetsADT(math::vector_3d const& pos);
|
||||
void ensureAllTilesetsADT(glm::vec3 const& pos);
|
||||
void ensureAllTilesetsAllADTs();
|
||||
|
||||
void notifyTileRendererOnSelectedTextureChange();
|
||||
|
||||
void addM2 ( std::string const& filename
|
||||
, math::vector_3d newPos
|
||||
, glm::vec3 newPos
|
||||
, float scale, math::degrees::vec3 rotation
|
||||
, noggit::object_paste_params*
|
||||
);
|
||||
void addWMO ( std::string const& filename
|
||||
, math::vector_3d newPos
|
||||
, glm::vec3 newPos
|
||||
, math::degrees::vec3 rotation
|
||||
);
|
||||
|
||||
ModelInstance* addM2AndGetInstance ( std::string const& filename
|
||||
, math::vector_3d newPos
|
||||
, glm::vec3 newPos
|
||||
, float scale, math::degrees::vec3 rotation
|
||||
, noggit::object_paste_params*
|
||||
);
|
||||
|
||||
WMOInstance* addWMOAndGetInstance ( std::string const& filename
|
||||
, math::vector_3d newPos
|
||||
, glm::vec3 newPos
|
||||
, math::degrees::vec3 rotation
|
||||
);
|
||||
|
||||
auto stamp(math::vector_3d const& pos, float dt, QImage const* img, float radiusOuter
|
||||
auto stamp(glm::vec3 const& pos, float dt, QImage const* img, float radiusOuter
|
||||
, float radiusInner, int BrushType, bool sculpt) -> void;
|
||||
|
||||
// add a m2 instance to the world (needs to be positioned already), return the uid
|
||||
@@ -334,9 +334,9 @@ public:
|
||||
|
||||
bool saveMinimap (tile_index const& tile_idx, MinimapRenderSettings* settings, std::optional<QImage>& combined_image);
|
||||
void drawMinimap ( MapTile *tile
|
||||
, math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
, math::vector_3d const& camera_pos
|
||||
, glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, glm::vec3 const& camera_pos
|
||||
, MinimapRenderSettings* settings
|
||||
);
|
||||
|
||||
@@ -350,18 +350,18 @@ public:
|
||||
|
||||
static bool IsEditableWorld(int pMapId);
|
||||
|
||||
void clearHeight(math::vector_3d const& pos);
|
||||
void clearHeight(glm::vec3 const& pos);
|
||||
void clearAllModelsOnADT(tile_index const& tile);
|
||||
|
||||
// liquids
|
||||
void paintLiquid( math::vector_3d const& pos
|
||||
void paintLiquid( glm::vec3 const& pos
|
||||
, float radius
|
||||
, int liquid_id
|
||||
, bool add
|
||||
, math::radians const& angle
|
||||
, math::radians const& orientation
|
||||
, bool lock
|
||||
, math::vector_3d const& origin
|
||||
, glm::vec3 const& origin
|
||||
, bool override_height
|
||||
, bool override_liquid_id
|
||||
, float opacity_factor
|
||||
@@ -376,10 +376,10 @@ public:
|
||||
|
||||
void convert_alphamap(bool to_big_alpha);
|
||||
|
||||
bool deselectVertices(math::vector_3d const& pos, float radius);
|
||||
void selectVertices(math::vector_3d const& pos, float radius);
|
||||
bool deselectVertices(glm::vec3 const& pos, float radius);
|
||||
void selectVertices(glm::vec3 const& pos, float radius);
|
||||
void moveVertices(float h);
|
||||
void orientVertices ( math::vector_3d const& ref_pos
|
||||
void orientVertices ( glm::vec3 const& ref_pos
|
||||
, math::degrees vertex_angle
|
||||
, math::degrees vertex_orientation
|
||||
);
|
||||
@@ -393,7 +393,7 @@ public:
|
||||
|
||||
float getMaxTileHeight(const tile_index& tile);
|
||||
|
||||
math::vector_3d const& vertexCenter();
|
||||
glm::vec3 const& vertexCenter();
|
||||
|
||||
void initShaders();
|
||||
|
||||
@@ -417,10 +417,11 @@ public:
|
||||
private:
|
||||
void update_models_by_filename();
|
||||
|
||||
void updateMVPUniformBlock(const math::matrix_4x4& model_view, const math::matrix_4x4& projection);
|
||||
void updateLightingUniformBlock(bool draw_fog, math::vector_3d const& camera_pos);
|
||||
void updateMVPUniformBlock(const glm::mat4x4& model_view, const glm::mat4x4& projection);
|
||||
void updateLightingUniformBlock(bool draw_fog, glm::vec3 const& camera_pos);
|
||||
void updateLightingUniformBlockMinimap(MinimapRenderSettings* settings);
|
||||
|
||||
|
||||
std::unordered_set<MapChunk*>& vertexBorderChunks();
|
||||
|
||||
void setupChunkVAO(opengl::scoped::use_program& mcnk_shader);
|
||||
@@ -432,8 +433,8 @@ private:
|
||||
std::unordered_set<MapTile*> _vertex_tiles;
|
||||
std::unordered_set<MapChunk*> _vertex_chunks;
|
||||
std::unordered_set<MapChunk*> _vertex_border_chunks;
|
||||
std::unordered_set<math::vector_3d*> _vertices_selected;
|
||||
math::vector_3d _vertex_center;
|
||||
std::unordered_set<glm::vec3*> _vertices_selected;
|
||||
glm::vec3 _vertex_center;
|
||||
bool _vertex_center_updated = false;
|
||||
bool _vertex_border_updated = false;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <forward_list>
|
||||
|
||||
template<typename Fun>
|
||||
void World::for_all_chunks_on_tile (math::vector_3d const& pos, Fun&& fun)
|
||||
void World::for_all_chunks_on_tile (glm::vec3 const& pos, Fun&& fun)
|
||||
{
|
||||
MapTile* tile (mapIndex.getTile (pos));
|
||||
|
||||
@@ -26,7 +26,7 @@ void World::for_all_chunks_on_tile (math::vector_3d const& pos, Fun&& fun)
|
||||
}
|
||||
|
||||
template<typename Fun>
|
||||
void World::for_chunk_at(math::vector_3d const& pos, Fun&& fun)
|
||||
void World::for_chunk_at(glm::vec3 const& pos, Fun&& fun)
|
||||
{
|
||||
MapTile* tile(mapIndex.getTile(pos));
|
||||
|
||||
@@ -38,7 +38,7 @@ void World::for_chunk_at(math::vector_3d const& pos, Fun&& fun)
|
||||
}
|
||||
|
||||
template<typename Fun>
|
||||
auto World::for_maybe_chunk_at(math::vector_3d const& pos, Fun&& fun) -> boost::optional<decltype (fun (nullptr))>
|
||||
auto World::for_maybe_chunk_at(glm::vec3 const& pos, Fun&& fun) -> boost::optional<decltype (fun (nullptr))>
|
||||
{
|
||||
MapTile* tile (mapIndex.getTile (pos));
|
||||
if (tile && tile->finishedLoading())
|
||||
@@ -63,7 +63,7 @@ void World::for_tile_at(tile_index const& pos, Fun&& fun)
|
||||
}
|
||||
|
||||
template<typename Fun>
|
||||
bool World::for_all_chunks_in_range (math::vector_3d const& pos, float radius, Fun&& fun)
|
||||
bool World::for_all_chunks_in_range (glm::vec3 const& pos, float radius, Fun&& fun)
|
||||
{
|
||||
bool changed (false);
|
||||
|
||||
@@ -87,7 +87,7 @@ bool World::for_all_chunks_in_range (math::vector_3d const& pos, float radius, F
|
||||
return changed;
|
||||
}
|
||||
template<typename Fun, typename Post>
|
||||
bool World::for_all_chunks_in_range (math::vector_3d const& pos, float radius, Fun&& fun, Post&& post)
|
||||
bool World::for_all_chunks_in_range (glm::vec3 const& pos, float radius, Fun&& fun, Post&& post)
|
||||
{
|
||||
std::forward_list<MapChunk*> modified_chunks;
|
||||
|
||||
@@ -115,7 +115,7 @@ bool World::for_all_chunks_in_range (math::vector_3d const& pos, float radius, F
|
||||
|
||||
|
||||
template<typename Fun>
|
||||
bool World::for_all_chunks_in_rect (math::vector_3d const& pos, float radius, Fun&& fun)
|
||||
bool World::for_all_chunks_in_rect (glm::vec3 const& pos, float radius, Fun&& fun)
|
||||
{
|
||||
bool changed (false);
|
||||
|
||||
@@ -140,7 +140,7 @@ bool World::for_all_chunks_in_rect (math::vector_3d const& pos, float radius, Fu
|
||||
}
|
||||
|
||||
template<typename Fun, typename Post>
|
||||
bool World::for_all_chunks_in_rect (math::vector_3d const& pos, float radius, Fun&& fun, Post&& post)
|
||||
bool World::for_all_chunks_in_rect (glm::vec3 const& pos, float radius, Fun&& fun, Post&& post)
|
||||
{
|
||||
std::forward_list<MapChunk*> modified_chunks;
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#include <noggit/camera.hpp>
|
||||
|
||||
#include <math/projection.hpp>
|
||||
|
||||
namespace noggit
|
||||
{
|
||||
camera::camera ( math::vector_3d const& position
|
||||
camera::camera ( glm::vec3 const& position
|
||||
, math::degrees yaw_
|
||||
, math::degrees pitch_
|
||||
)
|
||||
@@ -65,25 +63,33 @@ namespace noggit
|
||||
return _fov;
|
||||
}
|
||||
|
||||
math::vector_3d camera::look_at() const
|
||||
glm::vec3 camera::look_at() const
|
||||
{
|
||||
return position + direction();
|
||||
}
|
||||
|
||||
math::vector_3d camera::direction() const
|
||||
glm::vec3 camera::direction() const
|
||||
{
|
||||
math::vector_3d const forward (1.0f, 0.0f, 0.0f);
|
||||
glm::vec3 forward (1.0f, 0.0f, 0.0f);
|
||||
|
||||
return ( math::matrix_4x4 ( math::matrix_4x4::rotation_yzx
|
||||
, math::degrees::vec3 (_roll, _yaw, _pitch)
|
||||
)
|
||||
* forward
|
||||
).normalize();
|
||||
return glm::normalize((math::matrix_4x4(math::matrix_4x4::rotation_yzx, math::degrees::vec3(_roll._, _yaw._, _pitch._)) * forward));
|
||||
}
|
||||
|
||||
math::matrix_4x4 camera::look_at_matrix() const
|
||||
glm::mat4x4 camera::look_at_matrix() const
|
||||
{
|
||||
return math::look_at(position, look_at(), {0.f, 1.f, 0.f});
|
||||
auto eye = position;
|
||||
auto center = look_at();
|
||||
auto up = glm::vec3(0.f, 1.f, 0.f);
|
||||
|
||||
glm::vec3 const z = glm::normalize(eye - center);
|
||||
glm::vec3 const x = glm::normalize(glm::cross(up, z));
|
||||
glm::vec3 const y = glm::normalize(glm::cross(z, x));
|
||||
|
||||
return glm::transpose(glm::mat4x4(x.x, x.y, x.z, glm::dot(x, glm::vec3(-eye.x, -eye.y, -eye.z))
|
||||
, y.x, y.y, y.z, glm::dot(y, glm::vec3(-eye.x, -eye.y, -eye.z))
|
||||
, z.x, z.y, z.z, glm::dot(z, glm::vec3(-eye.x, -eye.y, -eye.z))
|
||||
, 0.f, 0.f, 0.f, 1.f
|
||||
));
|
||||
}
|
||||
|
||||
void camera::move_forward (float sign, float dt)
|
||||
@@ -98,15 +104,16 @@ namespace noggit
|
||||
|
||||
void camera::move_horizontal (float sign, float dt)
|
||||
{
|
||||
math::vector_3d const up (0.0f, 1.0f, 0.0f);
|
||||
math::vector_3d const right ( (direction() % up).normalize());
|
||||
glm::vec3 up (0.0f, 1.0f, 0.0f);
|
||||
auto cross = glm::cross(direction(), up);
|
||||
glm::vec3 right = glm::normalize(cross);
|
||||
|
||||
position += right * sign * move_speed * dt;
|
||||
}
|
||||
|
||||
void camera::move_vertical (float sign, float dt)
|
||||
{
|
||||
math::vector_3d const up (0.0f, 1.0f, 0.0f);
|
||||
glm::vec3 const up (0.0f, 1.0f, 0.0f);
|
||||
|
||||
position += up * sign * move_speed * dt;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace noggit
|
||||
class camera
|
||||
{
|
||||
public:
|
||||
camera ( math::vector_3d const& position
|
||||
camera ( glm::vec3 const& position
|
||||
, math::degrees yaw_
|
||||
, math::degrees pitch_
|
||||
);
|
||||
@@ -25,10 +25,10 @@ namespace noggit
|
||||
|
||||
math::radians fov() const;
|
||||
|
||||
math::vector_3d look_at() const;
|
||||
math::vector_3d direction() const;
|
||||
glm::vec3 look_at() const;
|
||||
glm::vec3 direction() const;
|
||||
|
||||
math::matrix_4x4 look_at_matrix() const;
|
||||
glm::mat4x4 look_at_matrix() const;
|
||||
|
||||
void move_forward (float sign, float dt);
|
||||
void move_horizontal (float sign, float dt);
|
||||
@@ -38,7 +38,7 @@ namespace noggit
|
||||
|
||||
void reset(float x, float y, float z, float roll, float yaw, float pitch);
|
||||
|
||||
math::vector_3d position;
|
||||
glm::vec3 position;
|
||||
float move_speed;
|
||||
|
||||
private:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace noggit
|
||||
{
|
||||
void cursor_render::draw(mode cursor_mode, math::matrix_4x4 const& mvp, math::vector_4d color, math::vector_3d const& pos, float radius, float inner_radius_ratio)
|
||||
void cursor_render::draw(mode cursor_mode, math::matrix_4x4 const& mvp, glm::vec4 color, glm::vec3 const& pos, float radius, float inner_radius_ratio)
|
||||
{
|
||||
if (!_uploaded)
|
||||
{
|
||||
@@ -16,7 +16,7 @@ namespace noggit
|
||||
opengl::scoped::use_program shader {*_cursor_program.get()};
|
||||
|
||||
shader.uniform("model_view_projection", mvp);
|
||||
shader.uniform("cursor_pos", pos);
|
||||
shader.uniform("cursor_pos", glm::vec3(pos.x,pos.y,pos.z));
|
||||
shader.uniform("color", color);
|
||||
shader.uniform("radius", radius);
|
||||
|
||||
@@ -55,15 +55,15 @@ namespace noggit
|
||||
|
||||
void cursor_render::create_circle_buffer(opengl::scoped::use_program& shader)
|
||||
{
|
||||
std::vector<math::vector_3d> vertices;
|
||||
std::vector<glm::vec3> vertices;
|
||||
std::vector<std::uint16_t> indices;
|
||||
|
||||
int segment = 60;
|
||||
|
||||
for (int i = 0; i < segment; ++i)
|
||||
{
|
||||
float x = math::cos(math::degrees(i * 360 / segment));
|
||||
float z = math::sin(math::degrees(i * 360 / segment));
|
||||
float x = glm::cos(math::radians(math::degrees(i * 360 / segment))._);
|
||||
float z = glm::sin(math::radians(math::degrees(i * 360 / segment))._);
|
||||
vertices.emplace_back(x, 0.f, z);
|
||||
indices.emplace_back(i);
|
||||
indices.emplace_back((i + 1) % segment);
|
||||
@@ -90,7 +90,7 @@ namespace noggit
|
||||
|
||||
void cursor_render::create_sphere_buffer(opengl::scoped::use_program& shader)
|
||||
{
|
||||
std::vector<math::vector_3d> vertices;
|
||||
std::vector<glm::vec3> vertices;
|
||||
std::vector<std::uint16_t> indices;
|
||||
|
||||
int segment = 60;
|
||||
@@ -102,14 +102,14 @@ namespace noggit
|
||||
{
|
||||
math::degrees rotation(360.f*r / static_cast<float>(rotation_plane));
|
||||
|
||||
math::matrix_4x4 m(math::matrix_4x4::rotation_xyz, math::degrees::vec3(math::degrees(0.f), math::degrees(0.f), rotation));
|
||||
math::matrix_4x4 m(math::matrix_4x4::rotation_xyz, math::degrees::vec3(math::degrees(0.f)._, math::degrees(0.f)._, rotation._));
|
||||
|
||||
for (int i = 0; i < segment; ++i)
|
||||
{
|
||||
float x = math::cos(math::degrees(i * 360 / segment));
|
||||
float z = math::sin(math::degrees(i * 360 / segment));
|
||||
float x = glm::cos(math::radians(math::degrees(i * 360 / segment))._);
|
||||
float z = glm::sin(math::radians(math::degrees(i * 360 / segment))._);
|
||||
|
||||
math::vector_3d v(x, 0.f, z);
|
||||
glm::vec3 v(x, 0.f, z);
|
||||
|
||||
vertices.emplace_back(m*v);
|
||||
if (r < rotation_plane)
|
||||
@@ -152,7 +152,7 @@ namespace noggit
|
||||
|
||||
void cursor_render::create_square_buffer(opengl::scoped::use_program& shader)
|
||||
{
|
||||
std::vector<math::vector_3d> vertices =
|
||||
std::vector<glm::vec3> vertices =
|
||||
{
|
||||
{-0.5f,0.f,-0.5f}
|
||||
,{ 0.5f,0.f,-0.5f}
|
||||
@@ -185,7 +185,7 @@ namespace noggit
|
||||
|
||||
void cursor_render::create_cube_buffer(opengl::scoped::use_program& shader)
|
||||
{
|
||||
std::vector<math::vector_3d> vertices =
|
||||
std::vector<glm::vec3> vertices =
|
||||
{
|
||||
{-0.5f,-0.5f,-0.5f}
|
||||
, { 0.5f,-0.5f,-0.5f}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math/matrix_4x4.hpp>
|
||||
#include <math/vector_3d.hpp>
|
||||
#include <opengl/scoped.hpp>
|
||||
#include <opengl/shader.fwd.hpp>
|
||||
|
||||
@@ -23,7 +21,7 @@ namespace noggit
|
||||
mode_count
|
||||
};
|
||||
|
||||
void draw(mode cursor_mode, math::matrix_4x4 const& mvp, math::vector_4d color, math::vector_3d const& pos, float radius, float inner_radius_ratio = 0.f);
|
||||
void draw(mode cursor_mode, math::matrix_4x4 const& mvp, glm::vec4 color, glm::vec3 const& pos, float radius, float inner_radius_ratio = 0.f);
|
||||
|
||||
void unload();
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
inline math::vector_2d default_uv(int px, int pz)
|
||||
inline glm::vec2 default_uv(int px, int pz)
|
||||
{
|
||||
return {static_cast<float>(px) / 4.f, static_cast<float>(pz) / 4.f};
|
||||
}
|
||||
}
|
||||
|
||||
liquid_layer::liquid_layer(ChunkWater* chunk, math::vector_3d const& base, float height, int liquid_id)
|
||||
liquid_layer::liquid_layer(ChunkWater* chunk, glm::vec3 const& base, float height, int liquid_id)
|
||||
: _liquid_id(liquid_id)
|
||||
, _liquid_vertex_format(0)
|
||||
, _minimum(height)
|
||||
@@ -36,7 +36,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk, math::vector_3d const& base, float
|
||||
unsigned v_index = z * 9 + x;
|
||||
_tex_coords[v_index] = default_uv(x, z);
|
||||
_depth[v_index] = 1.0f;
|
||||
_vertices[v_index] = math::vector_3d(
|
||||
_vertices[v_index] = glm::vec3(
|
||||
pos.x + UNITSIZE * x
|
||||
, height
|
||||
, pos.z + UNITSIZE * z
|
||||
@@ -48,7 +48,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk, math::vector_3d const& base, float
|
||||
|
||||
}
|
||||
|
||||
liquid_layer::liquid_layer(ChunkWater* chunk, math::vector_3d const& base, mclq& liquid, int liquid_id)
|
||||
liquid_layer::liquid_layer(ChunkWater* chunk, glm::vec3 const& base, mclq& liquid, int liquid_id)
|
||||
: _liquid_id(liquid_id)
|
||||
, _minimum(liquid.min_height)
|
||||
, _maximum(liquid.max_height)
|
||||
@@ -76,7 +76,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk, math::vector_3d const& base, mclq&
|
||||
if (_liquid_vertex_format == 1)
|
||||
{
|
||||
_depth[v_index] = 1.0f;
|
||||
_tex_coords[v_index] = math::vector_2d(static_cast<float>(v.magma.x) / 255.f, static_cast<float>(v.magma.y) / 255.f);
|
||||
_tex_coords[v_index] = glm::vec2(static_cast<float>(v.magma.x) / 255.f, static_cast<float>(v.magma.y) / 255.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -84,7 +84,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk, math::vector_3d const& base, mclq&
|
||||
_tex_coords[v_index] = default_uv(x, z);
|
||||
}
|
||||
|
||||
_vertices[v_index] = math::vector_3d(
|
||||
_vertices[v_index] = glm::vec3(
|
||||
pos.x + UNITSIZE * x
|
||||
// sometimes there's garbage data on unused tiles that mess things up
|
||||
, std::max(std::min(v.height, _maximum), _minimum)
|
||||
@@ -95,7 +95,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk, math::vector_3d const& base, mclq&
|
||||
|
||||
}
|
||||
|
||||
liquid_layer::liquid_layer(ChunkWater* chunk, MPQFile &f, std::size_t base_pos, math::vector_3d const& base, MH2O_Information const& info, std::uint64_t infomask)
|
||||
liquid_layer::liquid_layer(ChunkWater* chunk, MPQFile &f, std::size_t base_pos, glm::vec3 const& base, MH2O_Information const& info, std::uint64_t infomask)
|
||||
: _liquid_id(info.liquid_id)
|
||||
, _liquid_vertex_format(info.liquid_vertex_format)
|
||||
, _minimum(info.minHeight)
|
||||
@@ -122,7 +122,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk, MPQFile &f, std::size_t base_pos,
|
||||
const unsigned v_index = z * 9 + x;
|
||||
_tex_coords[v_index] = default_uv(x, z);
|
||||
_depth[v_index] = 1.0f;
|
||||
_vertices[v_index] = math::vector_3d(
|
||||
_vertices[v_index] = glm::vec3(
|
||||
pos.x + UNITSIZE * x
|
||||
, _minimum
|
||||
, pos.z + UNITSIZE * z
|
||||
@@ -452,21 +452,21 @@ void liquid_layer::setSubchunk(int x, int z, bool water)
|
||||
misc::set_bit(_subchunks, x, z, water);
|
||||
}
|
||||
|
||||
void liquid_layer::paintLiquid( math::vector_3d const& cursor_pos
|
||||
void liquid_layer::paintLiquid( glm::vec3 const& cursor_pos
|
||||
, float radius
|
||||
, bool add
|
||||
, math::radians const& angle
|
||||
, math::radians const& orientation
|
||||
, bool lock
|
||||
, math::vector_3d const& origin
|
||||
, glm::vec3 const& origin
|
||||
, bool override_height
|
||||
, MapChunk* chunk
|
||||
, float opacity_factor
|
||||
)
|
||||
{
|
||||
math::vector_3d ref ( lock
|
||||
glm::vec3 ref ( lock
|
||||
? origin
|
||||
: math::vector_3d (cursor_pos.x, cursor_pos.y + 1.0f, cursor_pos.z)
|
||||
: glm::vec3 (cursor_pos.x, cursor_pos.y + 1.0f, cursor_pos.z)
|
||||
);
|
||||
|
||||
int id = 0;
|
||||
@@ -512,7 +512,7 @@ void liquid_layer::update_min_max()
|
||||
_maximum = std::numeric_limits<float>::lowest();
|
||||
int x = 0, z = 0;
|
||||
|
||||
for (math::vector_3d& v : _vertices)
|
||||
for (glm::vec3& v : _vertices)
|
||||
{
|
||||
if (hasSubchunk(std::min(x, 7), std::min(z, 7)))
|
||||
{
|
||||
@@ -557,7 +557,7 @@ void liquid_layer::update_vertex_opacity(int x, int z, MapChunk* chunk, float fa
|
||||
_depth[z * 9 + x] = diff < 0.0f ? 0.0f : (std::min(1.0f, std::max(0.0f, (diff + 1.0f) * factor)));
|
||||
}
|
||||
|
||||
int liquid_layer::get_lod_level(math::vector_3d const& camera_pos) const
|
||||
int liquid_layer::get_lod_level(glm::vec3 const& camera_pos) const
|
||||
{
|
||||
auto const& center_vertex (_vertices[5 * 9 + 4]);
|
||||
auto const dist ((center_vertex - camera_pos).length());
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <noggit/MPQ.h>
|
||||
#include <opengl/scoped.hpp>
|
||||
#include <array>
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
class MapChunk;
|
||||
class sExtendableArray;
|
||||
@@ -27,9 +28,9 @@ class liquid_layer
|
||||
|
||||
public:
|
||||
liquid_layer() = delete;
|
||||
liquid_layer(ChunkWater* chunk, math::vector_3d const& base, float height, int liquid_id);
|
||||
liquid_layer(ChunkWater* chunk, math::vector_3d const& base, mclq& liquid, int liquid_id);
|
||||
liquid_layer(ChunkWater* chunk, MPQFile &f, std::size_t base_pos, math::vector_3d const& base, MH2O_Information const& info, std::uint64_t infomask);
|
||||
liquid_layer(ChunkWater* chunk, glm::vec3 const& base, float height, int liquid_id);
|
||||
liquid_layer(ChunkWater* chunk, glm::vec3 const& base, mclq& liquid, int liquid_id);
|
||||
liquid_layer(ChunkWater* chunk, MPQFile &f, std::size_t base_pos, glm::vec3 const& base, MH2O_Information const& info, std::uint64_t infomask);
|
||||
|
||||
liquid_layer(liquid_layer const& other);
|
||||
liquid_layer(liquid_layer&&);
|
||||
@@ -44,9 +45,9 @@ public:
|
||||
void crop(MapChunk* chunk);
|
||||
void update_opacity(MapChunk* chunk, float factor);
|
||||
|
||||
std::array<math::vector_3d, 9 * 9>& getVertices() { return _vertices; };
|
||||
std::array<glm::vec3, 9 * 9>& getVertices() { return _vertices; };
|
||||
std::array<float, 9 * 9>& getDepth() { return _depth; };
|
||||
std::array<math::vector_2d, 9 * 9>& getTexCoords() { return _tex_coords; };
|
||||
std::array<glm::vec2, 9 * 9>& getTexCoords() { return _tex_coords; };
|
||||
|
||||
float min() const { return _minimum; }
|
||||
float max() const { return _maximum; }
|
||||
@@ -61,13 +62,13 @@ public:
|
||||
bool full() const { return _subchunks == std::uint64_t(-1); }
|
||||
void clear() { _subchunks = std::uint64_t(0); }
|
||||
|
||||
void paintLiquid(math::vector_3d const& pos
|
||||
void paintLiquid(glm::vec3 const& pos
|
||||
, float radius
|
||||
, bool add
|
||||
, math::radians const& angle
|
||||
, math::radians const& orientation
|
||||
, bool lock
|
||||
, math::vector_3d const& origin
|
||||
, glm::vec3 const& origin
|
||||
, bool override_height
|
||||
, MapChunk* chunk
|
||||
, float opacity_factor
|
||||
@@ -80,7 +81,7 @@ public:
|
||||
private:
|
||||
void update_min_max();
|
||||
void update_vertex_opacity(int x, int z, MapChunk* chunk, float factor);
|
||||
int get_lod_level(math::vector_3d const& camera_pos) const;
|
||||
int get_lod_level(glm::vec3 const& camera_pos) const;
|
||||
void set_lod_level(int lod_level);
|
||||
|
||||
int _liquid_id;
|
||||
@@ -89,14 +90,14 @@ private:
|
||||
float _maximum;
|
||||
|
||||
std::uint64_t _subchunks;
|
||||
std::array<math::vector_3d, 9 * 9> _vertices;
|
||||
std::array<glm::vec3, 9 * 9> _vertices;
|
||||
std::array<float, 9 * 9> _depth;
|
||||
std::array<math::vector_2d, 9 * 9> _tex_coords;
|
||||
std::array<glm::vec2, 9 * 9> _tex_coords;
|
||||
|
||||
std::map<int, std::vector<std::uint16_t>> _indices_by_lod;
|
||||
|
||||
|
||||
private:
|
||||
math::vector_3d pos;
|
||||
glm::vec3 pos;
|
||||
ChunkWater* _chunk;
|
||||
};
|
||||
|
||||
@@ -245,7 +245,7 @@ map_horizon::minimap::minimap(const map_horizon& horizon)
|
||||
|
||||
map_horizon::render::render(const map_horizon& horizon)
|
||||
{
|
||||
std::vector<math::vector_3d> vertices;
|
||||
std::vector<glm::vec3> vertices;
|
||||
|
||||
for (size_t y (0); y < 64; ++y)
|
||||
{
|
||||
@@ -280,7 +280,7 @@ map_horizon::render::render(const map_horizon& horizon)
|
||||
}
|
||||
}
|
||||
|
||||
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d> (_vertex_buffer, vertices, GL_STATIC_DRAW);
|
||||
gl.bufferData<GL_ARRAY_BUFFER, glm::vec3> (_vertex_buffer, vertices, GL_STATIC_DRAW);
|
||||
}
|
||||
|
||||
static inline uint32_t outer_index(const map_horizon_batch &batch, int y, int x)
|
||||
@@ -293,13 +293,13 @@ static inline uint32_t inner_index(const map_horizon_batch &batch, int y, int x)
|
||||
return batch.vertex_start + 17 * 17 + y * 16 + x;
|
||||
};
|
||||
|
||||
void map_horizon::render::draw( math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
void map_horizon::render::draw( glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, MapIndex *index
|
||||
, const math::vector_3d& color
|
||||
, const glm::vec3& color
|
||||
, const float& cull_distance
|
||||
, const math::frustum& frustum
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, display_mode display
|
||||
)
|
||||
{
|
||||
@@ -382,7 +382,7 @@ void map_horizon::render::draw( math::matrix_4x4 const& model_view
|
||||
|
||||
shader.uniform ("model_view", model_view);
|
||||
shader.uniform ("projection", projection);
|
||||
shader.uniform ("color", color);
|
||||
shader.uniform ("color", glm::vec3(color.x, color.y, color.z));
|
||||
|
||||
shader.attrib ("position", _vertex_buffer, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
|
||||
@@ -48,13 +48,13 @@ public:
|
||||
{
|
||||
render(const map_horizon& horizon);
|
||||
|
||||
void draw( math::matrix_4x4 const& model_view
|
||||
, math::matrix_4x4 const& projection
|
||||
void draw(glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, MapIndex *index
|
||||
, const math::vector_3d& color
|
||||
, const glm::vec3& color
|
||||
, const float& cull_distance
|
||||
, const math::frustum& frustum
|
||||
, const math::vector_3d& camera
|
||||
, const glm::vec3& camera
|
||||
, display_mode display
|
||||
);
|
||||
|
||||
|
||||
@@ -332,7 +332,7 @@ bool MapIndex::has_unsaved_changes(const tile_index& tile) const
|
||||
return (tileLoaded(tile) ? getTile(tile)->changed.load() : false);
|
||||
}
|
||||
|
||||
void MapIndex::setFlag(bool to, math::vector_3d const& pos, uint32_t flag)
|
||||
void MapIndex::setFlag(bool to, glm::vec3 const& pos, uint32_t flag)
|
||||
{
|
||||
tile_index tile(pos);
|
||||
|
||||
@@ -727,7 +727,7 @@ uid_fix_status MapIndex::fixUIDs (World* world, bool cancel_on_model_loading_err
|
||||
continue;
|
||||
}
|
||||
|
||||
std::array<math::vector_3d, 2> tileExtents;
|
||||
std::array<glm::vec3, 2> tileExtents;
|
||||
tileExtents[0] = { x*TILESIZE, 0, z*TILESIZE };
|
||||
tileExtents[1] = { (x+1)*TILESIZE, 0, (z+1)*TILESIZE };
|
||||
misc::minmax(&tileExtents[0], &tileExtents[1]);
|
||||
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
([] (tile_index const&, MapTile* tile) { return !!tile && tile->finishedLoading(); });
|
||||
}
|
||||
|
||||
auto tiles_in_range (math::vector_3d const& pos, float radius)
|
||||
auto tiles_in_range (glm::vec3 const& pos, float radius)
|
||||
{
|
||||
return tiles<true>
|
||||
( [this, pos, radius] (tile_index const& index, MapTile*)
|
||||
@@ -151,10 +151,10 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
auto tiles_in_rect (math::vector_3d const& pos, float radius)
|
||||
auto tiles_in_rect (glm::vec3 const& pos, float radius)
|
||||
{
|
||||
math::vector_2d l_chunk{pos.x - radius, pos.z - radius};
|
||||
math::vector_2d r_chunk{pos.x + radius, pos.z + radius};
|
||||
glm::vec2 l_chunk{pos.x - radius, pos.z - radius};
|
||||
glm::vec2 r_chunk{pos.x + radius, pos.z + radius};
|
||||
|
||||
return tiles<true>
|
||||
( [this, pos, radius, l_chunk, r_chunk] (tile_index const& index, MapTile*)
|
||||
@@ -162,8 +162,8 @@ public:
|
||||
if (!hasTile(index) || radius == 0.f)
|
||||
return false;
|
||||
|
||||
math::vector_2d l_tile{index.x * TILESIZE, index.z * TILESIZE};
|
||||
math::vector_2d r_tile{index.x * TILESIZE + TILESIZE, index.z * TILESIZE + TILESIZE};
|
||||
glm::vec2 l_tile{index.x * TILESIZE, index.z * TILESIZE};
|
||||
glm::vec2 r_tile{index.x * TILESIZE + TILESIZE, index.z * TILESIZE + TILESIZE};
|
||||
|
||||
return ((l_chunk.x < r_tile.x) && (r_chunk.x >= l_tile.x) && (l_chunk.y < r_tile.y) && (r_chunk.y >= l_tile.y));
|
||||
}
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
void setChanged(MapTile* tile);
|
||||
|
||||
void unsetChanged(const tile_index& tile);
|
||||
void setFlag(bool to, math::vector_3d const& pos, uint32_t flag);
|
||||
void setFlag(bool to, glm::vec3 const& pos, uint32_t flag);
|
||||
bool has_unsaved_changes(const tile_index& tile) const;
|
||||
|
||||
void saveTile(const tile_index& tile, World*, bool save_unloaded = false);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user