Skip to content

Commit

Permalink
Refactor: Moved materials to libdoomsday's world domain (big commit)
Browse files Browse the repository at this point in the history
As they are currently implemented and used, the materials are the best
fit for the world domain. The classes are now all in the `world`
namespace (save for the client-specific ones).

The supporting MapElement and DmuArgs classes were also moved to
libdoomsday.

Because libdoomsday is used by the client, server, and all plugins,
this makes materials now available everywhere. An opaque pointer type
is still used in the published runtime APIs for C language support.

The MaterialArchive runtime API was removed as unnecessary, as
the class can now be directly accessed.
  • Loading branch information
skyjake committed Jul 11, 2016
1 parent 331e2fe commit a7adb4f
Show file tree
Hide file tree
Showing 154 changed files with 2,491 additions and 2,213 deletions.
9 changes: 5 additions & 4 deletions doomsday/apps/api/api_gl.h
Expand Up @@ -24,7 +24,8 @@
#define DOOMSDAY_GL_H

#include <de/rect.h>
#include "dd_share.h"
#include "api_map.h"
#include "dd_types.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -271,10 +272,10 @@ DENG_API_TYPEDEF(GL)
void (*DeleteLists)(DGLuint list, int range);

void (*SetNoMaterial)(void);
void (*SetMaterialUI)(Material *mat, DGLint wrapS, DGLint wrapT);
void (*SetMaterialUI)(world_Material *mat, DGLint wrapS, DGLint wrapT);
void (*SetPatch)(patchid_t id, DGLint wrapS, DGLint wrapT);
void (*SetPSprite)(Material *mat);
void (*SetPSprite2)(Material *mat, int tclass, int tmap);
void (*SetPSprite)(world_Material *mat);
void (*SetPSprite2)(world_Material *mat, int tclass, int tmap);
void (*SetRawImage)(lumpnum_t lumpNum, DGLint wrapS, DGLint wrapT);

void (*BlendOp)(int op);
Expand Down
55 changes: 8 additions & 47 deletions doomsday/apps/api/api_map.h
Expand Up @@ -31,50 +31,7 @@
#include <de/mathutil.h>
#include <de/str.h>
#include <doomsday/world/thinker.h>

#if defined __cplusplus

namespace de {

/**
* Encapsulates the arguments used when routing DMU API calls to map elements.
*/
class DmuArgs
{
public: /// @todo make private
int type;
uint prop;
int modifiers; /// Property modifiers (e.g., line of sector)
valuetype_t valueType;
dd_bool *booleanValues;
byte *byteValues;
int *intValues;
fixed_t *fixedValues;
float *floatValues;
double *doubleValues;
angle_t *angleValues;
void **ptrValues;

DmuArgs(int type, uint prop);

/**
* Read the value of an argument. Does some basic type checking so that
* incompatible types are not assigned. Simple conversions are also done,
* e.g., float to fixed.
*/
void value(valuetype_t valueType, void *dst, uint index) const;

/**
* Change the value of an argument. Does some basic type checking so that
* incompatible types are not assigned. Simple conversions are also done,
* e.g., float to fixed.
*/
void setValue(valuetype_t valueType, void const *src, uint index);
};

} // namespace de

#endif // __cplusplus
#include <doomsday/world/valuetype.h>

#define DMT_ARCHIVE_INDEX DDVT_INT

Expand Down Expand Up @@ -154,7 +111,7 @@ struct polyobj_s;
typedef struct convexsubspace_s ConvexSubspace;
typedef struct interceptor_s Interceptor;
typedef struct line_s Line;
typedef struct material_s Material;
typedef struct material_s world_Material;
typedef struct plane_s Plane;
typedef struct side_s Side;
typedef struct sector_s Sector;
Expand All @@ -163,11 +120,15 @@ typedef struct vertex_s Vertex;
#elif defined __cplusplus

