fixed simd normalize because i guess you needed to check for dot > eps2, actually enabled use of custom allocator for uf::stl containers, updated nlohmann/json wrapper to use supplied types (should fully remove the need to glue on float64_t to it for dreamcast, even though either -m4/-m4-single fixed that last i checked), fixed weird issue with debug draw having frame % 3 draw the wireframe without a transformation matrix presumably because the camera viewport was [4] instead of [6] (even-even though it fixed itself when i only set the specialization constant for debug text only), mostly corrected source-engine physics state even though it should probably get defined in the bsp loader or something
This commit is contained in:
parent
b309a60b8c
commit
9597916568
@ -1,6 +1,9 @@
|
||||
#version 450
|
||||
#pragma shader_stage(vertex)
|
||||
|
||||
#extension GL_EXT_multiview : enable
|
||||
|
||||
|
||||
#include "../../common/macros.h"
|
||||
#include "../../common/structs.h"
|
||||
|
||||
@ -22,6 +25,9 @@ layout (binding = 0) uniform Camera {
|
||||
layout (location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
uint viewportIndex = gl_ViewIndex;
|
||||
if ( PushConstant.aux == 1 ) viewportIndex += 2;
|
||||
|
||||
outColor = inColor;
|
||||
gl_Position = camera.viewport[PushConstant.pass].projection * camera.viewport[PushConstant.pass].view * vec4(inPos.xyz, 1.0);
|
||||
gl_Position = camera.viewport[viewportIndex].projection * camera.viewport[viewportIndex].view * vec4(inPos.xyz, 1.0);
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
#version 450
|
||||
#pragma shader_stage(vertex)
|
||||
|
||||
#extension GL_EXT_multiview : enable
|
||||
|
||||
#include "../../common/macros.h"
|
||||
#include "../../common/structs.h"
|
||||
|
||||
@ -25,10 +27,13 @@ layout (location = 0) out vec2 outUv;
|
||||
layout (location = 1) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
uint viewportIndex = gl_ViewIndex;
|
||||
if ( PushConstant.aux == 1 ) viewportIndex += 2;
|
||||
|
||||
outUv = inUv;
|
||||
outColor = inColor;
|
||||
|
||||
vec4 clipPos = camera.viewport[PushConstant.pass].projection * camera.viewport[PushConstant.pass].view * vec4(inPos.xyz, 1.0);
|
||||
vec4 clipPos = camera.viewport[viewportIndex].projection * camera.viewport[viewportIndex].view * vec4(inPos.xyz, 1.0);
|
||||
//clipPos.xy += inOffset * (clipPos.w / max(clipPos.w, 1.0));
|
||||
clipPos.xy += inOffset * min(clipPos.w, 1.0);
|
||||
gl_Position = clipPos;}
|
||||
@ -1,552 +0,0 @@
|
||||
/*
|
||||
The code is licensed under the MIT License <http://opensource.org/licenses/MIT>:
|
||||
|
||||
Copyright (c) 2015-2017 Niels Lohmann.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef NLOHMANN_FIFO_MAP_HPP
|
||||
#define NLOHMANN_FIFO_MAP_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
/*!
|
||||
@brief namespace for Niels Lohmann
|
||||
@see https://github.com/nlohmann
|
||||
*/
|
||||
namespace nlohmann
|
||||
{
|
||||
|
||||
template<class Key>
|
||||
class fifo_map_compare
|
||||
{
|
||||
public:
|
||||
/// constructor given a pointer to a key storage
|
||||
fifo_map_compare(
|
||||
std::unordered_map<Key, std::size_t>* keys,
|
||||
std::size_t timestamp = 1)
|
||||
:
|
||||
m_timestamp(timestamp),
|
||||
m_keys(keys)
|
||||
{}
|
||||
|
||||
/*!
|
||||
This function compares two keys with respect to the order in which they
|
||||
were added to the container. For this, the mapping keys is used.
|
||||
*/
|
||||
bool operator()(const Key& lhs, const Key& rhs) const
|
||||
{
|
||||
// look up timestamps for both keys
|
||||
const auto timestamp_lhs = m_keys->find(lhs);
|
||||
const auto timestamp_rhs = m_keys->find(rhs);
|
||||
|
||||
if (timestamp_lhs == m_keys->end())
|
||||
{
|
||||
// timestamp for lhs not found - cannot be smaller than for rhs
|
||||
return false;
|
||||
}
|
||||
|
||||
if (timestamp_rhs == m_keys->end())
|
||||
{
|
||||
// timestamp for rhs not found - timestamp for lhs is smaller
|
||||
return true;
|
||||
}
|
||||
|
||||
// compare timestamps
|
||||
return timestamp_lhs->second < timestamp_rhs->second;
|
||||
}
|
||||
|
||||
void add_key(const Key& key)
|
||||
{
|
||||
m_keys->insert({key, m_timestamp++});
|
||||
}
|
||||
|
||||
void remove_key(const Key& key)
|
||||
{
|
||||
m_keys->erase(key);
|
||||
}
|
||||
|
||||
private:
|
||||
/// helper to access m_timestamp from fifo_map copy ctor,
|
||||
/// must have same number of template args as fifo_map
|
||||
template <
|
||||
class MapKey,
|
||||
class MapT,
|
||||
class MapCompare,
|
||||
class MapAllocator
|
||||
> friend class fifo_map;
|
||||
|
||||
private:
|
||||
/// the next valid insertion timestamp
|
||||
std::size_t m_timestamp = 1;
|
||||
|
||||
/// pointer to a mapping from keys to insertion timestamps
|
||||
std::unordered_map<Key, std::size_t>* m_keys = nullptr;
|
||||
};
|
||||
|
||||
|
||||
template <
|
||||
class Key,
|
||||
class T,
|
||||
class Compare = fifo_map_compare<Key>,
|
||||
class Allocator = std::allocator<std::pair<const Key, T>>
|
||||
> class fifo_map
|
||||
{
|
||||
public:
|
||||
using key_type = Key;
|
||||
using mapped_type = T;
|
||||
using value_type = std::pair<const Key, T>;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using key_compare = Compare;
|
||||
using allocator_type = Allocator;
|
||||
using reference = value_type&;
|
||||
using const_reference = const value_type&;
|
||||
using pointer = typename std::allocator_traits<Allocator>::pointer;
|
||||
using const_pointer = typename std::allocator_traits<Allocator>::const_pointer;
|
||||
|
||||
using internal_map_type = std::map<Key, T, Compare, Allocator>;
|
||||
|
||||
using iterator = typename internal_map_type::iterator;
|
||||
using const_iterator = typename internal_map_type::const_iterator;
|
||||
using reverse_iterator = typename internal_map_type::reverse_iterator;
|
||||
using const_reverse_iterator = typename internal_map_type::const_reverse_iterator;
|
||||
|
||||
public:
|
||||
/// default constructor
|
||||
fifo_map() : m_keys(), m_compare(&m_keys), m_map(m_compare) {}
|
||||
|
||||
/// copy constructor
|
||||
fifo_map(const fifo_map &f) : m_keys(f.m_keys), m_compare(&m_keys, f.m_compare.m_timestamp), m_map(f.m_map.begin(), f.m_map.end(), m_compare) {}
|
||||
|
||||
/// constructor for a range of elements
|
||||
template<class InputIterator>
|
||||
fifo_map(InputIterator first, InputIterator last)
|
||||
: m_keys(), m_compare(&m_keys), m_map(m_compare)
|
||||
{
|
||||
for (auto it = first; it != last; ++it)
|
||||
{
|
||||
insert(*it);
|
||||
}
|
||||
}
|
||||
|
||||
/// constructor for a list of elements
|
||||
fifo_map(std::initializer_list<value_type> init) : fifo_map()
|
||||
{
|
||||
for (auto x : init)
|
||||
{
|
||||
insert(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Element access
|
||||
*/
|
||||
|
||||
/// access specified element with bounds checking
|
||||
T& at(const Key& key)
|
||||
{
|
||||
return m_map.at(key);
|
||||
}
|
||||
|
||||
/// access specified element with bounds checking
|
||||
const T& at(const Key& key) const
|
||||
{
|
||||
return m_map.at(key);
|
||||
}
|
||||
|
||||
/// access specified element
|
||||
T& operator[](const Key& key)
|
||||
{
|
||||
m_compare.add_key(key);
|
||||
return m_map[key];
|
||||
}
|
||||
|
||||
/// access specified element
|
||||
T& operator[](Key&& key)
|
||||
{
|
||||
m_compare.add_key(key);
|
||||
return m_map[key];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Iterators
|
||||
*/
|
||||
|
||||
/// returns an iterator to the beginning
|
||||
iterator begin() noexcept
|
||||
{
|
||||
return m_map.begin();
|
||||
}
|
||||
|
||||
/// returns an iterator to the end
|
||||
iterator end() noexcept
|
||||
{
|
||||
return m_map.end();
|
||||
}
|
||||
|
||||
/// returns an iterator to the beginning
|
||||
const_iterator begin() const noexcept
|
||||
{
|
||||
return m_map.begin();
|
||||
}
|
||||
|
||||
/// returns an iterator to the end
|
||||
const_iterator end() const noexcept
|
||||
{
|
||||
return m_map.end();
|
||||
}
|
||||
|
||||
/// returns an iterator to the beginning
|
||||
const_iterator cbegin() const noexcept
|
||||
{
|
||||
return m_map.cbegin();
|
||||
}
|
||||
|
||||
/// returns an iterator to the end
|
||||
const_iterator cend() const noexcept
|
||||
{
|
||||
return m_map.cend();
|
||||
}
|
||||
|
||||
/// returns a reverse iterator to the beginning
|
||||
reverse_iterator rbegin() noexcept
|
||||
{
|
||||
return m_map.rbegin();
|
||||
}
|
||||
|
||||
/// returns a reverse iterator to the end
|
||||
reverse_iterator rend() noexcept
|
||||
{
|
||||
return m_map.rend();
|
||||
}
|
||||
|
||||
/// returns a reverse iterator to the beginning
|
||||
const_reverse_iterator rbegin() const noexcept
|
||||
{
|
||||
return m_map.rbegin();
|
||||
}
|
||||
|
||||
/// returns a reverse iterator to the end
|
||||
const_reverse_iterator rend() const noexcept
|
||||
{
|
||||
return m_map.rend();
|
||||
}
|
||||
|
||||
/// returns a reverse iterator to the beginning
|
||||
const_reverse_iterator crbegin() const noexcept
|
||||
{
|
||||
return m_map.crbegin();
|
||||
}
|
||||
|
||||
/// returns a reverse iterator to the end
|
||||
const_reverse_iterator crend() const noexcept
|
||||
{
|
||||
return m_map.crend();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Capacity
|
||||
*/
|
||||
|
||||
/// checks whether the container is empty
|
||||
bool empty() const noexcept
|
||||
{
|
||||
return m_map.empty();
|
||||
}
|
||||
|
||||
/// returns the number of elements
|
||||
size_type size() const noexcept
|
||||
{
|
||||
return m_map.size();
|
||||
}
|
||||
|
||||
/// returns the maximum possible number of elements
|
||||
size_type max_size() const noexcept
|
||||
{
|
||||
return m_map.max_size();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Modifiers
|
||||
*/
|
||||
|
||||
/// clears the contents
|
||||
void clear() noexcept
|
||||
{
|
||||
m_map.clear();
|
||||
m_keys.clear();
|
||||
}
|
||||
|
||||
/// insert value
|
||||
std::pair<iterator, bool> insert(const value_type& value)
|
||||
{
|
||||
m_compare.add_key(value.first);
|
||||
return m_map.insert(value);
|
||||
}
|
||||
|
||||
/// insert value
|
||||
template<class P>
|
||||
std::pair<iterator, bool> insert( P&& value )
|
||||
{
|
||||
m_compare.add_key(value.first);
|
||||
return m_map.insert(value);
|
||||
}
|
||||
|
||||
/// insert value with hint
|
||||
iterator insert(const_iterator hint, const value_type& value)
|
||||
{
|
||||
m_compare.add_key(value.first);
|
||||
return m_map.insert(hint, value);
|
||||
}
|
||||
|
||||
/// insert value with hint
|
||||
iterator insert(const_iterator hint, value_type&& value)
|
||||
{
|
||||
m_compare.add_key(value.first);
|
||||
return m_map.insert(hint, value);
|
||||
}
|
||||
|
||||
/// insert value range
|
||||
template<class InputIt>
|
||||
void insert(InputIt first, InputIt last)
|
||||
{
|
||||
for (const_iterator it = first; it != last; ++it)
|
||||
{
|
||||
m_compare.add_key(it->first);
|
||||
}
|
||||
|
||||
m_map.insert(first, last);
|
||||
}
|
||||
|
||||
/// insert value list
|
||||
void insert(std::initializer_list<value_type> ilist)
|
||||
{
|
||||
for (auto value : ilist)
|
||||
{
|
||||
m_compare.add_key(value.first);
|
||||
}
|
||||
|
||||
m_map.insert(ilist);
|
||||
}
|
||||
|
||||
/// constructs element in-place
|
||||
template<class... Args>
|
||||
std::pair<iterator, bool> emplace(Args&& ... args)
|
||||
{
|
||||
typename fifo_map::value_type value(std::forward<Args>(args)...);
|
||||
m_compare.add_key(value.first);
|
||||
return m_map.emplace(std::move(value));
|
||||
}
|
||||
|
||||
/// constructs element in-place with hint
|
||||
template<class... Args>
|
||||
iterator emplace_hint(const_iterator hint, Args&& ... args)
|
||||
{
|
||||
typename fifo_map::value_type value(std::forward<Args>(args)...);
|
||||
m_compare.add_key(value.first);
|
||||
return m_map.emplace_hint(hint, std::move(value));
|
||||
}
|
||||
|
||||
/// remove element at position
|
||||
iterator erase(const_iterator pos)
|
||||
{
|
||||
m_compare.remove_key(pos->first);
|
||||
return m_map.erase(pos);
|
||||
}
|
||||
|
||||
/// remove elements in range
|
||||
iterator erase(const_iterator first, const_iterator last)
|
||||
{
|
||||
for (const_iterator it = first; it != last; ++it)
|
||||
{
|
||||
m_compare.remove_key(it->first);
|
||||
}
|
||||
|
||||
return m_map.erase(first, last);
|
||||
}
|
||||
|
||||
/// remove elements with key
|
||||
size_type erase(const key_type& key)
|
||||
{
|
||||
size_type res = m_map.erase(key);
|
||||
|
||||
if (res > 0)
|
||||
{
|
||||
m_compare.remove_key(key);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/// swaps the contents
|
||||
void swap(fifo_map& other)
|
||||
{
|
||||
std::swap(m_map, other.m_map);
|
||||
std::swap(m_compare, other.m_compare);
|
||||
std::swap(m_keys, other.m_keys);
|
||||
}
|
||||
|
||||
// reserve
|
||||
void reserve(size_t c) {
|
||||
// m_map.reserve(c);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Lookup
|
||||
*/
|
||||
|
||||
/// returns the number of elements matching specific key
|
||||
size_type count(const Key& key) const
|
||||
{
|
||||
return m_map.count(key);
|
||||
}
|
||||
|
||||
/// finds element with specific key
|
||||
iterator find(const Key& key)
|
||||
{
|
||||
return m_map.find(key);
|
||||
}
|
||||
|
||||
/// finds element with specific key
|
||||
const_iterator find(const Key& key) const
|
||||
{
|
||||
return m_map.find(key);
|
||||
}
|
||||
|
||||
/// returns range of elements matching a specific key
|
||||
std::pair<iterator, iterator> equal_range(const Key& key)
|
||||
{
|
||||
return m_map.equal_range(key);
|
||||
}
|
||||
|
||||
/// returns range of elements matching a specific key
|
||||
std::pair<const_iterator, const_iterator> equal_range(const Key& key) const
|
||||
{
|
||||
return m_map.equal_range(key);
|
||||
}
|
||||
|
||||
/// returns an iterator to the first element not less than the given key
|
||||
iterator lower_bound(const Key& key)
|
||||
{
|
||||
return m_map.lower_bound(key);
|
||||
}
|
||||
|
||||
/// returns an iterator to the first element not less than the given key
|
||||
const_iterator lower_bound(const Key& key) const
|
||||
{
|
||||
return m_map.lower_bound(key);
|
||||
}
|
||||
|
||||
/// returns an iterator to the first element greater than the given key
|
||||
iterator upper_bound(const Key& key)
|
||||
{
|
||||
return m_map.upper_bound(key);
|
||||
}
|
||||
|
||||
/// returns an iterator to the first element greater than the given key
|
||||
const_iterator upper_bound(const Key& key) const
|
||||
{
|
||||
return m_map.upper_bound(key);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Observers
|
||||
*/
|
||||
|
||||
/// returns the function that compares keys
|
||||
key_compare key_comp() const
|
||||
{
|
||||
return m_compare;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Non-member functions
|
||||
*/
|
||||
|
||||
friend bool operator==(const fifo_map& lhs, const fifo_map& rhs)
|
||||
{
|
||||
return lhs.m_map == rhs.m_map;
|
||||
}
|
||||
|
||||
friend bool operator!=(const fifo_map& lhs, const fifo_map& rhs)
|
||||
{
|
||||
return lhs.m_map != rhs.m_map;
|
||||
}
|
||||
|
||||
friend bool operator<(const fifo_map& lhs, const fifo_map& rhs)
|
||||
{
|
||||
return lhs.m_map < rhs.m_map;
|
||||
}
|
||||
|
||||
friend bool operator<=(const fifo_map& lhs, const fifo_map& rhs)
|
||||
{
|
||||
return lhs.m_map <= rhs.m_map;
|
||||
}
|
||||
|
||||
friend bool operator>(const fifo_map& lhs, const fifo_map& rhs)
|
||||
{
|
||||
return lhs.m_map > rhs.m_map;
|
||||
}
|
||||
|
||||
friend bool operator>=(const fifo_map& lhs, const fifo_map& rhs)
|
||||
{
|
||||
return lhs.m_map >= rhs.m_map;
|
||||
}
|
||||
|
||||
private:
|
||||
/// the keys
|
||||
std::unordered_map<Key, std::size_t> m_keys;
|
||||
/// the comparison object
|
||||
Compare m_compare;
|
||||
/// the internal data structure
|
||||
internal_map_type m_map;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// specialization of std::swap
|
||||
namespace std
|
||||
{
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline void swap(nlohmann::fifo_map<Key, T, Compare, Allocator>& m1,
|
||||
nlohmann::fifo_map<Key, T, Compare, Allocator>& m2)
|
||||
{
|
||||
m1.swap(m2);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@ -24,12 +24,12 @@ uf::hashed_string uf::Object::formatHookName( const uf::stl::string_view& n ) {
|
||||
if ( n.ends_with(PARENT_UID_SUFFIX) ) {
|
||||
size_t uid = this->hasParent() ? this->getParent().getUid() : this->getUid();
|
||||
uf::hashed_string hash{uf::stl::string_view(n).substr(0, n.size() - PARENT_UID_SUFFIX.size())};
|
||||
return uf::algo::fnv1a( ::fmt::format("{}", uid), hash );
|
||||
return uf::algo::fnv1a( FMT_FORMAT("{}", uid), hash );
|
||||
}
|
||||
if ( n.ends_with(UID_SUFFIX) ) {
|
||||
size_t uid = this->getUid();
|
||||
uf::hashed_string hash{uf::stl::string_view(n).substr(0, n.size() - UID_SUFFIX.size())};
|
||||
return uf::algo::fnv1a( ::fmt::format("{}", uid), hash );
|
||||
return uf::algo::fnv1a( FMT_FORMAT("{}", uid), hash );
|
||||
}
|
||||
|
||||
return n;
|
||||
@ -44,7 +44,7 @@ uf::hashed_string uf::Object::formatHookName( const uf::stl::string_view& n, siz
|
||||
|
||||
if ( n.ends_with(UID_SUFFIX) ) {
|
||||
uf::hashed_string hash = uf::stl::string_view(n).substr(0, n.size() - UID_SUFFIX.size());
|
||||
return uf::algo::fnv1a( ::fmt::format("{}", uid), hash );
|
||||
return uf::algo::fnv1a( FMT_FORMAT("{}", uid), hash );
|
||||
}
|
||||
|
||||
return n;
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
|
||||
#include <uf/utils/memory/vector.h>
|
||||
#include <uf/utils/memory/string.h>
|
||||
#include <uf/utils/memory/unordered_map.h>
|
||||
#include <uf/utils/memory/map.h>
|
||||
|
||||
#if !UF_EXCEPTIONS
|
||||
#define JSON_NOEXCEPTION 1
|
||||
@ -22,6 +24,12 @@ namespace uf {
|
||||
class UF_API Serializer;
|
||||
}
|
||||
|
||||
#if UF_ENV_DREAMCAST
|
||||
#define float64_t decltype(1.0L)
|
||||
#else
|
||||
#define float64_t double
|
||||
#endif
|
||||
|
||||
namespace ext {
|
||||
namespace json {
|
||||
class UF_API Value;
|
||||
@ -30,12 +38,40 @@ namespace ext {
|
||||
#if UF_JSON_NLOHMANN_FIFO_MAP
|
||||
template<class K, class V, class dummy_compare, class A>
|
||||
using fifo_map = nlohmann::fifo_map<K, V, nlohmann::fifo_map_compare<K>, A>;
|
||||
typedef nlohmann::basic_json<fifo_map> base_value;
|
||||
|
||||
typedef nlohmann::basic_json<
|
||||
uf::stl::fifo_map,
|
||||
uf::stl::vector,
|
||||
uf::stl::string,
|
||||
bool,
|
||||
int64_t,
|
||||
uint64_t,
|
||||
float64_t,
|
||||
uf::Allocator
|
||||
> base_value;
|
||||
#else
|
||||
typedef nlohmann::ordered_json base_value;
|
||||
typedef nlohmann::basic_json<
|
||||
nlohmann::ordered_map,
|
||||
uf::stl::vector,
|
||||
uf::stl::string,
|
||||
bool,
|
||||
int64_t,
|
||||
uint64_t,
|
||||
float64_t,
|
||||
uf::Allocator
|
||||
> base_value;
|
||||
#endif
|
||||
#else
|
||||
typedef nlohmann::json base_value;
|
||||
typedef nlohmann::basic_json<
|
||||
uf::stl::map,
|
||||
uf::stl::vector,
|
||||
uf::stl::string,
|
||||
bool,
|
||||
int64_t,
|
||||
uint64_t,
|
||||
float64_t,
|
||||
uf::Allocator
|
||||
> base_value;
|
||||
#endif
|
||||
|
||||
class UF_API Value : public base_value {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#if UF_USE_LGS
|
||||
#include <uf/config.h>
|
||||
#include <uf/engine/graph/graph.h>
|
||||
|
||||
@ -7,4 +7,5 @@ namespace ext {
|
||||
namespace lgs {
|
||||
bool UF_API loadBin( pod::Graph& graph, const uf::stl::string& filename );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#if UF_USE_LGS
|
||||
#include <uf/config.h>
|
||||
#include <uf/utils/mesh/mesh.h>
|
||||
#include <uf/engine/graph/graph.h>
|
||||
@ -59,4 +59,5 @@ namespace impl {
|
||||
inline pod::Vector3f convertPos_NewDark( const pod::Vector3f& v, float scale = impl::darkToMeters ) {
|
||||
return pod::Vector3f{ v.x, v.z, v.y } * scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#if UF_USE_LGS
|
||||
#include <uf/config.h>
|
||||
#include <uf/engine/graph/graph.h>
|
||||
|
||||
@ -7,4 +7,5 @@ namespace ext {
|
||||
namespace lgs {
|
||||
void UF_API loadMis( pod::Graph& graph, const uf::stl::string& filename, const uf::Serializer& metadata );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#if UF_USE_LGS
|
||||
#include <uf/config.h>
|
||||
#include <uf/engine/graph/graph.h>
|
||||
|
||||
@ -9,4 +9,4 @@ namespace ext {
|
||||
bool UF_API loadPcx( pod::Image& image, const uf::stl::vector<uint8_t>& buffer, const uint8_t* paletteData = NULL );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -12,7 +12,7 @@ namespace impl {
|
||||
template<typename T>
|
||||
T str2vec( uf::stl::string string ) {
|
||||
string = uf::string::replace(string, " ", ","); // replace spaces with commas
|
||||
string = ::fmt::format("[{}]", string); // wrap as an array
|
||||
string = FMT_FORMAT("[{}]", string); // wrap as an array
|
||||
ext::json::Value j; ext::json::decode( j, string ); // parse JSON string
|
||||
return uf::vector::decode( j, T{} ); // parse JSON object
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
#include <cpptrace/cpptrace.hpp>
|
||||
#define VK_REGISTER_HANDLE( handle ) if ( ext::vulkan::settings::validation::checkpoints ) {\
|
||||
VK_VALIDATION_MESSAGE("Registered handle: {}: {}", TYPE_NAME(decltype(handle)), (void*) handle);\
|
||||
uf::stl::string id = ::fmt::format("{}: {}", cpptrace::generate_trace().to_string(), TYPE_NAME(decltype(*this)));\
|
||||
uf::stl::string id = FMT_FORMAT("{}: {}", cpptrace::generate_trace().to_string(), TYPE_NAME(decltype(*this)));\
|
||||
ext::vulkan::Resource<std::remove_cvref_t<decltype(handle)>>::add( handle, id ); \
|
||||
}
|
||||
#define VK_UNREGISTER_HANDLE( handle ) if ( ext::vulkan::settings::validation::checkpoints ) {\
|
||||
|
||||
@ -23,8 +23,11 @@
|
||||
}\
|
||||
if ( time >= x && timerState.should && (timer.reset(), true) )
|
||||
|
||||
#define FMT_FORMAT uf::_fmt_format
|
||||
#define TO_STRING(x) FMT_FORMAT("{}", x)
|
||||
|
||||
#if UF_USE_FMT
|
||||
#define UF_MSG(CATEGORY, ...) uf::io::log(CATEGORY, __FILE__, __FUNCTION__, __LINE__, ::fmt::format(__VA_ARGS__));
|
||||
#define UF_MSG(CATEGORY, ...) uf::io::log(CATEGORY, __FILE__, __FUNCTION__, __LINE__, FMT_FORMAT(__VA_ARGS__));
|
||||
#else
|
||||
#define UF_MSG(CATEGORY, ...) uf::io::log(CATEGORY, __FILE__, __FUNCTION__, __LINE__, #__VA_ARGS__);
|
||||
#endif
|
||||
@ -53,20 +56,20 @@
|
||||
#define UF_ASSERT_BREAK(condition, ...) if ( !(condition) ) { UF_MSG_ERROR("Assert failed: {}", #condition); break; }
|
||||
#define UF_ASSERT_SAFE(condition) if ( !(condition) ) { UF_MSG_ERROR("Assertion failed: {}", #condition); }
|
||||
|
||||
#define UF_ASSERT_MSG(condition, ...) if ( !(condition) ) { UF_EXCEPTION("Assert failed: {} {}", #condition, ::fmt::format(__VA_ARGS__)); }
|
||||
#define UF_ASSERT_BREAK_MSG(condition, ...) if ( !(condition) ) { UF_MSG_ERROR("Assert failed: {} {}", #condition, ::fmt::format(__VA_ARGS__)); break; }
|
||||
#define UF_ASSERT_SAFE_MSG(condition, ...) if ( !(condition) ) { UF_MSG_ERROR("Assertion failed: {} {}", #condition, ::fmt::format(__VA_ARGS__)); }
|
||||
#define UF_ASSERT_MSG(condition, ...) if ( !(condition) ) { UF_EXCEPTION("Assert failed: {} {}", #condition, FMT_FORMAT(__VA_ARGS__)); }
|
||||
#define UF_ASSERT_BREAK_MSG(condition, ...) if ( !(condition) ) { UF_MSG_ERROR("Assert failed: {} {}", #condition, FMT_FORMAT(__VA_ARGS__)); break; }
|
||||
#define UF_ASSERT_SAFE_MSG(condition, ...) if ( !(condition) ) { UF_MSG_ERROR("Assertion failed: {} {}", #condition, FMT_FORMAT(__VA_ARGS__)); }
|
||||
|
||||
#define UF_TIMER_TRACE_INIT() uf::Timer<long long> TIMER_TRACE;
|
||||
|
||||
#define UF_TIMER_TRACE(...) {\
|
||||
auto elapsed = TIMER_TRACE.elapsed().asMicroseconds();\
|
||||
if ( elapsed > 0 ) UF_MSG_DEBUG("{} us\t{}", TIMER_TRACE.elapsed().asMicroseconds(), ::fmt::format(__VA_ARGS__));\
|
||||
if ( elapsed > 0 ) UF_MSG_DEBUG("{} us\t{}", TIMER_TRACE.elapsed().asMicroseconds(), FMT_FORMAT(__VA_ARGS__));\
|
||||
}
|
||||
|
||||
#define UF_TIMER_TRACE_RESET(...) {\
|
||||
auto elapsed = TIMER_TRACE.elapsed().asMicroseconds();\
|
||||
if ( elapsed > 0 ) UF_MSG_DEBUG("{} us\t{}", TIMER_TRACE.elapsed().asMicroseconds(), ::fmt::format(__VA_ARGS__));\
|
||||
if ( elapsed > 0 ) UF_MSG_DEBUG("{} us\t{}", TIMER_TRACE.elapsed().asMicroseconds(), FMT_FORMAT(__VA_ARGS__));\
|
||||
TIMER_TRACE.reset();\
|
||||
}
|
||||
|
||||
@ -77,7 +80,7 @@
|
||||
|
||||
#define UF_TIMER_MULTITRACE(...) {\
|
||||
TIMER_TRACE_CUR = TIMER_TRACE.elapsed().asMicroseconds();\
|
||||
UF_MSG_DEBUG("{} us\t{} us\t{}", TIMER_TRACE_CUR, (TIMER_TRACE_CUR - TIMER_TRACE_PREV), ::fmt::format(__VA_ARGS__));\
|
||||
UF_MSG_DEBUG("{} us\t{} us\t{}", TIMER_TRACE_CUR, (TIMER_TRACE_CUR - TIMER_TRACE_PREV), FMT_FORMAT(__VA_ARGS__));\
|
||||
TIMER_TRACE_PREV = TIMER_TRACE_CUR;\
|
||||
}
|
||||
|
||||
@ -137,7 +140,7 @@
|
||||
#if UF_LEAN_AND_MEAN
|
||||
#define UF_DEBUG 0
|
||||
#undef TYPE_NAME
|
||||
#define TYPE_NAME(T) std::to_string(TYPE_HASH(T))
|
||||
#define TYPE_NAME(T) TO_STRING(TYPE_HASH(T))
|
||||
|
||||
#undef UF_MSG
|
||||
#define UF_MSG(...) {}
|
||||
|
||||
@ -29,5 +29,5 @@ namespace uf {
|
||||
}
|
||||
}
|
||||
|
||||
#define UF_CHECKPOINT_INFO(...) ::fmt::format("{}:{}@{}", __FILE__, __FUNCTION__, __LINE__)
|
||||
#define UF_CHECKPOINT_INFO(...) FMT_FORMAT("{}:{}@{}", __FILE__, __FUNCTION__, __LINE__)
|
||||
#define UF_CHECKPOINT_MARK(COMMAND_BUFFER, TYPE, NAME, ...) markCommandBuffer( COMMAND_BUFFER, TYPE, NAME, UF_CHECKPOINT_INFO() );
|
||||
@ -10,6 +10,15 @@
|
||||
#endif
|
||||
#include <uf/utils/memory/string.h>
|
||||
|
||||
namespace uf {
|
||||
template <typename... Args>
|
||||
inline uf::stl::string _fmt_format(fmt::format_string<Args...> fmt_str, Args&&... args) {
|
||||
fmt::memory_buffer buffer;
|
||||
fmt::format_to(std::back_inserter(buffer), fmt_str, std::forward<Args>(args)...);
|
||||
return uf::stl::string(buffer.data(), buffer.size());
|
||||
}
|
||||
}
|
||||
|
||||
namespace uf {
|
||||
#if UF_USE_FMT
|
||||
using namespace fmt;
|
||||
|
||||
@ -816,7 +816,7 @@ typename T::type_t uf::vector::norm( const T& vector ) {
|
||||
}
|
||||
template<typename T>
|
||||
T uf::vector::normalize( const T& vector ) {
|
||||
#if 0 && UF_USE_SIMD // causes massive frame drops
|
||||
#if UF_USE_SIMD // causes massive frame drops
|
||||
if constexpr ( std::is_same_v<typename T::type_t, float> ) {
|
||||
return uf::simd::normalize( vector );
|
||||
}
|
||||
@ -833,12 +833,12 @@ T uf::vector::normalize( const T& vector ) {
|
||||
|
||||
template<typename T>
|
||||
T uf::vector::clampMagnitude( const T& v, float maxMag ) {
|
||||
T res = v;
|
||||
float magSq = uf::vector::magnitude( res );
|
||||
if ( magSq > (maxMag * maxMag) ) {
|
||||
res *= (maxMag / sqrt(magSq));
|
||||
}
|
||||
return res;
|
||||
T res = v;
|
||||
float magSq = uf::vector::magnitude( res );
|
||||
if ( magSq > (maxMag * maxMag) ) {
|
||||
res *= (maxMag / sqrt(magSq));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -897,7 +897,7 @@ uf::stl::string uf::vector::toString( const T& v, const uf::stl::string& s ) {
|
||||
ss << v[i];
|
||||
if ( i + 1 < T::size ) ss << ", ";
|
||||
});
|
||||
return ::fmt::format( fmt::runtime(s), ss.str() );
|
||||
return FMT_FORMAT( fmt::runtime(s), ss.str() );
|
||||
}
|
||||
|
||||
template<typename T, size_t N>
|
||||
|
||||
@ -890,7 +890,11 @@ FORCE_INLINE uf::simd::vector<float> uf::simd::cross( uf::simd::vector<float> x,
|
||||
return _impl_cross( x, y );
|
||||
}
|
||||
FORCE_INLINE uf::simd::vector<float> uf::simd::normalize( uf::simd::vector<float> v ) {
|
||||
__m128 len = _mm_sqrt_ss( _impl_dot( v,v ) );
|
||||
__m128 dot = _impl_dot( v,v );
|
||||
if ( _mm_cvtss_f32(dot) < 1.0e-12f ) {
|
||||
return v;
|
||||
}
|
||||
__m128 len = _mm_sqrt_ss( dot );
|
||||
len = _mm_shuffle_ps(len, len, 0x00);
|
||||
return _mm_div_ps(v, len);
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
|
||||
#define UF_MEMORYPOOL_USE_STL_ALLOCATOR 1
|
||||
#define UF_MEMORYPOOL_USE_ALLOCATOR 1
|
||||
#define UF_MEMORYPOOL_OVERRIDE_NEW_DELETE 1
|
||||
|
||||
namespace uf {
|
||||
namespace allocator {
|
||||
|
||||
@ -9,7 +9,7 @@ namespace uf {
|
||||
namespace stl {
|
||||
template<
|
||||
class T,
|
||||
#if UF_MEMORYPOOL_OVERRIDE_NEW_DELETE
|
||||
#if UF_MEMORYPOOL_USE_ALLOCATOR
|
||||
class Allocator = std::allocator<T>
|
||||
#else
|
||||
class Allocator = uf::Allocator<T>
|
||||
|
||||
@ -11,7 +11,7 @@ namespace uf {
|
||||
class Key,
|
||||
class T,
|
||||
class Compare = nlohmann::fifo_map_compare<Key>,
|
||||
#if UF_MEMORYPOOL_USE_STL_ALLOCATOR
|
||||
#if UF_MEMORYPOOL_USE_ALLOCATOR
|
||||
class Allocator = std::allocator<std::pair<const Key, T>>
|
||||
#else
|
||||
class Allocator = uf::Allocator<std::pair<const Key, T>>
|
||||
|
||||
@ -11,7 +11,7 @@ namespace uf {
|
||||
class Key,
|
||||
class T,
|
||||
class Compare = std::less<Key>,
|
||||
#if UF_MEMORYPOOL_USE_STL_ALLOCATOR
|
||||
#if UF_MEMORYPOOL_USE_ALLOCATOR
|
||||
class Allocator = std::allocator<std::pair<const Key, T>>
|
||||
#else
|
||||
class Allocator = uf::Allocator<std::pair<const Key, T>>
|
||||
|
||||
@ -76,7 +76,7 @@ namespace uf {
|
||||
|
||||
size_t UF_API size( const pod::MemoryPool& );
|
||||
size_t UF_API allocated( const pod::MemoryPool& );
|
||||
uf::stl::string UF_API stats( const pod::MemoryPool& );
|
||||
uf::stl::string UF_API stats( const pod::MemoryPool&, bool readable = false );
|
||||
void UF_API initialize( pod::MemoryPool&, size_t, pod::MemoryPool::Strategy = pod::MemoryPool::Strategy::BUDDY, size_t = 0 );
|
||||
void UF_API destroy( pod::MemoryPool& );
|
||||
|
||||
@ -107,7 +107,7 @@ namespace uf {
|
||||
|
||||
inline size_t size() const;
|
||||
inline size_t allocated() const;
|
||||
inline uf::stl::string stats() const;
|
||||
inline uf::stl::string stats( bool readable = false ) const;
|
||||
inline void initialize( size_t size, pod::MemoryPool::Strategy = pod::MemoryPool::Strategy::BUDDY, size_t = 0 );
|
||||
inline void destroy();
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ bool uf::memoryPool::free( pod::MemoryPool& pool, const T& data ) {
|
||||
|
||||
size_t uf::MemoryPool::size() const { return uf::memoryPool::size( *this ); }
|
||||
size_t uf::MemoryPool::allocated() const { return uf::memoryPool::allocated( *this ); }
|
||||
uf::stl::string uf::MemoryPool::stats() const { return uf::memoryPool::stats( *this ); }
|
||||
uf::stl::string uf::MemoryPool::stats( bool readable ) const { return uf::memoryPool::stats( *this, readable ); }
|
||||
void uf::MemoryPool::initialize( size_t size, pod::MemoryPool::Strategy strategy, size_t chunkSize ) { return uf::memoryPool::initialize( *this, size, strategy, chunkSize ); }
|
||||
void uf::MemoryPool::destroy() { return uf::memoryPool::destroy( *this ); }
|
||||
|
||||
|
||||
@ -12,7 +12,11 @@ namespace uf {
|
||||
template<
|
||||
class CharT,
|
||||
class Traits = std::char_traits<CharT>,
|
||||
class Allocator = std::allocator<CharT> //uf::Allocator<CharT>
|
||||
#if 0 && UF_MEMORYPOOL_USE_ALLOCATOR
|
||||
class Allocator = uf::Allocator<CharT>
|
||||
#else
|
||||
class Allocator = std::allocator<CharT>
|
||||
#endif
|
||||
>
|
||||
using basic_string = std::basic_string<CharT, Traits, Allocator>;
|
||||
using string = uf::stl::basic_string<char>;
|
||||
@ -27,7 +31,11 @@ namespace uf {
|
||||
template<
|
||||
class CharT,
|
||||
class Traits = std::char_traits<CharT>,
|
||||
class Allocator = std::allocator<CharT> //uf::Allocator<CharT>
|
||||
#if 0 && UF_MEMORYPOOL_USE_ALLOCATOR
|
||||
class Allocator = uf::Allocator<CharT>
|
||||
#else
|
||||
class Allocator = std::allocator<CharT>
|
||||
#endif
|
||||
>
|
||||
using basic_stringstream = std::basic_stringstream<CharT, Traits, Allocator>;
|
||||
using stringstream = uf::stl::basic_stringstream<char>;
|
||||
|
||||
@ -14,7 +14,7 @@ namespace uf {
|
||||
class T,
|
||||
class Hash = uf::algo::hasher,
|
||||
class KeyEqual = std::equal_to<Key>,
|
||||
#if UF_MEMORYPOOL_USE_STL_ALLOCATOR
|
||||
#if UF_MEMORYPOOL_USE_ALLOCATOR
|
||||
class Allocator = std::allocator<std::pair<const Key, T>>
|
||||
#else
|
||||
class Allocator = uf::Allocator<std::pair<const Key, T>>
|
||||
|
||||
@ -12,7 +12,7 @@ namespace uf {
|
||||
class Key,
|
||||
class Hash = std::hash<Key>,
|
||||
class KeyEqual = std::equal_to<Key>,
|
||||
#if UF_MEMORYPOOL_USE_STL_ALLOCATOR
|
||||
#if UF_MEMORYPOOL_USE_ALLOCATOR
|
||||
class Allocator = std::allocator<Key>
|
||||
#else
|
||||
class Allocator = uf::Allocator<Key>
|
||||
|
||||
@ -9,7 +9,7 @@ namespace uf {
|
||||
namespace stl {
|
||||
template<
|
||||
class T,
|
||||
#if UF_MEMORYPOOL_USE_STL_ALLOCATOR
|
||||
#if UF_MEMORYPOOL_USE_ALLOCATOR
|
||||
class Allocator = std::allocator<T>
|
||||
#else
|
||||
class Allocator = uf::Allocator<T>
|
||||
|
||||
@ -10,7 +10,21 @@
|
||||
|
||||
namespace uf {
|
||||
namespace string {
|
||||
template<typename T> uf::stl::string sha256( const T& input ) { return picosha2::hash256_hex_string(input); }
|
||||
template<typename T>
|
||||
uf::stl::string sha256( const T& input ) {
|
||||
unsigned char raw_hash[32];
|
||||
picosha2::hash256(input.begin(), input.end(), raw_hash, raw_hash + 32);
|
||||
|
||||
uf::stl::string result;
|
||||
result.reserve(64);
|
||||
const char hex_chars[] = "0123456789abcdef";
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
result.push_back(hex_chars[(raw_hash[i] >> 4) & 0x0F]);
|
||||
result.push_back(hex_chars[raw_hash[i] & 0x0F]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
namespace literals {
|
||||
|
||||
@ -8,63 +8,63 @@
|
||||
#define EXPECT_TRUE(expr) { \
|
||||
auto& test = uf::unitTests::tests[uf::unitTests::current];\
|
||||
test.passes = ((expr));\
|
||||
test.message = ::fmt::format("EXPECT_TRUE({})", #expr);\
|
||||
test.message = FMT_FORMAT("EXPECT_TRUE({})", #expr);\
|
||||
UF_MSG_DEBUG("[{}] {}", test.passes ? "PASS" : "FAIL", test.message);\
|
||||
}
|
||||
|
||||
#define EXPECT_FALSE(expr) { \
|
||||
auto& test = uf::unitTests::tests[uf::unitTests::current];\
|
||||
test.passes = (!(expr));\
|
||||
test.message = ::fmt::format("EXPECT_FALSE({})", #expr);\
|
||||
test.message = FMT_FORMAT("EXPECT_FALSE({})", #expr);\
|
||||
UF_MSG_DEBUG("[{}] {}", test.passes ? "PASS" : "FAIL", test.message);\
|
||||
}
|
||||
|
||||
#define EXPECT_EQ(a,b) { \
|
||||
auto& test = uf::unitTests::tests[uf::unitTests::current];\
|
||||
test.passes = (((a) == (b)));\
|
||||
test.message = ::fmt::format("EXPECT_EQ({}, {}), ({} == {})", #a, #b, a, b);\
|
||||
test.message = FMT_FORMAT("EXPECT_EQ({}, {}), ({} == {})", #a, #b, a, b);\
|
||||
UF_MSG_DEBUG("[{}] {}", test.passes ? "PASS" : "FAIL", test.message);\
|
||||
}
|
||||
|
||||
#define EXPECT_GT(a,b) { \
|
||||
auto& test = uf::unitTests::tests[uf::unitTests::current];\
|
||||
test.passes = (((a) > (b)));\
|
||||
test.message = ::fmt::format("EXPECT_GT({}, {}), ({} > {})", #a, #b, a, b);\
|
||||
test.message = FMT_FORMAT("EXPECT_GT({}, {}), ({} > {})", #a, #b, a, b);\
|
||||
UF_MSG_DEBUG("[{}] {}", test.passes ? "PASS" : "FAIL", test.message);\
|
||||
}
|
||||
|
||||
#define EXPECT_LT(a,b) { \
|
||||
auto& test = uf::unitTests::tests[uf::unitTests::current];\
|
||||
test.passes = (((a) < (b)));\
|
||||
test.message = ::fmt::format("EXPECT_LT({}, {}), ({} < {})", #a, #b, a, b);\
|
||||
test.message = FMT_FORMAT("EXPECT_LT({}, {}), ({} < {})", #a, #b, a, b);\
|
||||
UF_MSG_DEBUG("[{}] {}", test.passes ? "PASS" : "FAIL", test.message);\
|
||||
}
|
||||
|
||||
#define EXPECT_GE(a,b) { \
|
||||
auto& test = uf::unitTests::tests[uf::unitTests::current];\
|
||||
test.passes = (((a) >= (b)));\
|
||||
test.message = ::fmt::format("EXPECT_GE({}, {}), ({} >= {})", #a, #b, a, b);\
|
||||
test.message = FMT_FORMAT("EXPECT_GE({}, {}), ({} >= {})", #a, #b, a, b);\
|
||||
UF_MSG_DEBUG("[{}] {}", test.passes ? "PASS" : "FAIL", test.message);\
|
||||
}
|
||||
|
||||
#define EXPECT_LE(a,b) { \
|
||||
auto& test = uf::unitTests::tests[uf::unitTests::current];\
|
||||
test.passes = (((a) <= (b)));\
|
||||
test.message = ::fmt::format("EXPECT_LE({}, {}), ({} <= {})", #a, #b, a, b);\
|
||||
test.message = FMT_FORMAT("EXPECT_LE({}, {}), ({} <= {})", #a, #b, a, b);\
|
||||
UF_MSG_DEBUG("[{}] {}", test.passes ? "PASS" : "FAIL", test.message);\
|
||||
}
|
||||
|
||||
#define EXPECT_NEAR(a,b,eps) { \
|
||||
auto& test = uf::unitTests::tests[uf::unitTests::current];\
|
||||
test.passes = (std::fabs((a)-(b)) <= (eps));\
|
||||
test.message = ::fmt::format("EXPECT_NEAR({}, {}), ({} == {})", #a, #b, a, b);\
|
||||
test.message = FMT_FORMAT("EXPECT_NEAR({}, {}), ({} == {})", #a, #b, a, b);\
|
||||
UF_MSG_DEBUG("[{}] {}", test.passes ? "PASS" : "FAIL", test.message);\
|
||||
}
|
||||
|
||||
#define EXPECT_FLOAT_EQ(a,b) { \
|
||||
auto& test = uf::unitTests::tests[uf::unitTests::current];\
|
||||
test.passes = (std::fabs((a)-(b)) <= (1.0e-4f));\
|
||||
test.message = ::fmt::format("EXPECT_FLOAT_EQ({}, {}), ({} == {})", #a, #b, a, b);\
|
||||
test.message = FMT_FORMAT("EXPECT_FLOAT_EQ({}, {}), ({} == {})", #a, #b, a, b);\
|
||||
UF_MSG_DEBUG("[{}] {}", test.passes ? "PASS" : "FAIL", test.message);\
|
||||
}
|
||||
|
||||
|
||||
@ -175,5 +175,5 @@ uf::Entity* uf::Entity::globalFindByName( const uf::stl::string& name ) {
|
||||
}
|
||||
|
||||
uf::stl::string uf::string::toString( const uf::Entity& entity ) {
|
||||
return ::fmt::format("({}): {}", entity.getUid(), entity.getName());
|
||||
return FMT_FORMAT("({}): {}", entity.getUid(), entity.getName());
|
||||
}
|
||||
@ -29,7 +29,7 @@ void ext::AudioEmitterBehavior::initialize( uf::Object& self ) {
|
||||
|
||||
this->addHook( "sound:Emit.%UID%", [&]( pod::PCM& waveform ){
|
||||
/*
|
||||
uf::stl::string fakeUri = "pcm_dynamic_" + std::to_string((size_t)&waveform);
|
||||
uf::stl::string fakeUri = FMT_FORMAT("pcm_dynamic_{}", (size_t)&waveform);
|
||||
if ( !uf::asset::has(fakeUri) ) {
|
||||
auto payload = uf::asset::resolveToPayload(fakeUri, "");
|
||||
payload.type = uf::asset::Type::AUDIO;
|
||||
@ -97,7 +97,7 @@ void ext::AudioEmitterBehavior::initialize( uf::Object& self ) {
|
||||
this->addHook( "sound:QueueTrack.%UID%", [&](ext::json::Value& payload){
|
||||
uf::stl::string filename = payload["filename"].as<uf::stl::string>();
|
||||
int layer = payload["layer"].as<int>(1);
|
||||
uf::stl::string channelName = "managed_bgm_channel_" + std::to_string(layer);
|
||||
uf::stl::string channelName = FMT_FORMAT("managed_bgm_channel_{}", layer);
|
||||
|
||||
if ( emitter.has( channelName ) ) {
|
||||
auto& source = emitter.get(channelName);
|
||||
@ -139,7 +139,7 @@ void ext::AudioEmitterBehavior::initialize( uf::Object& self ) {
|
||||
pod::AudioClip* clip = &uf::asset::get<pod::AudioClip>( payload.filename );
|
||||
|
||||
int layer = payload.metadata["layer"].as<int>(1);
|
||||
uf::stl::string channelName = "managed_bgm_channel_" + std::to_string(layer);
|
||||
uf::stl::string channelName = FMT_FORMAT("managed_bgm_channel_{}", layer);
|
||||
|
||||
if ( emitter.has( channelName ) ) {
|
||||
uf::audio::stop( emitter.get( channelName ) );
|
||||
|
||||
@ -54,7 +54,7 @@ void ext::BakingBehavior::initialize( uf::Object& self ) {
|
||||
|
||||
this->addHook( "entity:PostInitialization.%UID%", [&](){
|
||||
metadata.output = this->resolveURI( metadataJson["baking"]["output"].as<uf::stl::string>(), metadataJson["baking"]["root"].as<uf::stl::string>() );
|
||||
metadata.renderModeName = ::fmt::format("B:{}", this->getUid());
|
||||
metadata.renderModeName = FMT_FORMAT("B:{}", this->getUid());
|
||||
|
||||
metadata.trigger.mode = metadataJson["baking"]["trigger"]["mode"].as( metadata.trigger.mode );
|
||||
metadata.trigger.value = metadataJson["baking"]["trigger"]["value"].as( metadata.trigger.value );
|
||||
@ -168,7 +168,7 @@ SAVE: {
|
||||
for ( size_t i = 0; i < metadata.max.layers; ++i ) {
|
||||
tasks.queue([&, i]{
|
||||
auto image = metadata.buffers.baked.screenshot(i);
|
||||
uf::stl::string filename = uf::string::replace( metadata.output, "%i", std::to_string(i) );
|
||||
uf::stl::string filename = uf::string::replace( metadata.output, "%i", TO_STRING(i) );
|
||||
bool status = image.save(filename);
|
||||
UF_MSG_DEBUG("Writing to {}: {}", filename, status);
|
||||
|
||||
|
||||
@ -112,6 +112,17 @@ namespace {
|
||||
} sceneTransition;
|
||||
}
|
||||
|
||||
namespace {
|
||||
void printPool( const uf::MemoryPool& pool, const uf::stl::string& name ) {
|
||||
if ( pool.size() <= 0 ) return;
|
||||
UF_MSG_DEBUG("{} pool:", name);
|
||||
uf::Serializer json(pool.stats( true ));
|
||||
ext::json::forEach( json, [&]( const uf::stl::string& key, ext::json::Value& value ){
|
||||
UF_MSG_DEBUG(" {}: {}", key, value.as<uf::stl::string>() );
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void UF_API uf::load() {
|
||||
uf::config.readFromFile(uf::io::root+"config.json");
|
||||
}
|
||||
@ -414,11 +425,6 @@ void UF_API uf::initialize() {
|
||||
UF_MSG_DEBUG("Setting JSON implicit preference: {}.{}", ext::json::PREFERRED_ENCODING, ext::json::PREFERRED_COMPRESSION);
|
||||
}
|
||||
|
||||
{
|
||||
uf::stl::string name = "window:Mouse.CursorVisibility";
|
||||
UF_MSG_DEBUG( "c_str={}, str={}", uf::algo::fnv1a("window:Mouse.CursorVisibility"), uf::algo::fnv1a(name) );
|
||||
}
|
||||
|
||||
/* Arguments */ {
|
||||
bool modified = false;
|
||||
auto& arguments = uf::config["arguments"];
|
||||
@ -438,7 +444,7 @@ void UF_API uf::initialize() {
|
||||
/*
|
||||
{
|
||||
std::regex regex("^--(.+?)=(.+?)$");
|
||||
std::smatch match;
|
||||
std::cmatch match;
|
||||
if ( std::regex_search( arg, match, regex ) ) {
|
||||
uf::stl::string keyString = match[1].str();
|
||||
uf::stl::string valueString = match[2].str();
|
||||
@ -457,7 +463,7 @@ void UF_API uf::initialize() {
|
||||
}
|
||||
/* Open output file */ {
|
||||
::io.filenames.output = uf::io::root+"/logs/output.txt";
|
||||
::io.output.open(::io.filenames.output);
|
||||
::io.output.open(::io.filenames.output.c_str());
|
||||
}
|
||||
/* Initialize timers */ {
|
||||
::times.sys.start();
|
||||
@ -477,14 +483,19 @@ void UF_API uf::initialize() {
|
||||
if ( value.is<uf::stl::string>() ) {
|
||||
uf::stl::string str = value.as<uf::stl::string>();
|
||||
std::regex regex("^(\\d+) ?((?:K|M|G)?(?:i?B)?)$");
|
||||
std::smatch match;
|
||||
if ( std::regex_search( str, match, regex ) ) {
|
||||
|
||||
std::cmatch match;
|
||||
if ( std::regex_search( str.c_str(), match, regex ) ) {
|
||||
size_t requested = std::stoi( match[1].str() );
|
||||
uf::stl::string prefix = match[2].str();
|
||||
switch ( prefix.at(0) ) {
|
||||
case 'K': return requested * 1024;
|
||||
case 'M': return requested * 1024 * 1024;
|
||||
case 'G': return requested * 1024 * 1024 * 1024;
|
||||
|
||||
uf::stl::string prefix(match[2].first, match[2].length());
|
||||
|
||||
if (prefix.length() > 0) {
|
||||
switch ( prefix.at(0) ) {
|
||||
case 'K': return requested * 1024;
|
||||
case 'M': return requested * 1024 * 1024;
|
||||
case 'G': return requested * 1024 * 1024 * 1024;
|
||||
}
|
||||
}
|
||||
return requested;
|
||||
}
|
||||
@ -825,10 +836,10 @@ void UF_API uf::tick() {
|
||||
/* Print Memory Pool Information */ {
|
||||
TIMER(1, uf::inputs::kbm::states::P ) {
|
||||
UF_MSG_DEBUG("==== Memory Pool Information ====");
|
||||
if ( uf::memoryPool::global.size() > 0 ) UF_MSG_DEBUG("Global Memory Pool: {}", uf::memoryPool::global.stats());
|
||||
if ( uf::Entity::memoryPool.size() > 0 ) UF_MSG_DEBUG("Entity Memory Pool: {}", uf::Entity::memoryPool.stats());
|
||||
if ( uf::component::memoryPool.size() > 0 ) UF_MSG_DEBUG("Components Memory Pool: {}", uf::component::memoryPool.stats());
|
||||
if ( uf::userdata::memoryPool.size() > 0 ) UF_MSG_DEBUG("Userdata Memory Pool: {}", uf::userdata::memoryPool.stats());
|
||||
::printPool( uf::memoryPool::global, "Global memory" );
|
||||
::printPool( uf::Entity::memoryPool, "Entity" );
|
||||
::printPool( uf::component::memoryPool, "Component" );
|
||||
::printPool( uf::userdata::memoryPool, "Userdata" );
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
|
||||
@ -96,7 +96,7 @@ void ext::LightBehavior::initialize( uf::Object& self ) {
|
||||
camera.setProjection( uf::matrix::perspective( fov, (float) size.x / (float) size.y, radius.x, radius.y ) );
|
||||
camera.update();
|
||||
|
||||
uf::stl::string name = ::fmt::format("RT:{}", this->getUid());
|
||||
uf::stl::string name = FMT_FORMAT("RT:{}", this->getUid());
|
||||
renderMode.blitter.process = false;
|
||||
renderMode.execute = false;
|
||||
renderMode.width = size.x;
|
||||
|
||||
@ -336,7 +336,7 @@ void ext::ExtSceneBehavior::tick( uf::Object& self ) {
|
||||
|
||||
for ( uf::Scene* scene : uf::scene::scenes ) {
|
||||
if ( !scene ) continue;
|
||||
uf::iostream << ::fmt::format("Scene: {}\n", uf::string::toString( *scene ));
|
||||
uf::iostream << FMT_FORMAT("Scene: {}\n", uf::string::toString( *scene ));
|
||||
scene->process([]( uf::Entity* entity, int depth ) {
|
||||
uf::stl::string indent = ""; for ( auto i = 1; i < depth; ++i ) indent += "\t";
|
||||
uf::stl::string location = "";
|
||||
@ -346,7 +346,7 @@ void ext::ExtSceneBehavior::tick( uf::Object& self ) {
|
||||
location = uf::string::toString( t.position ) + " " + uf::string::toString( t.orientation );
|
||||
}
|
||||
|
||||
uf::iostream << ::fmt::format("{} {} {}\n", indent, uf::string::toString( *entity ), location );
|
||||
uf::iostream << FMT_FORMAT("{} {} {}\n", indent, uf::string::toString( *entity ), location );
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
@ -358,7 +358,7 @@ void ext::ExtSceneBehavior::tick( uf::Object& self ) {
|
||||
auto image = renderMode.screenshot(uf::renderer::states::currentBuffer ? 0 : 1);
|
||||
|
||||
std::time_t t = std::time(nullptr);
|
||||
const uf::stl::string filename = ::fmt::format("{}/screenshots/{:%Y-%m-%d_%H-%M-%S}.png", uf::io::root, ::fmt::localtime(t));
|
||||
const uf::stl::string filename = FMT_FORMAT("{}/screenshots/{:%Y-%m-%d_%H-%M-%S}.png", uf::io::root, ::fmt::localtime(t));
|
||||
image.save(filename);
|
||||
UF_MSG_DEBUG("Screenshot saved to {}", filename);
|
||||
}
|
||||
@ -1191,7 +1191,7 @@ void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, uf::renderer::Graphic
|
||||
while ( textures3D.size() < metadata.max.textures3D ) textures3D.emplace_back().aliasTexture(uf::renderer::Texture3D::empty);
|
||||
|
||||
static uf::stl::unordered_map<uf::stl::string, UniformDescriptor> previousUniformsMap;
|
||||
auto& previousUniforms = previousUniformsMap[::fmt::format("{}:{}:{}", shaderType, shaderPipeline, (size_t)&graphic)];
|
||||
auto& previousUniforms = previousUniformsMap[FMT_FORMAT("{}:{}:{}", shaderType, shaderPipeline, (size_t)&graphic)];
|
||||
|
||||
// update uniform information
|
||||
// hopefully write combining kicks in
|
||||
|
||||
@ -119,7 +119,7 @@ void ext::VoxelizerSceneBehavior::initialize( uf::Object& self ) {
|
||||
if ( metadata.fragmentSize.y == 0 ) metadata.fragmentSize.y = metadata.voxelSize.y;
|
||||
|
||||
auto& renderMode = this->getComponent<uf::renderer::RenderTargetRenderMode>();
|
||||
metadata.renderModeName = ::fmt::format("VXGI:{}", this->getUid());
|
||||
metadata.renderModeName = FMT_FORMAT("VXGI:{}", this->getUid());
|
||||
renderMode.metadata.name = metadata.renderModeName;
|
||||
if ( uf::renderer::settings::experimental::registerRenderMode ) uf::renderer::addRenderMode( &renderMode, metadata.renderModeName );
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
namespace {
|
||||
uf::stl::string keyedID( size_t id ) {
|
||||
return ::fmt::format("{}", id);
|
||||
return FMT_FORMAT("{}", id);
|
||||
}
|
||||
|
||||
// lazy load animations if requested
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
namespace {
|
||||
uf::stl::string keyID( size_t id ) {
|
||||
return ::fmt::format("{}", id);
|
||||
return FMT_FORMAT("{}", id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ namespace {
|
||||
size_t meshID = graph.meshes.size();
|
||||
size_t objectID = storage.entities.keys.size();
|
||||
|
||||
uf::stl::string keyName = ::fmt::format("{}[{}]", graph.name, objectID);
|
||||
uf::stl::string keyName = FMT_FORMAT("{}[{}]", graph.name, objectID);
|
||||
|
||||
auto& node = graph.nodes.emplace_back();
|
||||
node.name = object.getName();
|
||||
@ -57,7 +57,7 @@ namespace {
|
||||
size_t textureID = graph.textures.size();
|
||||
size_t texture2DID = graph.images.size();
|
||||
|
||||
uf::stl::string subName = ::fmt::format("{}[{}]", keyName, sub++);
|
||||
uf::stl::string subName = FMT_FORMAT("{}[{}]", keyName, sub++);
|
||||
auto& material = storage.materials[graph.materials.emplace_back(subName)];
|
||||
auto& texture = storage.textures[graph.textures.emplace_back(subName)];
|
||||
auto& texture2D = storage.images[graph.images.emplace_back(subName)].handle;
|
||||
|
||||
@ -306,7 +306,7 @@ void uf::graph::load( pod::Graph& graph, const uf::stl::string& filename, const
|
||||
#if UF_USE_VALVE
|
||||
if ( extension == "bsp" ) return ext::valve::loadBsp( graph, filename, metadata );
|
||||
#endif
|
||||
#if UF_USE_TTLG
|
||||
#if UF_USE_LGS
|
||||
if ( extension == "mis" ) return ext::lgs::loadMis( graph, filename, metadata );
|
||||
#endif
|
||||
|
||||
|
||||
@ -410,8 +410,8 @@ uf::stl::string uf::graph::save( const pod::Graph& graph, const uf::stl::string&
|
||||
json["format"] = image.getFormat();
|
||||
|
||||
if ( !settings.combined ) {
|
||||
uf::stl::string f = ::fmt::format("image.{}.png", i );
|
||||
image.save(::fmt::format("{}/{}", directory, f));
|
||||
uf::stl::string f = FMT_FORMAT("image.{}.png", i );
|
||||
image.save(FMT_FORMAT("{}/{}", directory, f));
|
||||
json["filename"] = f;
|
||||
} else {
|
||||
uf::stl::vector<uint8_t> pngBytes;
|
||||
|
||||
@ -74,7 +74,7 @@ namespace {
|
||||
}
|
||||
|
||||
uf::stl::string keyedID( size_t id ) {
|
||||
return ::fmt::format("{}", id);
|
||||
return FMT_FORMAT("{}", id);
|
||||
}
|
||||
size_t allocateObjectID( pod::Graph::Storage& storage ) {
|
||||
return storage.entities.keys.size();
|
||||
@ -135,7 +135,7 @@ namespace {
|
||||
// standard pipeline
|
||||
{
|
||||
uf::stl::string dir = "/graph/base/";
|
||||
uf::stl::string vertexShaderFilename = graphMetadataJson["shaders"]["vertex"].as<uf::stl::string>(::fmt::format("{}/{}", dir, "vert.spv" )); {
|
||||
uf::stl::string vertexShaderFilename = graphMetadataJson["shaders"]["vertex"].as<uf::stl::string>(FMT_FORMAT("{}/{}", dir, "vert.spv" )); {
|
||||
std::pair<bool, uf::stl::string> settings[] = {
|
||||
{ graphMetadataJson["renderer"]["skinned"].as<bool>(), "skinned.vert" },
|
||||
{ !graphMetadataJson["renderer"]["separate"].as<bool>(), "instanced.vert" },
|
||||
@ -150,7 +150,7 @@ namespace {
|
||||
if ( graphic.descriptor.renderTarget == 1 ) {
|
||||
dir = "/base/graph/";
|
||||
}
|
||||
uf::stl::string fragmentShaderFilename = graphMetadataJson["shaders"]["fragment"].as<uf::stl::string>(::fmt::format("{}/{}", dir, "frag.spv")); {
|
||||
uf::stl::string fragmentShaderFilename = graphMetadataJson["shaders"]["fragment"].as<uf::stl::string>(FMT_FORMAT("{}/{}", dir, "frag.spv")); {
|
||||
fragmentShaderFilename = entity.resolveURI( fragmentShaderFilename, root );
|
||||
}
|
||||
|
||||
@ -1089,25 +1089,25 @@ void uf::graph::process( pod::Graph& graph ) {
|
||||
if ( ext::json::isObject( graphMetadataDark ) ) {
|
||||
// set transparent
|
||||
if ( name.find("glass") != uf::stl::string::npos ||
|
||||
name.find("trans") != uf::stl::string::npos ||
|
||||
name.find("grate") != uf::stl::string::npos ) {
|
||||
name.find("trans") != uf::stl::string::npos ||
|
||||
name.find("grate") != uf::stl::string::npos ) {
|
||||
|
||||
material.modeAlpha = pod::Material::AlphaMode::BLEND;
|
||||
material.modeCull = pod::Material::CullMode::NONE;
|
||||
}
|
||||
// set emissive
|
||||
for ( auto nodeID = 0; nodeID < graph.nodes.size(); ++nodeID ) {
|
||||
auto& node = graph.nodes[nodeID];
|
||||
// check if owns a light
|
||||
auto lightName = node.name;
|
||||
auto nameID = ::fmt::format( "{}_{}", node.name, nodeID );
|
||||
material.modeAlpha = pod::Material::AlphaMode::BLEND;
|
||||
material.modeCull = pod::Material::CullMode::NONE;
|
||||
}
|
||||
// set emissive
|
||||
for ( auto nodeID = 0; nodeID < graph.nodes.size(); ++nodeID ) {
|
||||
auto& node = graph.nodes[nodeID];
|
||||
// check if owns a light
|
||||
auto lightName = node.name;
|
||||
auto nameID = FMT_FORMAT( "{}_{}", node.name, nodeID );
|
||||
if ( graph.lights.count( nameID ) > 0 ) lightName = nameID;
|
||||
if ( graph.lights.count( lightName ) == 0 ) {
|
||||
continue;
|
||||
}
|
||||
auto& light = graph.lights[lightName];
|
||||
if ( !(0 <= node.mesh && node.mesh < graph.meshes.size()) ) continue;
|
||||
// iterate primitives for materials
|
||||
if ( !(0 <= node.mesh && node.mesh < graph.meshes.size()) ) continue;
|
||||
// iterate primitives for materials
|
||||
auto& primitives = storage.primitives.map[graph.primitives[node.mesh]];
|
||||
for ( auto& primitive : primitives ) {
|
||||
auto materialID = primitive.instance.materialID;
|
||||
@ -1121,7 +1121,7 @@ void uf::graph::process( pod::Graph& graph ) {
|
||||
material.colorEmissive = light.color * light.intensity;
|
||||
UF_MSG_DEBUG("name={}, light={}, emissive={}", node.name, lightName, uf::vector::toString( material.colorEmissive ));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto tag = ext::json::find( name, graphMetadataJson["tags"] );
|
||||
@ -1380,7 +1380,7 @@ void uf::graph::process( pod::Graph& graph, int32_t index, uf::Object& parent )
|
||||
uf::Object& entity = *pointer;
|
||||
node.entity = &entity;
|
||||
|
||||
auto nameID = ::fmt::format( "{}_{}", node.name, index );
|
||||
auto nameID = FMT_FORMAT( "{}_{}", node.name, index );
|
||||
bool setName = entity.getName() == "Entity";
|
||||
auto& metadata = entity.getComponent<uf::ObjectBehavior::Metadata>();
|
||||
auto& metadataJson = entity.getComponent<uf::Serializer>();
|
||||
@ -1426,11 +1426,12 @@ void uf::graph::process( pod::Graph& graph, int32_t index, uf::Object& parent )
|
||||
float massScale = metadataValve["massScale"].as<float>(1.0f);
|
||||
// flag as static
|
||||
// if ( node.name.starts_with("prop_static") || motionDisabled ) massScale = 0;
|
||||
massScale = 0;
|
||||
// massScale = 0;
|
||||
float mass = baseMass * massScale;
|
||||
|
||||
node.metadata["physics"]["type"] = "mesh";
|
||||
node.metadata["physics"]["type"] = massScale ? "obb" : "mesh";
|
||||
node.metadata["physics"]["mass"] = mass;
|
||||
node.metadata["physics"]["category"] = massScale ? "dynamic" : "static";
|
||||
|
||||
node.metadata["holdable"] = (mass <= 35.0f) && !motionDisabled && !preventPickup;
|
||||
}
|
||||
|
||||
@ -523,6 +523,6 @@ uf::asset::Payload uf::Object::resolveToPayload( const uf::stl::string& filename
|
||||
|
||||
/*
|
||||
uf::stl::string uf::string::toString( const uf::Object& object ) {
|
||||
return ::fmt::format("{} ({}): {}", object.getName(), object.getUid(), (void*) &object);
|
||||
return FMT_FORMAT("{} ({}): {}", object.getName(), object.getUid(), (void*) &object);
|
||||
}
|
||||
*/
|
||||
@ -194,12 +194,12 @@ uf::Scene& uf::scene::loadScene( const uf::stl::string& name, const uf::stl::str
|
||||
uf::scene::scenes.emplace_back( scene );
|
||||
|
||||
uf::stl::string filename = _filename;
|
||||
if ( _filename == "" ) filename = ::fmt::format("/{}/scene.json", uf::string::lowercase(name));
|
||||
if ( _filename == "" ) filename = FMT_FORMAT("/{}/scene.json", uf::string::lowercase(name));
|
||||
scene->load(filename);
|
||||
|
||||
auto& metadata = scene->getComponent<uf::SceneBehavior::Metadata>();
|
||||
auto& metadataObject = scene->getComponent<uf::ObjectBehavior::Metadata>();
|
||||
auto mountUri = ::fmt::format("://{}", uf::vfs::resolveBase( metadataObject.system.root ) );
|
||||
auto mountUri = FMT_FORMAT("://{}", uf::vfs::resolveBase( metadataObject.system.root ) );
|
||||
auto mount = uf::vfs::mount( uf::vfs::createDiskMount( mountUri, 200 ) );
|
||||
metadata.mount.hash = mount.hash;
|
||||
|
||||
|
||||
@ -253,7 +253,7 @@ namespace {
|
||||
case FFX_ERROR_BACKEND_API_ERROR: return "ERROR_BACKEND_API_ERROR"; break;
|
||||
case FFX_ERROR_INSUFFICIENT_MEMORY: return "ERROR_INSUFFICIENT_MEMORY"; break;
|
||||
}
|
||||
return ::fmt::format("{}", (void*) code);
|
||||
return FMT_FORMAT("{}", (void*) code);
|
||||
}
|
||||
|
||||
#define FFX_ERROR_CHECK(f) { auto error = f; if ( error != FFX_OK) UF_MSG_ERROR("FFX-FSR Error {}: {}", #f, FFX_ERROR_TO_STRING(error)); }
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#if UF_USE_LGS
|
||||
#include <uf/ext/lgs/bin.h>
|
||||
#include <uf/ext/lgs/common.h>
|
||||
#include <uf/ext/valve/common.h>
|
||||
@ -424,4 +425,5 @@ bool ext::lgs::loadBin( pod::Graph& graph, const uf::stl::string& filename ) {
|
||||
mesh.compile( meshlets, primitives );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1 +1,3 @@
|
||||
#if UF_USE_LGS
|
||||
#include <uf/ext/lgs/common.h>
|
||||
#endif
|
||||
@ -1,3 +1,4 @@
|
||||
#if UF_USE_LGS
|
||||
#include <uf/ext/lgs/common.h>
|
||||
#include <uf/ext/lgs/mis.h>
|
||||
#include <uf/ext/lgs/bin.h>
|
||||
@ -476,12 +477,12 @@ namespace impl {
|
||||
};
|
||||
|
||||
pod::Atlas::hash_t darkFaceHash(size_t cellIdx, size_t polyIdx) {
|
||||
return ::fmt::format("c_{}_p_{}", cellIdx, polyIdx);
|
||||
return FMT_FORMAT("c_{}_p_{}", cellIdx, polyIdx);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void extractProperty( impl::DarkContext& ctx, const uf::stl::string& name, uf::stl::unordered_map<int32_t, T>& map, size_t prefixSkip = 0 ) {
|
||||
auto invName = ::fmt::format("P${}", name).substr(0, 11);
|
||||
auto invName = FMT_FORMAT("P${}", name).substr(0, 11);
|
||||
if ( ctx.inventory.count(invName) == 0 ) return;
|
||||
|
||||
const auto& item = ctx.inventory.at( invName );
|
||||
@ -512,7 +513,7 @@ namespace impl {
|
||||
|
||||
template<>
|
||||
void extractProperty( impl::DarkContext& ctx, const uf::stl::string& propName, uf::stl::unordered_map<int32_t, uf::stl::string>& map, size_t prefixSkip ) {
|
||||
auto fullName = ::fmt::format("P${}", propName).substr(0, 11);
|
||||
auto fullName = FMT_FORMAT("P${}", propName).substr(0, 11);
|
||||
if (ctx.inventory.count(fullName) == 0) return;
|
||||
|
||||
const auto& item = ctx.inventory.at(fullName);
|
||||
@ -536,7 +537,7 @@ namespace impl {
|
||||
|
||||
template<>
|
||||
void extractProperty( impl::DarkContext& ctx, const uf::stl::string& propName, uf::stl::unordered_map<int32_t, uf::stl::vector<uf::stl::string>>& map, size_t prefixSkip ) {
|
||||
auto fullName = ::fmt::format("P${}", propName).substr(0, 11);
|
||||
auto fullName = FMT_FORMAT("P${}", propName).substr(0, 11);
|
||||
if (ctx.inventory.count(fullName) == 0) return;
|
||||
|
||||
const auto& item = ctx.inventory.at(fullName);
|
||||
@ -703,7 +704,7 @@ namespace impl {
|
||||
auto& node = graph.nodes.emplace_back();
|
||||
ctx.roomNodes[room.roomId] = nodeID;
|
||||
|
||||
node.name = ::fmt::format("room_{}", room.roomId);
|
||||
node.name = FMT_FORMAT("room_{}", room.roomId);
|
||||
|
||||
node.transform.position = impl::convertPos_NewDark( room.center );
|
||||
|
||||
@ -757,7 +758,7 @@ namespace impl {
|
||||
uf::stl::string newTags = currentTags;
|
||||
if (!newTags.empty()) newTags += ", ";
|
||||
|
||||
uf::stl::string tagName = tagMap.count(key->type) ? tagMap.at(key->type) : ::fmt::format("UnknownTag_{}", key->type);
|
||||
uf::stl::string tagName = tagMap.count(key->type) ? tagMap.at(key->type) : FMT_FORMAT("UnknownTag_{}", key->type);
|
||||
uf::stl::string valueNames = "";
|
||||
|
||||
bool isEnum = false;
|
||||
@ -769,12 +770,12 @@ namespace impl {
|
||||
for (int v = 0; v < 8; ++v) {
|
||||
if (key->aEnum[v] != 255 && key->aEnum[v] != 0) {
|
||||
if (!valueNames.empty()) valueNames += "|";
|
||||
valueNames += valueMap.count(key->aEnum[v]) ? valueMap.at(key->aEnum[v]) : std::to_string(key->aEnum[v]);
|
||||
valueNames += valueMap.count(key->aEnum[v]) ? valueMap.at(key->aEnum[v]) : TO_STRING(key->aEnum[v]);
|
||||
}
|
||||
}
|
||||
newTags += tagName + " " + valueNames;
|
||||
newTags += FMT_FORMAT("{} {}", tagName, valueNames);
|
||||
} else {
|
||||
newTags += tagName + " [" + std::to_string(key->minVal) + "-" + std::to_string(key->maxVal) + "]";
|
||||
newTags += FMT_FORMAT("{} [{}-{}]", tagName, key->minVal, key->maxVal);
|
||||
}
|
||||
|
||||
parseEnvSoundTree(reader, tagMap, valueMap, newTags, ctx);
|
||||
@ -1081,6 +1082,14 @@ namespace impl {
|
||||
UF_MSG_DEBUG("Could not load material: {}", matName);
|
||||
image.loadFromBuffer( missing_pixels, { 2, 2 }, 8, 4 );
|
||||
}
|
||||
bool hasTransparency = false;
|
||||
if ( image.channels == 4 && !image.pixels.empty() ) {
|
||||
for ( size_t i = 3; i < image.pixels.size(); i += 4 ) {
|
||||
if ( image.pixels[i] == 255 ) continue;
|
||||
hasTransparency = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
size_t imageID = graph.images.size();
|
||||
size_t textureID = graph.textures.size();
|
||||
@ -1094,7 +1103,7 @@ namespace impl {
|
||||
material.factorRoughness = 1.0f;
|
||||
material.factorMetallic = 0.0f;
|
||||
material.factorOcclusion = 1.0f;
|
||||
material.factorAlphaCutoff = 0.1f;
|
||||
material.factorAlphaCutoff = 0.5f;
|
||||
material.indexAlbedo = textureID;
|
||||
material.indexNormal = -1;
|
||||
material.indexEmissive = -1;
|
||||
@ -1104,6 +1113,8 @@ namespace impl {
|
||||
|
||||
if ( matName.find("glass") != uf::stl::string::npos ) {
|
||||
material.modeAlpha = pod::Material::AlphaMode::BLEND;
|
||||
} else if ( hasTransparency ) {
|
||||
material.modeAlpha = pod::Material::AlphaMode::MASK;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1230,7 +1241,7 @@ namespace impl {
|
||||
}
|
||||
}
|
||||
|
||||
pod::Atlas::hash_t animHash = ::fmt::format("c_{}_p_{}_anim_{}", c, i, lightID);
|
||||
pod::Atlas::hash_t animHash = FMT_FORMAT("c_{}_p_{}_anim_{}", c, i, lightID);
|
||||
uf::atlas::add( ctx.lightmapAtlas, image, animHash );
|
||||
}
|
||||
}
|
||||
@ -1426,7 +1437,7 @@ namespace impl {
|
||||
node.name = uf::stl::string(ctx.customNames.at(objectID).c_str());
|
||||
} else {
|
||||
if ( archetype != "Unknown" ) node.name = uf::stl::string(archetype.c_str());
|
||||
if ( node.name.empty()) node.name = ::fmt::format("object #{}", objectID);
|
||||
if ( node.name.empty()) node.name = FMT_FORMAT("object #{}", objectID);
|
||||
}
|
||||
|
||||
// bind position
|
||||
@ -1638,7 +1649,7 @@ namespace impl {
|
||||
PropertyLight light;
|
||||
if ( ctx.findInheritedProperty( objectID, ctx.properties.light, light ) ) {
|
||||
// create new node
|
||||
auto lightNodeName = ::fmt::format("{}_light", node.name);
|
||||
auto lightNodeName = FMT_FORMAT("{}_light", node.name);
|
||||
auto lightNodeID = graph.nodes.size();
|
||||
auto& lightNode = graph.nodes.emplace_back();
|
||||
lightNode.name = lightNodeName;
|
||||
@ -1646,7 +1657,7 @@ namespace impl {
|
||||
|
||||
float radiusFactor = 1.2f;
|
||||
float intensityFactor = 0.05f;
|
||||
graph.lights[::fmt::format("{}_{}", lightNode.name, lightNodeID)] = {
|
||||
graph.lights[FMT_FORMAT("{}_{}", lightNode.name, lightNodeID)] = {
|
||||
.range = light.radius * radiusFactor,
|
||||
.color = impl::hsvToRgb(light.hue, light.saturation, 1.0f),
|
||||
.intensity = light.brightness * intensityFactor,
|
||||
@ -1674,7 +1685,7 @@ namespace impl {
|
||||
if ( ctx.linkFlavorNames.count(link.flavor) ) {
|
||||
flavor = ctx.linkFlavorNames.at(link.flavor);
|
||||
} else {
|
||||
flavor = ::fmt::format("Unknown_{}", link.flavor);
|
||||
flavor = FMT_FORMAT("Unknown_{}", link.flavor);
|
||||
}
|
||||
|
||||
size_t sourceIdx = objectToNode[link.sourceId];
|
||||
@ -2092,4 +2103,5 @@ void ext::lgs::loadMis( pod::Graph& graph, const uf::stl::string& filename, cons
|
||||
graph.metadata["debug"]["parent node transforms"] = false; // disable parenting node transforms
|
||||
|
||||
uf::graph::postprocess(graph);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,3 +1,4 @@
|
||||
#if UF_USE_LGS
|
||||
#include <uf/ext/lgs/common.h>
|
||||
#include <uf/ext/lgs/pcx.h>
|
||||
|
||||
@ -93,4 +94,5 @@ bool ext::lgs::loadPcx( pod::Image& image, const uf::stl::vector<uint8_t>& buffe
|
||||
image.channels = 4;
|
||||
image.bpp = 32;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -141,14 +141,14 @@ namespace binds {
|
||||
#include <uf/ext/lua/component.h>
|
||||
|
||||
UF_LUA_REGISTER_ENUM(pod::ShapeType,
|
||||
"AABB", pod::ShapeType::AABB,
|
||||
"OBB", pod::ShapeType::OBB,
|
||||
"SPHERE", pod::ShapeType::SPHERE,
|
||||
"PLANE", pod::ShapeType::PLANE,
|
||||
"CAPSULE", pod::ShapeType::CAPSULE,
|
||||
"TRIANGLE", pod::ShapeType::TRIANGLE,
|
||||
"MESH", pod::ShapeType::MESH,
|
||||
"CONVEX_HULL", pod::ShapeType::CONVEX_HULL
|
||||
"AABB", pod::ShapeType::AABB,
|
||||
"OBB", pod::ShapeType::OBB,
|
||||
"SPHERE", pod::ShapeType::SPHERE,
|
||||
"PLANE", pod::ShapeType::PLANE,
|
||||
"CAPSULE", pod::ShapeType::CAPSULE,
|
||||
"TRIANGLE", pod::ShapeType::TRIANGLE,
|
||||
"MESH", pod::ShapeType::MESH,
|
||||
"CONVEX_HULL", pod::ShapeType::CONVEX_HULL
|
||||
)
|
||||
|
||||
UF_LUA_REGISTER_USERTYPE(pod::Collider,
|
||||
|
||||
@ -75,7 +75,7 @@ uf::stl::string ext::al::getError( ALCenum error ) {
|
||||
case AL_INVALID_OPERATION: return "AL_INVALID_OPERATION"; // the requested operation is not valid
|
||||
case AL_OUT_OF_MEMORY: return "AL_OUT_OF_MEMORY"; // the requested operation resulted in OpenAL running out ofmemory
|
||||
}
|
||||
return ::fmt::format("AL_UNKNOWN({})", error);
|
||||
return FMT_FORMAT("AL_UNKNOWN({})", error);
|
||||
}
|
||||
|
||||
void ext::al::Source::initialize() {
|
||||
|
||||
@ -356,7 +356,7 @@ namespace impl {
|
||||
};
|
||||
|
||||
pod::Atlas::hash_t faceHash( size_t i ) {
|
||||
return ::fmt::format("face_{}", i);
|
||||
return FMT_FORMAT("face_{}", i);
|
||||
}
|
||||
|
||||
void buildDisplacement( const impl::BspContext& context, impl::Meshlet& meshlet, size_t faceID ) {
|
||||
@ -648,7 +648,7 @@ void ext::valve::loadBsp( pod::Graph& graph, const uf::stl::string& filename, co
|
||||
context.texdataToMaterial.assign( context.texdatas.size(), -1 );
|
||||
|
||||
// mount pakfile
|
||||
auto pakfileMount = uf::vfs::mount( ext::zlib::createZipMount(::fmt::format("pakfile://{}", filename), context.pakfile, 1000 ), true );
|
||||
auto pakfileMount = uf::vfs::mount( ext::zlib::createZipMount(FMT_FORMAT("pakfile://{}", filename), context.pakfile, 1000 ), true );
|
||||
|
||||
// deduce mapname
|
||||
uf::stl::string mapName = filename; {
|
||||
@ -660,8 +660,8 @@ void ext::valve::loadBsp( pod::Graph& graph, const uf::stl::string& filename, co
|
||||
|
||||
// load baked cubemaps
|
||||
for ( const auto& cube : context.cubemaps ) {
|
||||
auto matName = ::fmt::format("maps/{}/c{}_{}_{}", mapName, cube.origin.x, cube.origin.y, cube.origin.z);
|
||||
auto vtfPath = ::fmt::format("materials/{}.vtf", matName);
|
||||
auto matName = FMT_FORMAT("maps/{}/c{}_{}_{}", mapName, cube.origin.x, cube.origin.y, cube.origin.z);
|
||||
auto vtfPath = FMT_FORMAT("materials/{}.vtf", matName);
|
||||
graph.metadata["cubemaps"].emplace_back( matName );
|
||||
|
||||
int32_t textureID = -1;
|
||||
@ -922,7 +922,7 @@ void ext::valve::loadBsp( pod::Graph& graph, const uf::stl::string& filename, co
|
||||
}
|
||||
|
||||
if ( !meshlets.empty() ) {
|
||||
auto meshName = ::fmt::format("model_{}", m);
|
||||
auto meshName = FMT_FORMAT("model_{}", m);
|
||||
context.modelToMesh[m] = graph.meshes.size();
|
||||
|
||||
graph.meshes.emplace_back(meshName);
|
||||
@ -956,7 +956,7 @@ void ext::valve::loadBsp( pod::Graph& graph, const uf::stl::string& filename, co
|
||||
}
|
||||
|
||||
if ( !skyboxMeshlets.empty() ) {
|
||||
auto meshName = ::fmt::format("model_{}_skybox", m);
|
||||
auto meshName = FMT_FORMAT("model_{}_skybox", m);
|
||||
graph.meshes.emplace_back(meshName);
|
||||
graph.primitives.emplace_back(meshName);
|
||||
|
||||
@ -1021,8 +1021,8 @@ void ext::valve::loadBsp( pod::Graph& graph, const uf::stl::string& filename, co
|
||||
|
||||
metadata["classname"] = "prop_static";
|
||||
metadata["model"] = dict[type];
|
||||
metadata["origin"] = ::fmt::format("{} {} {}", origin.x, origin.y, origin.z);
|
||||
metadata["angles"] = ::fmt::format("{} {} {}", angles.x, angles.y, angles.z);
|
||||
metadata["origin"] = FMT_FORMAT("{} {} {}", origin.x, origin.y, origin.z);
|
||||
metadata["angles"] = FMT_FORMAT("{} {} {}", angles.x, angles.y, angles.z);
|
||||
|
||||
if ( context.skyArea != -1 ) {
|
||||
int32_t propLeafIdx = impl::findLeaf(context, origin);
|
||||
@ -1108,7 +1108,7 @@ void ext::valve::loadBsp( pod::Graph& graph, const uf::stl::string& filename, co
|
||||
|
||||
// parse lighting info
|
||||
if ( classname.starts_with("light") ) {
|
||||
auto lightKeyName = ::fmt::format( "{}_{}", classname, nodeID );
|
||||
auto lightKeyName = FMT_FORMAT( "{}_{}", classname, nodeID );
|
||||
auto& light = graph.lights[lightKeyName];
|
||||
light.color = { 1.0f, 1.0f, 1.0f };
|
||||
light.intensity = 200.0f;
|
||||
@ -1141,7 +1141,7 @@ void ext::valve::loadBsp( pod::Graph& graph, const uf::stl::string& filename, co
|
||||
float ang = metadata["angle"].as<float>();
|
||||
if ( ang == -1 ) movedirStr = "-90 0 0";
|
||||
else if ( ang == -2 ) movedirStr = "90 0 0";
|
||||
else movedirStr = ::fmt::format("0 {} 0", ang);
|
||||
else movedirStr = FMT_FORMAT("0 {} 0", ang);
|
||||
}
|
||||
|
||||
if ( movedirStr != "" ) {
|
||||
@ -1208,8 +1208,8 @@ void ext::valve::loadBsp( pod::Graph& graph, const uf::stl::string& filename, co
|
||||
uf::stl::vector<uint8_t> missing_pixels = { 255, 0, 255, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 0, 255, 255 };
|
||||
for ( auto matName : graph.materials ) {
|
||||
uf::Serializer vmt;
|
||||
auto vmtPath = ::fmt::format("materials/{}.vmt", matName);
|
||||
auto vtfPath = ::fmt::format("materials/{}.vtf", matName);
|
||||
auto vmtPath = FMT_FORMAT("materials/{}.vmt", matName);
|
||||
auto vtfPath = FMT_FORMAT("materials/{}.vtf", matName);
|
||||
auto& image = storage.images[matName].data;
|
||||
auto& material = storage.materials[matName];
|
||||
|
||||
@ -1240,7 +1240,7 @@ void ext::valve::loadBsp( pod::Graph& graph, const uf::stl::string& filename, co
|
||||
// cubemap
|
||||
if ( vmt["$envmap"].as<uf::stl::string>() != "" ) {
|
||||
auto matName = uf::string::lowercase(vmt["$envmap"].as<uf::stl::string>());
|
||||
auto vtfPath = ::fmt::format("materials/{}.vtf", matName);
|
||||
auto vtfPath = FMT_FORMAT("materials/{}.vtf", matName);
|
||||
|
||||
// retrieve
|
||||
if ( matName == "env_cubemap" ) {
|
||||
@ -1267,7 +1267,7 @@ void ext::valve::loadBsp( pod::Graph& graph, const uf::stl::string& filename, co
|
||||
// normal map
|
||||
} else if ( vmt["$bumpmap"].is<uf::stl::string>() ) {
|
||||
auto matName = uf::string::lowercase(vmt["$bumpmap"].as<uf::stl::string>());
|
||||
auto vtfPath = ::fmt::format("materials/{}.vtf", matName);
|
||||
auto vtfPath = FMT_FORMAT("materials/{}.vtf", matName);
|
||||
|
||||
// retrieve
|
||||
if ( storage.images.map.count(matName) > 0 ) {
|
||||
@ -1285,7 +1285,7 @@ void ext::valve::loadBsp( pod::Graph& graph, const uf::stl::string& filename, co
|
||||
// metallic/roughness/occlusion map
|
||||
if ( vmt["$mrao"].is<uf::stl::string>() ) {
|
||||
auto matName = uf::string::lowercase(vmt["$mrao"].as<uf::stl::string>());
|
||||
auto vtfPath = ::fmt::format("materials/{}.vtf", matName);
|
||||
auto vtfPath = FMT_FORMAT("materials/{}.vtf", matName);
|
||||
|
||||
// retrieve
|
||||
if ( storage.images.map.count(matName) > 0 ) {
|
||||
@ -1300,7 +1300,7 @@ void ext::valve::loadBsp( pod::Graph& graph, const uf::stl::string& filename, co
|
||||
}
|
||||
// albedo map
|
||||
if ( vmt["$basetexture"].is<uf::stl::string>() ) {
|
||||
vtfPath = ::fmt::format("materials/{}.vtf", vmt["$basetexture"].as<uf::stl::string>());
|
||||
vtfPath = FMT_FORMAT("materials/{}.vtf", vmt["$basetexture"].as<uf::stl::string>());
|
||||
if ( ext::valve::loadVtf( image, vtfPath ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ pod::Mount ext::valve::createVpkMount( const uf::stl::string& uri, int priority
|
||||
} else {
|
||||
UF_MSG_DEBUG("Mounted VPK: {}", state.path);
|
||||
}
|
||||
state.name = ::fmt::format("vpk://{}", path);
|
||||
state.name = FMT_FORMAT("vpk://{}", path);
|
||||
|
||||
return mount;
|
||||
}
|
||||
@ -274,7 +274,7 @@ bool ext::valve::readVpk( const pod::VpkArchive& vpk, const uf::stl::string& pat
|
||||
fileOffset = entry.dirFileOffset + entry.metadata.entryOffset;
|
||||
} else {
|
||||
// data is in a chunk file
|
||||
archivePath = ::fmt::format("{}_{:03d}.vpk", vpk.basePath, entry.metadata.archiveIndex);
|
||||
archivePath = FMT_FORMAT("{}_{:03d}.vpk", vpk.basePath, entry.metadata.archiveIndex);
|
||||
fileOffset = entry.metadata.entryOffset;
|
||||
}
|
||||
|
||||
@ -293,7 +293,7 @@ bool ext::valve::readVpk( const pod::VpkArchive& vpk, const uf::stl::string& pat
|
||||
}
|
||||
|
||||
uf::vfs::Mount ext::valve::mountVpk( const uf::stl::string& uri, bool temp ) {
|
||||
return uf::vfs::mount( ext::valve::createVpkMount( ::fmt::format( "valve://{}", uri ), 10 ), temp );
|
||||
return uf::vfs::mount( ext::valve::createVpkMount( FMT_FORMAT( "valve://{}", uri ), 10 ), temp );
|
||||
}
|
||||
uf::vfs::Mount ext::valve::mountGame( const uf::stl::string& uri, bool temp ) {
|
||||
uf::stl::string path = "";
|
||||
@ -310,7 +310,7 @@ uf::vfs::Mount ext::valve::mountGame( const uf::stl::string& uri, bool temp ) {
|
||||
UF_MSG_ERROR("Failed to mount game: {}", uri);
|
||||
return { 0 };
|
||||
}
|
||||
return uf::vfs::mount( uf::vfs::createDiskMount( ::fmt::format( "game://{}", path ), 11 ), temp ); // for some reason a lower priority makes the footstep sound CS:S's
|
||||
return uf::vfs::mount( uf::vfs::createDiskMount( FMT_FORMAT( "game://{}", path ), 11 ), temp ); // for some reason a lower priority makes the footstep sound CS:S's
|
||||
}
|
||||
bool ext::valve::readVpkRange( const pod::VpkArchive& vpk, const uf::stl::string& path, size_t start, size_t len, uf::stl::vector<uint8_t>& buffer ) {
|
||||
auto it = vpk.files.find( path );
|
||||
@ -348,7 +348,7 @@ bool ext::valve::readVpkRange( const pod::VpkArchive& vpk, const uf::stl::string
|
||||
archivePath = vpk.basePath + "_dir.vpk";
|
||||
fileOffset = entry.dirFileOffset + entry.metadata.entryOffset;
|
||||
} else {
|
||||
archivePath = ::fmt::format("{}_{:03d}.vpk", vpk.basePath, entry.metadata.archiveIndex);
|
||||
archivePath = FMT_FORMAT("{}_{:03d}.vpk", vpk.basePath, entry.metadata.archiveIndex);
|
||||
fileOffset = entry.metadata.entryOffset;
|
||||
}
|
||||
|
||||
|
||||
@ -247,7 +247,7 @@ void ext::vulkan::BaseRenderMode::render() {
|
||||
auto& blitter = layer->blitter;
|
||||
if ( !blitter.initialized || !blitter.process || blitter.descriptor.subpass != currentPass || blitter.descriptor.renderMode != this->getName() ) continue;
|
||||
ext::vulkan::GraphicDescriptor descriptor = blitter.descriptor; // bindGraphicDescriptor(blitter.descriptor, currentSubpass);
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, ::fmt::format("blitter[{}: {}]", layer->getName(), layer->getType()) );
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, FMT_FORMAT("blitter[{}: {}]", layer->getName(), layer->getType()) );
|
||||
blitter.record(commandBuffer, descriptor, 0, 0, frame);
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,7 +301,7 @@ void ext::vulkan::DeferredRenderMode::initialize( Device& device ) {
|
||||
uf::stl::string vertexShaderFilename = uf::io::root+"/shaders/display/renderTarget/vert.spv";
|
||||
uf::stl::string fragmentShaderFilename = uf::io::root+"/shaders/display/renderTarget/frag.spv";
|
||||
|
||||
uf::stl::string postProcess = ::fmt::format("{}.frag", metadata.json["postProcess"].as<uf::stl::string>("postProcess"));
|
||||
uf::stl::string postProcess = FMT_FORMAT("{}.frag", metadata.json["postProcess"].as<uf::stl::string>("postProcess"));
|
||||
{
|
||||
std::pair<bool, uf::stl::string> settings[] = {
|
||||
{ settings::pipelines::postProcess /*&& !settings::pipelines::rt*/, postProcess },
|
||||
@ -842,7 +842,7 @@ void ext::vulkan::DeferredRenderMode::createCommandBuffers( const uf::stl::vecto
|
||||
descriptor.bind.depth = 1;
|
||||
descriptor.bind.point = VK_PIPELINE_BIND_POINT_COMPUTE;
|
||||
}
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, ::fmt::format("graphic[{}]", pipeline) );
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, FMT_FORMAT("graphic[{}]", pipeline) );
|
||||
graphic->record( commandBuffer, descriptor, 0, metadata.eyes, frame );
|
||||
}
|
||||
}
|
||||
@ -881,7 +881,7 @@ void ext::vulkan::DeferredRenderMode::createCommandBuffers( const uf::stl::vecto
|
||||
if ( graphic->descriptor.renderTarget != 0 /*this->getName()*/ ) continue;
|
||||
if ( graphic->descriptor.aux != 1 ) continue;
|
||||
ext::vulkan::GraphicDescriptor descriptor = bindGraphicDescriptor(graphic->descriptor, currentSubpass);
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, ::fmt::format("graphic[skybox][{}]", currentDraw) );
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, FMT_FORMAT("graphic[skybox][{}]", currentDraw) );
|
||||
graphic->record( commandBuffer, descriptor, 0, currentDraw++, frame );
|
||||
}
|
||||
// clear depth buffer
|
||||
@ -905,7 +905,7 @@ void ext::vulkan::DeferredRenderMode::createCommandBuffers( const uf::stl::vecto
|
||||
if ( graphic->descriptor.renderTarget != 0 /*this->getName()*/ ) continue;
|
||||
if ( graphic->descriptor.aux != 0 ) continue;
|
||||
ext::vulkan::GraphicDescriptor descriptor = bindGraphicDescriptor(graphic->descriptor, currentSubpass);
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, ::fmt::format("graphic[{}]", currentDraw) );
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, FMT_FORMAT("graphic[{}]", currentDraw) );
|
||||
graphic->record( commandBuffer, descriptor, 0, currentDraw++, frame );
|
||||
}
|
||||
}
|
||||
@ -996,8 +996,8 @@ void ext::vulkan::DeferredRenderMode::createCommandBuffers( const uf::stl::vecto
|
||||
//if ( graphic->descriptor.pipeline != "forward" ) continue;
|
||||
ext::vulkan::GraphicDescriptor descriptor = bindGraphicDescriptor(graphic->descriptor, currentSubpass);
|
||||
//descriptor.renderTarget = 1;
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, ::fmt::format("graphic[{}]", currentDraw) );
|
||||
graphic->record( commandBuffer, descriptor, 0, currentDraw++, frame );
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, FMT_FORMAT("graphic[{}]", currentDraw) );
|
||||
graphic->record( commandBuffer, descriptor, 0, currentDraw++, 0 );
|
||||
}
|
||||
}
|
||||
vkCmdEndRenderPass(commandBuffer);
|
||||
|
||||
@ -183,7 +183,7 @@ void ext::vulkan::RenderTargetRenderMode::initialize( Device& device ) {
|
||||
} else {
|
||||
uf::stl::string vertexShaderFilename = uf::io::root+"/shaders/display/renderTarget/vert.spv";
|
||||
uf::stl::string fragmentShaderFilename = uf::io::root+"/shaders/display/renderTarget/frag.spv"; {
|
||||
uf::stl::string postProcess = ::fmt::format("{}.frag", metadata.json["postProcess"].as<uf::stl::string>("postProcess"));
|
||||
uf::stl::string postProcess = FMT_FORMAT("{}.frag", metadata.json["postProcess"].as<uf::stl::string>("postProcess"));
|
||||
|
||||
std::pair<bool, uf::stl::string> settings[] = {
|
||||
{ settings::pipelines::postProcess, postProcess },
|
||||
@ -215,8 +215,8 @@ void ext::vulkan::RenderTargetRenderMode::initialize( Device& device ) {
|
||||
}
|
||||
#if UF_USE_OPENVR
|
||||
if ( ext::openvr::enabled && metadata.json["vr"].as<bool>() ) {
|
||||
uf::stl::string vertexShaderFilename = uf::io::resolveURI(::fmt::format("{}/shaders/display/vr/{}.vert.spv", uf::io::root, metadata.json["stereo"].as<bool>(metadata.views == 2) ? "stereo" : "flat"));
|
||||
uf::stl::string fragmentShaderFilename = uf::io::resolveURI(::fmt::format("{}/shaders/display/vr/{}.frag.spv", uf::io::root, metadata.json["stereo"].as<bool>(metadata.views == 2) ? "stereo" : "flat"));
|
||||
uf::stl::string vertexShaderFilename = uf::io::resolveURI(FMT_FORMAT("{}/shaders/display/vr/{}.vert.spv", uf::io::root, metadata.json["stereo"].as<bool>(metadata.views == 2) ? "stereo" : "flat"));
|
||||
uf::stl::string fragmentShaderFilename = uf::io::resolveURI(FMT_FORMAT("{}/shaders/display/vr/{}.frag.spv", uf::io::root, metadata.json["stereo"].as<bool>(metadata.views == 2) ? "stereo" : "flat"));
|
||||
|
||||
blitter.material.attachShader(vertexShaderFilename, uf::renderer::enums::Shader::VERTEX, "vr");
|
||||
blitter.material.attachShader(fragmentShaderFilename, uf::renderer::enums::Shader::FRAGMENT, "vr");
|
||||
@ -417,7 +417,7 @@ void ext::vulkan::RenderTargetRenderMode::createCommandBuffers( const uf::stl::v
|
||||
for ( auto graphic : graphics ) {
|
||||
if ( graphic->descriptor.renderMode != this->getTarget() ) continue;
|
||||
if ( graphic->descriptor.pipeline != uf::renderer::settings::pipelines::names::rt ) continue;
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, ::fmt::format("graphic[{}]", graphic->descriptor.pipeline) );
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, FMT_FORMAT("graphic[{}]", graphic->descriptor.pipeline) );
|
||||
graphic->record( commandBuffer );
|
||||
}
|
||||
} else {
|
||||
@ -440,7 +440,7 @@ void ext::vulkan::RenderTargetRenderMode::createCommandBuffers( const uf::stl::v
|
||||
} else {
|
||||
UF_MSG_DEBUG("Aux pipeline: {}", pipeline);
|
||||
}
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, ::fmt::format("graphic[{}]", pipeline) );
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, FMT_FORMAT("graphic[{}]", pipeline) );
|
||||
graphic->record( commandBuffer, descriptor, 0, metadata.type == uf::renderer::settings::pipelines::names::vxgi ? 0 : MIN(subpasses,6), frame );
|
||||
}
|
||||
}
|
||||
@ -454,12 +454,12 @@ void ext::vulkan::RenderTargetRenderMode::createCommandBuffers( const uf::stl::v
|
||||
for ( auto graphic : graphics ) {
|
||||
if ( graphic->descriptor.renderMode != this->getTarget() ) continue;
|
||||
ext::vulkan::GraphicDescriptor descriptor = bindGraphicDescriptor(graphic->descriptor, currentPass);
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, ::fmt::format("graphic[{}]", currentDraw) );
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, FMT_FORMAT("graphic[{}]", currentDraw) );
|
||||
graphic->record( commandBuffer, descriptor, currentPass, currentDraw++, frame );
|
||||
}
|
||||
|
||||
VK_COMMAND_BUFFER_CALLBACK( currentPass, commandBuffer, frame, {
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, ::fmt::format("callback[{}]", currentPass) );
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, FMT_FORMAT("callback[{}]", currentPass) );
|
||||
} );
|
||||
|
||||
if ( currentPass + 1 < subpasses ) {
|
||||
|
||||
@ -170,7 +170,7 @@ void ext::vulkan::VrRenderMode::createCommandBuffers(const uf::stl::vector<ext::
|
||||
|
||||
// to-do: transition attachment here
|
||||
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, ::fmt::format("blitter[{}: {}]", layer->getName(), layer->getType()) );
|
||||
device->UF_CHECKPOINT_MARK( commandBuffer, pod::Checkpoint::GENERIC, FMT_FORMAT("blitter[{}: {}]", layer->getName(), layer->getType()) );
|
||||
blitter.record(commandBuffer, descriptor, currentPass, currentDraw++, frame);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ ext::vulkan::userdata_t ext::vulkan::jsonToUserdata( const ext::json::Value& pay
|
||||
}
|
||||
if ( ext::json::isArray(value) ) {
|
||||
ext::json::forEach(value, [&]( size_t i, const ext::json::Value& element ){
|
||||
variableName.emplace_back(::fmt::format("[{}]", i));
|
||||
variableName.emplace_back(FMT_FORMAT("[{}]", i));
|
||||
parse(element);
|
||||
});
|
||||
#if UF_SHADER_TRACK_NAMES
|
||||
@ -253,7 +253,7 @@ ext::vulkan::userdata_t ext::vulkan::jsonToUserdata( const ext::json::Value& pay
|
||||
else if ( ext::json::isArray(input) ) {
|
||||
ext::json::forEach( input, [&]( size_t i, const ext::json::Value& value){
|
||||
#if UF_SHADER_TRACK_NAMES
|
||||
variableName.emplace_back(::fmt::format("[{}]", i));
|
||||
variableName.emplace_back(FMT_FORMAT("[{}]", i));
|
||||
SKIP_ADD = true;
|
||||
#endif
|
||||
parseDefinition(input[i], definition);
|
||||
@ -364,8 +364,8 @@ void ext::vulkan::Shader::initialize( ext::vulkan::Device& device, const uf::stl
|
||||
if ( name == "" ) name = comp.get_name(type.parent_type);
|
||||
if ( name == "" ) name = comp.get_fallback_name(type_id);
|
||||
if ( type.vecsize > 1 ) {
|
||||
if ( type.columns > 1 ) name = ::fmt::format( "Matrix{}x{}<{}>", type.vecsize, type.columns, name );
|
||||
else name = ::fmt::format("Vector{}<{}>", type.vecsize, name )
|
||||
if ( type.columns > 1 ) name = FMT_FORMAT( "Matrix{}x{}<{}>", type.vecsize, type.columns, name );
|
||||
else name = FMT_FORMAT("Vector{}<{}>", type.vecsize, name )
|
||||
}
|
||||
{
|
||||
ext::json::Value source = value;
|
||||
@ -382,7 +382,7 @@ void ext::vulkan::Shader::initialize( ext::vulkan::Device& device, const uf::stl
|
||||
for ( size_t i = 0; i < arraySize; ++i ) {
|
||||
value.emplace_back(source);
|
||||
}
|
||||
name += ::fmt::format("[{}]", arraySize);
|
||||
name += FMT_FORMAT("[{}]", arraySize);
|
||||
size *= arraySize;
|
||||
}
|
||||
}
|
||||
@ -462,7 +462,7 @@ void ext::vulkan::Shader::initialize( ext::vulkan::Device& device, const uf::stl
|
||||
case spv::Dim::DimBuffer: tname = "Buffer"; break;
|
||||
case spv::Dim::DimSubpassData: tname = "SubpassData"; break;
|
||||
}
|
||||
uf::stl::string key = ::fmt::format("{}", binding);
|
||||
uf::stl::string key = FMT_FORMAT("{}", binding);
|
||||
#if UF_SHADER_PARSE_AS_JSON
|
||||
metadata.json["definitions"]["textures"][key]["name"] = name;
|
||||
metadata.json["definitions"]["textures"][key]["index"] = index;
|
||||
|
||||
@ -202,7 +202,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL ext::vulkan::debugCallback(
|
||||
|
||||
uf::stl::string message = pCallbackData->pMessage;
|
||||
for ( auto& filter : ext::vulkan::settings::validation::filters ) {
|
||||
if ( message.find(::fmt::format("MessageID = {}", filter)) != uf::stl::string::npos ) return VK_FALSE;
|
||||
if ( message.find(FMT_FORMAT("MessageID = {}", filter)) != uf::stl::string::npos ) return VK_FALSE;
|
||||
}
|
||||
UF_MSG_ERROR("[Validation Layer] {}", message);
|
||||
return VK_FALSE;
|
||||
@ -219,7 +219,7 @@ uf::stl::string ext::vulkan::retrieveCheckpoint( VkQueue queue ) {
|
||||
uf::stl::vector<uf::stl::string> strings;
|
||||
|
||||
for ( auto& checkpoint : checkpoints ) {
|
||||
strings.emplace_back(::fmt::format( "{} | {} | {}:\n{}", ::fmt::ptr(queue), checkpoint.stage, ::fmt::ptr(checkpoint.pCheckpointMarker), uf::checkpoint::traverse( (pod::Checkpoint*) checkpoint.pCheckpointMarker )));
|
||||
strings.emplace_back(FMT_FORMAT( "{} | {} | {}:\n{}", ::fmt::ptr(queue), checkpoint.stage, ::fmt::ptr(checkpoint.pCheckpointMarker), uf::checkpoint::traverse( (pod::Checkpoint*) checkpoint.pCheckpointMarker )));
|
||||
}
|
||||
|
||||
return uf::string::join( strings, "\n" );
|
||||
@ -252,7 +252,7 @@ uf::stl::string ext::vulkan::errorString( VkResult result ) {
|
||||
STR(ERROR_INVALID_SHADER_NV);
|
||||
#undef STR
|
||||
default:
|
||||
return ::fmt::format("UNKNOWN_ERROR: {}", result);
|
||||
return FMT_FORMAT("UNKNOWN_ERROR: {}", result);
|
||||
}
|
||||
}
|
||||
VkSampleCountFlagBits ext::vulkan::sampleCount( uint8_t count ) {
|
||||
|
||||
@ -395,7 +395,7 @@ pod::Mount ext::zlib::createZipMount( const uf::stl::string& uri, uf::stl::vecto
|
||||
state.buffer = buffer;
|
||||
ext::zlib::directory( state.buffer, state.entries );
|
||||
|
||||
if ( mount.path.empty() ) mount.path = ::fmt::format( "{}/{}", uri, (void*) state.buffer.data() );
|
||||
if ( mount.path.empty() ) mount.path = FMT_FORMAT( "{}/{}", uri, (void*) state.buffer.data() );
|
||||
// for ( auto& [ k, v ] : state.entries ) UF_MSG_DEBUG("{} => {}/{}", mount.path, uri, k);
|
||||
|
||||
return mount;
|
||||
@ -411,7 +411,7 @@ pod::Mount ext::zlib::createZipMount( const uf::stl::string& uri, const uf::stl:
|
||||
return pod::Mount{};
|
||||
}
|
||||
|
||||
return ext::zlib::createZipMount( ::fmt::format("{}/{}", uri, filename), std::move(buffer), priority );
|
||||
return ext::zlib::createZipMount( FMT_FORMAT("{}/{}", uri, filename), std::move(buffer), priority );
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -322,7 +322,7 @@ namespace {
|
||||
CASE_KEY_RETURN('9', "Num9");
|
||||
CASE_KEY_RETURN('0', "Num0");
|
||||
}
|
||||
return ::fmt::format("{}", key);
|
||||
return FMT_FORMAT("{}", key);
|
||||
}
|
||||
uf::stl::string GetKeyName( WPARAM key, LPARAM flags = 0 ) {
|
||||
return uf::string::uppercase( _GetKeyName( key, flags ) );
|
||||
@ -865,7 +865,7 @@ void spec::win32::Window::processEvents() {
|
||||
};
|
||||
#if UF_HOOK_USE_JSON
|
||||
ext::json::Value json;
|
||||
json["type"] = ::fmt::format("{}.{}", event.type, (event.key.state == -1) ? "Pressed" : "Released");
|
||||
json["type"] = FMT_FORMAT("{}.{}", event.type, (event.key.state == -1) ? "Pressed" : "Released");
|
||||
json["invoker"] = event.invoker;
|
||||
json["key"]["code"] = "";
|
||||
json["key"]["raw"] = 0;
|
||||
@ -881,7 +881,7 @@ void spec::win32::Window::processEvents() {
|
||||
event.key.code = code;
|
||||
event.key.raw = key;
|
||||
|
||||
auto eventName = ::fmt::format("{}.{}", event.type, code);
|
||||
auto eventName = FMT_FORMAT("{}.{}", event.type, code);
|
||||
#if UF_HOOK_USE_USERDATA
|
||||
this->pushEvent(event.type, event);
|
||||
this->pushEvent(eventName, event);
|
||||
@ -1145,14 +1145,14 @@ void spec::win32::Window::processEvent(UINT message, WPARAM wParam, LPARAM lPara
|
||||
}
|
||||
}
|
||||
};
|
||||
auto eventName = ::fmt::format("{}.{}", event.type, event.key.code);
|
||||
auto eventName = FMT_FORMAT("{}.{}", event.type, event.key.code);
|
||||
#if UF_HOOK_USE_USERDATA
|
||||
this->pushEvent(event.type, event);
|
||||
this->pushEvent(eventName, event);
|
||||
#endif
|
||||
#if UF_HOOK_USE_JSON
|
||||
ext::json::Value json;
|
||||
json["type"] = ::fmt::format("{}.{}", event.type, (event.key.state == -1) ? "Pressed" : "Released");
|
||||
json["type"] = FMT_FORMAT("{}.{}", event.type, (event.key.state == -1) ? "Pressed" : "Released");
|
||||
json["invoker"] = event.invoker;
|
||||
json["key"]["state"] = (event.key.state == -1) ? "Down" : "Up";
|
||||
json["key"]["async"] = event.key.async;
|
||||
|
||||
@ -51,7 +51,7 @@ uf::stl::string uf::checkpoint::traverse( pod::Checkpoint* checkpoint ) {
|
||||
case pod::Checkpoint::BEGIN: type = "BEGIN"; break;
|
||||
case pod::Checkpoint::END: type = "END"; break;
|
||||
}
|
||||
res.emplace( res.begin(), ::fmt::format("[{}] [{}]: {}", type, checkpoint->info, checkpoint->name) );
|
||||
res.emplace( res.begin(), FMT_FORMAT("[{}] [{}]: {}", type, checkpoint->info, checkpoint->name) );
|
||||
checkpoint = checkpoint->previous;
|
||||
}
|
||||
|
||||
|
||||
@ -275,6 +275,12 @@ void uf::debug::drawLines( float dt ) {
|
||||
{
|
||||
auto& shader = graphic.material.getShader("vertex");
|
||||
shader.aliasBuffer( storage.buffers.camera );
|
||||
#if UF_USE_VULKAN
|
||||
uint32_t maxPasses = 6;
|
||||
shader.setSpecializationConstants({
|
||||
{ "PASSES", maxPasses }
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
graphic.initialize();
|
||||
@ -363,6 +369,12 @@ void uf::debug::drawTexts( float dt ) {
|
||||
{
|
||||
auto& shader = graphic.material.getShader("vertex");
|
||||
shader.aliasBuffer( storage.buffers.camera );
|
||||
#if UF_USE_VULKAN
|
||||
uint32_t maxPasses = 6;
|
||||
shader.setSpecializationConstants({
|
||||
{ "PASSES", maxPasses }
|
||||
});
|
||||
#endif
|
||||
}
|
||||
// fragment shader
|
||||
auto& texture = graphic.material.textures.emplace_back();
|
||||
|
||||
@ -57,9 +57,9 @@ void uf::console::initialize() {
|
||||
uf::stl::string s_result = "";
|
||||
for ( auto i = 0; i < results.size(); ++i ) {
|
||||
auto& res = results[i];
|
||||
if ( res.is<uf::stl::string>() ) s_result += ::fmt::format("\n[{}] => {}", i, res.as<uf::stl::string>());
|
||||
else if ( res.is<ext::json::Value>() ) s_result += ::fmt::format("\n[{}] => {}", i, ext::json::encode( res.as<ext::json::Value>() ));
|
||||
else s_result += ::fmt::format("\n[{}] => Userdata: {}", i, (void*) res);
|
||||
if ( res.is<uf::stl::string>() ) s_result += FMT_FORMAT("\n[{}] => {}", i, res.as<uf::stl::string>());
|
||||
else if ( res.is<ext::json::Value>() ) s_result += FMT_FORMAT("\n[{}] => {}", i, ext::json::encode( res.as<ext::json::Value>() ));
|
||||
else s_result += FMT_FORMAT("\n[{}] => Userdata: {}", i, (void*) res);
|
||||
}
|
||||
|
||||
return "Hook executed: " + match[1] + s_result;
|
||||
@ -100,7 +100,7 @@ void uf::console::initialize() {
|
||||
};
|
||||
for ( uf::Scene* scene : uf::scene::scenes ) {
|
||||
if ( !scene ) continue;
|
||||
res += ::fmt::format("Scene: {}: {}\n", scene->getName(), scene->getUid());
|
||||
res += FMT_FORMAT("Scene: {}: {}\n", scene->getName(), scene->getUid());
|
||||
scene->process(filter, 1);
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ void uf::io::exception( const uf::stl::string& exception ) {
|
||||
}
|
||||
*/
|
||||
uf::stl::string uf::io::log( const uf::stl::string& category, const uf::stl::string& file, const uf::stl::string& function, size_t line, const uf::stl::string& message ) {
|
||||
auto string = ::fmt::format("[{}] [{}:{}@{}]: {}", category, file, function, line, message);
|
||||
auto string = FMT_FORMAT("[{}] [{}:{}@{}]: {}", category, file, function, line, message);
|
||||
::fmt::print("{}\n", string);
|
||||
uf::iostream.pushHistory(string);
|
||||
std::cout.flush();
|
||||
|
||||
@ -85,7 +85,7 @@ char uf::IoStream::readChar(const bool& loop) {
|
||||
auto ch = std::cin.get();
|
||||
|
||||
addCh(ch);
|
||||
// ::info.input.history.push_back( ::fmt::format("{}", ch) );
|
||||
// ::info.input.history.push_back( FMT_FORMAT("{}", ch) );
|
||||
return ch;
|
||||
}
|
||||
uf::stl::string uf::IoStream::readString(const bool& loop) {
|
||||
@ -111,7 +111,7 @@ char uf::IoStream::writeChar( char ch ) {
|
||||
|
||||
if ( ch == '\n' ) std::cout << std::endl;
|
||||
else std::cout << ch;
|
||||
// ::info.input.history.push_back( ::fmt::format("{}", ch) );
|
||||
// ::info.input.history.push_back( FMT_FORMAT("{}", ch) );
|
||||
return ch;
|
||||
}
|
||||
const uf::stl::string& uf::IoStream::writeString( const uf::stl::string& str ) {
|
||||
|
||||
@ -37,6 +37,7 @@ void impl::updateActivity( pod::PhysicsBody& body, float dt ) {
|
||||
// reset grounded state
|
||||
bool wasGrounded = body.activity.grounded;
|
||||
body.activity.grounded = false;
|
||||
body.activity.referenceFrame = NULL;
|
||||
|
||||
// update bounds
|
||||
body.bounds = impl::computeAABB( body );
|
||||
|
||||
@ -70,9 +70,9 @@ void impl::drawBody( const pod::PhysicsBody& body ) {
|
||||
|
||||
if ( magSq < viewThresholdSq && dot > angleThreshold ) {
|
||||
STATIC_THREAD_LOCAL(uf::stl::vector<uf::stl::string>, strings);
|
||||
strings.emplace_back( ::fmt::format("{}\n", uf::string::toString( *body.object ) ) );
|
||||
strings.emplace_back( ::fmt::format("Mass: {:.3f} kg ({})\n", body.inverseMass == 0.0f ? 0.0f : 1.0f / body.inverseMass, impl::similarMass( body )) );
|
||||
strings.emplace_back( ::fmt::format(
|
||||
strings.emplace_back( FMT_FORMAT("{}\n", uf::string::toString( *body.object ) ) );
|
||||
strings.emplace_back( FMT_FORMAT("Mass: {:.3f} kg ({})\n", body.inverseMass == 0.0f ? 0.0f : 1.0f / body.inverseMass, impl::similarMass( body )) );
|
||||
strings.emplace_back( FMT_FORMAT(
|
||||
"Position: {} | Pitch: {:.1f} | Yaw: {:.1f} | Roll: {:.1f}\n",
|
||||
uf::vector::toString( transform.position, "{}" ),
|
||||
(RAD_2_DEG) * uf::quaternion::pitch( transform.orientation ),
|
||||
@ -80,10 +80,10 @@ void impl::drawBody( const pod::PhysicsBody& body ) {
|
||||
(RAD_2_DEG) * uf::quaternion::roll( transform.orientation )
|
||||
) );
|
||||
if ( uf::vector::magnitude( body.velocity ) > EPS2 || uf::vector::magnitude( body.angularVelocity ) > EPS2 ) {
|
||||
strings.emplace_back( ::fmt::format( "Velocity: {} | Angular Velocity: {}\n", uf::vector::toString( body.velocity, "{}" ), uf::vector::toString( body.angularVelocity, "{}" ) ) );
|
||||
strings.emplace_back( FMT_FORMAT( "Velocity: {} | Angular Velocity: {}\n", uf::vector::toString( body.velocity, "{}" ), uf::vector::toString( body.angularVelocity, "{}" ) ) );
|
||||
}
|
||||
strings.emplace_back( ::fmt::format("Awake: {} | Timer: {:.3f} | Grounded: {}\n", body.activity.awake, body.activity.sleepTimer, body.activity.grounded) );
|
||||
strings.emplace_back( ::fmt::format("Category: {:#X} | Mask: {:#X}", body.collider.category, body.collider.mask) );
|
||||
strings.emplace_back( FMT_FORMAT("Awake: {} | Timer: {:.3f} | Grounded: {}\n", body.activity.awake, body.activity.sleepTimer, body.activity.grounded) );
|
||||
strings.emplace_back( FMT_FORMAT("Category: {:#X} | Mask: {:#X}", body.collider.category, body.collider.mask) );
|
||||
uf::debug::drawText( uf::string::join(strings, ""), position );
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,8 +208,8 @@ void impl::integrate( pod::PhysicsBody& body, float dt ) {
|
||||
if ( body.activity.referenceFrame ) {
|
||||
auto ref = body.activity.referenceFrame->velocity;
|
||||
if ( body.velocity.y > ref.y + 1.0f ) {
|
||||
body.activity.referenceFrame = NULL;
|
||||
} else if ( body.velocity.y > ref.y ) body.velocity.y = ref.y;
|
||||
body.activity.referenceFrame = NULL;
|
||||
} else if ( body.velocity.y > ref.y ) body.velocity.y = ref.y;
|
||||
}
|
||||
|
||||
// linear integration
|
||||
|
||||
@ -1,17 +1,22 @@
|
||||
#include <uf/utils/memory/allocator.h>
|
||||
#include <uf/utils/memory/pool.h>
|
||||
#include <iostream>
|
||||
|
||||
bool uf::allocator::override = false;
|
||||
bool uf::allocator::override = true;
|
||||
|
||||
void* uf::allocator::allocate( size_t n ) {
|
||||
if ( override && uf::memoryPool::global.size() > 0 ) return uf::memoryPool::global.alloc( n );
|
||||
if ( override && uf::memoryPool::global.size() > 0 ) {
|
||||
return uf::memoryPool::global.alloc( n );
|
||||
}
|
||||
return std::malloc( n );
|
||||
}
|
||||
|
||||
void uf::allocator::deallocate( void* p, size_t n ) {
|
||||
if ( !p ) return;
|
||||
|
||||
if ( override && uf::memoryPool::global.size() > 0 ) uf::memoryPool::global.free( p, n );
|
||||
if ( override && uf::memoryPool::global.size() > 0 ) {
|
||||
uf::memoryPool::global.free( p, n );
|
||||
}
|
||||
else std::free( p );
|
||||
}
|
||||
|
||||
@ -19,36 +24,36 @@ void* uf::allocator::malloc_m( size_t n ) {
|
||||
return std::malloc( n );
|
||||
}
|
||||
|
||||
void uf::allocator::free_m( void* p, size_t /*n*/ ) {
|
||||
void uf::allocator::free_m( void* p, size_t n ) {
|
||||
std::free( p );
|
||||
}
|
||||
|
||||
#if UF_MEMORYPOOL_OVERRIDE_NEW_DELETE
|
||||
void* operator new( size_t n ) {
|
||||
void* p = uf::allocator::allocate( n );
|
||||
void* p = uf::allocator::malloc_m( n );
|
||||
if ( !p ) throw std::bad_alloc();
|
||||
return p;
|
||||
}
|
||||
|
||||
void operator delete( void* p ) noexcept {
|
||||
uf::allocator::deallocate( p, 0 );
|
||||
uf::allocator::free_m( p, 0 );
|
||||
}
|
||||
|
||||
void* operator new[]( size_t n ) {
|
||||
void* p = uf::allocator::allocate( n );
|
||||
void* p = uf::allocator::malloc_m( n );
|
||||
if ( !p ) throw std::bad_alloc();
|
||||
return p;
|
||||
}
|
||||
|
||||
void operator delete[]( void* p ) noexcept {
|
||||
uf::allocator::deallocate( p, 0 );
|
||||
uf::allocator::free_m( p, 0 );
|
||||
}
|
||||
|
||||
void operator delete( void* p, size_t n ) noexcept {
|
||||
uf::allocator::deallocate( p, n );
|
||||
uf::allocator::free_m( p, n );
|
||||
}
|
||||
|
||||
void operator delete[]( void* p, size_t n ) noexcept {
|
||||
uf::allocator::deallocate( p, n );
|
||||
uf::allocator::free_m( p, n );
|
||||
}
|
||||
#endif
|
||||
@ -51,6 +51,8 @@ namespace {
|
||||
inline bool getBit(uint8_t* bitset, size_t index) {
|
||||
return (bitset[index / 8] & (1 << (index % 8))) != 0;
|
||||
}
|
||||
|
||||
size_t subpoolSizes = 0;
|
||||
}
|
||||
|
||||
bool uf::memoryPool::subPool = true;
|
||||
@ -64,6 +66,7 @@ void uf::memoryPool::initialize( pod::MemoryPool& pool, size_t size, pod::Memory
|
||||
pool.size = size;
|
||||
pool.strategy = strategy;
|
||||
if ( uf::memoryPool::subPool && &pool != &uf::memoryPool::global.data() ) {
|
||||
subpoolSizes += size;
|
||||
pool.memory = uf::memoryPool::global.alloc( size );
|
||||
} else {
|
||||
pool.memory = uf::allocator::malloc_m( size );
|
||||
@ -136,6 +139,7 @@ void uf::memoryPool::initialize( pod::MemoryPool& pool, size_t size, pod::Memory
|
||||
void uf::memoryPool::destroy( pod::MemoryPool& pool ) {
|
||||
if ( uf::memoryPool::size( pool ) <= 0 || !pool.memory ) goto CLEAR;
|
||||
if ( uf::memoryPool::subPool && &pool != &uf::memoryPool::global.data() ) {
|
||||
subpoolSizes -= pool.size;
|
||||
uf::memoryPool::global.free( pool.memory, pool.size );
|
||||
} else {
|
||||
uf::allocator::free_m( pool.memory, pool.size );
|
||||
@ -386,7 +390,7 @@ MANUAL_FREE:
|
||||
#endif
|
||||
|
||||
#if UF_MEMORYPOOL_INVALID_FREE
|
||||
UF_MSG_DEBUG("memory pool {}: manually freeing {}", (void*) &pool, pointer );
|
||||
//UF_MSG_DEBUG("memory pool {}: manually freeing {}", (void*) &pool, pointer );
|
||||
uf::allocator::free_m(pointer);
|
||||
return true;
|
||||
#else
|
||||
@ -413,15 +417,47 @@ bool uf::memoryPool::exists( pod::MemoryPool& pool, void* pointer, size_t size )
|
||||
size_t uf::memoryPool::allocated( const pod::MemoryPool& pool ) {
|
||||
return pool.used;
|
||||
}
|
||||
uf::stl::string uf::memoryPool::stats( const pod::MemoryPool& pool ) {
|
||||
uf::stl::string uf::memoryPool::stats( const pod::MemoryPool& pool, bool readable ) {
|
||||
uf::Serializer metadata;
|
||||
metadata["size"] = pool.size;
|
||||
metadata["used"] = pool.used;
|
||||
metadata["free"] = pool.size - pool.used;
|
||||
metadata["strategy"] = (int) pool.strategy;
|
||||
auto size = pool.size;
|
||||
auto used = pool.used;
|
||||
auto free = pool.size - pool.used;
|
||||
if ( readable ) {
|
||||
uf::stl::string strategy;
|
||||
switch ( pool.strategy ) {
|
||||
case pod::MemoryPool::Strategy::LINEAR: {
|
||||
strategy = "linear";
|
||||
} break;
|
||||
case pod::MemoryPool::Strategy::POOL: {
|
||||
strategy = "pool";
|
||||
} break;
|
||||
case pod::MemoryPool::Strategy::SEGREGATED: {
|
||||
strategy = "segregated";
|
||||
} break;
|
||||
case pod::MemoryPool::Strategy::BUDDY: {
|
||||
strategy = "buddy";
|
||||
} break;
|
||||
default: {
|
||||
strategy = "?";
|
||||
} break;
|
||||
}
|
||||
// if global pool, offset by subpool sizes
|
||||
if ( &pool == &uf::memoryPool::global.data() ) {
|
||||
size -= subpoolSizes;
|
||||
used -= subpoolSizes;
|
||||
free -= subpoolSizes;
|
||||
}
|
||||
|
||||
uf::stl::stringstream ss; ss << std::hex << (void*) pool.memory;
|
||||
metadata["pool"] = ss.str();
|
||||
metadata["size"] = uf::string::si( size, "B" );
|
||||
metadata["used"] = uf::string::si( used, "B" );
|
||||
metadata["free"] = uf::string::si( free, "B" );
|
||||
metadata["strategy"] = strategy;
|
||||
} else {
|
||||
metadata["size"] = size;
|
||||
metadata["used"] = used;
|
||||
metadata["free"] = free;
|
||||
metadata["strategy"] = (int) pool.strategy;
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
/*
|
||||
|
||||
@ -16,24 +16,31 @@ bool uf::string::match( const uf::stl::string& str, const uf::stl::string& r ) {
|
||||
}
|
||||
*/
|
||||
bool uf::string::isRegex( const uf::stl::string& str ) {
|
||||
return str.size() > 2 && str.front() == '/' && str.back() == '/';
|
||||
return str.size() > 2 && str.front() == '/' && str.back() == '/';
|
||||
}
|
||||
|
||||
uf::stl::vector<uf::stl::string> uf::string::match( const uf::stl::string& str, const uf::stl::string& r ) {
|
||||
std::regex regex(uf::string::isRegex(r) ? r.substr(1,r.length()-2) : r);
|
||||
std::smatch match;
|
||||
uf::stl::string pattern = uf::string::isRegex(r) ? r.substr(1, r.length() - 2) : r;
|
||||
std::regex regex(pattern.c_str());
|
||||
|
||||
std::cmatch match;
|
||||
uf::stl::vector<uf::stl::string> matches;
|
||||
if ( std::regex_search( str, match, regex ) ) {
|
||||
|
||||
if ( std::regex_search( str.c_str(), match, regex ) ) {
|
||||
for ( auto& m : match ) {
|
||||
matches.emplace_back(m.str());
|
||||
matches.emplace_back(m.first, m.length());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
bool uf::string::matched( const uf::stl::string& str, const uf::stl::string& r ) {
|
||||
std::regex regex(uf::string::isRegex(r) ? r.substr(1,r.length()-2) : r);
|
||||
std::smatch match;
|
||||
return std::regex_search( str, match, regex );
|
||||
uf::stl::string pattern = uf::string::isRegex(r) ? r.substr(1, r.length() - 2) : r;
|
||||
std::regex regex(pattern.c_str());
|
||||
std::cmatch match;
|
||||
|
||||
return std::regex_search( str.c_str(), match, regex );
|
||||
}
|
||||
|
||||
uf::stl::string uf::string::lowercase( const uf::stl::string& str ) {
|
||||
@ -60,7 +67,7 @@ uf::stl::vector<uf::stl::string> uf::string::split( const uf::stl::string& str,
|
||||
return tokens;
|
||||
}
|
||||
uf::stl::vector<uf::stl::string> uf::string::split( const uf::stl::string& str, char delim ) {
|
||||
uf::stl::string d = ::fmt::format("{}", delim); // because it's such a pain apparently to convert a char to str
|
||||
uf::stl::string d = FMT_FORMAT("{}", delim); // because it's such a pain apparently to convert a char to str
|
||||
return uf::string::split( str, d );
|
||||
}
|
||||
/*
|
||||
|
||||
@ -264,7 +264,7 @@ bool uf::glyph::generateAtlas( const uf::stl::vector<pod::GlyphBox>& layout, con
|
||||
// generate atlas
|
||||
for ( const auto& g : layout ) {
|
||||
auto key = uf::glyph::hashSettings( g.code, metadata );
|
||||
auto hash = ::fmt::format( "{}", key );
|
||||
auto hash = FMT_FORMAT( "{}", key );
|
||||
auto& glyph = cache[key];
|
||||
|
||||
// already in atlas map
|
||||
@ -304,7 +304,7 @@ void uf::glyph::generateMesh( const uf::stl::vector<pod::GlyphBox>& layout, cons
|
||||
indices.reserve(layout.size() * 6);
|
||||
|
||||
for ( const auto& g : layout ) {
|
||||
auto hash = ::fmt::format( "{}", uf::glyph::hashSettings(g.code, metadata) );
|
||||
auto hash = FMT_FORMAT( "{}", uf::glyph::hashSettings(g.code, metadata) );
|
||||
|
||||
#if EXT_COLOR_FLOATS
|
||||
auto& color = g.color;
|
||||
|
||||
@ -48,7 +48,7 @@ pod::Thread& uf::thread::fetchWorker( const uf::stl::string& name ) {
|
||||
|
||||
while ( tries++ < limit ) {
|
||||
int val = current.fetch_add(1, std::memory_order_relaxed);
|
||||
auto workerName = ::fmt::format("{} {}", name, val % limit);
|
||||
auto workerName = FMT_FORMAT("{} {}", name, val % limit);
|
||||
auto& pod = uf::thread::get( workerName );
|
||||
if ( std::this_thread::get_id() == pod.thread.get_id() ) continue; // do not queue to current thread
|
||||
return pod;
|
||||
|
||||
@ -175,6 +175,6 @@ ifneq (,$(findstring valve,$(REQ_DEPS)))
|
||||
FLAGS += -DUF_USE_VALVE
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring ttlg,$(REQ_DEPS)))
|
||||
FLAGS += -DUF_USE_TTLG
|
||||
ifneq (,$(findstring lgs,$(REQ_DEPS)))
|
||||
FLAGS += -DUF_USE_LGS
|
||||
endif
|
||||
@ -1,5 +1,5 @@
|
||||
ifneq (,$(findstring -DUF_DEV_ENV,$(FLAGS)))
|
||||
REQ_DEPS += meshoptimizer toml xatlas curl dc:texconv ffx:sdk openvr valve ttlg # vall_e cpptrace # ncurses draco discord ultralight-ux
|
||||
REQ_DEPS += meshoptimizer toml xatlas curl dc:texconv ffx:sdk openvr valve lgs # vall_e cpptrace # ncurses draco discord ultralight-ux
|
||||
FLAGS += -march=native -g # -flto # -g
|
||||
endif
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user