X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcontent_cso.cpp;h=10d1f498b82b74fe47d731540dcaa8ef2f55c0ea;hb=b3a36f7378ea0f299cfa36c81de42e00adb7292d;hp=6f7ecbe503da17b724bccdca1a980ec0c50a127f;hpb=037b2591971d752e67fa7d47095b996b3f56da5a;p=minetest.git diff --git a/src/content_cso.cpp b/src/content_cso.cpp index 6f7ecbe50..10d1f498b 100644 --- a/src/content_cso.cpp +++ b/src/content_cso.cpp @@ -1,6 +1,6 @@ /* -Minetest-c55 -Copyright (C) 2012 celeron55, Perttu Ahola +Minetest +Copyright (C) 2013 celeron55, Perttu Ahola This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -19,35 +19,24 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "content_cso.h" #include -#include "tile.h" -#include "environment.h" -#include "gamedef.h" -#include "log.h" - -static void setBillboardTextureMatrix(scene::IBillboardSceneNode *bill, - float txs, float tys, int col, int row) -{ - video::SMaterial& material = bill->getMaterial(0); - core::matrix4& matrix = material.getTextureMatrix(0); - matrix.setTextureTranslate(txs*col, tys*row); - matrix.setTextureScale(txs, tys); -} +#include "client/tile.h" +#include "clientenvironment.h" +#include "client.h" +#include "map.h" class SmokePuffCSO: public ClientSimpleObject { - float m_age; - scene::IBillboardSceneNode *m_spritenode; + float m_age = 0.0f; + scene::IBillboardSceneNode *m_spritenode = nullptr; public: SmokePuffCSO(scene::ISceneManager *smgr, - ClientEnvironment *env, v3f pos, v2f size): - m_age(0), - m_spritenode(NULL) + ClientEnvironment *env, v3f pos, v2f size) { infostream<<"SmokePuffCSO: constructing"<addBillboardSceneNode( NULL, v2f(1,1), pos, -1); m_spritenode->setMaterialTexture(0, - env->getGameDef()->tsrc()->getTextureRaw("smoke_puff.png")); + env->getGameDef()->tsrc()->getTextureForMesh("smoke_puff.png")); m_spritenode->setMaterialFlag(video::EMF_LIGHTING, false); m_spritenode->setMaterialFlag(video::EMF_BILINEAR_FILTER, false); //m_spritenode->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF); @@ -57,13 +46,12 @@ class SmokePuffCSO: public ClientSimpleObject m_spritenode->setVisible(true); m_spritenode->setSize(size); /* Update brightness */ - u8 light = 64; - try{ - MapNode n = env->getMap().getNode(floatToInt(pos, BS)); - light = decode_light(n.getLightBlend(env->getDayNightRatio(), - env->getGameDef()->ndef())); - } - catch(InvalidPositionException &e){} + u8 light; + bool pos_ok; + MapNode n = env->getMap().getNodeNoEx(floatToInt(pos, BS), &pos_ok); + light = pos_ok ? decode_light(n.getLightBlend(env->getDayNightRatio(), + env->getGameDef()->ndef())) + : 64; video::SColor color(255,light,light,light); m_spritenode->setColor(color); }