This commit is contained in:
Mikulas Florek 2020-02-16 13:07:20 +01:00
parent 7a29be9ed3
commit 899ffdbb3d
23 changed files with 100 additions and 85 deletions

View file

@ -62,4 +62,4 @@ jobs:
cd tmp/gmake
pvs-studio-analyzer trace -- make -j EXTRA_WARNINGS=1
pvs-studio-analyzer analyze -e ../../../src/renderer/editor/miniz.c -e ../../../external -l ../../../pvs-studio.lic -o pvs-studio.log
plog-converter -a 'GA:1,2;OP:1' -d V730 -t errorfile -w pvs-studio.log
plog-converter -a 'GA:1,2;OP:1' -d V730,V1001 -t errorfile -w pvs-studio.log

View file

@ -476,7 +476,7 @@ void ControllerEditor::onWindowGUI() {
}
ImGui::EndCombo();
}
for (u32 j = ik.bones_count - 2; j != 0xffFFffFF; --j) {
for (u32 j = ik.bones_count - 2; j != 0xffFFffFF; --j) { //-V621
auto iter = m_model->getBoneIndex(ik.bones[j]);
if (iter.isValid()) {
ImGui::Text("%s", m_model->getBone(iter.value()).name.c_str());
@ -516,7 +516,7 @@ void ControllerEditor::onWindowGUI() {
}
}
if (m_controller->m_ik_count < (u32)lengthOf(m_controller->m_ik->bones) && ImGui::Button("Add chain")) {
if (m_controller->m_ik_count < (u32)lengthOf(m_controller->m_ik[0].bones) && ImGui::Button("Add chain")) {
m_controller->m_ik[m_controller->m_ik_count].bones_count = 1;
m_controller->m_ik[m_controller->m_ik_count].bones[0] = 0;
++m_controller->m_ik_count;

View file

@ -68,8 +68,8 @@ bool PropertyAnimation::load(u64 size, const u8* mem)
curve.frames.resize(keys_count);
curve.values.resize(keys_count);
for (int j = 0; j < keys_count; ++j) {
serializer.read(Ref(curve.frames[i]));
serializer.read(Ref(curve.values[i]));
serializer.read(Ref(curve.frames[j]));
serializer.read(Ref(curve.values[j]));
}
}
return true;

View file

@ -718,7 +718,7 @@ void ProfilerUIImpl::onGUICPUProfiler()
const u32 color = header.type == Profiler::EventType::END_FIBER_WAIT ? 0xffff0000 : 0xff00ff00;
dl->AddRect(ImVec2(x - 2, y - 2), ImVec2(x + 2, y + 2), color);
const bool mouse_hovered = ImGui::IsMouseHoveringRect(ImVec2(x - 2, y - 2), ImVec2(x + 2, y + 2));
if (mouse_hovered || is_begin && hovered_signal.signal == r.job_system_signal) {
if (mouse_hovered || (is_begin && hovered_signal.signal == r.job_system_signal)) {
hovered_signal.signal = r.job_system_signal;
hovered_signal.x = x;
hovered_signal.y = y;

View file

@ -872,7 +872,7 @@ static int LUA_instantiatePrefab(lua_State* L)
if (!prefab) {
luaL_argerror(L, 4, "Unknown prefab.");
}
if (!prefab->isReady()) {
if (!prefab->isReady()) { //-V1004
luaL_error(L, "Prefab '%s' is not ready, preload it.", prefab->getPath().c_str());
}
EntityMap entity_map(engine->getAllocator());

View file

@ -15,7 +15,7 @@ PageAllocator::~PageAllocator()
void* p = free_pages;
while (p) {
void* tmp = p;
memcpy(&p, p, sizeof(p));
memcpy(&p, p, sizeof(p)); //-V579
OS::memRelease(tmp);
}
}
@ -39,7 +39,7 @@ void* PageAllocator::allocate(bool lock)
++allocated_count;
if (free_pages) {
void* tmp = free_pages;
memcpy(&free_pages, free_pages, sizeof(free_pages));
memcpy(&free_pages, free_pages, sizeof(free_pages)); //-V579
if (lock) mutex.exit();
return tmp;
}

View file

@ -717,7 +717,7 @@ struct ConstArrayProperty : IArrayProperty
void addItem(ComponentUID cmp, int index) const override { ASSERT(false); }
void removeItem(ComponentUID cmp, int index) const override { ASSERT(false); }
void removeItem(ComponentUID cmp, int index) const override { ASSERT(false); } //-V524
int getCount(ComponentUID cmp) const override
@ -763,7 +763,7 @@ namespace internal
#if defined(_MSC_VER) && !defined(__clang__)
static const size_t size = sizeof(__FUNCTION__) - FRONT_SIZE - BACK_SIZE;
static char typeName[size] = {};
memcpy(typeName, __FUNCTION__ + FRONT_SIZE, size - 1u);
memcpy(typeName, __FUNCTION__ + FRONT_SIZE, size - 1u); //-V594
#else
static const size_t size = sizeof(__PRETTY_FUNCTION__) - FRONT_SIZE - BACK_SIZE;
static char typeName[size] = {};

View file

@ -128,7 +128,7 @@ StackNode* StackTree::getParent(StackNode* node)
bool StackTree::getFunction(StackNode* node, Span<char> out, Ref<int> line)
{
HANDLE process = GetCurrentProcess();
u8 symbol_mem[sizeof(SYMBOL_INFO) + 256 * sizeof(char)] = {};
alignas(SYMBOL_INFO) u8 symbol_mem[sizeof(SYMBOL_INFO) + 256 * sizeof(char)] = {};
SYMBOL_INFO* symbol = reinterpret_cast<SYMBOL_INFO*>(symbol_mem);
symbol->MaxNameLen = 255;
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
@ -154,7 +154,7 @@ void StackTree::printCallstack(StackNode* node)
while (node)
{
HANDLE process = GetCurrentProcess();
u8 symbol_mem[sizeof(SYMBOL_INFO) + 256 * sizeof(char)];
alignas(SYMBOL_INFO) u8 symbol_mem[sizeof(SYMBOL_INFO) + 256 * sizeof(char)];
SYMBOL_INFO* symbol = reinterpret_cast<SYMBOL_INFO*>(symbol_mem);
memset(symbol_mem, 0, sizeof(symbol_mem));
symbol->MaxNameLen = 255;
@ -298,7 +298,7 @@ void Allocator::checkLeaks()
AllocationInfo* info = m_root;
while (info != last_sentinel)
{
StaticString<2048> tmp("\nAllocation size : ", info->size, " , memory ", (u64)(info + sizeof(info)), "\n");
StaticString<2048> tmp("\nAllocation size : ", info->size, " , memory ", (u64)(info + sizeof(info)), "\n"); //-V568
OutputDebugString(tmp);
m_stack_tree.printCallstack(info->stack_leaf);
info = info->next;
@ -677,7 +677,7 @@ static void getStack(CONTEXT& context, Span<char> out)
{
BOOL result;
STACKFRAME64 stack;
char symbol_mem[sizeof(IMAGEHLP_SYMBOL64) + 256];
alignas(IMAGEHLP_SYMBOL64) char symbol_mem[sizeof(IMAGEHLP_SYMBOL64) + 256];
IMAGEHLP_SYMBOL64* symbol = (IMAGEHLP_SYMBOL64*)symbol_mem;
char name[256];
copyString(out, "Crash callstack:\n");

View file

@ -356,7 +356,7 @@ static void processEvents()
HRAWINPUT hRawInput = (HRAWINPUT)msg.lParam;
UINT dataSize;
GetRawInputData(hRawInput, RID_INPUT, NULL, &dataSize, sizeof(RAWINPUTHEADER));
char dataBuf[1024];
alignas(RAWINPUT) char dataBuf[1024];
if (dataSize == 0 || dataSize > sizeof(dataBuf)) break;
GetRawInputData(hRawInput, RID_INPUT, dataBuf, &dataSize, sizeof(RAWINPUTHEADER));

View file

@ -808,6 +808,9 @@ struct GUISceneImpl final : public GUIScene
handleKeyboardButtonEvent(event);
}
break;
case InputSystem::Event::DEVICE_ADDED:
case InputSystem::Event::DEVICE_REMOVED:
break;
}
}
}

View file

@ -273,7 +273,7 @@ namespace Lumix
lua_setfenv(script.m_state, -2);
m_scene.m_current_script_instance = &script;
errors = errors || lua_pcall(script.m_state, 0, 0, 0) != 0; // [env]
errors = lua_pcall(script.m_state, 0, 0, 0) != 0; // [env]
if (errors)
{
logError("Lua Script") << script.m_script->getPath() << ": "
@ -999,7 +999,7 @@ namespace Lumix
ASSERT(lua_type(script.m_state, -1) == LUA_TTABLE);
lua_setfenv(script.m_state, -2);
errors = errors || lua_pcall(state, 0, 0, 0) != 0;
errors = lua_pcall(state, 0, 0, 0) != 0;
if (errors)
{

View file

@ -3052,7 +3052,7 @@ struct PhysicsSceneImpl final : public PhysicsScene
for (int i = index; i < count; ++i)
{
PxShape* shape = getShape(entity, i, type);
shape->userData = (void*)(intptr_t)(i + 1);
shape->userData = (void*)(intptr_t)(i + 1); //-V1028
}
}

View file

@ -508,7 +508,7 @@ void FBXImporter::postprocessMeshes(const ImportConfig& cfg, const char* path)
Array<int> subblobs(allocator);
subblobs.reserve(vertex_count);
const int* materials = geom->getMaterials();
const int* geom_materials = geom->getMaterials();
Array<ofbx::Vec3> computed_tangents(allocator);
if (!tangents && normals && uvs) {
computeTangents(computed_tangents, vertex_count, vertices, normals, uvs);
@ -517,7 +517,7 @@ void FBXImporter::postprocessMeshes(const ImportConfig& cfg, const char* path)
for (int i = 0; i < vertex_count; ++i)
{
if (materials && materials[i / 3] != material_idx) continue;
if (geom_materials && geom_materials[i / 3] != material_idx) continue;
blob.clear();
ofbx::Vec3 cp = vertices[i];
@ -576,7 +576,7 @@ static int detectMeshLOD(const FBXImporter::ImportMesh& mesh)
{
char mesh_name[256];
FBXImporter::getImportMeshName(mesh, mesh_name);
const char* lod_str = stristr(mesh_name, "_LOD");
lod_str = stristr(mesh_name, "_LOD");
if (!lod_str) return 0;
}
@ -1132,7 +1132,7 @@ static void fill(const ofbx::Object& bone, double anim_len, const ofbx::Animatio
static bool shouldSample(u32 keyframe_count, float anim_len, float fps, u32 data_size) {
const u32 sampled_frame_count = u32(anim_len * fps);
const u32 sampled_size = sampled_frame_count * data_size;
const u32 time_size = sizeof(sizeof(u16));
const u32 time_size = sizeof(u16);
const u32 keyframed_size = keyframe_count * (data_size + time_size);
// * 4 / 3 -> prefer sampled even when a bit bigger, since sampled tracks are faster
@ -1189,19 +1189,19 @@ void FBXImporter::writeAnimations(const char* src, const ImportConfig& cfg)
const ofbx::AnimationStack* stack = anim.fbx;
const ofbx::AnimationLayer* layer = stack->getLayer(0);
const ofbx::IScene& scene = *anim.scene;
const float fps = scene.getSceneFrameRate();
const ofbx::TakeInfo* take_info = scene.getTakeInfo(stack->name);
ASSERT(anim.scene == scene);
const float fps = scene->getSceneFrameRate();
const ofbx::TakeInfo* take_info = scene->getTakeInfo(stack->name);
if(!take_info && startsWith(stack->name, "AnimStack::")) {
take_info = scene.getTakeInfo(stack->name + 11);
take_info = scene->getTakeInfo(stack->name + 11);
}
double anim_len;
if (take_info) {
anim_len = take_info->local_time_to - take_info->local_time_from;
}
else if(scene.getGlobalSettings()) {
anim_len = scene.getGlobalSettings()->TimeSpanStop;
else if(scene->getGlobalSettings()) {
anim_len = scene->getGlobalSettings()->TimeSpanStop;
}
else {
logError("Renderer") << "Unsupported animation in " << src;

View file

@ -544,7 +544,7 @@ static OptionalError<Property*> readProperty(Cursor* cursor)
OptionalError<u32> length = read<u32>(cursor);
OptionalError<u32> encoding = read<u32>(cursor);
OptionalError<u32> comp_len = read<u32>(cursor);
if (length.isError() | encoding.isError() | comp_len.isError()) return Error();
if (length.isError() | encoding.isError() | comp_len.isError()) return Error(); //-V792
if (cursor->current + comp_len.getValue() > cursor->end) return Error("Reading past the end");
cursor->current += comp_len.getValue();
break;
@ -984,7 +984,6 @@ struct MeshImpl : Mesh
{
MeshImpl(const Scene& _scene, const IElement& _element)
: Mesh(_scene, _element)
, scene(_scene)
{
is_node = true;
}
@ -1018,7 +1017,6 @@ struct MeshImpl : Mesh
const Pose* pose = nullptr;
const Geometry* geometry = nullptr;
const Scene& scene;
std::vector<const Material*> materials;
};
@ -2315,7 +2313,6 @@ static OptionalError<Object*> parseGeometryTangents(
if (!layer_tangent_element ) {
layer_tangent_element = findChild(element, "LayerElementTangent");
}
layer_tangent_element = findChild(element, "LayerElementTangent");
if (layer_tangent_element)
{
std::vector<Vec3> tmp;

View file

@ -491,7 +491,7 @@ struct MaterialPlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin
ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0));
bool is_node_open = ImGui::TreeNodeEx((const void*)(intptr_t)(i + 1),
bool is_node_open = ImGui::TreeNodeEx((const void*)(intptr_t)(i + 1), //-V1028
ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_Framed,
"%s",
"");
@ -674,7 +674,7 @@ struct ModelPlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin
FBXImporter importer(plugin->m_app);
AssetCompiler& compiler = plugin->m_app.getAssetCompiler();
const char* path = data->path[0] == '/' ? data->path.data + 1 : data->path;
const char* path = data->path[0] == '/' ? data->path.data + 1 : data->path.data;
importer.setSource(path, true);
if(data->meta.split) {
@ -2656,7 +2656,7 @@ struct LightProbeGridPlugin final : public PropertyGrid::IPlugin {
v.x = (&m_result[i].coefs[c0].x)[c00];
v.y = (&m_result[i].coefs[c1].x)[c10];
v.z = (&m_result[i].coefs[c2].x)[c20];
v.w = (&m_result[i].coefs[c3].x)[c30];
v.w = (&m_result[i].coefs[c3].x)[c30]; //-V557
file.write(&v, sizeof(v));
}
}
@ -2891,7 +2891,7 @@ struct EnvironmentProbePlugin final : public PropertyGrid::IPlugin
if (universe->hasComponent(job.entity, ENVIRONMENT_PROBE_TYPE)) {
RenderScene* scene = (RenderScene*)universe->getScene(ENVIRONMENT_PROBE_TYPE);
EnvironmentProbe& p = scene->getEnvironmentProbe(job.entity);
static_assert(sizeof(p.sh_coefs == job.sh.coefs));
static_assert(sizeof(p.sh_coefs) == sizeof(job.sh.coefs));
memcpy(p.sh_coefs, job.sh.coefs, sizeof(p.sh_coefs));
}
@ -3252,7 +3252,7 @@ struct RenderInterfaceImpl final : public RenderInterfaceBase
void addDebugCube(const DVec3& pos, const Vec3& dir, const Vec3& up, const Vec3& right, u32 color) override
{
m_render_scene->addDebugCube(pos, dir, right, up, color);
m_render_scene->addDebugCube(pos, dir, up, right, color);
}

View file

@ -461,8 +461,6 @@ static LoadInfo* getDXT10LoadInfo(const Header& hdr, const DXT10Header& dxt10_hd
{
switch(dxt10_hdr.dxgi_format) {
case DxgiFormat::B8G8R8A8_UNORM_SRGB:
return &loadInfoBGRA8;
break;
case DxgiFormat::B8G8R8A8_UNORM:
return &loadInfoBGRA8;
break;
@ -2019,7 +2017,7 @@ bool createProgram(ProgramHandle prog, const VertexDecl& decl, const char** srcs
case ShaderType::GEOMETRY: shader_type = GL_GEOMETRY_SHADER; break;
case ShaderType::FRAGMENT: shader_type = GL_FRAGMENT_SHADER; break;
case ShaderType::VERTEX: shader_type = GL_VERTEX_SHADER; break;
default: ASSERT(0); break;
default: ASSERT(false); return false;
}
const GLuint shd = glCreateShader(shader_type);
combined_srcs[0] = R"#(

View file

@ -286,9 +286,10 @@ inline u32 getBytesPerPixel(gpu::TextureFormat format) {
return 8;
case gpu::TextureFormat::RGBA32F:
return 16;
default:
ASSERT(false);
return 0;
}
ASSERT(false);
return 0;
}
} // namespace gpu

View file

@ -469,7 +469,7 @@ void ParticleEmitter::emit(const float* args)
++m_particles_count;
return;
case Instructions::MOV: {
const auto dst_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type dst_type = blob.read<Compiler::DataStream::Type>();
u8 dst_idx = blob.read<u8>();
ASSERT(dst_type == Compiler::DataStream::CHANNEL);
const float value = readSingleValue(blob);
@ -477,7 +477,7 @@ void ParticleEmitter::emit(const float* args)
break;
}
case Instructions::RAND: {
const auto dst_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type dst_type = blob.read<Compiler::DataStream::Type>();
ASSERT(dst_type == Compiler::DataStream::CHANNEL);
u8 dst_idx = blob.read<u8>();
@ -569,7 +569,7 @@ static float4* getStream(const ParticleEmitter& emitter
, float4* register_mem)
{
switch(type) {
case Compiler::DataStream::CHANNEL: return (float4*)emitter.getChannelData(idx);
case Compiler::DataStream::CHANNEL: return (float4*)emitter.getChannelData(idx); //-V1032
case Compiler::DataStream::REGISTER: return register_mem + particles_count * idx;
default: ASSERT(false); return nullptr;
}
@ -609,11 +609,11 @@ void ParticleEmitter::update(float dt)
case Instructions::END:
goto end;
case Instructions::MUL: {
const auto dst_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type dst_type = blob.read<Compiler::DataStream::Type>();
const u8 dst_idx = blob.read<u8>();
const auto arg0_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type arg0_type = blob.read<Compiler::DataStream::Type>();
const u8 arg0_idx = blob.read<u8>();
const auto arg1_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type arg1_type = blob.read<Compiler::DataStream::Type>();
const float4* arg0 = getStream(*this, arg0_type, arg0_idx, m_particles_count, reg_mem.begin());
float4* result = getStream(*this, dst_type, dst_idx, m_particles_count, reg_mem.begin());
@ -637,9 +637,9 @@ void ParticleEmitter::update(float dt)
break;
}
case Instructions::MOV: {
const auto dst_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type dst_type = blob.read<Compiler::DataStream::Type>();
const u8 dst_idx = blob.read<u8>();
const auto src_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type src_type = blob.read<Compiler::DataStream::Type>();
const u8 src_idx = blob.read<u8>();
float4* result = getStream(*this, dst_type, dst_idx, m_particles_count, reg_mem.begin());
@ -663,11 +663,11 @@ void ParticleEmitter::update(float dt)
break;
}
case Instructions::ADD: {
const auto dst_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type dst_type = blob.read<Compiler::DataStream::Type>();
const u8 dst_idx = blob.read<u8>();
const auto arg0_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type arg0_type = blob.read<Compiler::DataStream::Type>();
const u8 arg0_idx = blob.read<u8>();
const auto arg1_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type arg1_type = blob.read<Compiler::DataStream::Type>();
const u8 arg1_idx = blob.read<u8>();
// TODO
@ -694,9 +694,9 @@ void ParticleEmitter::update(float dt)
break;
}
case Instructions::COS: {
const auto dst_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type dst_type = blob.read<Compiler::DataStream::Type>();
const u8 dst_idx = blob.read<u8>();
const auto arg_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type arg_type = blob.read<Compiler::DataStream::Type>();
const u8 arg_idx = blob.read<u8>();
const float* arg = (float*)getStream(*this, arg_type, arg_idx, m_particles_count, reg_mem.begin());
@ -709,9 +709,9 @@ void ParticleEmitter::update(float dt)
break;
}
case Instructions::SIN: {
const auto dst_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type dst_type = blob.read<Compiler::DataStream::Type>();
const u8 dst_idx = blob.read<u8>();
const auto arg_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type arg_type = blob.read<Compiler::DataStream::Type>();
const u8 arg_idx = blob.read<u8>();
const float* arg = (float*)getStream(*this, arg_type, arg_idx, m_particles_count, reg_mem.begin());
@ -772,9 +772,9 @@ void ParticleEmitter::fillInstanceData(const DVec3& cam_pos, float* data)
case Instructions::END:
return;
case Instructions::SIN: {
const auto dst_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type dst_type = blob.read<Compiler::DataStream::Type>();
const u8 dst_idx = blob.read<u8>();
const auto arg_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type arg_type = blob.read<Compiler::DataStream::Type>();
const u8 arg_idx = blob.read<u8>();
const float* arg = (float*)getStream(*this, arg_type, arg_idx, m_particles_count, reg_mem.begin()) + offset;
@ -787,9 +787,9 @@ void ParticleEmitter::fillInstanceData(const DVec3& cam_pos, float* data)
break;
}
case Instructions::COS: {
const auto dst_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type dst_type = blob.read<Compiler::DataStream::Type>();
const u8 dst_idx = blob.read<u8>();
const auto arg_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type arg_type = blob.read<Compiler::DataStream::Type>();
const u8 arg_idx = blob.read<u8>();
const float* arg = (float*)getStream(*this, arg_type, arg_idx, m_particles_count, reg_mem.begin()) + offset;
@ -802,11 +802,11 @@ void ParticleEmitter::fillInstanceData(const DVec3& cam_pos, float* data)
break;
}
case Instructions::MUL: {
const auto dst_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type dst_type = blob.read<Compiler::DataStream::Type>();
const u8 dst_idx = blob.read<u8>();
const auto arg0_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type arg0_type = blob.read<Compiler::DataStream::Type>();
const u8 arg0_idx = blob.read<u8>();
const auto arg1_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type arg1_type = blob.read<Compiler::DataStream::Type>();
float4* result = getStream(*this, dst_type, dst_idx, m_particles_count, reg_mem.begin()) + (offset >> 2);
const float4* arg0 = getStream(*this, arg0_type, arg0_idx, m_particles_count, reg_mem.begin()) + (offset >> 2);
@ -831,7 +831,7 @@ void ParticleEmitter::fillInstanceData(const DVec3& cam_pos, float* data)
}
case Instructions::OUTPUT: {
const int stride = m_resource->getOutputsCount();
const auto arg_type = blob.read<Compiler::DataStream::Type>();
const Compiler::DataStream::Type arg_type = blob.read<Compiler::DataStream::Type>();
const u8 arg_idx = blob.read<u8>();
const float* arg = (float*)getStream(*this, arg_type, arg_idx, m_particles_count, reg_mem.begin()) + offset;
float* dst = data + output_idx + offset * stride;

View file

@ -74,7 +74,7 @@ public:
private:
struct Channel
{
float* data = nullptr;
alignas(16) float* data = nullptr;
u32 name = 0;
};

View file

@ -1300,20 +1300,27 @@ struct PipelineImpl final : Pipeline
lua_pop(L, 1);
luaL_error(L, "Frustum is not a table");
}
float* points = cp.frustum.xs;
if(!LuaWrapper::checkField(L, -1, "origin", &cp.frustum.origin)) {
lua_pop(L, 1);
luaL_error(L, "Frustum without origin");
}
for (int i = 0; i < 32 + 24; ++i) {
lua_rawgeti(L, -1, i + 1);
if(!LuaWrapper::isType<float>(L, -1)) {
lua_pop(L, 2);
luaL_error(L, "Frustum must contain exactly 24 floats");
auto load_floats = [L](float* data, int count, int offset) {
for (int i = 0; i < count; ++i) {
lua_rawgeti(L, -1, offset + i + 1);
if(!LuaWrapper::isType<float>(L, -1)) {
lua_pop(L, 2);
luaL_error(L, "Invalid frustum");
}
data[i] = LuaWrapper::toType<float>(L, -1);
lua_pop(L, 1);
}
points[i] = LuaWrapper::toType<float>(L, -1);
lua_pop(L, 1);
}
};
load_floats(cp.frustum.xs, (int)Frustum::Planes::COUNT, 0);
load_floats(cp.frustum.ys, (int)Frustum::Planes::COUNT, (int)Frustum::Planes::COUNT);
load_floats(cp.frustum.zs, (int)Frustum::Planes::COUNT, (int)Frustum::Planes::COUNT * 2);
load_floats(cp.frustum.ds, (int)Frustum::Planes::COUNT, (int)Frustum::Planes::COUNT * 3);
load_floats(&cp.frustum.points[0].x, 24, (int)Frustum::Planes::COUNT * 4);
lua_pop(L, 1);
cp.frustum.setPlanesFromPoints();
@ -1822,10 +1829,19 @@ struct PipelineImpl final : Pipeline
lua_createtable(L, 32+24, 0);
const float* frustum = params.frustum.xs;
for(int i = 0; i < 32+24; ++i) {
LuaWrapper::push(L, frustum[i]);
lua_rawseti(L, -2, i + 1);
}
auto push_floats = [L](const float* values, int count, int offset){
for(int i = 0; i < count; ++i) {
LuaWrapper::push(L, values[i]);
lua_rawseti(L, -2, offset + i + 1);
}
};
push_floats(params.frustum.xs, (int)Frustum::Planes::COUNT, 0);
push_floats(params.frustum.ys, (int)Frustum::Planes::COUNT, (int)Frustum::Planes::COUNT);
push_floats(params.frustum.zs, (int)Frustum::Planes::COUNT, (int)Frustum::Planes::COUNT * 2);
push_floats(params.frustum.ds, (int)Frustum::Planes::COUNT, (int)Frustum::Planes::COUNT * 3);
push_floats(&params.frustum.points[0].x, 24, (int)Frustum::Planes::COUNT * 4);
LuaWrapper::push(L, params.frustum.origin);
lua_setfield(L, -2, "origin");
lua_setfield(L, -2, "frustum");

View file

@ -59,9 +59,9 @@ class LUMIX_RENDERER_API Pipeline
public:
struct Stats
{
int draw_call_count;
int instance_count;
int triangle_count;
u32 draw_call_count;
u32 instance_count;
u32 triangle_count;
};
struct CustomCommandHandler

View file

@ -595,7 +595,7 @@ RayCastModelHit Terrain::castRay(const DVec3& origin, const Vec3& dir)
float next_z = fabs(rel_dir.z) < 0.01f ? hz : ((hz + (rel_dir.z < 0 ? 0 : 1)) * m_scale.x - rel_origin.z) / rel_dir.z;
float delta_x = fabsf(rel_dir.x) < 0.01f ? 0 : m_scale.x / fabsf(rel_dir.x);
float delta_z = fabsf(rel_dir.z) < 0.01f ? 0 : m_scale.x / fabsf(rel_dir.z);
float delta_z = fabsf(rel_dir.z) < 0.01f ? 0 : m_scale.z / fabsf(rel_dir.z);
int step_x = (int)signum(rel_dir.x);
int step_z = (int)signum(rel_dir.z);

View file

@ -126,7 +126,7 @@ u32 Texture::getPixel(float x, float y) const
int w3 = (int)(fx1 * fy * 256.0f);
int w4 = (int)(fx * fy * 256.0f);
u8 res[4];
alignas(u32) u8 res[4];
res[0] = (u8)((p1[0] * w1 + p2[0] * w2 + p3[0] * w3 + p4[0] * w4) >> 8);
res[1] = (u8)((p1[1] * w1 + p2[1] * w2 + p3[1] * w3 + p4[1] * w4) >> 8);
res[2] = (u8)((p1[2] * w1 + p2[2] * w2 + p3[2] * w3 + p4[2] * w4) >> 8);