// Foward declarations.
namespace world { class ConvexSubspace; }
namespace world
{
class ConvexSubspace;
class Material; // libdoomsday/world
}
typedef world::Material world_Material;
class Interceptor;
class Line;
class Plane;
class Material;
class Sector;
class Vertex;

Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/api/api_material.h
Expand Up @@ -35,7 +35,7 @@ DENG_API_TYPEDEF(Material)
{
de_api_t api;

Material *(*ForTextureUri)(Uri const *textureUri);
world_Material *(*ForTextureUri)(Uri const *textureUri);
Uri *(*ComposeUri)(materialid_t materialId);
materialid_t (*ResolveUri)(Uri const *uri);
materialid_t (*ResolveUriCString)(char const *path);
Expand Down
121 changes: 0 additions & 121 deletions doomsday/apps/api/api_materialarchive.h

This file was deleted.

3 changes: 2 additions & 1 deletion doomsday/apps/api/apis.h
Expand Up @@ -130,7 +130,8 @@ enum {
DE_API_MATERIALS = DE_API_MATERIALS_v1,

DE_API_MATERIAL_ARCHIVE_v1 = 1400, // 1.10
DE_API_MATERIAL_ARCHIVE = DE_API_MATERIAL_ARCHIVE_v1,
DE_API_MATERIAL_ARCHIVE_REMOVED
= 1401, // 2.0 (API removed)

DE_API_PLAYER_v1 = 1500, // 1.10
DE_API_PLAYER_v2 = 1501, // 1.13
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/api/dd_share.h
Expand Up @@ -669,7 +669,7 @@ typedef struct {

/// Sprite Info
typedef struct {
Material *material;
world_Material *material;
int flip;
RectRaw geometry;
float texCoord[2]; // Prepared texture coordinates.
Expand Down
1 change: 0 additions & 1 deletion doomsday/apps/api/doomsday.h
Expand Up @@ -44,7 +44,6 @@
#include "api_map.h"
#include "api_mapedit.h"
#include "api_material.h"
#include "api_materialarchive.h"
#include "api_render.h"
#include "api_resource.h"
#include "api_server.h"
Expand Down
1 change: 1 addition & 0 deletions doomsday/apps/client/include/ClientMaterial
@@ -0,0 +1 @@
#include "resource/clientmaterial.h"
1 change: 0 additions & 1 deletion doomsday/apps/client/include/MapElement

This file was deleted.

1 change: 0 additions & 1 deletion doomsday/apps/client/include/Material

This file was deleted.

1 change: 0 additions & 1 deletion doomsday/apps/client/include/MaterialArchive

This file was deleted.

1 change: 0 additions & 1 deletion doomsday/apps/client/include/MaterialManifest

This file was deleted.

1 change: 0 additions & 1 deletion doomsday/apps/client/include/MaterialScheme

This file was deleted.

4 changes: 2 additions & 2 deletions doomsday/apps/client/include/clientapp.h
Expand Up @@ -30,7 +30,7 @@
#include "ui/clientwindowsystem.h"
#include "ui/infine/infinesystem.h"
#include "render/rendersystem.h"
#include "resource/resourcesystem.h"
#include "resource/clientresources.h"
#include "updater.h"
#include "busyrunner.h"
#include "world/clientserverworld.h"
Expand Down Expand Up @@ -82,7 +82,7 @@ class ClientApp : public de::BaseGuiApp, public DoomsdayApp
static ClientWindowSystem & windowSystem();
static ::audio::System & audioSystem();
static RenderSystem & renderSystem();
static ResourceSystem & resourceSystem();
static ClientResources & resources();
static ClientServerWorld & world();

static bool hasInputSystem();
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/client/include/dd_main.h
Expand Up @@ -30,7 +30,7 @@
#include <doomsday/Games>

#include "audio/system.h"
#include "resource/resourcesystem.h"
#include "resource/clientresources.h"
#include "world/clientserverworld.h"
#include "ui/infine/infinesystem.h"

Expand Down Expand Up @@ -62,7 +62,7 @@ audio::System &App_AudioSystem();
InFineSystem &App_InFineSystem();

/// Returns the application's global ResourceSystem.
ResourceSystem &App_ResourceSystem();
ClientResources &App_ResourceSystem();

/// Returns the application's global WorldSystem.
ClientServerWorld &App_World();
Expand Down
8 changes: 4 additions & 4 deletions doomsday/apps/client/include/gl/gl_main.h
Expand Up @@ -43,7 +43,7 @@ struct material_s;
struct texturevariant_s;

class ColorPalette;
class Material;
namespace world { class Material; }

#define TEXQ_BEST 8
#define MINTEXWIDTH 8
Expand Down Expand Up @@ -213,10 +213,10 @@ void GL_CallList(DGLuint list);

void GL_DeleteLists(DGLuint list, int range);

void GL_SetMaterialUI2(Material *mat, de::gl::Wrapping wrapS, de::gl::Wrapping wrapT);
void GL_SetMaterialUI(Material *mat);
void GL_SetMaterialUI2(world::Material *mat, de::gl::Wrapping wrapS, de::gl::Wrapping wrapT);
void GL_SetMaterialUI(world::Material *mat);

void GL_SetPSprite(Material *mat, int tclass, int tmap);
void GL_SetPSprite(world::Material *mat, int tclass, int tmap);

void GL_SetRawImage(lumpnum_t lumpNum, de::gl::Wrapping wrapS, de::gl::Wrapping wrapT);

Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/include/mesh.h
Expand Up @@ -25,7 +25,7 @@
#include <de/Error>
#include <de/Vector>

#include "MapElement"
#include <doomsday/world/MapElement>

class Vertex;

Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/client/include/render/billboard.h
Expand Up @@ -22,7 +22,7 @@
#define DENG_CLIENT_RENDER_BILLBOARD_H

#include "dd_types.h"
#include "Material"
#include "ClientMaterial"
#include "MaterialAnimator"
#include "MaterialVariantSpec"

Expand Down Expand Up @@ -67,7 +67,7 @@ struct rendpspriteparams_t
de::dfloat width;
de::dfloat height;

Material *mat;
ClientMaterial *mat;
de::dfloat texOffset[2];
dd_bool texFlip[2]; ///< [X, Y] Flip along the specified axis.

Expand Down
3 changes: 2 additions & 1 deletion doomsday/apps/client/include/render/rend_main.h
Expand Up @@ -36,6 +36,7 @@
class Lumobj;
class Sector;
struct VectorLightData;
class ClientMaterial;
namespace de { class LightGrid; }
namespace world {
class ConvexSubspace;
Expand Down Expand Up @@ -279,7 +280,7 @@ Lumobj *Rend_MakeLumobj(de::Record const &sprite);
* Selects a Material for the given map @a surface considering the current map
* renderer configuration.
*/
Material *Rend_ChooseMapSurfaceMaterial(Surface const &surface);
ClientMaterial *Rend_ChooseMapSurfaceMaterial(Surface const &surface);

de::MaterialVariantSpec const &Rend_MapSurfaceMaterialSpec();
de::MaterialVariantSpec const &Rend_MapSurfaceMaterialSpec(int wrapS, int wrapT);
Expand Down
3 changes: 2 additions & 1 deletion doomsday/apps/client/include/render/vissprite.h
Expand Up @@ -30,6 +30,7 @@
#define MAXVISSPRITES 8192

namespace world { class BspLeaf; }
class ClientMaterial;

/**
* These constants are used as the type of vissprite.
Expand Down Expand Up @@ -139,7 +140,7 @@ struct vissprite_t

void VisSprite_SetupSprite(vissprite_t *spr, VisEntityPose const &pose, VisEntityLighting const &light,
de::dfloat secFloor, de::dfloat secCeil, de::dfloat floorClip, de::dfloat top,
Material &material, bool matFlipS, bool matFlipT, blendmode_t blendMode,
ClientMaterial &material, bool matFlipS, bool matFlipT, blendmode_t blendMode,
de::dint tClass, de::dint tMap, world::BspLeaf *bspLeafAtOrigin,
bool floorAdjust, bool fitTop, bool fitBottom);

Expand Down

0 comments on commit a7adb4f

Please sign in to comment.